Skip to content

Instantly share code, notes, and snippets.

@robert-spurrier
robert-spurrier / sample_fiddlin.clj
Created January 11, 2016 14:20
Using Clojure with Java interop to play a sample (javax.sound.sampled)
(ns sample-fiddlin.core
(import javax.sound.sampled.AudioSystem
javax.sound.sampled.DataLine$Info
javax.sound.sampled.Clip)
(:gen-class))
;; (play "clap/clap-808.wav")
(defn play [sound]
(let [audio-file (java.io.File. (str "dev-resources/" sound))
audio-stream (AudioSystem/getAudioInputStream audio-file)