Commit 73e88607 authored by Sandro Andrade's avatar Sandro Andrade

Refactor pitch, volume, and tempo control to new architecture

parent f2cb707a
......@@ -36,8 +36,8 @@ class MINUETINTERFACES_EXPORT ISoundBackend : public IPlugin
{
Q_OBJECT
Q_PROPERTY(int pitch MEMBER m_pitch NOTIFY pitchChanged)
Q_PROPERTY(quint8 volume MEMBER m_volume NOTIFY volumeChanged)
Q_PROPERTY(qint8 pitch MEMBER m_pitch WRITE setPitch NOTIFY pitchChanged)
Q_PROPERTY(quint8 volume MEMBER m_volume WRITE setVolume NOTIFY volumeChanged)
Q_PROPERTY(quint8 tempo MEMBER m_tempo WRITE setTempo NOTIFY tempoChanged)
Q_PROPERTY(QString playbackLabel READ playbackLabel NOTIFY playbackLabelChanged)
Q_ENUMS(PlayMode)
......@@ -65,7 +65,9 @@ public:
ISoundBackend::State state() const;
public Q_SLOTS:
virtual void setTempo (quint8 tempo) = 0;
virtual void setPitch(qint8 pitch) = 0;
virtual void setVolume(quint8 tempo) = 0;
virtual void setTempo(quint8 tempo) = 0;
virtual void prepareFromExerciseOptions(QJsonArray selectedOptions) = 0;
virtual void prepareFromMidiFile(const QString &fileName) = 0;
......@@ -75,7 +77,7 @@ public Q_SLOTS:
virtual void stop() = 0;
Q_SIGNALS:
void pitchChanged(int newPitch);
void pitchChanged(qint8 newPitch);
void volumeChanged(quint8 newVolume);
void tempoChanged(quint8 newTempo);
void playbackLabelChanged(QString newPlaybackLabel);
......@@ -87,7 +89,7 @@ protected:
void setPlaybackLabel(const QString &playbackLabel);
void setState(State state);
int m_pitch;
qint8 m_pitch;
quint8 m_volume;
quint8 m_tempo;
QString m_playbackLabel;
......
......@@ -116,6 +116,22 @@ DrumstickSoundBackend::~DrumstickSoundBackend()
qCDebug(MINUET) << "TiMidity++ stoped!";
}
void DrumstickSoundBackend::setPitch(qint8 pitch)
{
if (m_midiSequencerOutputThread->pitch() != pitch) {
m_midiSequencerOutputThread->setPitch(pitch);
emit pitchChanged(pitch);
}
}
void DrumstickSoundBackend::setVolume(quint8 volume)
{
if (m_midiSequencerOutputThread->volume() != volume) {
m_midiSequencerOutputThread->setVolume(volume);
emit volumeChanged(volume);
}
}
void DrumstickSoundBackend::setTempo (quint8 tempo)
{
float tempoFactor = (tempo*tempo + 100.0*tempo + 20000.0) / 40000.0;
......
......@@ -55,6 +55,8 @@ public:
virtual ~DrumstickSoundBackend() override;
public Q_SLOTS:
virtual void setPitch(qint8 pitch);
virtual void setVolume(quint8 volume);
virtual void setTempo (quint8 tempo);
virtual void prepareFromExerciseOptions(QJsonArray selectedOptions) override;
......
......@@ -122,7 +122,7 @@ unsigned int MidiSequencerOutputThread::volume() const
return m_volume;
}
void MidiSequencerOutputThread::setPitch(int value)
void MidiSequencerOutputThread::setPitch(qint8 value)
{
bool playing = isRunning();
if (playing) {
......@@ -137,7 +137,7 @@ void MidiSequencerOutputThread::setPitch(int value)
start();
}
int MidiSequencerOutputThread::pitch() const
qint8 MidiSequencerOutputThread::pitch() const
{
return m_pitchShift;
}
......
......@@ -45,8 +45,8 @@ public:
virtual unsigned int getInitialPosition() { return m_songPosition; }
void setSong(Song *song);
void setPitch(int value);
int pitch() const;
void setPitch(qint8 value);
qint8 pitch() const;
void setVolume(unsigned int volume);
unsigned int volume() const;
void setPosition(unsigned int pos);
......@@ -64,7 +64,7 @@ private:
drumstick::SequencerEvent *m_lastEvent;
unsigned int m_volume;
int m_channelVolume[MIDI_CHANNELS];
int m_pitchShift;
qint8 m_pitchShift;
float m_tempoFactor;
QListIterator<drumstick::SequencerEvent *>* m_songIterator;
};
......
......@@ -31,6 +31,16 @@ FluidSynthSoundBackend::~FluidSynthSoundBackend()
{
}
void FluidSynthSoundBackend::setPitch(qint8 pitch)
{
Q_UNUSED(pitch);
}
void FluidSynthSoundBackend::setVolume(quint8 volume)
{
Q_UNUSED(volume);
}
void FluidSynthSoundBackend::setTempo (quint8 tempo)
{
Q_UNUSED(tempo);
......
......@@ -38,7 +38,9 @@ public:
virtual ~FluidSynthSoundBackend() override;
public Q_SLOTS:
virtual void setTempo (quint8 tempo);
virtual void setPitch(qint8 pitch);
virtual void setVolume(quint8 volume);
virtual void setTempo(quint8 tempo);
virtual void prepareFromExerciseOptions(QJsonArray selectedOptions) override;
virtual void prepareFromMidiFile(const QString &fileName) override;
......
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