196
preenfm2 and preenfm3 / Re: custom extended firmware
« on: January 07, 2018, 11:10:19 PM »
and here is the "standard" firmware with all the additions mentioned in the above post. have fun!
This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.
if (selectedMenu == MIDICONFIG_GLOBAL_TUNE) {
Osc::tune(fullState.midiConfigValue[fullState.menuSelect]);
void Osc::tune( int tuneconfig) {
float tuneFactor[] = {435.0,435.5,436.0,436.5,437.0,437.5,438.0,438.5,439.0,439.5,440.0,440.5,441.0,441.5,442.0,442.5,443.0,443.5,444.0} ;
float frecAdjust = tuneFactor[tuneconfig] / 440.0f;
for (int k=0; k<127; k++) {
midiNoteTunedFrequency[k]= frequency[k] * frecAdjust;
}
// Set frequencyToUse to frequency (no Scala scale defined)
frequencyToUse = midiNoteTunedFrequency;
}
if (fullState.midiConfigValue[fullState.menuSelect] == MIDICONFIG_GLOBAL_TUNE) {
Osc::tune(this->fullState.midiConfigValue[MIDICONFIG_GLOBAL_TUNE]);
}
On microcontroller, const are not moved to RAM, they stay on the flash memory, so they're slower. That's fine for your tuneFactor, but not for value used in the real time audio engine.
float tuneFactor[] = {435.0,435.5,436.0,436.5,437.0,437.5,438.0,438.5,439.0,439.5,440.0,440.5,441.0,441.5,442.0,442.5,443.0,443.5,444.0} ;
float frecAdjust = tuneFactor[this->synthState->fullState.midiConfigValue[MIDICONFIG_GLOBAL_TUNE]] / 440.0f;
for (int k=0; k<127; k++) {
midiNoteTunedFrequency[k]= frequency[k] * frecAdjust;
}
// Set frequencyToUse to frequency (no Scala scale defined)
frequencyToUse = midiNoteTunedFrequency;
float currentA = frequency[81];
for (int k=0; k<127; k++) {
frequency[k] = frequency[k] * ((870.0 + this->synthState->fullState.midiConfigValue[MIDICONFIG_GLOBAL_TUNE])/currentA);
}