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