Commit 9d6a7821 authored by Kushagra Surana's avatar Kushagra Surana Committed by Sandro Andrade

Keep tempo factor settings across exercises playing

Unlike volume factor or pitch factor, the tempo factor was nowhere stored for the next song.
With this diff tempo factor will be stored and used when a new song is loaded.

Reviewers: sandroandrade

Subscribers: itsback

Tags: #minuet

Differential Revision: https://phabricator.kde.org/D1243
parent db805087
...@@ -235,6 +235,8 @@ void MidiSequencer::setVolumeFactor(unsigned int vol) ...@@ -235,6 +235,8 @@ void MidiSequencer::setVolumeFactor(unsigned int vol)
void MidiSequencer::setTempoFactor(unsigned int value) void MidiSequencer::setTempoFactor(unsigned int value)
{ {
float tempoFactor = (value*value + 100.0*value + 20000.0) / 40000.0; float tempoFactor = (value*value + 100.0*value + 20000.0) / 40000.0;
m_midiSequencerOutputThread->setTempoFactor(tempoFactor);
drumstick::QueueTempo queueTempo = m_queue->getTempo(); drumstick::QueueTempo queueTempo = m_queue->getTempo();
queueTempo.setTempoFactor(tempoFactor); queueTempo.setTempoFactor(tempoFactor);
m_queue->setTempo(queueTempo); m_queue->setTempo(queueTempo);
......
...@@ -36,6 +36,7 @@ MidiSequencerOutputThread::MidiSequencerOutputThread(drumstick::MidiClient *clie ...@@ -36,6 +36,7 @@ MidiSequencerOutputThread::MidiSequencerOutputThread(drumstick::MidiClient *clie
m_lastEvent(0), m_lastEvent(0),
m_volumeFactor(100), m_volumeFactor(100),
m_pitchShift(0), m_pitchShift(0),
m_tempoFactor(1.0),
m_songIterator(0) m_songIterator(0)
{ {
for (int chan = 0; chan < MIDI_CHANNELS; ++chan) for (int chan = 0; chan < MIDI_CHANNELS; ++chan)
...@@ -100,7 +101,7 @@ void MidiSequencerOutputThread::setSong(Song *song) ...@@ -100,7 +101,7 @@ void MidiSequencerOutputThread::setSong(Song *song)
drumstick::QueueTempo firstTempo = m_Queue->getTempo(); drumstick::QueueTempo firstTempo = m_Queue->getTempo();
firstTempo.setPPQ(m_song->division()); firstTempo.setPPQ(m_song->division());
firstTempo.setTempo(m_song->initialTempo()); firstTempo.setTempo(m_song->initialTempo());
firstTempo.setTempoFactor(1.0); firstTempo.setTempoFactor(m_tempoFactor);
m_Queue->setTempo(firstTempo); m_Queue->setTempo(firstTempo);
} }
...@@ -131,6 +132,11 @@ void MidiSequencerOutputThread::setPitchShift(int value) ...@@ -131,6 +132,11 @@ void MidiSequencerOutputThread::setPitchShift(int value)
start(); start();
} }
void MidiSequencerOutputThread::setTempoFactor(float value)
{
m_tempoFactor = value;
}
void MidiSequencerOutputThread::setPosition(unsigned int pos) void MidiSequencerOutputThread::setPosition(unsigned int pos)
{ {
m_songPosition = pos; m_songPosition = pos;
......
...@@ -48,6 +48,7 @@ public: ...@@ -48,6 +48,7 @@ public:
void setVolumeFactor(unsigned int vol); void setVolumeFactor(unsigned int vol);
void setPitchShift(int value); void setPitchShift(int value);
void setPosition(unsigned int pos); void setPosition(unsigned int pos);
void setTempoFactor(float value);
void resetPosition(); void resetPosition();
Q_SIGNALS: Q_SIGNALS:
...@@ -65,6 +66,7 @@ private: ...@@ -65,6 +66,7 @@ private:
int m_volume[MIDI_CHANNELS]; int m_volume[MIDI_CHANNELS];
unsigned int m_volumeFactor; unsigned int m_volumeFactor;
int m_pitchShift; int m_pitchShift;
float m_tempoFactor;
QListIterator<drumstick::SequencerEvent *>* m_songIterator; QListIterator<drumstick::SequencerEvent *>* m_songIterator;
}; };
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment