Overtone MIDI event management (in/out?)

118 views
Skip to first unread message

Tom K

unread,
Feb 26, 2017, 11:16:42 AM2/26/17
to Overtone
Hi All

I need a bit of help around the midi utilities in Overtone - as someone not too familiar with Clojure (but keen to learn). 

I have been extending the below (simple) snippet from the basic.clj example, to consume events from a specific MIDI device (fun stuff):

(defonce memory (agent {}))

(on-event [:midi :note-on]
          (fn [m]
            (send memory
                  (fn [mem]
                    (let [n (:note m)
                          s (pad2 :freq (midi->hz n))]
                      (assoc mem n s)))))
          ::play-note)


I am interested in processing these events and transmitting real-time MIDI events; are outbound events possible within Overtone? I may be missing something, but couldn't find examples against midi-note-on.

If so, regarding the function I noticed below, I would be very keen to see an example (if relevant) on processing a given event stream in a synchronous way. Is it even necessary to use this?

(defn midi-agent-for-control
  "Returns an agent representing the current value of a
  controller-specific control identified by a fully-qualified MIDI event
  key such as that generated by midi-mk-full-control-event-key. If the
  agent doesn't exist, it is created and cached. Subsequent calls with
  the same control-key will return the same agent.

  Agents are used because the event to update them can be safely handled
  synchronously (with on-sync-event) without watchers being able to
  block the thread generating the MIDI events. This also means that
  incoming events are sent to the agent in the correct order whereas if
  the thread pool were used (via on-event), the incoming events may be
  arbitrarily ordered."

Thanks
Tom

Ben Glover

unread,
Mar 1, 2017, 7:21:03 AM3/1/17
to Overtone
The documentation's a bit scanty, but I think you'll find the relevant definitions are here:


...midi.clj now having been integrated into Overtone. There's a simple example in this thread:


* * * * *

...so using:

(def my-synth (midi-out))

...will allow you to select a device from a popup window, and you can then use:

(midi-note-on my-synth 65 90 1)

...specifying note, vel, channel. 
Reply all
Reply to author
Forward
0 new messages