Skip to content

Instantly share code, notes, and snippets.

@pepijndevos
Created July 4, 2011 19:48
Show Gist options
  • Save pepijndevos/1063841 to your computer and use it in GitHub Desktop.
Save pepijndevos/1063841 to your computer and use it in GitHub Desktop.
Overtone Vocoder
(ns test
(:use overtone.live
;overtone.inst.synth
overtone.inst.io))
(def a (buffer 2048))
(def b (buffer 2048))
(definst vocoder [freq 432]
(let [input (in 8)
src (mix [(saw (* 1.01 freq)) (saw (* 0.99 freq))]); synth
formed (pv-mul (fft a input) (fft b src))
audio (ifft formed)]
(normalizer audio)))
(def kb (midi-in))
(def mem (atom {}))
(def logg (atom ()))
(defn assoc-once [m k v]
(if-not (get m k)
(assoc m k (v))
m))
(defn midi-responder [event timestamp]
; my synth has no :note-off, ajust accordingly
(when (= (:cmd event) :note-on)
(swap! logg conj event)
(if (> (:vel event) 0)
(swap! mem assoc-once
(:note event)
#(vocoder (midi->hz (:note event))))
(do
(kill (get @mem (:note event)))
(swap! mem dissoc (:note event))))))
(midi-handle-events kb midi-responder)
@samaaron
Copy link

samaaron commented Jul 5, 2011

What are a and b in this code?

@pepijndevos
Copy link
Author

Two buffers. I'll add them.

@samaaron
Copy link

samaaron commented Jul 5, 2011

What fun! Sounds nice with pink noise and a bit of reverb too:

(demo 60
      (let [input    (in 8) ; mic
            src      (pink-noise) ; synth
            formed   (pv-mul (fft a input) (fft b src))
            audio    (ifft formed)
            reverbed (g-verb audio 9 0.7 0.7)]
    (pan2 (* 0.1 reverbed))))

@pepijndevos
Copy link
Author

What I want to try is to find/make a synth with a 'full' sound, and hook it up to my keyboard. Only my keyboard doesn't send :note-off signals :(

@samaaron
Copy link

samaaron commented Jul 5, 2011

You could make a monophonic keyboard :-) Have you had a look in overtone.inst.synth for something 'full'?

@pepijndevos
Copy link
Author

I figured mine sends {:note-on :vel 0} on release. pad is fine, although I'd like it more pinchy.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment