<script type="text/x-red" data-help-name="AudioAnalyzeNoteFrequency">
	<h3>Summary</h3>
	<div class=tooltipinfo>
	<p>Detect with fairly good accuracy the fundamental frequency f<sub>o</sub>
		of musical notes, such as electric guitar and bass.</p>
	</div>
    <p>Written By Collin Duffy</p>
	<h3>Audio Connections</h3>
	<table class=doc align=center cellpadding=3>
		<tr class=top><th>Port</th><th>Purpose</th></tr>
		<tr class=odd><td align=center>In 0</td><td>Signal to analyze</td></tr>
	</table>
	<h3>Functions</h3>
	<p class=func><span class=keyword>begin</span>(threshold);</p>
	<p class=desc>Initialize and start detecting frequencies,
		with an initial threshold (the amount of allowed uncertainty).
	</p>
	<p class=func><span class=keyword>available</span>();</p>
	<p class=desc>Returns true (non-zero) when a valid
		frequency is detected.
	</p>
	<p class=func><span class=keyword>read</span>();</p>
	<p class=desc>Read the detected frequency.
	</p>
	<p class=func><span class=keyword>probability</span>();</p>
	<p class=desc>Return the level of certainty, betweeo 0 to 1.0.
	</p>
	<p class=func><span class=keyword>threshold</span>(level);</p>
	<p class=desc>Set the detection threshold, the amount of allowed uncertainty.
	</p>
	<h3>Examples</h3>
	<p class=exam>File &gt; Examples &gt; Audio &gt; Analysis &gt; NoteFrequency
	</p>
	<h3>Notes</h3>
	<p>The <a href="http://recherche.ircam.fr/equipes/pcm/cheveign/pss/2002_JASA_YIN.pdf">YIN algorithm</a> (PDF)
		is used to detect frequencies, with many optimizations for
		frequencies between 29-400Hz.  This algorithm can be somewhat
		memory and processor hungry but will allow you to detect with
		fairly good accuracy the fundamental frequencies from
		electric guitars and basses.</p>
	<p>Within the code, AUDIO_GUITARTUNER_BLOCKS
		may be edited to control low frequency range.  The default
		(24) allows measurement down to 29.14 Hz, or B(flat)0.</p>
	<p>TODO: The usable upper range of this object is not well known.
		Duff says "it should be good up to 1000Hz", but may have trouble
		at 4 kHz.  Please <a href="https://forum.pjrc.com/threads/32252-Different-Range-FFT-Algorithm/page2">post feedback here</a>, ideally with audio clips for the NoteFrequency example.</p>
	<p>This object was contributed by Collin Duffy from his
		<a href="https://github.com/duff2013/AudioTuner">AudioTuner project</a>.
		Additional details and documentation may be found there.</p>
</script>
<script type="text/x-red" data-template-name="AudioAnalyzeNoteFrequency">
	<div class="form-row">
		<label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
		<input type="text" id="node-input-name" placeholder="Name">
	</div>
</script>