From 72dec2f3e783b19688639197ea13aa01b23a4143 Mon Sep 17 00:00:00 2001 From: Paul Date: Sun, 5 Jan 2020 19:25:38 -0500 Subject: [PATCH] Display the Tuning Frequency Table (#1454) Display the full tuning frequency table in the HTML Part of #1041 --- src/common/Tunings.cpp | 30 +++++++++++++++++++++++++++++- src/common/Tunings.h | 4 +++- src/common/gui/SurgeGUIEditor.cpp | 4 ++-- 3 files changed, 34 insertions(+), 4 deletions(-) diff --git a/src/common/Tunings.cpp b/src/common/Tunings.cpp index f96df59b041..9209f43bb12 100644 --- a/src/common/Tunings.cpp +++ b/src/common/Tunings.cpp @@ -1,5 +1,6 @@ #include "Tunings.h" +#include "SurgeStorage.h" #include #include @@ -146,7 +147,7 @@ bool Surge::Storage::Scale::isValid() const return true; } -std::string Surge::Storage::Scale::toHtml() +std::string Surge::Storage::Scale::toHtml(SurgeStorage *storage) { std::ostringstream htmls; @@ -216,6 +217,33 @@ R"HTML( htmls << "" << t.cents << "" << t.floatValue << "\n"; }; + htmls << R"HTML( + + +

+ + + + + + +)HTML"; + + for( int i=0; i<127; ++i ) + { + int octave = (i / 12) - 1; + char notenames[12][3] = {"C ", "C#", "D ", "D#", "E ", "F ", "F#", "G ", "G#", "A ", "A#", "B "}; + + htmls << "\n"; + + auto tn = i - storage->scaleConstantNote(); + while( tn < 0 ) tn += count; + + auto p = storage->note_to_pitch(i); + htmls << ""; + htmls << "\n"; + } + htmls << R"HTML(
Midi NoteScale PositionFrequency
" << i << " (" << notenames[i % 12 ] << octave << ")" << (tn % count + 1) << "" << 8.175798915 * p << " hz
diff --git a/src/common/Tunings.h b/src/common/Tunings.h index ace0854b1bc..af522d55948 100644 --- a/src/common/Tunings.h +++ b/src/common/Tunings.h @@ -3,6 +3,8 @@ #include #include +class SurgeStorage; + namespace Surge { namespace Storage @@ -40,7 +42,7 @@ struct Scale bool isValid() const; - std::string toHtml(); + std::string toHtml(SurgeStorage *storage); }; std::ostream& operator<<(std::ostream& os, const Tone& sc); diff --git a/src/common/gui/SurgeGUIEditor.cpp b/src/common/gui/SurgeGUIEditor.cpp index c08b9fd02c4..fe5fb2091c4 100644 --- a/src/common/gui/SurgeGUIEditor.cpp +++ b/src/common/gui/SurgeGUIEditor.cpp @@ -3494,8 +3494,8 @@ VSTGUI::COptionMenu *SurgeGUIEditor::makeTuningMenu(VSTGUI::CRect &menuRect) auto *sct = addCallbackMenu(tuningSubMenu, "Show current tuning", [this]() { - // Surge::UserInteractions::promptOKCancel( "Surge tuning is NONstandard tuning", "Tuning Info" ); - Surge::UserInteractions::showHTML( this->synth->storage.currentScale.toHtml() ); + // Surge::UserInteractions::promptOKCancel( "Surge tuning is NONstandard tuning", "Tuning Info" ); + Surge::UserInteractions::showHTML( this->synth->storage.currentScale.toHtml(&(this->synth->storage)) ); } ); sct->setEnabled(! this->synth->storage.isStandardTuning );