Skip to content

Instantly share code, notes, and snippets.

@BurkeB
Created October 7, 2016 19:49
Show Gist options
  • Save BurkeB/ebf5f01c0d20ff6b9dc111ac427ddea8 to your computer and use it in GitHub Desktop.
Save BurkeB/ebf5f01c0d20ff6b9dc111ac427ddea8 to your computer and use it in GitHub Desktop.
Microphone Clojure test
(def audioformat (new javax.sound.sampled.AudioFormat 44100 16 2 true true))
(def info (new javax.sound.sampled.DataLine$Info javax.sound.sampled.TargetDataLine audioformat))
(if (not= (javax.sound.sampled.AudioSystem/isLineSupported info))(print "dataline not supported")(print "ok lets start\n"))
(def line (javax.sound.sampled.AudioSystem/getTargetDataLine audioformat))
(.open line audioformat)
(.start line)
(let [size (/ (.getBufferSize line) 5)
buf (byte-array size)]
(if (> (.read line buf 0 size) 0)
(println (map int buf))))
(.close line)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment