File indexing completed on 2024-05-12 03:52:14
0001 /**************************************************************************** 0002 ** 0003 ** Copyright (C) 2016 by Sandro S. Andrade <sandroandrade@kde.org> 0004 ** 0005 ** This program is free software; you can redistribute it and/or 0006 ** modify it under the terms of the GNU General Public License as 0007 ** published by the Free Software Foundation; either version 2 of 0008 ** the License or (at your option) version 3 or any later version 0009 ** accepted by the membership of KDE e.V. (or its successor approved 0010 ** by the membership of KDE e.V.), which shall act as a proxy 0011 ** defined in Section 14 of version 3 of the license. 0012 ** 0013 ** This program is distributed in the hope that it will be useful, 0014 ** but WITHOUT ANY WARRANTY; without even the implied warranty of 0015 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 0016 ** GNU General Public License for more details. 0017 ** 0018 ** You should have received a copy of the GNU General Public License 0019 ** along with this program. If not, see <http://www.gnu.org/licenses/>. 0020 ** 0021 ****************************************************************************/ 0022 0023 #ifndef MINUET_FLUIDSYNTHSOUNDCONTROLLER_H 0024 #define MINUET_FLUIDSYNTHSOUNDCONTROLLER_H 0025 0026 #include <interfaces/isoundcontroller.h> 0027 0028 #include <fluidsynth.h> 0029 0030 class FluidSynthSoundController : public Minuet::ISoundController 0031 { 0032 Q_OBJECT 0033 0034 Q_PLUGIN_METADATA(IID "org.kde.minuet.IPlugin" FILE "fluidsynthsoundcontroller.json") 0035 Q_INTERFACES(Minuet::IPlugin) 0036 Q_INTERFACES(Minuet::ISoundController) 0037 0038 public: 0039 explicit FluidSynthSoundController(QObject *parent = nullptr); 0040 virtual ~FluidSynthSoundController() override; 0041 0042 public Q_SLOTS: 0043 virtual void setPitch(qint8 pitch) override; 0044 virtual void setVolume(quint8 volume) override; 0045 virtual void setTempo(quint8 tempo) override; 0046 0047 virtual void prepareFromExerciseOptions(QJsonArray selectedExerciseOptions) override; 0048 virtual void prepareFromMidiFile(const QString &fileName) override; 0049 0050 virtual void play() override; 0051 virtual void pause() override; 0052 virtual void stop() override; 0053 virtual void reset() override; 0054 0055 private: 0056 void appendEvent(int channel, short key, short velocity, unsigned int duration); 0057 static void sequencerCallback(unsigned int time, fluid_event_t *event, fluid_sequencer_t *seq, 0058 void *data); 0059 void resetEngine(); 0060 void deleteEngine(); 0061 0062 private: 0063 fluid_settings_t *m_settings; 0064 fluid_audio_driver_t *m_audioDriver; 0065 fluid_sequencer_t *m_sequencer; 0066 fluid_synth_t *m_synth; 0067 fluid_event_t *m_unregisteringEvent; 0068 0069 short m_synthSeqID; 0070 short m_callbackSeqID; 0071 static unsigned int m_initialTime; 0072 0073 QScopedPointer<QList<fluid_event_t *>> m_song; 0074 }; 0075 0076 #endif