Hi Dmitry,

Thank you for the explanation. I have switched to SpectrAnalyzer.asFrequencies(), as a test I am reading frames out of a wav file with a single note (G) being played several times.

So with asFrequencies() then, is there a simple formula for determining which
chunk is which actual frequency? For example I have these constants:

CHANNELS= 1
NUM_FREQS= 512
RATE= 44100

Now, if I analyze my data:
analyzer= sound.SpectrAnalyzer( CHANNELS, SAMPLES, NUM_FREQS )
freqs= analyzer.asFrequencies( data )

Then the len(freqs) is 2, and len(freqs[0]) for example is 512.

So the actual data in the lists in freqs is the decibel value for each frequency correct? I am not sure how to go about determining which value is for which frequency.. although I can see how it should be available given the 3 constants defined above, I am just not sure how to go about it.

Sorry to be so dense :) This is the first time I have tried to create any kind of audio application before.


Thanks,
Rob

Dmitry Borisov wrote:
asBands actually returning the bacnds like low frequencies, mdeium frquencies and stuff. I believe you need asFrequencies() which will split the whole interval 0-11KHz into equal chunks and calc the power of the desired audio chunk in a particular range.
See doc for example:
http://pymedia.org//docs/pymedia.audio.sound.html#SpectrAnalyzer
For now the smallest frequency range you can get via asFrequencies() is 44000/ ( 4* 512 )= 22Hz
Dmitry/

----- Original Message ----- From: "Robert Helmer" <[EMAIL PROTECTED]>
To: <[email protected]>
Sent: Sunday, January 08, 2006 12:27 AM
Subject: Re: [Pymedia-users] pitch detection


Hi Dmitry,

Thank you for your reply! I have been trying out the asBands() method, which seems to yield some result to different voice tones. However, it seems that asBands() can only return a limited set of possible frequencies.. I am basically doing this :

snd= sound.Input( RATE, CHANNELS, sound.AFMT_S16_LE )
snd.start()
analyzer= sound.SpectrAnalyzer( CHANNELS, SAMPLES, NUM_FREQS )

while 1:
 largestFreqName= 0
 largestFreqValue= 0
 previousLargestFreqValue= 0
 bands= analyzer.asBands( BANDS, snd.getData() )
 for i in range( 0, len( bands ) ):
   for j in range( 0, len( bands[i] ) ):
     freqName= bands[i][j][0]
     if freqName >= 1000:
       continue
     freqValue= bands[i][j][1]
     if freqValue > largestFreqValue:
       previousLargestFreqValue= largestFreqValue
       largestFreqName= freqName
       largestFreqValue= freqValue
       print largestFreqValue

Am I understanding how this data may be used correctly? Is there some way to do something similar with the analyzer.asFrequencies() method? I cannot seem to make any sense out of the returned data through experimentation :)


Thanks!
Rob Helmer

Dmitry Borisov wrote:
Hi,
It could work for you.
Basically SpectrAnalyzer is taking the fixed number of samples >512 and returns the frequencies strength. If you use much more samples it may not work well for you though. Sorry I never did pitch detection myself, so I cannot tell if it'll work for you.
Dmitry/

----- Original Message ----- From: "Robert Helmer" <[EMAIL PROTECTED]>
To: <[email protected]>
Sent: Tuesday, January 03, 2006 12:25 PM
Subject: [Pymedia-users] pitch detection


Hello,

I am working on a voice-training python application that involves pitch detection. I have had some good results using FFT but it's a bit too slow (I can't get good detection without a very large sample size it seems).

Could SpectrAnalyzer be useful for pitch detection? I am a bit confused as to how to use this class properly; the example (sound_viz.py) doesn't work in the latest release due to what looks like API changes. I think being able to experiment with a working implementation would help me to be able to play around with FFT and other algorithms (Schmitt-triggering for instance).

I took a peek at the implementation of SpectrAnalyzer in C and I am not sure how much overlap there is between what I am trying to do and SpectrAnalyzer; it seems quite capable but my inexperience in digital audio processing is holding back my understanding.

I've been learning just how little I know about DSP by embarking on this, so any suggestions would be greatly appreciated!


Thanks,
Rob Helmer


-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems?  Stop!  Download the new AJAX search engine that makes
searching your log files as easy as surfing the web. DOWNLOAD SPLUNK!
http://ads.osdn.com/?ad_id=7637&alloc_id=16865&op=click
_______________________________________________
Pymedia-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/pymedia-users




-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems?  Stop!  Download the new AJAX search engine that makes
searching your log files as easy as surfing the  web.  DOWNLOAD SPLUNK!
http://ads.osdn.com/?ad_id=7637&alloc_id=16865&op=click
_______________________________________________
Pymedia-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/pymedia-users



-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems?  Stop!  Download the new AJAX search engine that makes
searching your log files as easy as surfing the  web.  DOWNLOAD SPLUNK!
http://ads.osdn.com/?ad_id=7637&alloc_id=16865&op=click
_______________________________________________
Pymedia-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/pymedia-users




-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems?  Stop!  Download the new AJAX search engine that makes
searching your log files as easy as surfing the  web.  DOWNLOAD SPLUNK!
http://ads.osdn.com/?ad_id=7637&alloc_id=16865&op=click
_______________________________________________
Pymedia-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/pymedia-users



-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems?  Stop!  Download the new AJAX search engine that makes
searching your log files as easy as surfing the  web.  DOWNLOAD SPLUNK!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=103432&bid=230486&dat=121642
_______________________________________________
Pymedia-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/pymedia-users

Reply via email to