From 939b93107babdcd557da0c5d05bf59711c919e93 Mon Sep 17 00:00:00 2001 From: Jean Pierre Cimalando Date: Tue, 6 Apr 2021 14:08:52 +0200 Subject: [PATCH 1/4] Update tunings to d9660ef --- src/external/tunings/README.txt | 2 +- src/external/tunings/include/Tunings.h | 2 +- src/external/tunings/src/Tunings.cpp | 39 +++++++++++++++++++++++--- 3 files changed, 37 insertions(+), 6 deletions(-) diff --git a/src/external/tunings/README.txt b/src/external/tunings/README.txt index 4a6507b1..bd610bfc 100644 --- a/src/external/tunings/README.txt +++ b/src/external/tunings/README.txt @@ -1,2 +1,2 @@ -Based on the Surge tuning library, revision a5f2879, with small modifications +Based on the Surge tuning library, revision d9660ef, with small modifications https://github.com/surge-synthesizer/tuning-library diff --git a/src/external/tunings/include/Tunings.h b/src/external/tunings/include/Tunings.h index 2ff3df15..55e0735a 100644 --- a/src/external/tunings/include/Tunings.h +++ b/src/external/tunings/include/Tunings.h @@ -96,7 +96,7 @@ namespace Tunings int middleNote = 60; int tuningConstantNote = 60; double tuningFrequency = MIDI_0_FREQ * 32.0, tuningPitch = 32.0; // pitch = frequency / MIDI_0_FREQ - int octaveDegrees = 12; + int octaveDegrees = 0; int keys[MAX_CAPACITY]; // rather than an 'x' we use a '-1' for skipped keys }; diff --git a/src/external/tunings/src/Tunings.cpp b/src/external/tunings/src/Tunings.cpp index cacae2d6..87e72ca9 100644 --- a/src/external/tunings/src/Tunings.cpp +++ b/src/external/tunings/src/Tunings.cpp @@ -414,6 +414,26 @@ namespace Tunings int mappingKey = distanceFromScale0 % k.count; if( mappingKey < 0 ) mappingKey += k.count; + // Now have we gone off the end + int rotations = 0; + int dt = distanceFromScale0; + if( dt > 0 ) + { + while( dt >= k.count ) + { + dt -= k.count; + rotations ++; + } + } + else + { + while( dt < 0 ) + { + dt += k.count; + rotations --; + } + } + int cm = k.keys[mappingKey]; int push = 0; if( cm < 0 ) @@ -424,11 +444,22 @@ namespace Tunings { push = mappingKey - cm; } - rounds = (distanceFromScale0 - push - 1) / s.count; - thisRound = (distanceFromScale0 - push - 1) % s.count; + + if( k.octaveDegrees > 0 && k.octaveDegrees != k.count ) + { + rounds = rotations; + thisRound = cm-1; + if( thisRound < 0 ) { thisRound = k.octaveDegrees - 1; rounds--; } + } + else + { + rounds = (distanceFromScale0 - push - 1) / s.count; + thisRound = (distanceFromScale0 - push - 1) % s.count; + } + #ifdef DEBUG_SCALES - if( i > 296 && i < 340 ) - std::cout << "MAPPING n=" << i - 256 << " pushes ds0=" << distanceFromScale0 << " cmc=" << k.count << " tr=" << thisRound << " r=" << rounds << " mk=" << mappingKey << " cm=" << cm << " push=" << push << " dis=" << disable << " mk-p-1=" << mappingKey - push - 1 << std::endl; + if( i > 256+53 && i < 265+85 ) + std::cout << "MAPPING n=" << i - 256 << " pushes ds0=" << distanceFromScale0 << " cmc=" << k.count << " tr=" << thisRound << " r=" << rounds << " mk=" << mappingKey << " cm=" << cm << " push=" << push << " dis=" << disable << " mk-p-1=" << mappingKey - push - 1 << " rotations=" << rotations << " od=" << k.octaveDegrees << std::endl; #endif From e6e28a6a449b75d6811e5b2dd72c806923f74e3e Mon Sep 17 00:00:00 2001 From: Jean Pierre Cimalando Date: Tue, 6 Apr 2021 14:14:04 +0200 Subject: [PATCH 2/4] Update tunings to 0ba372f --- src/external/tunings/README.txt | 2 +- src/external/tunings/src/Tunings.cpp | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/external/tunings/README.txt b/src/external/tunings/README.txt index bd610bfc..5b4f8232 100644 --- a/src/external/tunings/README.txt +++ b/src/external/tunings/README.txt @@ -1,2 +1,2 @@ -Based on the Surge tuning library, revision d9660ef, with small modifications +Based on the Surge tuning library, revision 0ba372f, with small modifications https://github.com/surge-synthesizer/tuning-library diff --git a/src/external/tunings/src/Tunings.cpp b/src/external/tunings/src/Tunings.cpp index 87e72ca9..7952328c 100644 --- a/src/external/tunings/src/Tunings.cpp +++ b/src/external/tunings/src/Tunings.cpp @@ -83,7 +83,7 @@ namespace Tunings { lineno ++; - if (line.empty() || line[0] == '!') + if ((state == read_note && line.empty()) || line[0] == '!') { continue; } @@ -209,7 +209,7 @@ namespace Tunings while (std::getline(inf, line)) { lineno ++; - if (line.empty() || line[0] == '!') + if (!line.empty() && line[0] == '!') { continue; } From 97597123c674b5e6115e5843e1a6fedbda12cca3 Mon Sep 17 00:00:00 2001 From: Jean Pierre Cimalando Date: Tue, 6 Apr 2021 14:22:22 +0200 Subject: [PATCH 3/4] Update tunings to 0aec52c --- src/external/tunings/README.txt | 2 +- src/external/tunings/src/Tunings.cpp | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/external/tunings/README.txt b/src/external/tunings/README.txt index 5b4f8232..05d91b24 100644 --- a/src/external/tunings/README.txt +++ b/src/external/tunings/README.txt @@ -1,2 +1,2 @@ -Based on the Surge tuning library, revision 0ba372f, with small modifications +Based on the Surge tuning library, revision 0aec52c, with small modifications https://github.com/surge-synthesizer/tuning-library diff --git a/src/external/tunings/src/Tunings.cpp b/src/external/tunings/src/Tunings.cpp index 7952328c..ae535db3 100644 --- a/src/external/tunings/src/Tunings.cpp +++ b/src/external/tunings/src/Tunings.cpp @@ -55,7 +55,7 @@ namespace Tunings if( t.ratio_n == 0 || t.ratio_d == 0 ) { - std::string s = "Invalid Tone in SCL file."; + std::string s = "Invalid tone in SCL file."; if( lineno >= 0 ) s += "Line " + std::to_string(lineno) + "."; s += " Line is '" + line + "'."; @@ -112,13 +112,13 @@ namespace Tunings if( ! ( state == read_note || state == trailing ) ) { - throw TuningError( "Incomplete SCL file. Found no notes section in the file" ); + throw TuningError( "Incomplete SCL file. Found no notes section in the file." ); } if( tone_index != res.count ) { - std::string s = "Read fewer notes than count in file. Count=" + std::to_string( res.count ) - + " notes array size=" + std::to_string( tone_index ); + std::string s = "Read fewer notes than count in file. Count = " + std::to_string( res.count ) + + " notes. Array size = " + std::to_string( tone_index ); throw TuningError(s); } @@ -231,7 +231,7 @@ namespace Tunings } if( ! validLine ) { - throw TuningError( "Invalid line " + std::to_string( lineno ) + ". line='" + line + "'. Bad char is '" + + throw TuningError( "Invalid line " + std::to_string( lineno ) + ". line='" + line + "'. Bad character is '" + badChar + "/" + std::to_string( (int)badChar ) + "'" ); } } @@ -281,7 +281,7 @@ namespace Tunings if( ! ( state == keys || state == trailing ) ) { - throw TuningError( "Incomplete KBM file. Ubable to get to keys section of file" ); + throw TuningError( "Incomplete KBM file. Ubable to get to keys section of file." ); } if( key_index != res.count ) From 1bd32a533ff97c6b2b55b23496e9a70cb56e7eb1 Mon Sep 17 00:00:00 2001 From: Jean Pierre Cimalando Date: Tue, 6 Apr 2021 14:34:08 +0200 Subject: [PATCH 4/4] Update tunings to e8aab5b --- src/external/tunings/README.txt | 2 +- src/external/tunings/src/Tunings.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/external/tunings/README.txt b/src/external/tunings/README.txt index 05d91b24..088474d5 100644 --- a/src/external/tunings/README.txt +++ b/src/external/tunings/README.txt @@ -1,2 +1,2 @@ -Based on the Surge tuning library, revision 0aec52c, with small modifications +Based on the Surge tuning library, revision e8aab5b, with small modifications https://github.com/surge-synthesizer/tuning-library diff --git a/src/external/tunings/src/Tunings.cpp b/src/external/tunings/src/Tunings.cpp index ae535db3..8119f7b1 100644 --- a/src/external/tunings/src/Tunings.cpp +++ b/src/external/tunings/src/Tunings.cpp @@ -281,7 +281,7 @@ namespace Tunings if( ! ( state == keys || state == trailing ) ) { - throw TuningError( "Incomplete KBM file. Ubable to get to keys section of file." ); + throw TuningError( "Incomplete KBM file. Unable to get to keys section of file." ); } if( key_index != res.count )