Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- program kickdrum;
- const Milliseconds=250;
- SampleRate=44100;
- SampleLen=(SampleRate*Milliseconds) div 1000;
- var i:integer;
- Phases:array[0..1] of single;
- s,pi2,Pitch,Frequency,Volume:single;
- begin
- SetSampleLength(SampleLen); // in samples
- SetSampleChannels(1); // 1=mono, 2=stereo
- SetSampleRate(SampleRate); // the sample rate
- Phases[0]:=0;
- Phases[1]:=0;
- pi2:=pi*2;
- for i:=0 to SampleLen-1 do begin
- // Lower sine from 220 Hz down to 55 Hz (for the abdomen)
- Pitch:=pow(1-(i/SampleLen),4);
- Frequency:=(220*Pitch)+(55*(1-Pitch));
- Volume:=pow(1-(i/SampleLen),0.25);
- s:=(sin(Phases[0]*pi2)*Volume);
- Phases[0]:=frac(Phases[0]+(Frequency/SampleRate));
- // Higher sine from 440 Hz down to 88 Hz (for the head)
- Pitch:=pow(1-(i/SampleLen),16);
- Frequency:=(440*Pitch)+(88*(1-Pitch));
- Volume:=pow(1-(i/SampleLen),2);
- s:=s+(sin(Phases[1]*pi2)*Volume);
- Phases[1]:=frac(Phases[1]+(Frequency/SampleRate));
- // Kick noise (also for the head as additional kick effect)
- Volume:=pow(1-(i/SampleLen),4);
- s:=s+((random-0.5)*Volume);
- // Amplify
- s:=s*0.5;
- // Clip to -1 .. 1
- if s<-1 then begin
- s:=-1;
- end else if s>1 then begin
- s:=1;
- end;
- // Write out sample
- SetSample(i,s);
- end;
- end.
Advertisement
Add Comment
Please, Sign In to add comment