Is there a way to write multiple frequencies to a .wav file?

Viewed 213

I have an array of numbers

a = [440, 320, 650]

I am trying to write a .wav file that writes those frequencies in order. But I don't know if scipy.io.wavfile is able to write an array of frequencies to a wav file. All I can do right now is something like

wavfile.write('Sine.wav', rate, a[0])

I am thinking to do something like this though.

for x in range(0, len(a)): #wavfile.addFrequency('Sine.wav', rate, a[x])

1 Answers

"In order" doesn't sound very clear to me. I guess you would like to mix those sine waves. For that you must make a single wave with the 3 sines by summation of their amplitude values. For each sample, three values must be added (one for each sine) taking care that the result never overflows -1.0 or 1.0 (for float values, for 16 bit integers the range would be -32768 to 32767 instead).

Now if you plane to render the three waves successively instead, you have to determine the duration of each segment and take care that the junction between two waves is done at amplitude zero to prevent numeric clicks.

Related