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