Hi Mikkel,
What, specifically, do you mean by "kinda works"? :-) Also, is it fair to assume that you're working with the latest version of 0.8-dev from Github?
You're correct though, using the event system is now the preferred way of handling MIDI.
>
> But I cannot find out how to specify the event-type. Currently, it seems to be triggered on every event, including those that I send out with midi-note-on, which causes an infinite loop. How do I get it to only trigger on some specific device?
What are you trying to achieve? If you let us know, then we can probably help you more effectively.
In the meantime, in order to see which events are being fired, you can turn on event debugging:
(event-debug-on)
Then hit your keyboard, observe the events, then when you've found the correct event-key, turn off debugging with:
(event-debug-off)
Another approach, is to ask the event system to record the keys its sees over a short period of time. This can be achieved with:
(event-monitor-timer)
Which, by default, records the event keys it sees in the next 5 seconds. So bash away at one of the keyboard keys...
Then, when the timer has finished, you can observe the keys it saw with:
(event-monitor-keys)
With my Korg NanoKEY2 I see the following event-keys: (You should rebase to the latest master to see the same as this)
([:midi-device "KORG INC." "KEYBOARD" "nanoKEY2 KEYBOARD" :note-off]
(:midi-device "KORG INC." "KEYBOARD" "nanoKEY2 KEYBOARD" :note-off 49)
[:midi :note-off]
[:midi-device "KORG INC." "KEYBOARD" "nanoKEY2 KEYBOARD" :note-on]
(:midi-device "KORG INC." "KEYBOARD" "nanoKEY2 KEYBOARD" :note-on 49)
[:midi :note-on])
So, assuming the following super simple synth exists:
(definst beep [note 40] (* (env-gen (perc 0.1 0.1) :action FREE) (sin-osc (midicps note))))
(on-event
[:midi-device "KORG INC." "KEYBOARD" "nanoKEY2 KEYBOARD" :note-on]
(fn [msg]
(beep (:note msg)))
::play-beep)
Should allow you to play the beeps with the keyboard...
Sam
---
http://sam.aaron.name