next Bibliografía
up Ejemplos en SuperCollider
previous SuperCollider: Reverberación
  Índice General   Índice de Materias


SuperCollider: Procesador de efectos genérico


// Procesador de efectos generico
// Rodrigo F. Cadiz
// Codigo para SuperCollider 2

var w;
var caption1,caption2,caption3,captionfbSlider,captionddSlider;
var captionfreqSlider,captiondelaySlider,captionmixSlider,captiongainSlider;
var vdBox, radio1, range1;
var freqSlider,delaySlider,mixSlider,gainSlider,fbBox,fbSlider,ddSlider;
var delayNum,freqNum,mixNum,gainNum,fbNum,ddNum;
var in1Box,in2Box,in3Box,captionSource;
var filename, sound, signal;
var fore_color;
var xoff1,xoff2;

// convert dB to amplitude
var dBtoA;
dBtoA = { arg decibels; r = 0.5011872336; r*10**(decibels/20.0);};

// GUI Window
w = GUIWindow.new("Generic Effects Processor >>> Rodrigo F. Cadiz", Rect.newBy(500, 70, 650, 400));
w.backColor = Color.new(99,130,160);

// Offsets
xoff1 = 10;
xoff2 = 350;

// Colors
fore_color = Color.new(255,255,0);

// Various labels
caption1 = StringView.new( w, Rect.newBy(xoff1, 10, 228, 20), "Advanced Audio Signal Processing");
caption1.labelColor = fore_color;
caption2 = StringView.new( w, Rect.newBy(xoff1, 30, 328, 20), "Generic Effects Processor");
caption2.labelColor = fore_color;
caption3 = StringView.new( w, Rect.newBy(xoff1, 50, 128, 20), "Rodrigo F. Cadiz");
caption3.labelColor = fore_color; 

// Mix
captionmixSlider = StringView.new( w, Rect.newBy(xoff1, 90, 235, 20), "Output Mix : 0.0 (dry) - 1.0 (wet) "); 
mixSlider = SliderView.new( w, Rect.newBy( xoff1, 110, 230, 20 ), "Mix", 0.5, 0.0, 1.0, 0.1, 'linear');
mixNum = NumericalView.new( w, Rect.newBy( xoff1+235, 110, 50, 20 ), "NumericalView", 0.5, 0.0, 1.0, 0.1, 'linear');
mixNum.backColor = fore_color;
mixSlider.action = { mixNum.value = mixSlider.value};

// Input Gain
captiongainSlider = StringView.new( w, Rect.newBy(xoff2, 10, 235, 20),"Input gain [dB] "); 
gainSlider = SliderView.new( w, Rect.newBy( xoff2, 30, 230, 20 ),"Mix", 0, -30 , 6 , 1, 'linear');
gainNum = NumericalView.new( w, Rect.newBy( xoff2+235, 30, 50, 20 ), "NumericalView", 0, -30, 6, 1, 'linear');
gainNum.backColor = fore_color;
gainSlider.action = { gainNum.value = gainSlider.value};

// Feedback phase
fbBox = CheckBoxView.new( w, Rect.newBy( xoff2, 65, 230, 20 ), "Feedback phase : -1 (off) +1 (on) ", 1, 0, 1, 0, 'linear');

// Feedback
captionfbSlider = StringView.new( w, Rect.newBy( xoff2, 90, 230, 20), "Feedback [%]");
fbSlider = SliderView.new( w, Rect.newBy( xoff2, 110, 230, 20 ), "Feedback", 50, 0, 99, 1, 'linear');
fbNum = NumericalView.new( w, Rect.newBy( xoff2+235, 110, 50, 20 ), "NumericalView", 50, 0, 99, 1, 'linear');
fbNum.backColor = fore_color;
fbSlider.action = { fbNum.value = fbSlider.value};

// Delay time 
captiondelaySlider = StringView.new( w, Rect.newBy(xoff1, 170, 235, 20), "Delay time : (seconds)"); 
delaySlider = SliderView.new( w, Rect.newBy( xoff1, 190, 230, 20 ),"Delay time", 0.001, 0, 0.05, 0.0005, 'linear');
delayNum = NumericalView.new( w, Rect.newBy( xoff1+235, 190, 50, 20), "NumericalView", 0.001, 0, 1, 0.0005, 'linear');
delayNum.backColor = fore_color;
delaySlider.action = { delayNum.value = delaySlider.value};

// Delay switch
vdBox = CheckBoxView.new( w, Rect.newBy(xoff2, 145, 428, 20), "Variable delay", 0, 0, 1, 0, 'linear');

// Oscillator frequency
captionfreqSlider = StringView.new( w, Rect.newBy(xoff2, 170, 235, 20),"Oscillator Frequency (delay) [Hz]"); 
freqSlider = SliderView.new( w, Rect.newBy( xoff2, 190, 230, 20 ),"SliderView", 10, 0, 20, 1, 'linear');
freqNum = NumericalView.new( w, Rect.newBy( xoff2+235, 190, 50, 20), "NumericalView", 10, 0, 20, 1, 'linear');
freqNum.backColor = fore_color;
freqSlider.action = { freqNum.value = freqSlider.value};

// Delay deviation
captionddSlider = StringView.new( w, Rect.newBy( xoff1, 240, 230, 20),"Delay deviation : 0% - 99%");
ddSlider = SliderView.new( w, Rect.newBy( xoff1, 260, 230, 20 ),"Deviation", 50, 0, 99, 1, 'linear');
ddNum = NumericalView.new( w, Rect.newBy( xoff1+235, 260, 50, 20 ),"NumericalView", 50, 0, 99, 1, 'linear');
ddNum.backColor = fore_color;
ddSlider.action = { ddNum.value = ddSlider.value};

// Select source
captionSource = StringView.new( w, Rect.newBy(xoff2, 220, 235, 20),"Select source"); 
captionSource.labelColor = fore_color;
in1Box = CheckBoxView.new( w, Rect.newBy( xoff2, 240, 230, 20 ), "Soundfile ", 1, 0, 1, 0, 'linear');
in2Box = CheckBoxView.new( w, Rect.newBy( xoff2, 260, 230, 20 ),"LFSaw", 0, 0, 1, 0, 'linear');
in3Box = CheckBoxView.new( w, Rect.newBy( xoff2, 280, 230, 20 ),"BrownNoise ", 0, 0, 1, 0, 'linear');

filename = ":Sounds:redobles.aiff";
sound = SoundFile.new;

if (sound.read(filename), {
	Synth.dualScope({

	var signal;// for audiofile stream
	var input,input1,input2,input3;// for effects processor
	var buffer;// for delay line
	var msignal;// wet signal
	var delsignal=0;// delayed signal 

	buffer = Signal.newClear(Synth.sampleRate * 3 * 0.5);
	signal = sound.data.at(0);

	// Different sources
	input1 = PlayBuf.ar(signal, sound.sampleRate, 1, 0, 0, signal.size-2)*dBtoA.value(gainSlider.kr); 
	input2 = LFSaw.ar(200, 0.1)*dBtoA.value(gainSlider.kr);
	input3 = BrownNoise.ar(0.1)*dBtoA.value(gainSlider.kr);

	// Source mix
	input = Mix.ar([input1 * in1Box.kr,input2 * in2Box.kr, input3 * in3Box.kr]);

	// Oscillator for variable delay
	v = SinOsc.kr(freqSlider.kr, 0.0, vdBox.kr * delaySlider.kr * ddSlider.kr * 0.01);
	
	delsignal = TapN.ar(buffer,delaySlider.kr + v);
	msignal = Mix.ar([input ,2*(fbBox.kr - 0.5) * delsignal * fbSlider.kr * 0.01]); 
	DelayWr.ar(buffer, msignal);

	Mix.ar([mixSlider.kr*msignal,(1.0 - mixSlider.kr)*input]);

	},0.1);

},{ (filename ++ " not found.\n").post });

w.close;


next Bibliografía
up Ejemplos en SuperCollider
previous SuperCollider: Reverberación
  Índice General   Índice de Materias

Copyright © 2008-06-05
Rodrigo F. Cádiz   - Centro de Investigación en Tecnologías de Audio, Instituto de Música, Pontificia Universidad Católica de Chile