[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[sc-dev] 2 bugs and 2 q's



Hi, i have a few questions and bugs.  First, i got my
patch working a few days ago but tonight i added a
bunch of ffts for the effects it seems to work but
there are 2 problems one is ill get a "RESULT 11" i
think and the synth shuts off (too mcuh cpu?  im using
a 667g4). The other is that on the ones that it does
work on the sound is being chopped on and off at about
8hz (rough estimate) i have no idea why that is.

As for the bug reports, just the PV_BinScramble doesnt
seem to be installed and BufFrames.kr doesnt seem to
work either.

// Var ***********************************************
var numberOutputs, soundLoad, soundArray,
soundDurationArray;
var group, bus, bufferArray, writeBuffer, dir, path,
shell;
var selectedSize, sizeTemp;
var playStraight, playSynth, mainRoutine;
var effectArray, delay, distorsion, filter, ringMod,
math1, math2;
var pvBuffer, magAbove, magBelow, magSmear, binShift,
magSquared, brickWall;
var effectProb;

bus = Bus.new(index:0);

selectedSize = 0;
sizeTemp = 0;
numberOutputs = 10;

// Disk Out ******************************************

SynthDef("diskout", {
	arg bus, buffer;
	RecordBuf.ar(In.ar(bus, 2), buffer);
	ReplaceOut.ar(0, In.ar(bus,2));
}).writeDefFile;
s.sendSynthDef("diskout");

dir = (Date.localtime.rawSeconds * 10000);

shell = SCShell.new;
shell.cd("/Music/Samples/FileProcess");
shell.mkdir(dir);

path = "/Music/Samples/FileProcess/" ++ dir ++ "/";

// Synth Defs ****************************************

SynthDef("SoundFile", {
	arg amp = 1.0, rate = 1.0 , start, length, slope =
0.0, buffer, bus = 0;
	var env, sound;
	env =
EnvGen.kr(Env.new([0,1,1,0],[0.01,length-0.02,0.01]),levelScale:amp);
	sound = PlayBuf.ar(2, buffer, rate, 0.0, start *
44100,loop:1) * env;
	Out.ar(bus, sound);
}).writeDefFile;
s.sendSynthDef("SoundFile");

SynthDef("Delay", {
	arg mix, time, feedback, bus = 0;
	var sound, delay;
	sound = In.ar(bus, 2);
	delay = CombN.ar(sound, time, time, feedback);
	XOut.ar(bus, mix, delay);
}).writeDefFile;
s.sendSynthDef("Delay");

SynthDef("Distorsion", {
	arg mix, bit, clip, smp, bus = 0;
	var sound, dist;
	sound = In.ar(bus, 2);
	dist = Latch.ar(sound.trunc(bit).clip2(clip) *
(1/clip), Pulse.ar(smp));
	XOut.ar(bus, mix, dist);
}).writeDefFile;
s.sendSynthDef("Distorsion");

SynthDef("Filter", {
	arg mix, cuttoff, res, hplp, bus = 0;
	var sound, lowpass, highpass, filter;
	sound = In.ar(bus, 2);
	filter = RLPF.ar(sound,cuttoff,res,hplp) +
		RHPF.ar(sound,cuttoff,res,(1-hplp));
	XOut.ar(bus, mix, filter);
}).writeDefFile;
s.sendSynthDef("Filter");

SynthDef("RingMod", {
	arg mix, freq = 440, bus = 0;
	var sound, ring;
	sound = In.ar(bus, 2);
	ring = sound * SinOsc.ar(freq);
	XOut.ar(bus, mix, ring);
}).writeDefFile;
s.sendSynthDef("RingMod");

SynthDef("Math1", {
	arg mix, bus = 0, aa = 1;
	var sound, math;
	sound = In.ar(bus, 2);
	sound = (sound * (sound ** aa));
	XOut.ar(bus, mix, sound);
}).writeDefFile;
s.sendSynthDef("Math1");

SynthDef("Math2", {
	arg mix, bus = 0, aa = 2;
	var sound, math;
	sound = In.ar(bus, 2);
	4.do({
		sound = cos(sound) % sin(sound);
	});
	XOut.ar(bus, mix, sound);
}).writeDefFile;
s.sendSynthDef("Math2");

SynthDef("MagAbove", {
	arg mix, bus = 0, buffer = 0, thresh = 0.5;
	var sound, magAbove;
	sound = FFT.new(buffer, In.ar(bus, 2));
	magAbove = PV_MagAbove(sound, thresh);
	XOut.ar(bus, mix, IFFT.new(magAbove));
}).writeDefFile;
s.sendSynthDef("MagAbove");

SynthDef("MagBelow", {
	arg mix, bus = 0, buffer = 0, thresh = 0.5;
	var sound, magBelow;
	sound = FFT.new(buffer, In.ar(bus, 2));
	magBelow = PV_MagBelow(sound, thresh);
	XOut.ar(bus, mix, IFFT.new(magBelow));
}).writeDefFile;
s.sendSynthDef("MagBelow");

SynthDef("MagSmear", {
	arg mix, bus = 0, buffer = 0, bins = 5;
	var sound, magSmear;
	sound = FFT.new(buffer, In.ar(bus, 2));
	magSmear = PV_MagSmear(sound, bins);
	XOut.ar(bus, mix, IFFT.new(magSmear));
}).writeDefFile;
s.sendSynthDef("MagSmear");

SynthDef("BinShift", {
	arg mix, bus = 0, buffer = 0, stretch = 5, shift = 2;
	var sound, binShift;
	sound = FFT.new(buffer, In.ar(bus, 2));
	binShift = PV_BinShift(sound, stretch, shift);
	XOut.ar(bus, mix, IFFT.new(binShift));
}).writeDefFile;
s.sendSynthDef("BinShift");

SynthDef("MagSquared", {
	arg mix, bus = 0, buffer = 0;
	var sound, magSquared;
	sound = FFT.new(buffer, In.ar(bus, 2));
	magSquared = PV_MagSquared(sound);
	XOut.ar(bus, mix, IFFT.new(magSquared));
}).writeDefFile;
s.sendSynthDef("MagSquared");

SynthDef("BrickWall", {
	arg mix, bus = 0, buffer = 0, wipe = 0.1;
	var sound, brickWall;
	sound = FFT.new(buffer, In.ar(bus, 2));
	brickWall = PV_BrickWall(sound, wipe);
	XOut.ar(bus, mix, IFFT.new(brickWall));
}).writeDefFile;
s.sendSynthDef("BrickWall");

// Sound Files ***************************************

soundArray = [
	"/Rock Samples/A Day in the Life_01.aif",
	"/Rock Samples/A Day in the Life_02.aif",
	"/Rock Samples/A Day in the Life_03.aif",
	"/Rock Samples/A Day in the Life_04.aif",
	"/Rock Samples/Along The Watchtower_01.aif",
	"/Rock Samples/Along The Watchtower_02.aif",
	"/Rock Samples/Along The Watchtower_03.aif",
	"/Rock Samples/Along The Watchtower_04.aif",
	"/Rock Samples/Along The Watchtower_05.aif",
	"/Rock Samples/Bohemian Rhapsody_01.aif",
	"/Rock Samples/Bohemian Rhapsody_02.aif",
	"/Rock Samples/Bohemian Rhapsody_03.aif",
	"/Rock Samples/Bohemian Rhapsody_04.aif",
	"/Rock Samples/Bohemian Rhapsody_05.aif",
	"/Rock Samples/Bohemian Rhapsody_06.aif",
	"/Rock Samples/Girls On Film_01.aif",
	"/Rock Samples/Girls On Film_02.aif",
	"/Rock Samples/Girls On Film_03.aif",
	"/Rock Samples/Girls On Film_04.aif",
	"/Rock Samples/Girls On Film_05.aif",
	"/Rock Samples/Light My Fire_01.aif",
	"/Rock Samples/Peggy Sue_01.aif",
	"/Rock Samples/Peggy Sue_02.aif",
	"/Rock Samples/Rebel Yell_01.aif",
	"/Rock Samples/Rebel Yell_02.aif",
	"/Rock Samples/Rebel Yell_03.aif",
	"/Rock Samples/Rebel Yell_04.aif",
	"/Rock Samples/Rebel Yell_05.aif",
	"/Rock Samples/Rebel Yell_06.aif",
	"/Rock Samples/Rebel Yell_07.aif",
	"/Rock Samples/Rebel Yell_08.aif",
	"/Rock Samples/Tainted Love_01.aif",
	"/Rock Samples/Tainted Love_02.aif",
	"/Rock Samples/Tainted Love_03.aif",
	"/Rock Samples/Tainted Love_04.aif",
	"/Rock Samples/Tainted Love_05.aif",
	"/Rock Samples/That'll Be the Day_01.aif",
	"/Rock Samples/That'll Be the Day_02.aif",
	"/Rock Samples/That'll Be the Day_03.aif",
	"/Rock Samples/That'll Be the Day_04.aif",
	"/Rock Samples/You Really Got Me_01.aif",
	"/Rock Samples/You Really Got Me_02.aif"

];	

// Determine Buffer Numbers
bufferArray = Array.fill(soundArray.size, {
	arg i;
	Buffer.read(s, soundArray.at(i));
});

// Load Soundfiles
soundDurationArray = Array.fill(soundArray.size, {
	arg i;
	var soundfile, duration;
	soundfile = SoundFile.new;
	soundfile.openRead(soundArray.at(i));
	duration = soundfile.duration;
	soundfile.close;
	duration;
});

// Play Routine **************************************

playStraight = {
	arg length;
	var file, offset;
	file = bufferArray.size.rand;
	offset = (soundDurationArray.at(file) - length).rand;
	playSynth = playSynth.add(Synth.head(group,
"SoundFile", [
		"rate", [1, -1].choose * 2.0.rand,
		"start", offset,
		"length", length,
		"buffer", bufferArray.at(file).bufnum.postln,
		"bus", bus.index]));
	"play".postln;
};

// Effect Routines***********************************

delay = {
	playSynth = playSynth.add(Synth.tail(group, "Delay",
[ 
		"mix", 1.0.rand,
		"time", rrand(0.01, 2.0),
		"feedback", rrand(0.0, 3.0),
		"bus", bus.index]));
	"delay".postln;
};

distorsion = {
	playSynth = playSynth.add(Synth.tail(group,
"Distorsion", [
		"mix", 1.0.rand,
		"bit", rrand(0.0, 1.0),
		"clip", [rrand(0.01, 1.0), 1.0].choose,
		"smp", [rrand(40, 96000), rrand(40, 10000)].choose,
		"bus", bus.index]));
	"distorsion".postln;
};

filter = {
	playSynth = playSynth.add(Synth.tail(group, "Filter",
[
		"mix", 1.0.rand,
		"cuttoff", 50 + 2000.rand,
		"resonance", 1.0.rand,
		"hplp", [1, 0].choose,
		"bus", bus.index]));
	"filter".postln;
};

ringMod = {
	playSynth = playSynth.add(Synth.tail(group,
"RingMod", [
		"mix", 1.0.rand,
		"freq", [200.rand, 10000.rand].choose,
		"bus", bus.index]));
	"ring".postln;
};

math1 = {
	playSynth = playSynth.add(Synth.tail(group, "Math1",
[
		"mix", 1.0.rand,
		"bus", bus.index,
		"aa", rrand(0.1, 1.0)]));
	"math1".postln;
};

math2 = {
	playSynth = playSynth.add(Synth.tail(group, "Math2",
[
		"mix", 1.0.rand,
		"aa", 4.rand + 1,
		"bus", bus.index]));
	"math2".postln;
};

magAbove = {
	playSynth = playSynth.add(Synth.tail(group,
"MagAbove", [ 
		"mix", 1.0.rand,
		"bus", bus.index,
		"buffer", pvBuffer.bufnum,
		"thresh", rrand(40, 100)]));
	"magAbove".postln;
};

magBelow = {
	playSynth = playSynth.add(Synth.tail(group,
"MagBelow", [ 
		"mix", 1.0.rand,
		"bus", bus.index,
		"buffer", pvBuffer.bufnum,
		"thresh", rrand(40, 100)]));
	"magBelow".postln;
};

magSmear = {
	playSynth = playSynth.add(Synth.tail(group,
"MagSmear", [ 
		"mix", 1.0.rand,
		"bus", bus.index,
		"buffer", pvBuffer.bufnum,
		"bins", rrand(0.1, 32)]));
	"magSmear".postln;
};

binShift = {
	playSynth = playSynth.add(Synth.tail(group,
"BinShift", [ 
		"mix", 1.0.rand,
		"bus", bus.index,
		"buffer", pvBuffer.bufnum,
		"stretch", rrand(0, 0.4),
		"shift", rrand(-128, 128)]));
	"binShift".postln;
};

magSquared = {
	playSynth = playSynth.add(Synth.tail(group,
"MagSquared", [ 
		"mix", 1.0.rand,
		"bus", bus.index,
		"buffer", pvBuffer.bufnum,
		"thresh", rrand(0.1, 0.9)]));
	"magSquared".postln;
};

brickWall = {
	playSynth = playSynth.add(Synth.tail(group,
"BrickWall", [ 
		"mix", 1.0.rand,
		"bus", bus.index,
		"buffer", pvBuffer.bufnum,
		"wipe", rrand(-128, 128)]));
	"brickWall".postln;
};

effectProb = [10, 9, 15, 10, 10, 10, 5, 5, 10, 10, 5,
5].normalizeSum;

effectArray = [delay, distorsion, filter, ringMod,
math1, math2, magAbove	magBelow, magSmear, binShift,
magSquared, brickWall];

// Main **********************************************

mainRoutine = Routine({
	1.wait;
	numberOutputs.do({
		arg i;
		var numberEffects, size;
		
		size = rrand(0.1, 2.0);
		writeBuffer = Buffer.new(s, size * 44100, 2);
		
		group = Group.new;
		playSynth = Array.new;
		pvBuffer = Buffer.new(s, 2048, 2);
		0.5.wait;
		
		playSynth = playSynth.add(Synth.after(group,
"diskout", [
			"bus", bus.index, "buffer", writeBuffer.bufnum]));
		"write".postln;
				
		playStraight.value(size);
		selectedSize = size;
		
		numberEffects = 7.rand;
		numberEffects.do({
			effectArray.at(windex(effectProb)).value;
		});
					
		selectedSize.wait;
		
		writeBuffer.write((path ++ i.asString ++ ".aiff"),
leaveOpen:true);
		
		writeBuffer.close;
		writeBuffer.free;
		pvBuffer.free;
		group.free;
		playSynth.at(0).free;
		"done".postln;
		0.5.wait;
	});
	bus.free;
	bufferArray.size.do({
		arg i;
		bufferArray.at(i).free;
	});
});

SystemClock.play(mainRoutine);


__________________________________________________
Do you Yahoo!?
Yahoo! Mail Plus - Powerful. Affordable. Sign up now.
http://mailplus.yahoo.com