overtone 2024-09-20

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

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))

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

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

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

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

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

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"]]

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

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

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

Are you using midi/midi-in?

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

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)

this works now thanks @diego.vid.eco!

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

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

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

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

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

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

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

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