Capture USB-microphone in clojure overtone

226 Views Asked by At

How I can use USB-mic in Overtone? Here is an example to use regular 3.5mm microphone:

(ns insane-noises.vocoder)
(use 'overtone.live)

(def a (buffer 2048))
(def b (buffer 2048))

(demo 5
      (let [input  (sound-in 0); mic
            src    (white-noise) ; synth - try replacing this with other sound sources
            formed (pv-mul (fft a input) (fft b src))
            audio  (ifft formed)]
          (pan2 (* 0.1 audio))))

When I try in (sound-in 0) change 0 to 1, 2, 3... - nothing works. My mic works good in all applications like skype etc.

1

There are 1 best solutions below

1
On

I've just tried to reproduce it. It works only intermittently. I ran

(event-debug-on) 

in the REPL, allowing me to see the OSC communication between Overtone and SuperCollider.

It fails in two different ways depending on whether I'm using overtone.core and connecting to an external server, or using overtone.live.

With overtone.live, I allocate the buffers just fine, but when I run the demo function, I get:

event:  [:overtone :osc-msg-received] (:msg {:path "/done", :type-tag "s", :args ("/d_recv")}) 

event:  "/done" (:path "/done" :args ("/d_recv")) 

event:  [:overtone :osc-msg-received] (:msg {:path "/synced", :type-tag "i", :args (18)}) 

event:  "/synced" (:path "/synced" :args (18)) 

zombified - calling shutdown handler
event:  [:overtone :osc-msg-received] (:msg {:path "/n_go", :type-tag "iiiii", :args (34 7 -1 -1 0)}) 

event:  "/n_go" (:path "/n_go" :args (34 7 -1 -1 0)) 

event:  [:overtone :node-created 34] ({:node #<synth-node[live]: beatboxchad-l394/audition-synth 34>}) 

... followed by a bunch of events related to Overtone cleaning up its default nodes and groups and such as part of shutting down. If you don't get the same output from your overtone.live, I'll know I have something to troubleshoot about my JACK settings or something.

Using overtone.core connected to an external server, it works intermittently.

When it works, I get the following events:

event:  [:overtone :osc-msg-received] (:msg {:path "/d_removed", :type-tag "s", :args ("beatboxchad-l394/audition-synth"), :src-host "localhost.localdomain", :src-port 57110}) 

event:  "/d_removed" (:path "/d_removed" :args ("beatboxchad-l394/audition-synth")) 

event:  [:overtone :osc-msg-received] (:msg {:path "/done", :type-tag "s", :args ("/d_recv"), :src-host "localhost.localdomain", :src-port 57110}) 

event:  "/done" (:path "/done" :args ("/d_recv")) 

event:  [:overtone :osc-msg-received] (:msg {:path "/synced", :type-tag "i", :args (71), :src-host "localhost.localdomain", :src-port 57110}) 

event:  "/synced" (:path "/synced" :args (71)) 

event:  [:overtone :osc-msg-received] (:msg {:path "/n_go", :type-tag "iiiii", :args (114 7 -1 -1 0), :src-host "localhost.localdomain", :src-port 57110}) 

event:  "/n_go" (:path "/n_go" :args (114 7 -1 -1 0)) 

event:  [:overtone :node-created 114] ({:node #<synth-node[live]: beatboxchad-l394/audition-synth 114>}) 

event:  [:overtone :osc-msg-received] (:msg {:path "/n_end", :type-tag "iiiii", :args (114 7 -1 -1 0), :src-host "localhost.localdomain", :src-port 57110}) 

event:  "/n_end" (:path "/n_end" :args (114 7 -1 -1 0)) 

event:  [:overtone :node-destroyed 114] ({:node #<synth-node[destroyed]: beatboxchad-l394/audition-synth 114>}) 

When it fails, I get these:

event:  [:overtone :osc-msg-received] (:msg {:path "/d_removed", :type-tag "s", :args ("beatboxchad-l394/audition-synth"), :src-host "localhost.localdomain", :src-port 57110}) 

event:  "/d_removed" (:path "/d_removed" :args ("beatboxchad-l394/audition-synth")) 

event:  [:overtone :osc-msg-received] (:msg {:path "/done", :type-tag "s", :args ("/d_recv"), :src-host "localhost.localdomain", :src-port 57110}) 

event:  "/done" (:path "/done" :args ("/d_recv")) 

event:  [:overtone :osc-msg-received] (:msg {:path "/synced", :type-tag "i", :args (72), :src-host "localhost.localdomain", :src-port 57110}) 

event:  "/synced" (:path "/synced" :args (72)) 

event:  [:overtone :osc-msg-received] (:msg {:path "/fail", :type-tag "ss", :args ("/s_new" "duplicate node ID"), :src-host "localhost.localdomain", :src-port 57110}) 

event:  "/fail" (:path "/fail" :args ("/s_new" "duplicate node ID")) 

This looks like a malfunction in the OSC communication with the server -- somewhere the node ID isn't getting incremented correctly.

What do you get in terms of events when you try?