473,698 Members | 2,434 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Pymedia audio analyzer

Is there any other option to analyze audio frequencies?

Or

Any here try to use pymedia to a simple audio FingerPrint.

A cant understand what the information the asBands() really giveme.
The Docs, say that asBands() return a List of tupples grouped by
frquenciy, and the first two values are frquency limits. But I dont
thonk so ! Its not seems to be correct!

THis is part of my output to an audio file of 2 seconds and a 1000Hz frequency
And the code is below
But I read a lot, search .. and I still cant understand what this
tuples really means.

Thanks oin advance

190.283203125;0 .244085595012
211.42578125;1. 08019864559
253.7109375;3.9 267279307
317.138671875;9 .92583847046
359.423828125;3 0.9667332967
422.8515625;202 3.64868164
507.421875;1721 .98303223
591.9921875;45. 5271911621
697.705078125;6 .53225898743
824.560546875;2 .08980056218
972.55859375;0. 794676959515
1141.69921875;0 .362428373761
1331.98242188;0 .29334748875
1564.55078125;0 .218693238038
1839.40429688;0 .278315830231
2156.54296875;0 .146333972613
2537.109375;0.2 6632910683
2981.10351563;0 .496793937683
3509.66796875;0 .742335747028
4122.80273438;0 .619799894445
4841.65039063;0 .941718482971
5687.35351563;0 .703689981014
6681.0546875;1. 38942857222
7843.89648438;1 .78449742244
9218.1640625;3. 77672335976
190.283203125;0 .194098889828
211.42578125;1. 05994915962
253.7109375;3.9 0520095825
317.138671875;1 0.0715675354
359.423828125;3 1.0263417562
422.8515625;202 3.83581543
507.421875;1721 .99328613
591.9921875;45. 4988830566
697.705078125;6 .51365725199
824.560546875;2 .10594912938
972.55859375;0. 806965708733
1141.69921875;0 .369390010834
1331.98242188;0 .381403446198
1564.55078125;0 .279652008644
1839.40429688;0 .307544994354
2156.54296875;0 .252535131243
2537.109375;0.3 4709642047
2981.10351563;0 .604796524048
3509.66796875;0 .553077500442
4122.80273438;1 .07670492284
4841.65039063;1 .21294984818
5687.35351563;1 .33566446507
6681.0546875;1. 47083462802
7843.89648438;2 .5437119704
9218.1640625;4. 14210630718
import pymedia.audio.s ound as sound
import pymedia.audio.a codec as acodec
import sys

freqs=''
def playFile(file_n ame):
#Leitura do arquivo
file_extension = file_name.split ('.' )[ -1 ].lower()
parms = {'id': acodec.getCodec ID(file_extensi on), 'ext': file_extension}
decoder = acodec.Decoder( parms)
f = open(file_name, 'rb')
s = f.read(8192)
r = decoder.decode( s)
sampleFreqs= []
#snd = sound.Output(r. sample_rate, r.channels, sound.AFMT_S16_ LE)
SAMPLES= 500
NUM_FREQS= 12
BANDS= 25
resampler= sound.Resampler ( (r.sample_rate, r.channels), (r.sample_rate, 1) )
analyzer= sound.SpectrAna lyzer( 1, SAMPLES, 512 )
arqb = open('saida_ban ds.txt' , 'w')
arqf = open('saida_fre qs.txt', 'w')
arqb.write('%s \n' %(f.name))
contador = 0
while len(s)0:
contador = contador + 1
if r:
#snd.play(r.dat a)
s = f.read(512)
r = decoder.decode( s)

snd= sound.Output( r.sample_rate, r.channels, sound.AFMT_S16_ LE )
s1= resampler.resam ple( r.data )
bTmp= analyzer.asBand s( BANDS, s1 )
sampleFreqs.app end( ( snd.getPosition ()+ snd.getLeft(), bTmp ) )
fTmp= analyzer.asFreq uencies(r.data)
#print (bTmp )
for k in bTmp:
for l in k:
#print l
arqb.write('%s; %s \n' % (l[0].__str__(),l[1].__str__(),))

arqb.write('Fra me: %s \n' % (contador.__str __()))
arqf.write ('Leitura: %s \n ' % (contador.__str __()))
arqf.write ('Freq: %s \n ' % (fTmp.__str__() ))
arqb.write('LOO PS: %s \n' % (contador.__str __()))
arqb.close()
arqf.close()
if __name__ == "__main__":
file_name = sys.argv[1]
playFile(file_n ame)

--
Carlos Leite
www.znc.com.br
Oct 15 '07 #1
0 2282

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

Similar topics

4
2625
by: CptPicard | last post by:
Hi, I am currently trying to use pymedia so to get the following informations (author, song title, ...) from a mp3 file. The documentation I downloaded is quite limited : It gives some clues on how to get that information (method getInfo() from pymedia.audio.acodec). However, it does not explain what has to be done prior to that call. I downloaded pycar but it did not help me. Could someone give me a more detailed documentation on...
1
1500
by: Dmitry Borisov | last post by:
> > Thank you for your help! > > "Lawrence Oluyede" <raims@dot.com> wrote in message > news:3x8w4pqd3emo.15wp1jkrwkqua.dlg@40tude.net... > > In data Thu, 05 Aug 2004 02:28:48 GMT, CptPicard ha scritto: > > > > > Could someone give me a more detailed documentation on pymedia or some > clues > > > on how to get the information I need ?
1
1570
by: Dmitry Borisov | last post by:
From: "CptPicard" Date: Thu, 05 Aug 2004 17:48:04 GMT Subject: Re: Re: Need help on how to use Pymedia! > > Here is the code which will give you what you need( from pycar ). It is > modified to match what you need and therefore not tested.: > > > > f= open( <file_name>, 'rb' ) > > dec= acodec.Decoder( <file_extension> ) > > s= f.read( 20000 )
1
4297
by: Ron Provost | last post by:
Hello, I'm developing a piece of software to assist illiteraate adults to learn to read. I'm trying to figure out how, if possible, to make audio playback asynchrnous but still controllable. I'm using python 2.4 with pymedia on XP. I started out with the example in the tutorials section of the pymedia website. The pymedia docs imply to me that playback using Output's play() method should already be asynchronous and controllable. I...
1
11051
by: David S. Zuza | last post by:
Hi, I am an intermediate vb developer but I am an infant to DirectX programming, I want to develop a spectrum analyzer for audio whether it be from microphone or audio file...but there doesn't seem to be a good resource on where to begin...can anyone provide thanx in advance, David S. Zuza
1
2020
by: Lad | last post by:
Hi, Can anyone answer the following questions? Question 1. Can pyMedia create/convert FLV format? I explain in details. As I would like to publish videos for viewing in a browser , I need a good video format. I learned that FLV (Flash(tm) Video) format could be a good choice. Or does anybody suggest a better format???
2
2608
by: zenologia | last post by:
Hello, I need to write an audio recorder application, and before starting writing code I'd like to know what components are available on the market. I'm looking for one or more .net audio component that let me do the following things: - converting wav into mp3, or some other compressed format - equalizing and playing that file - apply anti noise filters - display a trackbar that shows the playing file
1
2441
by: Sebouh | last post by:
Hi guys. I need your help to solve this problem. You see, i need to get the samples from an audio stream, to do FFT analysis. I need to read those amplitudes and pass them to an analyzer so i can check which frequencies are present in the sound. I'm having trouble accessing the sample values. I tried to create a small program which records sound and prints the values to the screen, but it keeps printing 130 and 131. I print out the bytes...
1
3108
by: patelss23 | last post by:
Hello All Experts, I am quite new to Ctypes. I am using one c library and writing python bindings for it. I need to pass a character pointer to one function. I am reading one mp3 file and decoding it to raw pcm using pymedia. Now I need to pass this raw data in to a C function. Here is my code.
0
8675
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8604
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9160
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9029
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8897
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
6521
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4619
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2331
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2002
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.