summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCedric Bonhomme <bonhomme@mailoo.org>2016-10-17 13:41:11 (GMT)
committerSandro S. Andrade <sandroandrade@kde.org>2016-10-17 14:43:28 (GMT)
commite65e0a073c4d17f8155b7843bde4907fb858d474 (patch)
treed182674e829b755bb65f585007baff18bd09d094
parent54f585f4e34302ea83785268a34c17473d6049f3 (diff)
Pitch, Tempo and Volume using FluidSynth
Summary: Use of the FluidSynth Library to set the pitch. The documentations does mention that: 0 << **pitch** << 1024 * 16 - 1 The **pitch** **slider** has been set from 0 to 16 Changing the pitch has immediate effect. The **tempo** has only been reactivated, it does work but needs the current question to be stopped() and played() again. Reviewers: sandroandrade Tags: #minuet Differential Revision: https://phabricator.kde.org/D2713
-rw-r--r--src/app/qml/midiplayer/MidiPlayer.qml4
-rw-r--r--src/plugins/fluidsynthsoundbackend/fluidsynthsoundbackend.cpp13
2 files changed, 12 insertions, 5 deletions
diff --git a/src/app/qml/midiplayer/MidiPlayer.qml b/src/app/qml/midiplayer/MidiPlayer.qml
index 1256677..86a0f68 100644
--- a/src/app/qml/midiplayer/MidiPlayer.qml
+++ b/src/app/qml/midiplayer/MidiPlayer.qml
@@ -71,7 +71,7 @@ Rectangle {
text: i18n("Pitch: %1").arg(Math.round(pitch))
}
}
- }
+ }
Item {
id: item1
@@ -135,7 +135,7 @@ Rectangle {
source: "../images/multimedia-volume.png"
tooltipText: "Volume (%)"
- maximumValue: 200; value: 100
+ maximumValue: 200; minimumValue: 50; value: 100
}
}
}
diff --git a/src/plugins/fluidsynthsoundbackend/fluidsynthsoundbackend.cpp b/src/plugins/fluidsynthsoundbackend/fluidsynthsoundbackend.cpp
index 5a0cc67..37a1399 100644
--- a/src/plugins/fluidsynthsoundbackend/fluidsynthsoundbackend.cpp
+++ b/src/plugins/fluidsynthsoundbackend/fluidsynthsoundbackend.cpp
@@ -45,6 +45,8 @@ FluidSynthSoundBackend::FluidSynthSoundBackend(QObject *parent)
m_synth = new_fluid_synth(m_settings);
+ fluid_synth_cc(m_synth, 1, 100, 0);
+
int fluid_res = fluid_synth_sfload(m_synth, QStandardPaths::locate(QStandardPaths::AppDataLocation, QStringLiteral("soundfonts/GeneralUser-v1.47.sf2")).toLatin1(), 1);
if (fluid_res == FLUID_FAILED)
qDebug() << "Error when loading soundfont!";
@@ -61,17 +63,22 @@ FluidSynthSoundBackend::~FluidSynthSoundBackend()
void FluidSynthSoundBackend::setPitch(qint8 pitch)
{
- Q_UNUSED(pitch);
+ m_pitch = pitch;
+ fluid_synth_cc(m_synth, 1, 101, 0);
+ fluid_synth_cc(m_synth, 1, 6, 12);
+ float accurate_pitch = (m_pitch + 12) * (2.0 / 3) * 1024;
+ fluid_synth_pitch_bend(m_synth, 1, qMin(qRound(accurate_pitch), 16 * 1024 - 1));
}
void FluidSynthSoundBackend::setVolume(quint8 volume)
{
- Q_UNUSED(volume);
+ m_volume = volume;
+ fluid_synth_cc(m_synth, 1, 7, m_volume * 127 / 200);
}
void FluidSynthSoundBackend::setTempo (quint8 tempo)
{
- Q_UNUSED(tempo);
+ m_tempo = tempo;
}
void FluidSynthSoundBackend::prepareFromExerciseOptions(QJsonArray selectedExerciseOptions)