Previous Up Next

28.2.17  Joining audio clips together

The splice command joins two audio clips together with an overlap and optionally a crossfade.

Example

With the audio file gettysburg.wav downloaded from here:

clip:=normalize(readwav("/home/luka/Downloads/gettysburg.wav"),-1)
     
a sound clip with 387574 samples at 22050 Hz (16 bit, mono)           

To remove the portion of the speech between 5.6 and 10.5 seconds, splice the portions on the left and right by using an overlap of size 0.25 seconds. To visualize the audio and the selected portion, you can enter:

t1:=5.6:; t2:=10.5:; d:=duration(clip):; cfl:=0.25:; rectangle(t1-i,t2-i,2/(t2-t1),display=pink+filled); plotwav(clip);

Extract the portions from 0 to t1 and from t2 to the end and splice them with an automatic crossfade:

snd:=splice(clip(0.0..t1),clip(t2..d),cfl)
     
a sound clip with 274016 samples at 22050 Hz (16 bit, mono)           

Use playsnd (see Section 28.2.14) to hear the result.


Previous Up Next