1 /*************************************************************************** 2 ** ** 3 ** Polyphone, a soundfont editor ** 4 ** Copyright (C) 2013-2020 Davy Triponney ** 5 ** ** 6 ** This program is free software: you can redistribute it and/or modify ** 7 ** it under the terms of the GNU General Public License as published by ** 8 ** the Free Software Foundation, either version 3 of the License, or ** 9 ** (at your option) any later version. ** 10 ** ** 11 ** This program is distributed in the hope that it will be useful, ** 12 ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** 13 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** 14 ** GNU General Public License for more details. ** 15 ** ** 16 ** You should have received a copy of the GNU General Public License ** 17 ** along with this program. If not, see http://www.gnu.org/licenses/. ** 18 ** ** 19 **************************************************************************** 20 ** Author: Davy Triponney ** 21 ** Website/Contact: https://www.polyphone-soundfonts.com ** 22 ** Date: 01.01.2013 ** 23 ***************************************************************************/ 24 25 #ifndef RUNNABLECHORDCREATOR_H 26 #define RUNNABLECHORDCREATOR_H 27 28 #include <QRunnable> 29 #include "basetypes.h" 30 #include "toolchords_parameters.h" 31 class ToolChords; 32 33 class RunnableChordCreator: public QRunnable 34 { 35 public: 36 RunnableChordCreator(ToolChords * tool, EltID idInst, ChordInfo ci, quint32 key, quint32 minKey, bool loop, bool stereo, int side); 37 ~RunnableChordCreator() override; 38 void run() override; 39 40 private: 41 EltID closestSample(EltID idInst, double pitch, double &ecart, int cote, EltID &idInstSmpl); 42 QByteArray getSampleData(EltID idSmpl, quint32 nbRead); 43 void addSampleData(QByteArray &baData1, QByteArray &baData2, double mult); 44 static QMap<int, int> getChordKeys(quint32 key, ChordInfo& chordInfo); 45 46 static double SAMPLE_DURATION; // In seconds 47 static quint32 SAMPLE_RATE; // In samples per second 48 49 ToolChords * _tool; 50 EltID _idInst; 51 ChordInfo _ci; 52 quint32 _key, _minKey; 53 bool _loop; 54 bool _stereo; 55 int _side; 56 }; 57 58 #endif // RUNNABLECHORDCREATOR_H 59