Warp1 playback speed?

Hi folks,

How could I tell to the Warp1 object this thing : “play the audio file from the 0 position of the buffer (start) to the position 0.4 of the buffer at 10% of his speed, and then from this positions to the end at 60% of his speed…” and of course add as many segment that I want: ie automation of the playback speed.
So far I only know to use it, using a envelope or a line as a pointer value (code below), which is not the same thing (ie go from here to here in X time).

Thanks!

(
b.free;
b = Buffer.read(s, “…”);
{
var pointer = EnvGen.ar(Env([0,1],[900],\lin));
var sound = Warp1.ar(2, b, pointer,1, 0.2, -1, 16, pointer, 4);

Out.ar(0!2,sound*0.1)

}.play
)

no matter what you do, you’ll need the pointer to have a sense of the buffer’s duration.

var env, pointer, bufDur;
bufDur = b.duration;
env = Env([0, 0.4, 1.0], [4, 1.0]); // 0.4 is 40% of the file, stretched 10 times, or 0.4/0.1, and , 1.0 is 60% of the file at 60% rate, or 0.6 / 0.6
pointer = EnvGen.kr(env, timeScale: bufDur); // use kr here - no reason to use ar on this EnvGen

I think that should do what you want.

Hope that helps.
Josh

1 Like

It totally makes sens, thanks Josh.
Unfortunately i got an error message (that i don’t get) when i run the line, can you try with your own soundfile and tell me what happens ? Thx a lot

(
b.free;
b = Buffer.read(s, “…”);
{
var bufDur = b.duration;
var env= Env([0,0.4,1],[4,1]);
var pointer = EnvGen.kr(env,timeScale: bufDur);
var sound = Warp1.ar(2, b, pointer,1, 0.2, -1, 16, pointer, 4);

Out.ar(0!2,sound*0.1)

}.play
)

No error on my end… what does your error say? Also - is your buffer mono or stereo? Warp1 really only works with mono files, so your first argument should be 1. I am going to try and make it work with multi-channel in the near future, but for now (as stated in the helpfile) it needs mono.

Same thing with mono file…

ERROR: Message ‘/’ not understood.
RECEIVER:
nil
ARGS:
nil
PATH: /Users/raphaelhhhh/Desktop/Crucifixus111.scd

PROTECTED CALL STACK:
Meta_MethodError:new 0x11275f440
arg this = DoesNotUnderstandError
arg what = nil
arg receiver = nil
Meta_DoesNotUnderstandError:new 0x112761400
arg this = DoesNotUnderstandError
arg receiver = nil
arg selector = /
arg args = [ nil ]
Object:doesNotUnderstand 0x10d4fa340
arg this = nil
arg selector = /
arg args = nil
a FunctionDef 0x10d35cfc8
sourceCode = "{
var bufDur = b.duration;
var env= Env([0,0.4,1],[4,1]);
var pointer = EnvGen.kr(env,timeScale: bufDur);
var sound = Warp1.ar(1, b, pointer,1, 0.2, -1, 16, pointer, 4);

Out.ar(0!2,sound*0.1)

}"
var bufDur = nil
var env = nil
var pointer = nil
var sound = nil
SynthDef:buildUgenGraph 0x11411e480
arg this = a SynthDef
arg func = a Function
arg rates = nil
arg prependArgs = [ ]
var result = nil
var saveControlNames = [ ControlName P 0 i_out scalar 0 ]
a FunctionDef 0x1132bc100
sourceCode = “”
arg i_out = an OutputProxy
var result = nil
var rate = nil
var env = nil
SynthDef:buildUgenGraph 0x11411e480
arg this = a SynthDef
arg func = a Function
arg rates = nil
arg prependArgs = [ ]
var result = nil
var saveControlNames = nil
a FunctionDef 0x11411cac0
sourceCode = “”
Function:prTry 0x1129cd3c0
arg this = a Function
var result = nil
var thread = a Thread
var next = nil
var wasInProtectedFunc = false

CALL STACK:
DoesNotUnderstandError:reportError
arg this =
Nil:handleError
arg this = nil
arg error =
Thread:handleError
arg this =
arg error =
Object:throw
arg this =
Function:protect
arg this =
arg handler =
var result =
SynthDef:build
arg this =
arg ugenGraphFunc =
arg rates = nil
arg prependArgs = nil
Function:play
arg this =
arg target =
arg outbus = 0
arg fadeTime = 0.02
arg addAction = ‘addToHead’
arg args = nil
var def = nil
var synth = nil
var server =
var bytes = nil
var synthMsg = nil
Interpreter:interpretPrintCmdLine
arg this =
var res = nil
var func =
var code = “(
b.free;
b = Buffer.read(s,…”
var doc = nil
var ideClass =
Process:interpretPrintCmdLine
arg this =
^^ The preceding error dump is for ERROR: Message ‘/’ not understood.
RECEIVER: nil

The code:

(
b.free;
b = Buffer.read(s, “/Users/raphaelhhhh/Desktop/Crucifixius_01.L.wav”);
{
var bufDur = b.duration;
var env= Env([0,0.4,1],[4,1]);
var pointer = EnvGen.kr(env);
var sound = Warp1.ar(1, b, pointer,1, 0.2, -1, 16, pointer, 4);

Out.ar(0,sound*0.1)

}.play
)

so - the error dump shows that b.duration is failing. This is an asynchronous task, and I am guessing that you are getting nils by running all of this at once. Try:

(
s.boot;
s.waitForBoot({
b = Buffer.read(s, “/Users/raphaelhhhh/Desktop/Crucifixius_01.L.wav”);
s.sync;
{
var bufDur = b.duration;
var env= Env([0,0.4,1],[4,1]);
var pointer = EnvGen.kr(env, timeScale: b.duration);
var sound = Warp1.ar(1, b, pointer,1, 0.2, -1, 16, pointer, 4);
Out.ar(0,sound*0.1)
}.play
})
)

That’s it. Thanks a lot.

Last thing, in this case how would you could write this line: from 100% of the speed at the buffer start to 0.10% of the speed at the buffer end, in 15 minutes ?
Superthanks.

You might want to download the WarpExt quark, and take a look at Warp0. That creates a pointer for you, based on a warp factor:

Warp0 {
*ar {arg numChannels = 1, buffer = 0, warpFactor = 1, freqScale=1.0, windowSize=0.2,
envbufnum = -1, overlaps=10, windowRandRatio = 0.1, interp = 1, mul=1, add=0;
var pointer;
pointer = LFSaw.kr( warpFactor * BufDur.kr(buffer).reciprocal, 1, 0.5, 0.5 );
^Warp1.ar(numChannels, buffer, pointer, freqScale, windowSize, envbufnum, overlaps,
windowRandRatio, interp, mul, add);

}

}

With that, you can change the amount of stretch as it’s own signal, and you don’t have to worry quite as much about making the pointer.

However - the question you ask about (stretching from full to 10x stretch over 15 minutes) - part of this would depend on how big your buffer is and if looping is ok. A 1 second sound file wouldn’t be able to do that in a linear fashion (for instance). So you would need to calculate a curve that is a function of stretching that gets you from the beginning of your sound file to the end in 15 minutes with the duration of the original file dictating what that curve would look like. You can certainly make the Warp0 work with Line.kr(1.0, 0.1, 15 * 60), but if your sound file isn’t the right length, it would have to loop.