The mixdown command is used for mixing several audio clips down together into one clip.
In the following example we create a music track with six individual tones. First we write a function for creating tones with vibrato.
vibrato:=proc(f,t) local f1,f2,dl,dr,s; purge(s); f1:=rand(0.5,2.0); f2:=rand(0.5,2.0); dl:=[]; dr:=[]; for s in t do dl.append(sin(2*pi*(f+0.2*sin(2*pi*f1*s))*s)); dr.append(sin(2*pi*(f+5+0.2*sin(2*pi*f1*s))*s)); od; return createwav([dl,dr]); end:; |
Now create several tones of different lengths…
s:=2.0^(1/12):; clip1:=vibrato(880,soundsec(7.5)):; clip2:=vibrato(880*s,soundsec(5)):; clip3:=vibrato(880/s^2,soundsec(2.5)):; clip4:=vibrato(880/s^3,soundsec(6)):; clip5:=vibrato(880/s^11,soundsec(6)):; clip6:=vibrato(880/(2*s^7),soundsec(6)):; |
… and mix them down at different positions.
g:=-6:; mix:=mixdown(clip1,[0,g,-0.3,2.0,0.2], clip2,[5.0,g,0.7,0.5,2.0], clip3,[7.3,g,-0.3,0.2,0.2], clip4,[9.6,g,-0.3,0.2,3.0], clip5,[9.8,-6.0,0.0,0.5,4.0],clip6,[10.0,-8.0,0.15,0.5,2.0]) |
|
Finally, play the music:
playsnd(normalize(mix,-1)) |
Output: a 16 seconds of synthesized music.