(
SynthDef(\storm, {|out, freq=800, pan=0, master=0.3|
var perlin = Perlin3.ar(*{Phasor.ar(0, 1, 0, 1000)}.dup(3));
var noise = LPF.ar(WhiteNoise.ar, freq + (perlin*1000));
var noise2 = HPF.ar(noise, freq + (perlin*1000-400));
var sig = noise * master;
Out.ar(out, Pan2.ar(sig, pan));
}).add
)
I am trying to develop a way of using Perlin Noise in an easily reusable manner where I have control over the rate at which the noise is traversed and its amplitude.
First things first, the above code does not work. I think I am right to be using Phasor, but I am confident I am using it wrongly. I don’t really understand how to measure rate in relation to the Pelin3 UGen. The code doesn’t throw up an error, but it doesn’t work either.
It does work! You have added the SynthDef but you haven’t created the synth. After you add the Def, you need to run:
Synth("storm")
and it will play the sound.
Since you are traversing a 3D space, you can use any inputs that will stay between 0 and 1 (or something - not sure what the bounds are). So, something like this will be totally different:
(
SynthDef(\storm, {|out, freq=800, pan=0, master=0.3|
var perlin = Perlin3.ar(*{Phasor.ar(0, [0.7, 0.8, 0.9], 0, 1)});
var noise = LPF.ar(WhiteNoise.ar, freq + (perlin*1000));
var noise2 = HPF.ar(noise, freq + (perlin*1000-400));
var sig = noise * master;
Out.ar(out, Pan2.ar(sig, pan));
}).add
)
Okay, this is where I am confused. I was running Synths, but with the example I provided I couldn’t hear much modulation at all. With the example you have provided I can hear the modulation but it sounds ‘jagged’ and not what I’m after. The reason I’m using Perlin Noise is to get a smooth curve.
If I replace the perlin variable line with this line I get the effect I am after.
var perlin = Perlin3.ar(*{Line.ar(0, 1000, Rand(6000,30000))}.dup(3));
However, this does not work for my requirements as I want the speed at which the Perlin noise is traversed - or to put it in practical terms, the speed at which the filters are modulated - to be variable.
My question is how do I aquire that same smooth modulation that is found in the Line.ar example but using Perlin3.ar?
I would suggest to work in normalized phase space between 0 and 1 and scale to the desired range afterwards.
Here on the plot, you can see a Line going from 0 to 1 over the duration of 0.02 seconds and a Phasor going from 0 to 1 over the duration of 0.02 seconds. To convert from duration in seconds to frequency you can just take the reciprocal → frequency = 1 / duration. Phasor then wants to have the slope as its argument which is the rate of change per sample, you can take the frequency and multiply it by the duration of one sample (SampleDur.ir) or divide it by the sample rate (SampleRate.ir).
After that you can scale both of you linear phases between 0 and 1 to the desired range by multiplying it by a factor. The only difference between Line and Phasor is that Line wants the duration in seconds and is a one-shot ramp (it rests at the end value for ever after reaching it, without wrapping it between 0 and 1, like im doing here) and Phasor wants a slope and does wrap around from 1 to 0 after reaching its end value of the current cycle before it starts the next cycle.
(
{
var dur = 0.02;
var line = Line.ar(0, 1, dur).wrap(0, 1) * 1000;
var phasor = Phasor.ar(DC.ar(0), 1 / dur * SampleDur.ir) * 1000;
[line, phasor];
}.plot(0.041);
)
Your message and code are great - very clear. I’m just working my way through them. I have not yet had the opportunity to test it yet. Once I do I’ll hit the solution button.