commit
ba8227de24
3 changed files with 45 additions and 14 deletions
2
src/external/tunings/README.txt
vendored
2
src/external/tunings/README.txt
vendored
|
|
@ -1,2 +1,2 @@
|
||||||
Based on the Surge tuning library, revision a5f2879, with small modifications
|
Based on the Surge tuning library, revision e8aab5b, with small modifications
|
||||||
https://github.com/surge-synthesizer/tuning-library
|
https://github.com/surge-synthesizer/tuning-library
|
||||||
|
|
|
||||||
2
src/external/tunings/include/Tunings.h
vendored
2
src/external/tunings/include/Tunings.h
vendored
|
|
@ -96,7 +96,7 @@ namespace Tunings
|
||||||
int middleNote = 60;
|
int middleNote = 60;
|
||||||
int tuningConstantNote = 60;
|
int tuningConstantNote = 60;
|
||||||
double tuningFrequency = MIDI_0_FREQ * 32.0, tuningPitch = 32.0; // pitch = frequency / MIDI_0_FREQ
|
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
|
int keys[MAX_CAPACITY]; // rather than an 'x' we use a '-1' for skipped keys
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
55
src/external/tunings/src/Tunings.cpp
vendored
55
src/external/tunings/src/Tunings.cpp
vendored
|
|
@ -55,7 +55,7 @@ namespace Tunings
|
||||||
|
|
||||||
if( t.ratio_n == 0 || t.ratio_d == 0 )
|
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 )
|
if( lineno >= 0 )
|
||||||
s += "Line " + std::to_string(lineno) + ".";
|
s += "Line " + std::to_string(lineno) + ".";
|
||||||
s += " Line is '" + line + "'.";
|
s += " Line is '" + line + "'.";
|
||||||
|
|
@ -83,7 +83,7 @@ namespace Tunings
|
||||||
{
|
{
|
||||||
lineno ++;
|
lineno ++;
|
||||||
|
|
||||||
if (line.empty() || line[0] == '!')
|
if ((state == read_note && line.empty()) || line[0] == '!')
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
@ -112,13 +112,13 @@ namespace Tunings
|
||||||
|
|
||||||
if( ! ( state == read_note || state == trailing ) )
|
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 )
|
if( tone_index != res.count )
|
||||||
{
|
{
|
||||||
std::string s = "Read fewer notes than count in file. Count=" + std::to_string( 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 );
|
+ " notes. Array size = " + std::to_string( tone_index );
|
||||||
throw TuningError(s);
|
throw TuningError(s);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -209,7 +209,7 @@ namespace Tunings
|
||||||
while (std::getline(inf, line))
|
while (std::getline(inf, line))
|
||||||
{
|
{
|
||||||
lineno ++;
|
lineno ++;
|
||||||
if (line.empty() || line[0] == '!')
|
if (!line.empty() && line[0] == '!')
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
@ -231,7 +231,7 @@ namespace Tunings
|
||||||
}
|
}
|
||||||
if( ! validLine )
|
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 ) + "'" );
|
badChar + "/" + std::to_string( (int)badChar ) + "'" );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -281,7 +281,7 @@ namespace Tunings
|
||||||
|
|
||||||
if( ! ( state == keys || state == trailing ) )
|
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 )
|
if( key_index != res.count )
|
||||||
|
|
@ -414,6 +414,26 @@ namespace Tunings
|
||||||
int mappingKey = distanceFromScale0 % k.count;
|
int mappingKey = distanceFromScale0 % k.count;
|
||||||
if( mappingKey < 0 )
|
if( mappingKey < 0 )
|
||||||
mappingKey += k.count;
|
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 cm = k.keys[mappingKey];
|
||||||
int push = 0;
|
int push = 0;
|
||||||
if( cm < 0 )
|
if( cm < 0 )
|
||||||
|
|
@ -424,11 +444,22 @@ namespace Tunings
|
||||||
{
|
{
|
||||||
push = mappingKey - cm;
|
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
|
#ifdef DEBUG_SCALES
|
||||||
if( i > 296 && i < 340 )
|
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 << std::endl;
|
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
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue