3
* Copyright (C) 2018 Timothée Giet <animtim@gmail.com>
6
* Johnny Jazeix <jazeix@gmail.com>
7
* Timothée Giet <animtim@gmail.com>
9
* This program is free software; you can redistribute it and/or modify
10
* it under the terms of the GNU General Public License as published by
11
* the Free Software Foundation; either version 3 of the License, or
12
* (at your option) any later version.
14
* This program is distributed in the hope that it will be useful,
15
* but WITHOUT ANY WARRANTY; without even the implied warranty of
16
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17
* GNU General Public License for more details.
19
* You should have received a copy of the GNU General Public License
20
* along with this program; if not, see <https://www.gnu.org/licenses/>.
25
#include <QAudioDeviceInfo>
26
#include <QAudioOutput>
33
class GSynth : public QObject
38
explicit GSynth(QObject *parent = 0);
42
* Generate a note and start the corresponding timer
43
* to stop it at "duration" ms.
45
* @param note note to play
46
* @param duration how much time the note needs to be played
48
Q_INVOKABLE void generate(int note, int duration);
50
static GSynth *getInstance() {
52
m_instance = new GSynth();
56
static QObject *synthProvider(QQmlEngine *engine,
57
QJSEngine *scriptEngine);
60
static GSynth *m_instance;
63
void stopAudio(int note);
66
unsigned int bufferSize;
68
Generator *m_generator;
69
QAudioDeviceInfo m_device;
70
QAudioFormat m_format;
72
QAudioOutput *m_audioOutput;
73
QMap<int, QTimer *> m_timers;