473,372 Members | 1,555 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,372 software developers and data experts.

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 2187

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

Similar topics

1
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
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
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
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
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
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
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
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
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...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.