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 DUPLICATIONTOOL_H 26 #define DUPLICATIONTOOL_H 27 28 #include "soundfontmanager.h" 29 #include <QMap> 30 31 class DuplicationTool : QObject 32 { 33 Q_OBJECT 34 35 public: 36 /// Initialize the duplication tool with an instrument or a preset 37 DuplicationTool(EltID id); 38 39 /// Duplicate each division by key 40 void duplicateByKey(); 41 42 /// Duplicate each division by velocity 43 void duplicateByVelocity(QList<QPair<int, int> > velocities); 44 45 private: 46 /// Duplicate a division 47 void duplicateByKey(QPair<int, int> keyRange, QPair<int, int> velRange, EltID id); 48 49 /// Duplicate a series of division sharing the same key range 50 void duplicateByVelocity(QMap<QPair<int, int>, QList<EltID> > elts, QList<QPair<int, int> > velocities); 51 52 /// Copy the attributes of idFrom to idTo 53 void duplicateGenMod(EltID idFrom, EltID idTo); 54 55 SoundfontManager * _sf2; 56 EltID _id; 57 QMap<QPair<int, int>, QMap<QPair<int, int>, QList<EltID> > > _elts; 58 bool _isInst; 59 60 static bool lessThan(QPair<int, int> elt1, QPair<int, int> elt2); 61 }; 62 63 #endif // DUPLICATIONTOOL_H 64