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 #include "tooldivisionduplication_parameters.h" 26 #include "contextmanager.h" 27 28 void ToolDivisionDuplication_parameters::loadConfiguration() 29 { 30 // Duplication types 31 _instDuplicKey = ContextManager::configuration()->getToolValue(ConfManager::TOOL_TYPE_INSTRUMENT, "duplication", "duplicationKeys", true).toBool(); 32 _prstDuplicKey = ContextManager::configuration()->getToolValue(ConfManager::TOOL_TYPE_PRESET, "duplication", "duplicationKeys", true).toBool(); 33 _instDuplicVel = ContextManager::configuration()->getToolValue(ConfManager::TOOL_TYPE_INSTRUMENT, "duplication", "duplicationVelocity", true).toBool(); 34 _prstDuplicVel = ContextManager::configuration()->getToolValue(ConfManager::TOOL_TYPE_PRESET, "duplication", "duplicationVelocity", true).toBool(); 35 36 // Velocity ranges 37 QList<QVariant> defaultList; 38 defaultList << 0 << 127; 39 40 _instVelocityRanges.clear(); 41 QList<QVariant> listTmp = ContextManager::configuration()->getToolValue(ConfManager::TOOL_TYPE_INSTRUMENT, "duplication", "velocities", defaultList).toList(); 42 for (int i = 0; i < listTmp.size() / 2; i++) 43 _instVelocityRanges << QPair<int, int>(listTmp[2 * i].toInt(), listTmp[2 * i + 1].toInt()); 44 45 _prstVelocityRanges.clear(); 46 listTmp = ContextManager::configuration()->getToolValue(ConfManager::TOOL_TYPE_PRESET, "duplication", "velocities", defaultList).toList(); 47 for (int i = 0; i < listTmp.size() / 2; i++) 48 _prstVelocityRanges << QPair<int, int>(listTmp[2 * i].toInt(), listTmp[2 * i + 1].toInt()); 49 } 50 51 void ToolDivisionDuplication_parameters::saveConfiguration() 52 { 53 // Duplication types 54 ContextManager::configuration()->setToolValue(ConfManager::TOOL_TYPE_INSTRUMENT, "duplication", "duplicationKeys", _instDuplicKey); 55 ContextManager::configuration()->setToolValue(ConfManager::TOOL_TYPE_PRESET, "duplication", "duplicationKeys", _prstDuplicKey); 56 ContextManager::configuration()->setToolValue(ConfManager::TOOL_TYPE_INSTRUMENT, "duplication", "duplicationVelocity", _instDuplicVel); 57 ContextManager::configuration()->setToolValue(ConfManager::TOOL_TYPE_PRESET, "duplication", "duplicationVelocity", _prstDuplicVel); 58 59 // Velocity ranges 60 QVariantList listTmp; 61 for (int i = 0; i < _instVelocityRanges.size(); i++) 62 listTmp << _instVelocityRanges[i].first << _instVelocityRanges[i].second; 63 ContextManager::configuration()->setToolValue(ConfManager::TOOL_TYPE_INSTRUMENT, "duplication", "velocities", listTmp); 64 65 listTmp.clear(); 66 for (int i = 0; i < _prstVelocityRanges.size(); i++) 67 listTmp << _prstVelocityRanges[i].first << _prstVelocityRanges[i].second; 68 ContextManager::configuration()->setToolValue(ConfManager::TOOL_TYPE_PRESET, "duplication", "velocities", listTmp); 69 } 70