473,396 Members | 1,866 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,396 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 2269

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...
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
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,...
0
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
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...
0
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...

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.