InDashPC.org Forum Index InDashPC.org
In Dash Car PC forum
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Make a music tuner

 
Post new topic   Reply to topic    InDashPC.org Forum Index -> Software
View previous topic :: View next topic  
Author Message
guerran



Joined: 02 Oct 2005
Posts: 3

PostPosted: Sun Oct 02, 2005 3:43 pm    Post subject: Make a music tuner Reply with quote

first, excuse my english.
Can someone tell me what are numbers returned by
pymedia.audio.sound.SpectrAnalyzer.asFrequencies()

Indeed, I want to make a music tuner, so I need
to know frequencies to compare to musical notes.
Back to top
View user's profile Send private message
jbors
Site Admin


Joined: 12 Nov 2004
Posts: 1675

PostPosted: Sun Oct 02, 2005 8:23 pm    Post subject: Reply with quote

The numbers returned are (excerpt from the fft.cpp file):
Code:
    // The last sample of the output data will represent the frequency
    //   that is 1/4th of the input sampling rate.  For example,
    //   if the input wave data is sampled at 44,100 Hz, then the last
    //   sample of the spectral data output will represent the frequency
    //   11,025 Hz.  The first sample will be 0 Hz; the frequencies of
    //   the rest of the samples vary linearly in between.
    // Note that since human hearing is limited to the range 200 - 20,000
    //   Hz.  200 is a low bass hum; 20,000 is an ear-piercing high shriek.
    // Each time the frequency doubles, that sounds like going up an octave.
    //   That means that the difference between 200 and 300 Hz is FAR more
    //   than the difference between 5000 and 5100, for example!
    // So, when trying to analyze bass, you'll want to look at (probably)
    //   the 200-800 Hz range; whereas for treble, you'll want the 1,400 -
    //   11,025 Hz range.
    // If you want to get 3 bands, try it this way:
    //   a) 11,025 / 200 = 55.125
    //   b) to get the number of octaves between 200 and 11,025 Hz, solve for n:
    //          2^n = 55.125
    //          n = log 55.125 / log 2
    //          n = 5.785
    //   c) so each band should represent 5.785/3 = 1.928 octaves; the ranges are:
    //          1) 200 - 200*2^1.928                    or  200  - 761   Hz
    //          2) 200*2^1.928 - 200*2^(1.928*2)        or  761  - 2897  Hz
    //          3) 200*2^(1.928*2) - 200*2^(1.928*3)    or  2897 - 11025 Hz

    // A simple sine-wave-based envelope is convolved with the waveform
    //   data before doing the FFT, to emeliorate the bad frequency response
    //   of a square (i.e. nonexistent) filter.

    // You might want to slightly damp (blur) the input if your signal isn't
    //   of a very high quality, to reduce high-frequency noise that would
    //   otherwise show up in the output.

In simple words it is the non normalized values of signal strength for frequencies from 0-11 KHz (in case if you have 44KHz sampling). Number of intervals depends on number you supply as 3-rd parameter to SpectrAnalyzer. Note that in many cases supplying 512-576 is the best choice for that parameter. In that case first returned value from asFrequencies() will represent strength for 0-20 Hz, second 20-40 Hz etc.
Back to top
View user's profile Send private message
guerran



Joined: 02 Oct 2005
Posts: 3

PostPosted: Sun Oct 02, 2005 11:47 pm    Post subject: Reply with quote

thanks,
these informations are very helpfull...
Back to top
View user's profile Send private message
guerran



Joined: 02 Oct 2005
Posts: 3

PostPosted: Wed Dec 21, 2005 7:59 am    Post subject: Reply with quote

Is somebody know how to code the Fourier transformation in python?
Back to top
View user's profile Send private message
onionparadise
Newbie


Joined: 14 Feb 2008
Posts: 16

PostPosted: Sat Nov 01, 2008 5:22 pm    Post subject: Reply with quote

So, I am also trying to use the SpectrAnalyzer in my program, in order to analyze sound files and determine whether they are major, minor, etc, yadda yadda yadda what it really boils down to is am I right in thinking that the numbers output by the asFrequencies function represent the amplitude of the frequencies in that band (given that the frequency range is 200 to 1/4 the sampling rate or usually 11025 and is divided by the number of bands as provided in the arguments for the function)? So if I wanted to be able to identify every note present, I should figure out what the frequency margin of error for intonation of a note is and thus figure out how many bands I would need, and plug that in, and those bands that were not negligibly low I should identify as notes? I'm hoping to be able to get my code functional and finished without ever having to print anything to see what it is, because I tried that with a full band arrangement of Pachelbel's Canon and the SpectrAnalyzer printed so much that viewing it in the Shell crashed python. I think if I don't print it it won't crash python.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    InDashPC.org Forum Index -> Software All times are GMT - 8 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group