audio - A clojure friendly library for playing sounds -
i'm looking easy program library infrequently playing sounds (notifications , like) clojure function.
edit: this
(use 'my.sound.lib')  (play-file "filename") (beep-loudly) (bark-like-a-dog) ...      
ok, question including api wishlist... ;-)
you can use jlayer mp3 playback on jvm. on ubuntu it's packaged libjlayer-java. there's simple example of use in java here. clojure wrapper:
(defn play-file [filename & opts]   (let [fis (java.io.fileinputstream. filename)         bis (java.io.bufferedinputstream. fis)         player (javazoom.jl.player.player. bis)]     (if-let [synchronously (first opts)]       (doto player         (.play)         (.close))       (.start (thread. #(doto player (.play) (.close)))))))   use (play-file "/path/to/file.mp3") play mp3 fly in separate thread, (play-file "/path/to/file.mp3" true) if you'd prefer play on current thread instead. tweak liking. supply own loud beep , barking dog mp3. ;-)
for load beep , like, use midi... perhaps blog entry helpful if choose try.
also, link original answer may still helpful in tweaking: java sound resources: links.
Comments
Post a Comment