I'm writing a Java application that takes MIDI events from an external
device (a Casio keyboard) and prints out the MIDI events of the notes
that I'm playing.
My problem is that after I run the program once, I can't open the
device again!
It seems that whether or not I call close() on an instance of a
MidiDevice, I get
"javax.sound.midi.MidiUnavailableException: Failed to open the device."
the next time I run my application.
In addition, if I try to undock the USB connection to my Casio
keyboard, Windows tells me I can't do that, because the device is still
being used.
Any ideas?
Thank you!
-Dave
Andrew Thompson - 22 Nov 2006 06:10 GMT
> I'm writing a Java application that takes MIDI events from an external
> device (a Casio keyboard) and prints out the MIDI events of the notes
> that I'm playing.
>
> My problem is that after I run the program once, I can't open the
> device again!
...
> Any ideas?
I vaguely recall encountering similar problems with
audio code, but did not resolve them at the time.
(Revisits java docs for sound..)
They mention in MidiDevice.getReceivers() that
"A receiver can be removed from the device by closing it."
I am not sure of the exact signinficance of that,
but it suggests it might be a good strategy to close
all Recievers and Transmitters attached to the
MidiDevice.
Any improvement?
Andrew T.
dmkoelle@gmail.com - 22 Nov 2006 15:27 GMT
That may work - I tried something similar because I had added a new
receiver, but maybe I need to close the default receiver as well.
I'll let you know how it goes!
-Dave