Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

How to access UniMIDI::Output's @buffer to see if a note is still playing? #17

christiangenco opened this Issue Jul 20, 2012 · 5 comments


None yet
2 participants

I have an imperfect method of sending notes to be played to UniMIDI (javascript/ajax) and sometimes the signal to stop playing the note isn't sent, so the note keeps going on indefinitely.

I need a way to view which notes are currently playing, but can't find it in the documentation or demos. When I inspect my Output object, however, I see this:

=> #<UniMIDI::CoreMIDIAdapter::Output:0x007fceb217b5f0
   @client=#<FFI::Pointer address=0x00000005eeb01c>,
           [{:data=>[144, 36, 100], :timestamp=>19540.279150009155},
            {:data=>[144, 40, 100], :timestamp=>48366.633892059326}],

That @buffer array is exactly what I need (it's currently showing two notes, 36 and 40, that haven't been stopped), but after several minutes pouring through the docs and poking each of Output's public methods, I can't seem to get at it. Is there a correct way to do this?


arirusso commented Jul 22, 2012



@ghost ghost assigned arirusso Jul 22, 2012


arirusso commented Jul 22, 2012


(disregard my last message)

I'll need to know a little more about your setup. What exactly are you doing with the output?

You may need to instantiate an input eg.

@i = UniMIDI::Input.first

Then you can inspect the buffer directly on that object

=> [144, 36, 100]

Ahh hah! That fixes my problem - thanks :D

Is there a good reason why UniMIDI::Output can't have a buffer method as well?


arirusso commented Jul 23, 2012

@christiangenco Great, glad to help.

The output itself doesn't have a buffer. The fact that you can see the input buffer associated with the output buffer (as in the example you posted) is a peculiarity of how OSX CoreMIDI organizes MIDI ins and outs.

I'm more than happy to consider anything if you have a compelling argument

but (to my knowledge) Linux and Windows wouldn't natively accomodate that functionality, and Unimidi is cross-platform...so it could be impossible or a ton of trouble to implement, for what I would currently consider not a lot of gain

@arirusso arirusso closed this Jul 23, 2012

Reason enough for me!

Thanks for your work on this gem - it's absolutely perfect for turning things into MIDI keyboards via MaKey MaKey.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment