SuperCollider

From Noah.org
Revision as of 10:19, 14 February 2017 by Root (Talk | contribs) (Running SuperCollider)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search


Running SuperCollider

Language | Reboot Server
Language | Evaluate File

Shifting pitch and reading mouse

This is probably a bit messed up. It is in an incomplete state of having a feature added. It works, but does not do what it appears.

(
{
        var mouse = MouseX.kr(100000,110000,1);
//w = SCWindow.new("I catch keystrokes");
	w = GUI.window.new( "my name is... panel", Rect( 128, 64, 340, 360 ));
	w.front;
	FreeVerb.ar(BPF.ar((SinOsc.ar(100000, 0, KeyState.kr(36, 0, MouseY.kr(1,0)) ) * SinOsc.ar(mouse)), mouse -100000, 0.2), 0.5, 0.3);
}.freqscope

//play({ SinOsc.ar(XLine.kr(200,17000,10),0,0.1) });

(
// A new example audio file replaces the older example.
// The older example appears to be a clip from NASA Houston
// trying to reach Columbia after it exploded during reentry.
// A bit morbid.  Now there is a trippy baby example in its place.
// Hopefully this doesn't turn out to have some creepy backstory.
//b = Buffer.read(s, Platform.resourceDir +/+ "sounds/a11wlk01-44_1.aiff");
b = Buffer.read(s, Platform.resourceDir +/+ "sounds/a11wlk01.wav");
{FreqShift.ar(PlayBuf.ar(1,b.bufnum,BufRateScale.kr(b.bufnum),loop:1),LFNoise0.kr(0.45,1000),0,[1,1])}.play(s);
)

//
{Splay.ar(Ringz.ar(Impulse.ar([2, 1, 4], [0.1, 0.11, 0.12]), [0.1,
0.1, 0.5])) * EnvGen.kr(Env([1, 1, 0], [120, 10]), doneAction: 2)}.play
)

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');