SuperCollider

From Noah.org
Revision as of 10:53, 14 February 2017 by Root (talk | contribs)
Jump to navigationJump to search


Running SuperCollider

Language | Reboot Server
Language | Evaluate File

audio feedback

Be ready to hit the Mute button of your master volume control before you evaluate this code in SuperCollider.

This reads audio from the sound input hardware (microphone input by default on a laptop). Channel numbers begin at 1.

// mono -- patch input to output
(
SynthDef("help-AudioIn",{ arg out=0;
	Out.ar(out,
		AudioIn.ar(1)
	)
}).play;
)
// stereo -- patch input to output
(
SynthDef("help-AudioIn",{ arg out=0;
	Out.ar(out,
		AudioIn.ar([1,2])
	)
}).play;
)

audio feedback with frequency shift

This creates an echo feedback with a frequency shift. All sounds are shifted higher in frequency before being played back in the audio output. If the microphone is on then you should get some interesting feedback. You will have to adjust the microphone sensitivity and the output volume. You can adjust for the balance of feedback that either settles down or never settles down, depending on what you want.

// mono: patch input to output with frequency shift.
(
SynthDef("help-AudioIn",{ arg out=0;
	Out.ar(out,
FreqShift.ar(DelayC.ar(LPF.ar(AudioIn.ar(1),1000),0.2),50,0)
	)
}).play
)

//		FreqShift.ar(LPF.ar(AudioIn.ar(1), 1, 600, 0),10)
//		FreqShift.ar(AudioIn.ar(1),300,0)
//		FreqShift.ar(DelayC.ar(LPF.ar(AudioIn.ar(1),1000),0.2),50,0)
//    FreqShift(LPF.ar(AudioIn.ar(1),2000),200,0)
//Filter.Formlet.dumpClassSubtree
// 		LPF.ar(FreqShift.ar(AudioIn.ar(1,10),
//			MouseX.kr(-500,500)), 1000)

Record Microphone into a buffer for later processing

// IXI tutorial #4
// Record into an 8 second mono buffer.
b = Buffer.alloc(s, 44100 * 8.0, 1);
(
SynthDef(\recBuf,{ arg out=0, bufnum=0;
	var in;
	in = AudioIn.ar(1);
	RecordBuf.ar(in, bufnum);
}).load(s);
)

// record into the buffer
x = Synth(\recBuf, [\out, 0, \bufnum, b.bufnum]);
x.free;

// play it back using the playBuf synthdef created above
z = Synth(\playBuf, [\bufnum, b.bufnum])
z.free;

// save buffer to disk as an AIFF soundfile.
b.write("myBufRecording.aif", "AIFF", 'int16');