Hello clojure group,

First off, everything I'm about to say only applies to Windows. The
code in question works fine (for me anyhow) on Linux, and I haven't
tried it on OSX.

Here's some Java code to get the first channel out of the default midi
synth. Assume the appropriate things are imported from
javax.sound.midi:
Synthesizer synth = MidiSystem.getSynthesizer();
MidiChannel c0 = synth.getChannels()[0];

In clojure:
(with-open [synth (MidiSystem/getSynthesizer)]
  (first (.getChannels synth)))

And that works fine, except that it closes the synthesizer. For my
purposes I have to keep the synth around and open, so I do something
like this:
(def synth (MidiSystem/getSynthesizer))
...later...
(some stuff (first (.getChannels synth)))

At which point I get the following exception:
java.lang.IllegalArgumentException: Can't call public method of non-
public class: public javax.sound.midi.MidiChannel[]
com.sun.media.sound.AbstractPlayer.getChannels()

synth is reported as being of type com.sun.media.sound.MixerSynth in
every case.

I thought, hey, maybe it's a concurrency issue, since in the code
where this originally cropped up getChannels was being called by an
agent and calling stuff on the synth obviously has side effects. But
unless I'm mistaken, doing
(do (def synth (MidiSystem/getSynthesizer))
    (.getChannels synth))
at the REPL should restrict it to happening sequentially in one
thread, and I still get the same exception.

Help?

/brian

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Reply via email to