Make shifting notes by octaves respect microtuning (#6545)
This commit is contained in:
@@ -54,6 +54,7 @@ public:
|
||||
float baseFreq() const;
|
||||
|
||||
float keyToFreq(int key, int userBaseNote) const;
|
||||
int octaveSize() const;
|
||||
|
||||
QString nodeName() const override {return "microtuner";}
|
||||
void saveSettings(QDomDocument & document, QDomElement &element) override;
|
||||
|
||||
@@ -108,6 +108,17 @@ float Microtuner::keyToFreq(int key, int userBaseNote) const
|
||||
return middleFreq * intervals[scaleDegree].getRatio() * pow(octaveRatio, keymapOctave + scaleOctave);
|
||||
}
|
||||
|
||||
int Microtuner::octaveSize() const
|
||||
{
|
||||
const int keymapSize = Engine::getSong()->getKeymap(currentKeymap())->getSize();
|
||||
if (keymapSize > 0)
|
||||
{
|
||||
return keymapSize;
|
||||
}
|
||||
|
||||
// Determine octave size from the scale if the keymap isn't in use.
|
||||
return Engine::getSong()->getScale(currentScale())->getIntervals().size() - 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Update scale name displayed in the microtuner scale list.
|
||||
@@ -170,4 +181,4 @@ void Microtuner::loadSettings(const QDomElement &element)
|
||||
}
|
||||
|
||||
|
||||
} // namespace lmms
|
||||
} // namespace lmms
|
||||
|
||||
@@ -1310,16 +1310,25 @@ void PianoRoll::keyPressEvent(QKeyEvent* ke)
|
||||
int direction = (ke->key() == Qt::Key_Up ? +1 : -1);
|
||||
if( ( ke->modifiers() & Qt::ControlModifier ) && m_action == ActionNone )
|
||||
{
|
||||
// shift selection up an octave
|
||||
// shift selection by one octave
|
||||
// if nothing selected, shift _everything_
|
||||
if (hasValidMidiClip())
|
||||
{
|
||||
shiftSemiTone( 12 * direction );
|
||||
// An octave could potentially be greater or less than twelve semitones if the microtuner is in use.
|
||||
const auto microtuner = m_midiClip->instrumentTrack()->microtuner();
|
||||
if (microtuner->enabled())
|
||||
{
|
||||
shiftSemiTone(microtuner->octaveSize() * direction);
|
||||
}
|
||||
else
|
||||
{
|
||||
shiftSemiTone(12 * direction);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if((ke->modifiers() & Qt::ShiftModifier) && m_action == ActionNone)
|
||||
{
|
||||
// Move selected notes up by one semitone
|
||||
// Move selected notes by one semitone
|
||||
if (hasValidMidiClip())
|
||||
{
|
||||
shiftSemiTone( 1 * direction );
|
||||
|
||||
Reference in New Issue
Block a user