Skip to content

Commit

Permalink
implemented the 'use Tuning' option internally for transposition sliders
Browse files Browse the repository at this point in the history
  • Loading branch information
dantrueman committed Oct 22, 2024
1 parent 43d8865 commit 87813ec
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 8 deletions.
2 changes: 1 addition & 1 deletion source/synthesis/framework/Synthesiser/BKSynthesiser.h
Original file line number Diff line number Diff line change
Expand Up @@ -403,7 +403,7 @@ class BKSynthesiser
*
* the "un-transposed" midiNoteNumber is the midi note played by the performer, and used for voice tracking
*/
juce::Array<float> midiNoteTranspositions = { 0.}; // needs to be set via UI
juce::Array<float> midiNoteTranspositions = { 0., 4, 7, 10}; // needs to be set via UI
juce::HashMap<int, juce::Array<BKSamplerVoice*>> playingVoicesByNote; // Hash of current voices playing for a particular midiNoteNumber (perhaps should just be an array)

template <typename floatType>
Expand Down
27 changes: 20 additions & 7 deletions source/synthesis/framework/Synthesiser/Sample.h
Original file line number Diff line number Diff line change
Expand Up @@ -662,13 +662,26 @@ class BKSamplerVoice : public BKSynthesiserVoice
double getTargetFrequency()
{
/**
* lastNoteOffset = (currentTuning[(midiNoteNumber - tuning->prep->getFundamental()) % currentTuning.size()]
+ tuning->prep->getAbsoluteOffsets().getUnchecked(midiNoteNumber)
+ tuning->prep->getFundamentalOffset());
* by default, transpositions are tuned literally, relative to the played note
* using whatever value, fractional or otherwise, that the user indicates
* and ignores the tuning system
* The played note is tuned according to the tuning system, but the transpositions are not
*
* if "tuneTranspositions" is set to true, then the transposed notes themselves are also tuned
* according to the current tuning system
*
* this should be the same behavior we had in the original bK, with "use Tuning" on transposition sliders
*/

float newOffset = (currentTuning[(currentlyPlayingNote - currentTuningFundamental) % currentTuning.size()]);
return mtof ( newOffset + (double)currentlyPlayingNote + currentTransposition );
if (!tuneTranspositions)
{
float newOffset = (currentTuning[(currentlyPlayingNote - currentTuningFundamental) % currentTuning.size()]);
return mtof ( newOffset + (double)currentlyPlayingNote + currentTransposition );
}
else
{
float newOffset = (currentTuning[(currentlyPlayingNote + (int)std::trunc(currentTransposition) - currentTuningFundamental) % currentTuning.size()]);
return mtof ( newOffset + (double)currentlyPlayingNote + currentTransposition );
}
}

virtual void stopNote (float velocity, bool allowTailOff)
Expand Down Expand Up @@ -931,8 +944,8 @@ class BKSamplerVoice : public BKSynthesiserVoice

float currentTransposition; // comes from Transposition sliders in Direct/Nostalgic/Synchronic
juce::Array<float> currentTuning = tPartialTuning;
//juce::Array<float> currentTuning = { 0., .117313, .039101, -.331291, -.13686, -.019547, -.486824, .019547, .405273, -.15641, -.311745, -.506371 };
int currentTuningFundamental = 0;
bool tuneTranspositions = false; // if this is true, then Transposition slider values will be tuned using the currentTuning system

juce::SmoothedValue<double> level { 0 };
juce::SmoothedValue<double> frequency { 0 };
Expand Down

0 comments on commit 87813ec

Please sign in to comment.