Pitch detection plug-in
Forum rules
This Forum is an archive of old topics concerning Nyquist plug-ins.
Feedback and questions relating to topics may be posted, but please
DO NOT POST NEW TOPICS HERE.
New plug-ins may be posted on the New Plug-Ins board.
Other posts relating to Nyquist should be posted to the main Nyquist board.
The main repository for Audacity/Nyquist Plug-ins is on the Audacity Wiki.
This Forum is an archive of old topics concerning Nyquist plug-ins.
Feedback and questions relating to topics may be posted, but please
DO NOT POST NEW TOPICS HERE.
New plug-ins may be posted on the New Plug-Ins board.
Other posts relating to Nyquist should be posted to the main Nyquist board.
The main repository for Audacity/Nyquist Plug-ins is on the Audacity Wiki.
Pitch detection plug-in
Here's a little analysis plug-in for detecting the pitch notes.
In most cases the default settings should work pretty well.
The default frequency range is 100 to 2000 Hz.
For detecting very low frequencies (less than a few hundred Hz) the plug-in should be set to the low frequency range (20 to 1000 Hz).
For detecting very high frequencies (several kHz) the plug-in should be set to the high frequency range (1 kHz to 10 kHz)
By default, the plug-in detects the pitch by analysing the first 0.2 seconds of the selection. In most cases this should work well.
If required the analysed section can be set to the first part of the selection ranging from the first 10th of a second (0.1 seconds) up to one second.
Limitations:
Extremely high frequencies may not be detected very accurately, especially if the sample rate is not very high. The plug-in will often detect very high frequencies better if the sample rate is 96000 Hz rather than 44100 Hz.
This plug-in is intended to detect single notes - you may get strange results if you try to analyse chords.
The plug-in should usually be able to detect pitches of single notes to within a few percent of the actual frequency. Don't expect the frequency in Hz to be exact. The most accurate measure of frequency in Audacity is to use "Plot Spectrum" and set the "Size" setting to a high value.
Original version: This plug-in is now available on the Audacity wiki
In most cases the default settings should work pretty well.
The default frequency range is 100 to 2000 Hz.
For detecting very low frequencies (less than a few hundred Hz) the plug-in should be set to the low frequency range (20 to 1000 Hz).
For detecting very high frequencies (several kHz) the plug-in should be set to the high frequency range (1 kHz to 10 kHz)
By default, the plug-in detects the pitch by analysing the first 0.2 seconds of the selection. In most cases this should work well.
If required the analysed section can be set to the first part of the selection ranging from the first 10th of a second (0.1 seconds) up to one second.
Limitations:
Extremely high frequencies may not be detected very accurately, especially if the sample rate is not very high. The plug-in will often detect very high frequencies better if the sample rate is 96000 Hz rather than 44100 Hz.
This plug-in is intended to detect single notes - you may get strange results if you try to analyse chords.
The plug-in should usually be able to detect pitches of single notes to within a few percent of the actual frequency. Don't expect the frequency in Hz to be exact. The most accurate measure of frequency in Audacity is to use "Plot Spectrum" and set the "Size" setting to a high value.
Original version: This plug-in is now available on the Audacity wiki
Learn more about Nyquist programming at audionyq.com
Re: Pitch detection plug-in
Hi Stevesteve wrote:Here's a little analysis plug-in for detecting the pitch notes.
could need some help in adapting you plug in for my needs, but I'm not allowed to PM you yet.
Would only need the extracted frequency in Hz as a variable for further processing.
Any way you could point guide me there ?
Re: Pitch detection plug-in
The frequency in Hz is the value of the variable "f0" which is calculated by the function "bestguess" (line 86). The function is called at line 100:mige0 wrote:Would only need the extracted frequency in Hz as a variable for further processing.
Code: Select all
(bestguess (getyin s dur))To convert a "note" value to a frequency, use the function "step-to-hz"
So to get just the frequency value you could use:
Code: Select all
(step-to-hz (bestguess (getyin s dur)))This is done in the last section of code (from line 98).
If you just want to set a variable (for example "f0") to the Hz value, then you can delete from line 98 to the end and replace it with something like:
Code: Select all
(setq f0 (bestguess (getyin s dur)))
(if f0 (setq f0 (step-to-hz f0))
(setf err "Frequency not foundn"))
Learn more about Nyquist programming at audionyq.com
Re: Pitch detection plug-in
Your code works great.
Thanks, you have saved me a looot of time !
How precise is the frequency - I mean - if I have a singele frequency to analyze not centered to a note ?
For example with a readout from the standard FFT analyze tool I get the peak at say 3.133Hz and the pitch detected says 3.157Hz.
Witch one is "correct" ?
Thanks, you have saved me a looot of time !
How precise is the frequency - I mean - if I have a singele frequency to analyze not centered to a note ?
For example with a readout from the standard FFT analyze tool I get the peak at say 3.133Hz and the pitch detected says 3.157Hz.
Witch one is "correct" ?
Re: Pitch detection plug-in
Which tool is that? "Plot Spectrum" does not show decimal places.mige0 wrote:For example with a readout from the standard FFT analyze tool I get the peak at say 3.133Hz
Pitch detect does not work with such low frequencies.mige0 wrote:and the pitch detected says 3.157Hz.
To get an idea of accuracy, try generating some tones ("Generate" menu) and test them.
Learn more about Nyquist programming at audionyq.com
Re: Pitch detection plug-in
Sorrry, its 3133Hz and 3157Hz thus in teh kHz range
Re: Pitch detection plug-in
In my tests, the pitch detect plug-in is accurate to within about 1%.
How does that compare with your tests?
How does that compare with your tests?
Learn more about Nyquist programming at audionyq.com
Re: Pitch detection plug-in
Well my example above is a real one, so its even well beyond your findings.
More than good enough, I guess.
I just was unsure if there are possibly steps too wide, if its first hand based on midi notes
More than good enough, I guess.
I just was unsure if there are possibly steps too wide, if its first hand based on midi notes