Task glissando / Wavesets

Hello,

I am totally new on SC and I would like to know the appropriate syntax to decrease, in this code, the playRate of 0.01 for each iteration. There is 100.do, so it would mean going from playRate 1 to playRate 0.01 at the end of the process (100.do and 0.01 decrease for each .do) : like a pitch glissando. I hope it’s clear :slight_smile:

Thanks a lot.


w = Wavesets.from("soundfile");

(


SynthDef(\wvst0, { arg out = 0, buf = 0, start = 0, length = 441, playRate = 0.01, sustain = 1,
	                   amp= 0.2, pan;
    var phasor = Phasor.ar(0, BufRateScale.ir(buf) * playRate, 0, length) + start;
    var env = EnvGen.ar(Env([amp, amp, 0], [sustain, 0]), doneAction: 2);
	var snd = BufRd.ar(1, buf, phasor) * 1;

	OffsetOut.ar(out, Pan2.ar(snd, pan));
}, \ir.dup(8)).add;

)

(
Task({
	inf.do {


		   100.do({ arg i;
	 		var ev = w.eventFor( i ,numWs:17 +  10.rand, repeats:3 + 5.rand, playRate: 1); ///???
			ev.putPairs([\pan, [-1, 1].choose, \amp,1]);
			ev.play;
			0.01.wait;
		});

	4.wait;


}
}).play;
)

Wavesets is not a standard SuperCollider class.
So what’s your goal ? Play that soundfile over and over at an increasing play rate ?

So generally speaking you can replace your

100.do({ arg i;

by

1.forBy(0.01, -0.01, { arg prate;

and use prate as argument for the playrate

The goal here is to increase or decrease the playRate wavesets after wavesets:
100.do means it’s gone play the first 100 wavesets of the soundfile, one after the other, starting from the begining. I would like the playRate value of the first waveset to be 1, the second 0.09 and so on to reach 0.01 at the 100th wavesets - end of the Task (let’s forget the inf.do in the example which is confusing). It’s supposed to play a short glissando of the pitch, on a short fragment of the soundfile (the first 100 wavesets)

And thanks Igvr123, but can you write the complete Task, I am sorry I don’t get it

It would be like this

(
Task({
	inf.do {
		   1.forBy(0.01, -0.01, { arg prate;
	 		var ev = w.eventFor( i ,numWs:17 +  10.rand, repeats:3 + 5.rand, playRate: prate); ///???
			ev.putPairs([\pan, [-1, 1].choose, \amp,1]);
			ev.play;
			0.01.wait;
		});
	4.wait;
}
}).play;
)

but I can’t test because I don’t have that quark installed.

I would suggest you to look at Patterns. You’d be able to right that far more easily.

This is as example with a basic Synth that plays a basic sound:

(
~buf = Buffer.read(s, "C:/temp/a.wav");
~buf.bufnum.postln;

SynthDef(\synth, {
	var out = \out.kr(0),
	amp=\amp.kr(1), pan=\pan.kr(0),
	bufnum=\buf.ir(0), rateCtrl=\playRate.ir(1);
	var sig;
	sig = PlayBuf.ar(1, bufnum, BufRateScale.ir(bufnum)*rateCtrl, doneAction: 2);
	sig = sig * amp * EnvGate.new(fadeTime: 3);
	Out.ar(out,Pan2.ar(sig,pan));
}).add;
)

// HERE COMES THE INTERESTING PART
(
q=
Pseq([
	Pbind(
		\instrument,\synth,
		\buf,~buf.bufnum,
		\amp,1,
		\dur, 0.01, play each next iteration after 0.01 beat
		\playRate, Pseries(1,-0.01,100) // play the Synth 100 times and decrease by 0.01 the playRate at each iteration
	),
	Rest(4) // wait for 4 beats
	],inf // repeat the pattern indefinitely
).play;
)

You can also keep to the 100.do syntax and use the linlin syntax to map the i variable to 1 … 0.01 range.

Or just write 1 - (i/100)

		   100.do({ arg i;
	 		var ev = w.eventFor( i ,numWs:17 +  10.rand, repeats:3 + 5.rand, playRate: i.linlin(0,99, 1,0.01)); 

Thanks hemiketal, really minimal, and that’s it!

And thanks Ivgr for the discovery of Pseries which is extremely handy. As for information, the forBy method gave me this error message:


-> a Task
ERROR: Primitive '_BasicClipAt' failed.
Index not an Integer
RECEIVER:
Instance of Array {    (0x11a76e080, gc=00, fmt=01, flg=00, set=0C)
  indexed slots [3765]
      0 : Float 19.076842   EC990FA1 403313AB
      1 : Float 62.582837   64B0F8FB 404F4A9A
      2 : Float 101.728300   76CB4DF3 40596E9C
      3 : Float 141.821287   FB1EB428 4061BA47
      4 : Float 160.872135   878C7E52 40641BE8
      5 : Float 209.575209   1C860FB0 406A3268
      6 : Float 291.170942   2D83FC31 407232BC
      7 : Float 310.779702   A94527C6 40736C79
      8 : Float 346.351022   C99C53A7 4075A59D
      9 : Float 379.841356   315B51EF 4077BD76
     10 : Float 420.839448   60BEA974 407A4D6E
     11 : Float 432.753363   C699D460 407B0C0D
     12 : Float 470.104917   BD373750 407D61AD
     13 : Float 515.508290   FA9596E8 40801C10
     14 : Float 594.650103   6927AB18 40829533
     15 : Float 609.900327   DE8933DF 40830F33
     16 : Float 654.317553   591FE22B 4084728A
     17 : Float 690.391806   6B421463 40859322
     18 : Float 749.117022   A933212D 408768EF
     19 : Float 792.732140   6C774CB6 4088C5DB
     20 : Float 822.000000   00000000 4089B000
     21 : Float 884.353907   CD348448 408BA2D4
     22 : Float 918.607988   28CB80DE 408CB4DD
     23 : Float 951.744868   7D2EAA95 408DBDF5
     24 : Float 995.106692   812356DA 408F18DA
     25 : Float 1008.114840   316FA115 408F80EB
     26 : Float 1062.526231   DC2BFDAA 40909A1A
     27 : Float 1106.372615   8EC64DD3 4091497D
     28 : Float 1189.761149   6AA4B67C 4092970B
     29 : Float 1219.707691   ACD8AAA3 40930ED4
     30 : Float 1243.572013   BDB4556A 40936E49
     31 : Float 1283.510334   94E61333 40940E0A
    ...
}
PATH: /Users/perso/Documents/PPP/P15.scd
CALL STACK:
	MethodError:reportError
		arg this = <instance of PrimitiveFailedError>
	Nil:handleError
		arg this = nil
		arg error = <instance of PrimitiveFailedError>
	Thread:handleError
		arg this = <instance of Thread>
		arg error = <instance of PrimitiveFailedError>
	Thread:handleError
		arg this = <instance of Routine>
		arg error = <instance of PrimitiveFailedError>
	Object:throw
		arg this = <instance of PrimitiveFailedError>
	Object:primitiveFailed
		arg this = [*3765]
	Wavesets:frameFor
		arg this = <instance of Wavesets>
		arg startWs = nil
		arg numWs = 21
		arg useFrac = true
		var whichXings = [*3765]
		var startFrame = nil
		var endFrame = nil
		var length = nil
		var sustain = nil
	Wavesets:eventFor
		arg this = <instance of Wavesets>
		arg startWs = nil
		arg numWs = 21
		arg repeats = 3
		arg playRate = 1.0
		arg useFrac = true
		var start = nil
		var length = nil
		var sustain1 = nil
	< closed FunctionDef >
		arg prate = 1.0
		var ev = nil
	Integer:forBy
		arg this = 1
		arg endval = 0.01
		arg stepval = -0.01
		arg function = <instance of Function>
		var i = 1.0
		var j = 0
	< closed FunctionDef >  (no arguments or variables)
	Float:do
		arg this = inf
		arg function = <instance of Function>
		var i = 0.0
	Routine:prStart
		arg this = <instance of Routine>
		arg inval = 13546.724652643
^^ The preceding error dump is for ERROR: Primitive '_BasicClipAt' failed.
Index not an Integer
RECEIVER: [ 19.076842105263, 62.582836710369, 101.72829980711, 141.8212867355, 160.87213494721, 209.57520891365, 291.17094184453, 310.77970244421, 346.35102234903, 379.84135566399, 420.83944773176, 432.7533632287, 470.10491677827, 515.50829045169, 594.65010291091, 609.90032679739, 654.31755280408, 690.39180614114, 749.11702194161, 792.73214047625, 822.0, 884.35390702275, 918.60798796641, 951.74486767252, 995.10669162377, 1008.1148403855, 1062.5262305139, 1106.3726149545, 1189.7611489998, 1219.7076906065, 1243.5720127...etc...