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 RUNNABLESAMPLECREATOR_H
26 #define RUNNABLESAMPLECREATOR_H
27 
28 #include <QRunnable>
29 #include "basetypes.h"
30 #include "toolmixturecreation_parameters.h"
31 class ToolMixtureCreation;
32 
33 class RunnableSampleCreator: public QRunnable
34 {
35 public:
36     RunnableSampleCreator(ToolMixtureCreation * tool, EltID idInst, DivisionInfo di, int key, int minKey, bool loop, bool stereo, int side);
37     ~RunnableSampleCreator() 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 
45     static double SAMPLE_DURATION; // In seconds
46     static quint32 SAMPLE_RATE; // In samples per second
47 
48     ToolMixtureCreation * _tool;
49     EltID _idInst;
50     DivisionInfo _di;
51     int _key, _minKey;
52     bool _loop;
53     bool _stereo;
54     int _side;
55 };
56 
57 #endif // RUNNABLESAMPLECREATOR_H
58