473,287 Members | 1,793 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,287 software developers and data experts.

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.9267279307
317.138671875;9.92583847046
359.423828125;30.9667332967
422.8515625;2023.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.26632910683
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.90520095825
317.138671875;10.0715675354
359.423828125;31.0263417562
422.8515625;2023.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.34709642047
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.sound as sound
import pymedia.audio.acodec as acodec
import sys

freqs=''
def playFile(file_name):
#Leitura do arquivo
file_extension = file_name.split('.' )[ -1 ].lower()
parms = {'id': acodec.getCodecID(file_extension), '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.SpectrAnalyzer( 1, SAMPLES, 512 )
arqb = open('saida_bands.txt' , 'w')
arqf = open('saida_freqs.txt', 'w')
arqb.write('%s \n' %(f.name))
contador = 0
while len(s)0:
contador = contador + 1
if r:
#snd.play(r.data)
s = f.read(512)
r = decoder.decode(s)

snd= sound.Output( r.sample_rate, r.channels, sound.AFMT_S16_LE )
s1= resampler.resample( r.data )
bTmp= analyzer.asBands( BANDS, s1 )
sampleFreqs.append( ( snd.getPosition()+ snd.getLeft(), bTmp ) )
fTmp= analyzer.asFrequencies(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('Frame: %s \n' % (contador.__str__()))
arqf.write ('Leitura: %s \n ' % (contador.__str__()))
arqf.write ('Freq: %s \n ' % (fTmp.__str__()))
arqb.write('LOOPS: %s \n' % (contador.__str__()))
arqb.close()
arqf.close()
if __name__ == "__main__":
file_name = sys.argv[1]
playFile(file_name)

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

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

Similar topics

4
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...
1
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...
1
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...
1
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. ...
1
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...
1
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...
2
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...
1
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...
1
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...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
0
by: Aftab Ahmad | last post by:
Hello Experts! I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...
0
by: Aftab Ahmad | last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below. Dim IE As Object Set IE =...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: marcoviolo | last post by:
Dear all, I would like to implement on my worksheet an vlookup dynamic , that consider a change of pivot excel via win32com, from an external excel (without open it) and save the new file into a...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...

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.