473,508 Members | 2,335 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How do i record and invert a sound wave in real time using Tkinter,tkSnack and wave modules?

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()

Sep 5 '07 #1
0 2210

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
2697
by: jmdeschamps | last post by:
I'm trying to play programmed music by iteratively applying filter changes to a playing Sound object. It almost seem to work but i can't control duration of sounds??? Using tkSnack 2.2.4 for...
3
7434
by: Bill Dandreta | last post by:
I posted a message ("Help with my 1st Tkinter program") a few days ago complaining that Python did not have any built in basic cross platform sound capability. I was wrong (at least partly). Python...
1
3202
by: Niklas Paro | last post by:
Hello I would need way to check the amplitude (over time) for a sound file in python. I'm sure this can be done, for example the audioop.rms function seems to be able return amplitude values....
0
1583
by: didifouke | last post by:
Hi, I try to sample and playback speech using snack. My idea is to have a socket based server that plays back the sound and a client that samples the input from the sound card and sends it to...
0
1939
by: MLH | last post by:
Edit, Insert Object & choose Wave Object, the following OLE object thing gets inserted onto the form... Microsoft Sound Recorder Version 5.1 (Build 2600.xpsp2.030422-1633: Service Pack 1)...
4
3460
by: Robert Gravereaux | last post by:
I'm putting together a C# .Net forms project on win2k. The application requires some sort of horn sound. I've never implemented any audio in .Net, so I'm not sure how best to accomplish this. ...
7
6419
by: Lee Moody | last post by:
I just want quick and easy way to play a .wav file out the standard sound device. It could even be as simple as activating a sound assigned to an existing windows sound event. Any suggestions?...
4
2109
by: sittner | last post by:
Hi everyone, I'm looking for a module for sound processing (manipulating sound objets, filters, ffts etc.). I tried Snack, but when i downloaded the package that was supposed to be for python,...
6
29093
by: homevista | last post by:
PART III: Putting things together In part I we examined the modem to verify that it supported voice. If so, we took a note about the voice data format that we would use. In the second part, we...
0
7120
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7323
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7380
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
7039
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
5626
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5050
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4706
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
1553
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
763
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.