He aquí una función en Python que hace que un archivo con una sola onda sinusoidal:
# based on : www.daniweb.com/code/snippet263775.html
import math
import wave
import struct
def make_sine(freq=440, datasize=10000, fname="test.wav", framerate=44100.00):
amp=8000.0 # amplitude
sine_list=[]
for x in range(datasize):
sine_list.append(math.sin(2*math.pi * freq * (x/frate)))
# Open up a wav file
wav_file=wave.open(fname,"w")
# wav params
nchannels = 1
sampwidth = 2
framerate = int(frate)
nframes=datasize
comptype= "NONE"
compname= "not compressed"
wav_file.setparams((nchannels, sampwidth, framerate, nframes, comptype, compname))
#write on file
for s in sine_list:
wav_file.writeframes(struct.pack('h', int(s*amp/2)))
wav_file.close()
frate = 44100.00 #that's the framerate
freq=987.0 #that's the frequency, in hertz
seconds = 3 #seconds of file
data_length = frate*seconds #number of frames
fname = "WaveTest2.wav" #name of file
make_sine(freq, data_length, fname)
No es el código más rápido ... Pero si no necesita velocidad, no tendrán ningún problema!
Por qué plataforma? – martineau