Hi, I want to record a sound wave from a mic and at the same time invert it and play the inverted wave.My code goes as follows, however nothing is written into the E:\inverted.wav file.Thanks in advance for any help.
from Tkinter import * root = Tk() import tkSnack tkSnack.initializeSnack(root) t=tkSnack import wave import audioop a=audioop w=wave import threading import os def fin(): s=t.Sound(file='E:/final.wav') s.frequency=44100 s.record() #Start recording def invert(): global f,i,as f=w.open("E:\\final.wav","r") frame=f.readframes(1) i=w.open("E:\\inverted.wav","w") #sw=f.getsampwidth() i.setsampwidth(2) #nf=f.getnframes() i.setnframes(30*50000) #nc=f.getnchannels() i.setnchannels(1) #fr=f.getframerate() i.setframerate(44100) f.setpos(220500) c=0 while frame: #invert and write it to inverted.wav i.writeframesraw(audioop.mul(frame,2,-1.0)) c=c+1 frame=f.readframes(1) if c==100: as=t.Sound(load='E:/inverted.wav') as.play() def stp(): s.stop() as.stop() f.close() i.close() k=threading.Timer(30.0000,stp) #Stop recording after 30 sec k.start() j=threading.Timer(5.00000,invert) #Start reading recorded file j.start() #after 5sec fin() -- http://mail.python.org/mailman/listinfo/python-list