Sorted out separation between sequencer and interface code, added
harmonic quantisation for chorus
This commit is contained in:
		
							parent
							
								
									90e4ad3032
								
							
						
					
					
						commit
						bc282aa727
					
				| @ -24,9 +24,24 @@ OSCdef.freeAll; | ||||
| 
 | ||||
| ~quantspeed = { |v| 2.pow((v * 4 + 0.5).round - 5) }; | ||||
| 
 | ||||
| 
 | ||||
| ~quantharmonics = { | ||||
| 	arg f, quantise=0; | ||||
| 	quantise.postln; | ||||
| 	if(quantise != 0, { | ||||
| 		var fraction = f.asFraction(7, false); | ||||
| 		[f, fraction].postln; | ||||
| 		fraction[0] / fraction[1]; | ||||
| 	}, | ||||
| 	{ f } | ||||
| 	); | ||||
| }; | ||||
| 
 | ||||
| 
 | ||||
| // control ganging is hella laggy, do it in TouchOSC | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| ~setspeed = { | track, v | | ||||
| 	var speed, qv = if(~speedquant > 0, { ~quantspeed.value(v) }, { v }); | ||||
| 	speed = qv / ~buflen; | ||||
| @ -94,6 +109,15 @@ OSCdef.freeAll; | ||||
| 
 | ||||
| ~to.button('/grains/quant',   0, { |v| ~speedquant = v }); | ||||
| 
 | ||||
| ~to.button('/grains/metronome', 0, { |v| | ||||
| 	if( v == 1, { | ||||
| 		~bps = ~beatsperbar / ~buflen; | ||||
| 		~tc.tempo_(~bps); | ||||
| 	}); | ||||
| 
 | ||||
| 	~metromix.set(\amp, v) | ||||
| }); | ||||
| 
 | ||||
| 
 | ||||
| // Page 2: track | ||||
| 
 | ||||
| @ -110,6 +134,9 @@ OSCdef.freeAll; | ||||
| ~to.button('/track/slope',   0,                          { |v| ~granulator.slope_(v) }); | ||||
| 
 | ||||
| ~to.button('/track/chorus', 0,                            { |v| ~granulator.chorus_(v) }); | ||||
| ~to.slider('/track/harmonics', 2, TouchOSCScale(0.5, 3),     { |v| | ||||
| 	~granulator.harmonics_(~quantharmonics.value(v, 1)) | ||||
| }); | ||||
| ~to.slider('/track/detune', 0, TouchOSCScale(0, 0.059),   { |v| ~granulator.detune_(v) }); | ||||
| ~to.slider('/track/pitch', 0, TouchOSCScale(-2, 2),       { |v| ~granulator.pitch_(v.round) }); | ||||
| 
 | ||||
| @ -134,6 +161,7 @@ OSCdef.freeAll; | ||||
|  	~to.v_('/track/slope',  ~granulator.slope); | ||||
|  	~to.v_('/track/back',   ~granulator.back); | ||||
|  	~to.v_('/track/chorus', ~granulator.chorus); | ||||
|  	~to.v_('/track/harmonics', ~granulator.harmonics); | ||||
|  	~to.v_('/track/detune', ~granulator.detune); | ||||
|  	~to.v_('/track/pitch',  ~granulator.pitch); | ||||
|  }); | ||||
| @ -186,52 +214,6 @@ OSCdef.freeAll; | ||||
| ~to.slider('/lfos/cfreq',  0.5,TouchOSCScale(0.1, 200),   { |v| ~lfoc.set(\freq, v) } ); | ||||
| ~to.slider('/lfos/camp',  0,   TouchOSCScale(0, 1),       { |v| ~lfoc.set(\amp, v) }); | ||||
| 
 | ||||
| // metronome code here is a bit gross but easier | ||||
| 
 | ||||
| ~beatsperbar = 4; | ||||
| ~bps = ~beatsperbar / ~buflen; | ||||
| ~tc = TempoClock.new(~bps); | ||||
| 
 | ||||
| SynthDef(\metronome, { | ||||
| 	arg out=0, amp=1, pan=0, filter=1000, atk=0.01, rel=0.1; | ||||
| 	var sig, env; | ||||
| 	env = EnvGen.kr(Env.perc(atk, rel, amp), doneAction: Done.freeSelf); | ||||
| 	sig = HPF.ar(WhiteNoise.ar(), filter); | ||||
| 	Out.ar(out, Pan2.ar(sig * env, pan)); | ||||
| } | ||||
| ).add; | ||||
| 
 | ||||
| ~metrob = Bus.audio(s, 2); | ||||
| 
 | ||||
| ~metromix = SynthDef(\metromix, { | ||||
| 	arg in=1, out=0, amp=1; | ||||
| 	Out.ar(out, amp * In.ar(in, 2)); | ||||
| }).play(s, [\in, ~metrob, \out, 0, \amp, 0]); | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| ~metronome = Pbind( | ||||
| 	\instrument, \metronome, | ||||
| 	\dur, 1, | ||||
| 	\amp, 0.5, | ||||
| 	\pan, 0, | ||||
| 	\out, ~metrob | ||||
| ).play(~tc); | ||||
| 
 | ||||
| 
 | ||||
| ~to.button('/grains/metronome', 0, { |v| | ||||
| 	// reset tempo when turning metronome on | ||||
| 	if( v == 1, { | ||||
| 		~bps = ~beatsperbar / ~buflen; | ||||
| 		~tc.tempo_(~bps); | ||||
| 	}); | ||||
| 	// FIXME | ||||
| 	~metromix.set(\amp, v) | ||||
| 
 | ||||
| }); | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| ) | ||||
| 
 | ||||
|  | ||||
							
								
								
									
										14
									
								
								main.scd
									
									
									
									
									
								
							
							
						
						
									
										14
									
								
								main.scd
									
									
									
									
									
								
							| @ -11,6 +11,15 @@ Server.killAll; | ||||
| ( | ||||
| Routine.run({ | ||||
| 
 | ||||
| 	~usbinput = 2; | ||||
| 	~usbinput1 = 2; | ||||
| 	~usbinput2 = 3; | ||||
| 
 | ||||
| 	~buflen = 4.0; | ||||
| 	~beatsperbar = 4; | ||||
| 
 | ||||
| 	~touchosc_ip = "192.168.0.209"; | ||||
| 
 | ||||
| 	("./synths.scd").loadRelative; | ||||
| 	Granulator.init(s); | ||||
| 	s.sync; | ||||
| @ -20,11 +29,10 @@ Routine.run({ | ||||
| 	s.sync; | ||||
| 	("./effects.scd").loadRelative; | ||||
| 	s.sync; | ||||
| 	~touchosc_ip = "192.168.0.209"; | ||||
| 	("./sequencer.scd").loadRelative; | ||||
| 	s.sync; | ||||
| 	("./interface.scd").loadRelative; | ||||
| }); | ||||
| ) | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
|  | ||||
| @ -1,6 +1,6 @@ | ||||
| // metronome code here is a bit gross but easier | ||||
| 
 | ||||
| ~beatsperbar = 4; | ||||
| ( | ||||
| 
 | ||||
| ~bps = ~beatsperbar / ~buflen; | ||||
| ~tc = TempoClock.new(~bps); | ||||
| 
 | ||||
| @ -21,8 +21,6 @@ SynthDef(\metronome, { | ||||
| }).play(s, [\in, ~metrob, \out, 0, \amp, 0]); | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| ~metronome = Pbind( | ||||
| 	\instrument, \metronome, | ||||
| 	\dur, 1, | ||||
| @ -32,15 +30,5 @@ SynthDef(\metronome, { | ||||
| ).play(~tc); | ||||
| 
 | ||||
| 
 | ||||
| ~to.button('/grains/metronome', 0, { |v| | ||||
| 	// reset tempo when turning metronome on | ||||
| 	if( v == 1, { | ||||
| 		~bps = ~beatsperbar / ~buflen; | ||||
| 		~tc.tempo_(~bps); | ||||
| 	}); | ||||
| 	// FIXME | ||||
| 	~metromix.set(\amp, v) | ||||
| 
 | ||||
| }); | ||||
| 
 | ||||
| ) | ||||
| 
 | ||||
|  | ||||
| @ -1,12 +1,5 @@ | ||||
| ( | ||||
| 
 | ||||
| ~usbinput = 2; | ||||
| ~usbinput1 = 2; | ||||
| ~usbinput2 = 3; | ||||
| 
 | ||||
| ~buflen = 4.0; | ||||
| ~beatsperbar = 4; | ||||
| 
 | ||||
| SynthDef(\pos_sine, { | ||||
| 	arg out, speed=1; | ||||
| 	Out.kr(out, 0.5 + SinOsc.kr(speed * 0.5, 0, 0.5)); | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user