Skip to content

Commit

Permalink
Rename AudioAnalyzeGuitarTuner to AudioAnalyzeNoteFrequency
Browse files Browse the repository at this point in the history
  • Loading branch information
PaulStoffregen committed Dec 31, 2015
1 parent c4cea1d commit 7e017b1
Show file tree
Hide file tree
Showing 22 changed files with 39 additions and 28 deletions.
2 changes: 1 addition & 1 deletion Audio.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
#include "analyze_fft1024.h"
#include "analyze_print.h"
#include "analyze_tonedetect.h"
#include "analyze_guitartuner.h"
#include "analyze_notefreq.h"
#include "analyze_peak.h"
#include "control_sgtl5000.h"
#include "control_wm8731.h"
Expand Down
20 changes: 10 additions & 10 deletions analyze_guitartuner.cpp → analyze_notefreq.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* Audio Library Guitar and Bass Tuner
/* Audio Library Note Frequency Detection & Guitar/Bass Tuner
* Copyright (c) 2015, Colin Duffy
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
Expand All @@ -20,7 +20,7 @@
* THE SOFTWARE.
*/

#include "analyze_guitartuner.h"
#include "analyze_notefreq.h"
#include "utility/dspinst.h"
#include "arm_math.h"

Expand All @@ -42,7 +42,7 @@ static void copy_buffer(void *destination, const void *source) {
for (int i=0; i < AUDIO_BLOCK_SAMPLES; i++) *dst++ = *src++;
}

void AudioAnalyzeGuitarTuner::update( void ) {
void AudioAnalyzeNoteFrequency::update( void ) {

audio_block_t *block;

Expand Down Expand Up @@ -80,7 +80,7 @@ void AudioAnalyzeGuitarTuner::update( void ) {
}
}

FASTRUN void AudioAnalyzeGuitarTuner::process( void ) {
FASTRUN void AudioAnalyzeNoteFrequency::process( void ) {
//digitalWriteFast(0, HIGH);

const int16_t *p;
Expand Down Expand Up @@ -164,7 +164,7 @@ FASTRUN void AudioAnalyzeGuitarTuner::process( void ) {
*
* @return tau
*/
uint16_t AudioAnalyzeGuitarTuner::estimate( int64_t *yin, int64_t *rs, uint16_t head, uint16_t tau ) {
uint16_t AudioAnalyzeNoteFrequency::estimate( int64_t *yin, int64_t *rs, uint16_t head, uint16_t tau ) {
const int64_t *y = ( int64_t * )yin;
const int64_t *r = ( int64_t * )rs;
uint16_t _tau, _head;
Expand Down Expand Up @@ -202,7 +202,7 @@ uint16_t AudioAnalyzeGuitarTuner::estimate( int64_t *yin, int64_t *rs, uint16_t
* @param threshold Allowed uncertainty
* @param cpu_max How much cpu usage before throttling
*/
void AudioAnalyzeGuitarTuner::begin( float threshold ) {
void AudioAnalyzeNoteFrequency::begin( float threshold ) {
__disable_irq( );
process_buffer = false;
yin_threshold = threshold;
Expand All @@ -223,7 +223,7 @@ void AudioAnalyzeGuitarTuner::begin( float threshold ) {
*
* @return true if data is ready else false
*/
bool AudioAnalyzeGuitarTuner::available( void ) {
bool AudioAnalyzeNoteFrequency::available( void ) {
__disable_irq( );
bool flag = new_output;
if ( flag ) new_output = false;
Expand All @@ -236,7 +236,7 @@ bool AudioAnalyzeGuitarTuner::available( void ) {
*
* @return frequency in hertz
*/
float AudioAnalyzeGuitarTuner::read( void ) {
float AudioAnalyzeNoteFrequency::read( void ) {
__disable_irq( );
float d = data;
__enable_irq( );
Expand All @@ -248,7 +248,7 @@ float AudioAnalyzeGuitarTuner::read( void ) {
*
* @return periodicity
*/
float AudioAnalyzeGuitarTuner::probability( void ) {
float AudioAnalyzeNoteFrequency::probability( void ) {
__disable_irq( );
float p = periodicity;
__enable_irq( );
Expand All @@ -260,7 +260,7 @@ float AudioAnalyzeGuitarTuner::probability( void ) {
*
* @param thresh Allowed uncertainty
*/
void AudioAnalyzeGuitarTuner::threshold( float p ) {
void AudioAnalyzeNoteFrequency::threshold( float p ) {
__disable_irq( );
yin_threshold = p;
__enable_irq( );
Expand Down
10 changes: 5 additions & 5 deletions analyze_guitartuner.h → analyze_notefreq.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* Audio Library Guitar and Bass Tuner
/* Audio Library Note Frequency Detection & Guitar/Bass Tuner
* Copyright (c) 2015, Colin Duffy
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
Expand All @@ -20,8 +20,8 @@
* THE SOFTWARE.
*/

#ifndef AudioAnalyzeGuitarTuner_h_
#define AudioAnalyzeGuitarTuner_h_
#ifndef AudioAnalyzeNoteFrequency_h_
#define AudioAnalyzeNoteFrequency_h_

#include "AudioStream.h"
/***********************************************************************
Expand All @@ -38,14 +38,14 @@
***********************************************************************/
#define AUDIO_GUITARTUNER_BLOCKS 24
/***********************************************************************/
class AudioAnalyzeGuitarTuner : public AudioStream {
class AudioAnalyzeNoteFrequency : public AudioStream {
public:
/**
* constructor to setup Audio Library and initialize
*
* @return none
*/
AudioAnalyzeGuitarTuner( void ) : AudioStream( 1, inputQueueArray ), enabled( false ), new_output(false) {
AudioAnalyzeNoteFrequency( void ) : AudioStream( 1, inputQueueArray ), enabled( false ), new_output(false) {

}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
/* Detect the frequency of music notes, by Colin Duffy
This example repeatedly plays a guitar note (output to the DAC pin)
and prints an analysis of the frequency to the Arduino Serial Monitor
https://forum.pjrc.com/threads/32252-Different-Range-FFT-Algorithm/page2
https://github.com/duff2013/AudioTuner
*/
/*
C C# D Eb E F F# G G# A Bb B
0 16.35 17.32 18.35 19.45 20.60 21.83 23.12 24.50 25.96 27.50 29.14 30.87
Expand Down Expand Up @@ -32,13 +40,13 @@
#include "b3_note.h"
#include "e4_note.h"
//---------------------------------------------------------------------------------------
AudioAnalyzeGuitarTuner tuner;
AudioAnalyzeNoteFrequency notefreq;
AudioOutputAnalog dac;
AudioPlayMemory wav_note;
AudioMixer4 mixer;
//---------------------------------------------------------------------------------------
AudioConnection patchCord0(wav_note, 0, mixer, 0);
AudioConnection patchCord1(mixer, 0, tuner, 0);
AudioConnection patchCord1(mixer, 0, notefreq, 0);
AudioConnection patchCord2(mixer, 0, dac, 0);
//---------------------------------------------------------------------------------------
IntervalTimer playNoteTimer;
Expand All @@ -61,16 +69,16 @@ void setup() {
* Initialize the yin algorithm's absolute
* threshold, this is good number.
*/
tuner.begin(.15);
notefreq.begin(.15);
pinMode(LED_BUILTIN, OUTPUT);
playNoteTimer.begin(playNote, 1000);
}

void loop() {
// read back fundamental frequency
if (tuner.available()) {
float note = tuner.read();
float prob = tuner.probability();
if (notefreq.available()) {
float note = notefreq.read();
float prob = notefreq.probability();
Serial.printf("Note: %3.2f | Probability: %.2f\n", note, prob);
}
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Empty file modified extras/wav2sketch/wav2sketch.exe
100755 → 100644
Empty file.
Empty file modified gui/font-awesome/fonts/fontawesome-webfont.eot
100755 → 100644
Empty file.
Empty file modified gui/font-awesome/fonts/fontawesome-webfont.svg
100755 → 100644
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file modified gui/font-awesome/fonts/fontawesome-webfont.ttf
100755 → 100644
Empty file.
Empty file modified gui/font-awesome/fonts/fontawesome-webfont.woff
100755 → 100644
Empty file.
15 changes: 9 additions & 6 deletions gui/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,7 @@ <h5 id="node-help-label">Keyboard Shortcuts <span style="float: right;"><a href=
{"type":"AudioAnalyzeFFT256","data":{"defaults":{"name":{"value":"new"}},"shortName":"fft256","inputs":1,"outputs":0,"category":"analyze-function","color":"#E6E0F8","icon":"arrow-in.png"}},
{"type":"AudioAnalyzeFFT1024","data":{"defaults":{"name":{"value":"new"}},"shortName":"fft1024","inputs":1,"outputs":0,"category":"analyze-function","color":"#E6E0F8","icon":"arrow-in.png"}},
{"type":"AudioAnalyzeToneDetect","data":{"defaults":{"name":{"value":"new"}},"shortName":"tone","inputs":1,"outputs":0,"category":"analyze-function","color":"#E6E0F8","icon":"arrow-in.png"}},
{"type":"AudioAnalyzeGuitarTuner","data":{"defaults":{"name":{"value":"new"}},"shortName":"guitartuner","inputs":1,"outputs":0,"category":"analyze-function","color":"#E6E0F8","icon":"arrow-in.png"}},
{"type":"AudioAnalyzeNoteFrequency","data":{"defaults":{"name":{"value":"new"}},"shortName":"notefreq","inputs":1,"outputs":0,"category":"analyze-function","color":"#E6E0F8","icon":"arrow-in.png"}},
{"type":"AudioAnalyzePrint","data":{"defaults":{"name":{"value":"new"}},"shortName":"print","inputs":1,"outputs":0,"category":"analyze-function","color":"#E6E0F8","icon":"arrow-in.png"}},
{"type":"AudioControlSGTL5000","data":{"defaults":{"name":{"value":"new"}},"shortName":"sgtl5000","inputs":0,"outputs":0,"category":"control-function","color":"#E6E0F8","icon":"arrow-in.png"}},
{"type":"AudioControlWM8731","data":{"defaults":{"name":{"value":"new"}},"shortName":"wm8731","inputs":0,"outputs":0,"category":"control-function","color":"#E6E0F8","icon":"arrow-in.png"}},
Expand Down Expand Up @@ -2286,10 +2286,10 @@ <h3>Notes</h3>
</div>
</script>

<script type="text/x-red" data-help-name="AudioAnalyzeGuitarTuner">
<script type="text/x-red" data-help-name="AudioAnalyzeNoteFrequency">
<h3>Summary</h3>
<p>Detect with fairly good accuracy the fundamental frequencies f<sub>o</sub> from
electric guitars and basses.</p>
<p>Detect with fairly good accuracy the fundamental frequency f<sub>o</sub>
of musical notes, such as electric guitar and bass.</p>
<p>Written By Collin Duffy</p>
<h3>Audio Connections</h3>
<table class=doc align=center cellpadding=3>
Expand All @@ -2315,7 +2315,7 @@ <h3>Functions</h3>
<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; GuitarTuneNotes
<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)
Expand All @@ -2327,11 +2327,14 @@ <h3>Notes</h3>
<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="AudioAnalyzeGuitarTuner">
<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">
Expand Down

0 comments on commit 7e017b1

Please sign in to comment.