From: sgunderson@bigfoot.com <> Date: Mon, 19 Jul 2010 21:35:33 +0000 (+0200) Subject: Move the notes array into its own file, and add a separate version for equal temperam... X-Git-Url: https://git.sesse.net/index.cgi/?p=pitch;a=commitdiff_plain;h=f08b6405c3248dc9c4852bf93d82f87a8c45a179 Move the notes array into its own file, and add a separate version for equal temperament, although it is currently not used. --- diff --git a/config.h b/config.h index 87f25e9..2829d83 100644 --- a/config.h +++ b/config.h @@ -13,6 +13,7 @@ #define EQUAL_TEMPERAMENT 0 #define WELL_TEMPERED_GUITAR 1 -#define TUNING WELL_TEMPERED_GUITAR +//#define TUNING WELL_TEMPERED_GUITAR +#define TUNING EQUAL_TEMPERAMENT #endif /* !defined(_CONFIG_H) */ diff --git a/notes.h b/notes.h new file mode 100644 index 0000000..d5c178a --- /dev/null +++ b/notes.h @@ -0,0 +1,33 @@ +#ifndef _NOTES_H +#define _NOTES_H 1 + +#include + +#include "config.h" + +struct note { + char notename[16]; + double freq; +}; + +#if TUNING == WELL_TEMPERED_GUITAR +static note notes[] = { + { "E-3", BASE_PITCH/4.0 * (3.0/4.0) }, + { "A-3", BASE_PITCH/4.0 }, + { "D-4", BASE_PITCH/4.0 * (4.0/3.0) }, + { "G-4", BASE_PITCH/4.0 * (4.0/3.0)*(4.0/3.0) }, + { "B-4", BASE_PITCH * (3.0/4.0)*(3.0/4.0) }, + { "E-5", BASE_PITCH * (3.0/4.0) } +}; +#else +static note notes[] = { + { "E-3", BASE_PITCH/4.0 * pow(2.0, -5.0/12.0) }, + { "A-3", BASE_PITCH/4.0 }, + { "D-4", BASE_PITCH/4.0 * pow(2.0, 5.0/12.0) }, + { "G-4", BASE_PITCH/4.0 * pow(2.0, 10.0/12.0) }, + { "B-4", BASE_PITCH/2.0 * pow(2.0, 2.0/12.0) }, + { "E-5", BASE_PITCH/2.0 * pow(2.0, 7.0/12.0) }, +}; +#endif + +#endif /* !defined(_NOTES_H) */ diff --git a/pitch.cpp b/pitch.cpp index bc97ee5..6ec6155 100644 --- a/pitch.cpp +++ b/pitch.cpp @@ -78,19 +78,6 @@ void print_spectrogram(double freq, double amp) } #else -struct note { - char notename[16]; - double freq; -}; -static note notes[] = { - { "E-3", BASE_PITCH/4.0 * (3.0/4.0) }, - { "A-3", BASE_PITCH/4.0 }, - { "D-4", BASE_PITCH/4.0 * (4.0/3.0) }, - { "G-4", BASE_PITCH/4.0 * (4.0/3.0)*(4.0/3.0) }, - { "B-4", BASE_PITCH * (3.0/4.0)*(3.0/4.0) }, - { "E-5", BASE_PITCH * (3.0/4.0) } -}; - void print_spectrogram(double freq, double amp) { double best_away = 999999999.9;