Générateur de fichier .wav à partir d'un fichier .k7 pour Thomson TO7/70.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

35 lines
848 B

#!/usr/bin/env python
import numpy as N
import wave
class SoundFile:
def __init__(self, signal):
self.file = wave.open('test.wav', 'wb')
self.signal = signal
self.sr = 44100
def write(self):
self.file.setparams((1, 1, self.sr, 44100*4, 'NONE', 'noncompressed'))
self.file.writeframes(self.signal)
self.file.close()
# let's prepare signal
duration = 1 # seconds
samplerate = 44100 # Hz
samples = duration*samplerate
frequency = 6300 # Hz
period = samplerate / float(frequency) # in sample points
omega = N.pi * 2 / period
xaxis = N.arange(int(period),dtype = N.float) * omega
ydata = 16384 * N.sin(xaxis)
signal = N.resize(ydata, (samples,))
ssignal = ''
for i in range(len(signal)):
ssignal += wave.struct.pack('h',signal[i]) # transform to binary
print signal[i]
print 'file written'