overtone

Joakim Verona 2024-09-20T14:54:28.191649Z

how do you do midi in overtone now? I would like to control stuff in overtone from my midi keyboard

plexus 2024-09-23T07:41:14.556729Z

midi automatically translates to events, so you can do something like this

(defn keyboard-insts [& insts]
  (on-event [:midi :note-on]
            (fn [{:keys [note channel velocity] :as e}]
              (when-let [inst (get (vec insts) channel)]
                (event :note :instrument inst :midinote note
                       :overtone.studio.event/key note
                       :end-time nil
                       :amp (* 1.5 (/ velocity 128) @(:value (param inst "amp"))))))
            ::midi-on)

  (on-event [:midi :note-off]
            (fn [{:keys [note channel] :as e}]
              (when-let [inst (get (vec insts) channel)]
                (event :note-end :instrument inst :midinote note
                       :overtone.studio.event/key note
                       :end-time (now))))
            ::midi-off))

plexus 2024-09-23T07:41:48.295559Z

or (sounds like you're on linux) use https://github.com/squidcasa/casa.squid.jack

plexus 2024-09-23T07:42:29.938009Z

note that the (event :note ...) stuff is still subject to change, that got added as part of the pattern library stuff

plexus 2024-09-23T07:42:42.658239Z

now that HoC is over I should be able to resume work on those things

Joakim Verona 2024-09-23T16:07:24.650469Z

nice

Joakim Verona 2024-09-23T16:07:53.159039Z

atm im at the point of having a hassle with setting up a session, closing it down, restoring it

Joakim Verona 2024-09-23T16:08:26.101629Z

i did manage to feed some of my overtone insts with midi

diego.videco 2024-09-20T20:36:08.348459Z

You can use overtone.midi/midi-handle-events .

Joakim Verona 2024-09-20T21:04:26.999029Z

tnx. But atm I dont get any midi devices listed. this is all i get: (javax.sound.midi.MidiSystem/getMidiDeviceInfo) [#object[com.sun.media.sound.SoftSynthesizer$Info 0x28c642b0 "Gervill"], #object[com.sun.media.sound.RealTimeSequencer$RealTimeSequencerInfo 0x51f719e8 "Real Time Sequencer"]]

Joakim Verona 2024-09-20T21:05:04.107869Z

(I went down a bit in overtone.midi to find the underlying midi api)

diego.videco 2024-09-20T21:10:47.645999Z

I think you need to connect you midi devices before starting up the repl

diego.videco 2024-09-20T21:27:08.273139Z

At least, that is one issue that I have encountered.

diego.videco 2024-09-20T21:28:01.585419Z

Are you using midi/midi-in?

Joakim Verona 2024-09-20T21:38:10.618479Z

yes, i tried midi-in, but it tried to open up a window, which didnt work well under sway for some reason, thats why i extracted the java code above. Anyway, ill try to simply restart the repl, tnx

diego.videco 2024-09-20T21:40:03.171999Z

Ah yeha, if there’s no arg to midi-in it will attempt to do that IIRC. This one’s also useful to get the name of the device: (midi/midi-devices)

Joakim Verona 2024-09-20T22:15:26.112849Z

this works now thanks @diego.vid.eco!

diego.videco 2024-09-20T22:16:47.487829Z

Welcome, also struggled a lot with these under-documented aspects of overtone.

Joakim Verona 2024-11-04T14:38:34.159839Z

i was going to try the casa.squid.jack method, but wound up in some issues

Joakim Verona 2024-11-04T14:39:05.136589Z

The documentation differs slightly from the walkthrough file (ns declaration)

Joakim Verona 2024-11-04T14:39:47.427399Z

the step connceting the midi kbd string to the jack client failed with an exception

Joakim Verona 2024-11-04T16:30:58.535199Z

(jack/connect "Midi-Bridge:MPK mini 3 3:(capture_0) MPK mini 3 MIDI 1" midi-in )

Joakim Verona 2024-11-04T16:31:23.037419Z

returns an exception, but it succeeded once ( irestarted the repl a couple of times)

Joakim Verona 2024-11-04T16:32:16.615279Z

jack/connections does return "sylt:midi-in" and its visible in the graph

Joakim Verona 2024-11-04T16:32:39.905209Z

and the later jack/register call seems to have no effect

Joakim Verona 2024-11-04T19:15:36.824289Z

I made a ticket https://github.com/squidcasa/casa.squid.jack/issues/1