Skip to content

Instantly share code, notes, and snippets.

@xavriley xavriley/README.md
Created Jun 18, 2018

Embed
What would you like to do?
Sonic Pi Vocoder Prototype

Prototype of vocoder on Sonic Pi

Demo here: https://www.dropbox.com/s/qiktze3ml7bz5iq/autotune_the_shipping_forecast.wav?dl=0 Original voice input here: https://soundcloud.com/jb_uk/neil-nunes-bbc-radio-4-and

This is a demo of a simple effects synth using the Vocoder.ar UGen from SuperCollider. This is a fairly primitive vocoder implementation made of a bunch of bandpass filters which are "tuned" to various frequencies.

The results are mixed, but it's difficult to get a decent reproduction of the words from this.

To get T-Pain/Imogen Heap style auto-tune it would be necessary to write a different algorithm probably using a technique called PSOLA which is described at the following links:

Part of the problem is that the algorithm is probably under copyright which makes distribution of an open source version more difficult.

//s.boot;
//s.quit;
(
SynthDef('sonic-pi-fx_vocoder', {
arg out_bus=0, in_bus=0;
var car, mod, result;
car = In.ar(in_bus,1);
mod = In.ar(in_bus+1,1);
result = Vocoder.ar(car, mod, 32);
Out.ar(out_bus, result.dup);
}).writeDefFile("/Users/xriley/Projects/sonic-pi/etc/synthdefs/compiled/"); // change this path to point to Sonic Pi on your system
)
live_loop :bd do
sample :bd_haus
sleep 0.5
end
in_thread do
with_fx :vocoder do
# right channel provides the voice input to the effect
with_fx :band_eq, freq: 70, db: 2 do
sample "/Users/xriley/Movies/shipping_forecast.wav", start: 0.506, amp: 5, rate: 1, pan: 1
end
# using a noisy synth gives more for the vocoder to work with
x = synth :supersaw, sustain: 200, note_slide: 0.05, pan: -1
200.times do
control(x, note: (scale :a2, :minor_pentatonic, num_octaves: 2).choose)
sleep [0.5,0.25,1].choose
end
end
end
diff --git a/app/server/ruby/lib/sonicpi/synths/synthinfo.rb b/app/server/ruby/lib/sonicpi/synths/synthinfo.rb
index d70c85199..135c8c765 100644
--- a/app/server/ruby/lib/sonicpi/synths/synthinfo.rb
+++ b/app/server/ruby/lib/sonicpi/synths/synthinfo.rb
@@ -4942,6 +4942,28 @@ A decent range of Q factors for naturally sounding boosts/cuts is 0.6 to 1.
end
end
+ class FXVocoder < FXInfo
+ def name
+ "Vocoder"
+ end
+
+ def introduced
+ Version.new(2,10,0)
+ end
+
+ def synth_name
+ "fx_vocoder"
+ end
+
+ def doc
+ ""
+ end
+
+ def arg_defaults
+ super.merge({})
+ end
+ end
+
class FXMono < FXInfo
def name
"Mono"
@@ -7606,6 +7628,7 @@ Use FX `:band_eq` with a negative db for the opposite effect - to attenuate a gi
:fx_replace_reverb => FXReverb.new,
:fx_level => FXLevel.new,
:fx_mono => FXMono.new,
+ :fx_vocoder => FXVocoder.new,
:fx_replace_level => FXLevel.new,
:fx_echo => FXEcho.new,
:fx_replace_echo => FXEcho.new,
@xavriley

This comment has been minimized.

Copy link
Owner Author

xavriley commented Jun 18, 2018

This might be worth looking at for a PSOLA implementation

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.