Hello,

I have a small problem for writing a .wav file. I can't find in which format
I have to pass my data in the writeframes function of the wave module.

here's my code, I am just trying to open a wav file, extracting the data
from it, and writing it in another wav file.
The problem is that the sound I get in the second wav file isn't the same as
from the firs file (in fact it is horrible).

import wave, audioop, numpy
from numpy.fft import *
from math import *

signal = wave.open('C:\demo.wav', 'rb' )
Nframes = float(signal.getnframes())
width = signal.getsampwidth()
frameRate = signal.getframerate()

frame = signal.readframes(1)
power =[]
while len(frame):
   power.append(audioop.rms( frame, width ))
   frame = signal.readframes(1)

new_signal = wave.open('C:\demo2.wav', 'wb')
new_signal.setsampwidth(width)
new_signal.setframerate(frameRate)
new_signal.setnchannels(signal.getnchannels())

for j in range(len(power)):
    data = hex(power[j])    ---> I guess that my problem is located at this
line
    new_signal.writeframes(data)
new_signal.close()


thanks a lot,
--
Gautier Krings
[EMAIL PROTECTED]
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to