Got to admit that I had a bit of a fight with the imports and the line that reads:
(. javax.sound.sampled.LineEvent$Type STOP) Your solution/syntax with (LineEvent$Type/STOP) is a clear winner! :-) Thanks. On Jul 28, 9:23 am, Michael Wood <esiot...@gmail.com> wrote: > 2009/7/28 verec <jeanfrancois.brouil...@googlemail.com>: > > > > > Here's a simple translation of my java production code (tested on OSX/ > > Vista/XP, java 1.5 & 6) > > The gotcha is to forget the line listener and never dispose the > > resources. > > When I first tried without it, it worked perfectly on OS X but > > stacked sound threads upon sound threads on XP. > > > This very same (java) code has been tested with: .wav. .aiff, .aif. > > and .au and works fine :-) > > > So here's my clojure attempt: > > That's a useful example :) > > I removed some of the imports that aren't being used: > > (ns sound-tests > (:import > (javax.sound.sampled AudioSystem LineEvent$Type LineListener) > (java.net URL))) > > (defn simple-play > [url] > (let [stream (AudioSystem/getAudioInputStream url) > clip (AudioSystem/getClip)] > (.addLineListener clip > (proxy[LineListener] [] > (update [event] > (when (and event > (= (.getType event) > (LineEvent$Type/STOP))) > (.close clip) > (.close stream))))) > (try > (.open clip stream) > (.start clip) > (catch Exception e nil)))) > > (simple-play (URL. > "file:///Developer/Examples/Java/Sound/JavaSoundDemo/audio/1-welcome.wav")) > > -- > Michael Wood <esiot...@gmail.com> --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---