Professional Documents
Culture Documents
6.5 Effects 2
6.5 Effects 2
(
Server.default= s=Server.internal;
s.waitForBoot({
s.scope;
FreqScope();
});
)
Spatialization
We'll pan some PinkNoise (which has some energy across the spectrum, without being
the full equal power harshness of WhiteNoise), rather than a much harder to
localise sine tone
//stereo panners:
//equal power
{Pan2.ar(PinkNoise.ar(0.2),MouseX.kr(-1,1))}.scope
//multichannel:
//direct to speaker
{Out.ar(1,PinkNoise.ar(0.1))}.scope //straight to right/second speaker
//between speakers:
//PanAz main arguments: numchannels, signal to pan, pan position from 0 to 2 around
the ring of speakers
{PanAz.ar(8,PinkNoise.ar(0.2),MouseX.kr(0,2))}.scope;
See Also:
Pan4 quad panning
Balance2 adjust stereo mix to bias towards left or right speaker
Rotate2 rotate stereo mix circularly around two speakers
Ambisonics UGens
Ambisonics is a special format for representing spatial sound, modeling a sound and
its strength on three dimensional axes (more generally, in higher order spherical
co-ordinate systems).
We go:
sound -> encode Ambisonics format signal -> decode Ambisonics signal to a given
speaker set-up.
The Ambisonics format is speaker set-up independent, so you can design a piece in
terms of intended spatial positioning, and (in theory) smoothly cope with different
concert playback conditions.
//stereo decode
DecodeB2.ar(2,w,x,y);
See also
VBAP //in BEAST UGens, vector based amplitude panning, used for positioning sounds
in an arbitrary 3D speaker configuration: works by considering triangles of
speakers (like triangularization in computer graphics)
Simulation of space
Modeling air absorption: high frequencies drop off more quickly in air. Filter the
high frequencies more with distance, e.g. low pass filter where decrease cutoff
frequency with distance.
}.scope
)
Doppler effect: pitch shift due to change of radial distance of object from
observer
//reference sound
{Saw.ar(440,0.2)}.play
//starts above pitch, ends below pitch, due to cycle starts being closer together
when approaching (reducing delay), and further apart when retreating (increasing
delay)
(
{
var radialdistance = Line.kr(10,-10,5,doneAction:2);
DelayC.ar(Saw.ar(440,0.2),1.0, radialdistance.abs/340.0);
}.scope
)
source=
Saw.ar(Demand.kr(Impulse.kr(LFNoise0.kr(0.5,0.1,2)),0,Dseq([63,60].midicps,inf)));
//nee-naw emergency vehicle simulation
absoluterd= radialdistance.abs;
//if something is 340 metres away, takes 1 second to get there; so make delay
depend on distance away in metres
dopplershift= DelayC.ar(source, 1.0, absoluterd/340.0);
//inversely proportional
amplitude= (absoluterd.max(1.0)).reciprocal;
Pan2.ar(amplitude*dopplershift,0.0)
}.play
)
//More complicated: object will move past 5 metres to your right, on a line
vertically down the page (as per ICM figure)
//could add position dependent filtering for head shadow and separate delay to two
ears...
(
{
var source, distance, radialdistance, absoluterd, dopplershift, amplitude;
var side, angle;
source=
Saw.ar(Demand.kr(Impulse.kr(LFNoise0.kr(0.5,0.1,2)),0,Dseq([63,60].midicps,inf)));
//nee-naw emergency vehicle simulation
side=5;
//central side marker, placed 5 metres directly right of observer, observer facing
ahead
//in metres, moving at 6.8 metres per second
distance= EnvGen.ar(Env([34,-34],[10]), doneAction:2);
angle= atan(distance/side);
//radial distance by
absoluterd= (distance.squared+ side.squared).sqrt;
//inversely proportional
amplitude= (absoluterd.max(1.0)).reciprocal;
Pan2.ar(amplitude*dopplershift,1.0)
}.play
)
We know that we can get frequency shifting by using ring modulation, though there
are two sidebands. As well as low pass filtering out the lower band in ring
modulation, there is aso a technique called 'single side band modulation' via a
technical device called the Hilbert transform. There are UGens for this:
FreqShift.ar(input, amount of shift in Hz, phase shift)
//shift the harmonic set detailed above. No audible effect of phase shifts on sines
{FreqShift.ar(Mix(SinOsc.ar(100*(1..6)))*0.1,MouseX.kr(0,1000),MouseY.kr(0,2pi))}.s
cope;
We mentioned the granular pitch shifter UGens PitchShift and Warp1 in passing back
in the granular synthesis materials.
Let's take a closer look at Warp1, which accomplishes granular time stretching and
pitch shifting of the grains.
b = Buffer.read(s,Platform.resourceDir +/+"sounds/a11wlk01.wav");
//overlaps eight windows of 0.1 seconds, so one window every 0.1/8 = 0.0125 seconds
{Warp1.ar(1,b,pointer:MouseX.kr,freqScale:(2**(MouseY.kr(-
2,2))),windowSize:0.1)}.scope
Building your own basic Overlap Add stretcher (requires Buffer b from above):
source =
PlayBuf.ar(1,bufnum,BufRateScale.kr(bufnum)*rate,1.0,pos*BufFrames.ir(bufnum),loop:
0); //don't allow loop
{
timedone = 0.0;
while({timedone<playbacktime},{
//proportion.postln;
//linear interpolation (can make exponential etc)
ratenow = ((1.0-proportion)*startrate) + (proportion*endrate);
//ratenow.postln;
s.bind({ Synth(\windowofsound,[\dur,grainsize*rrand(1.0,1.1),\bufnum,b,\
amp,rrand(0.09,0.11),\rate,ratenow,\pos,proportion]); });
grainspacing.wait;
});
}.fork;
)
The PitchShift and Warp1 UGens just do this more efficiently under the hood.