| 1 |
/* |
| 2 |
* Copyright (C) 2018-2022 Rerrah |
| 3 |
* |
| 4 |
* Permission is hereby granted, free of charge, to any person |
| 5 |
* obtaining a copy of this software and associated documentation |
| 6 |
* files (the "Software"), to deal in the Software without |
| 7 |
* restriction, including without limitation the rights to use, |
| 8 |
* copy, modify, merge, publish, distribute, sublicense, and/or sell |
| 9 |
* copies of the Software, and to permit persons to whom the |
| 10 |
* Software is furnished to do so, subject to the following |
| 11 |
* conditions: |
| 12 |
* |
| 13 |
* The above copyright notice and this permission notice shall be |
| 14 |
* included in all copies or substantial portions of the Software. |
| 15 |
* |
| 16 |
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, |
| 17 |
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES |
| 18 |
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND |
| 19 |
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT |
| 20 |
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, |
| 21 |
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING |
| 22 |
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR |
| 23 |
* OTHER DEALINGS IN THE SOFTWARE. |
| 24 |
*/ |
| 25 |
|
| 26 |
#include "fm_instrument_editor.hpp" |
| 27 |
#include "ui_fm_instrument_editor.h" |
| 28 |
#include <stdexcept> |
| 29 |
#include <QString> |
| 30 |
#include <QPoint> |
| 31 |
#include <QMenu> |
| 32 |
#include <QApplication> |
| 33 |
#include <QClipboard> |
| 34 |
#include <QAction> |
| 35 |
#include <QRegularExpression> |
| 36 |
#include <QGraphicsScene> |
| 37 |
#include <QGraphicsSimpleTextItem> |
| 38 |
#include <QStringList> |
| 39 |
#include <QMessageBox> |
| 40 |
#include <set> |
| 41 |
#include "gui/event_guard.hpp" |
| 42 |
#include "gui/jam_layout.hpp" |
| 43 |
#include "gui/instrument_editor/instrument_editor_utils.hpp" |
| 44 |
#include "gui/gui_utils.hpp" |
| 45 |
|
| 46 |
FmInstrumentEditor::FmInstrumentEditor(int num, QWidget* parent) : |
| 47 |
InstrumentEditor(num, parent), |
| 48 |
ui(new Ui::FmInstrumentEditor), |
| 49 |
isIgnoreEvent_(false) |
| 50 |
{ |
| 51 |
ui->setupUi(this); |
| 52 |
|
| 53 |
/******************** Envelope editor ********************/ |
| 54 |
ui->envGroupBox->setContextMenuPolicy(Qt::CustomContextMenu); |
| 55 |
|
| 56 |
auto scene = new QGraphicsScene(ui->alGraphicsView); |
| 57 |
ui->alGraphicsView->setScene(scene); |
| 58 |
|
| 59 |
ui->alSlider->setText("AL"); |
| 60 |
ui->alSlider->setMaximum(7); |
| 61 |
QObject::connect(ui->alSlider, &LabeledHorizontalSlider::valueChanged, this, [&](int value) { |
| 62 |
if (!isIgnoreEvent_) { |
| 63 |
bt_.lock()->setEnvelopeFMParameter(ui->envNumSpinBox->value(), FMEnvelopeParameter::AL, value); |
| 64 |
emit envelopeParameterChanged(ui->envNumSpinBox->value(), instNum_); |
| 65 |
emit modified(); |
| 66 |
} |
| 67 |
paintAlgorithmDiagram(); |
| 68 |
resizeAlgorithmDiagram(); |
| 69 |
}); |
| 70 |
ui->fbSlider->setText("FB"); |
| 71 |
ui->fbSlider->setMaximum(7); |
| 72 |
QObject::connect(ui->fbSlider, &LabeledHorizontalSlider::valueChanged, this, [&](int value) { |
| 73 |
if (!isIgnoreEvent_) { |
| 74 |
bt_.lock()->setEnvelopeFMParameter(ui->envNumSpinBox->value(), FMEnvelopeParameter::FB, value); |
| 75 |
emit envelopeParameterChanged(ui->envNumSpinBox->value(), instNum_); |
| 76 |
emit modified(); |
| 77 |
} |
| 78 |
}); |
| 79 |
|
| 80 |
ui->op1Table->setOperatorNumber(0); |
| 81 |
QObject::connect(ui->op1Table, &FMOperatorTable::operatorEnableChanged, this, [&](bool enable) { |
| 82 |
if (!isIgnoreEvent_) { |
| 83 |
bt_.lock()->setEnvelopeFMOperatorEnable(ui->envNumSpinBox->value(), 0, enable); |
| 84 |
emit envelopeParameterChanged(ui->envNumSpinBox->value(), instNum_); |
| 85 |
emit modified(); |
| 86 |
} |
| 87 |
}); |
| 88 |
QObject::connect(ui->op1Table, &FMOperatorTable::operatorValueChanged, |
| 89 |
this, [&](Ui::FMOperatorParameter opParam, int value) { |
| 90 |
if (!isIgnoreEvent_) { |
| 91 |
FMEnvelopeParameter param; |
| 92 |
switch (opParam) { |
| 93 |
case Ui::FMOperatorParameter::AR: param = FMEnvelopeParameter::AR1; break; |
| 94 |
case Ui::FMOperatorParameter::DR: param = FMEnvelopeParameter::DR1; break; |
| 95 |
case Ui::FMOperatorParameter::SR: param = FMEnvelopeParameter::SR1; break; |
| 96 |
case Ui::FMOperatorParameter::RR: param = FMEnvelopeParameter::RR1; break; |
| 97 |
case Ui::FMOperatorParameter::SL: param = FMEnvelopeParameter::SL1; break; |
| 98 |
case Ui::FMOperatorParameter::TL: param = FMEnvelopeParameter::TL1; break; |
| 99 |
case Ui::FMOperatorParameter::KS: param = FMEnvelopeParameter::KS1; break; |
| 100 |
case Ui::FMOperatorParameter::ML: param = FMEnvelopeParameter::ML1; break; |
| 101 |
case Ui::FMOperatorParameter::DT: param = FMEnvelopeParameter::DT1; break; |
| 102 |
case Ui::FMOperatorParameter::SSGEG: param = FMEnvelopeParameter::SSGEG1; break; |
| 103 |
default: throw std::invalid_argument("Unexpected FMOperatorParameter."); |
| 104 |
} |
| 105 |
bt_.lock()->setEnvelopeFMParameter(ui->envNumSpinBox->value(), param, value); |
| 106 |
emit envelopeParameterChanged(ui->envNumSpinBox->value(), instNum_); |
| 107 |
emit modified(); |
| 108 |
} |
| 109 |
}); |
| 110 |
QObject::connect(ui->op1Table, &FMOperatorTable::copyEnvelopePressed, |
| 111 |
this, &FmInstrumentEditor::copyEnvelope); |
| 112 |
QObject::connect(ui->op1Table, &FMOperatorTable::pasteEnvelopePressed, |
| 113 |
this, &FmInstrumentEditor::pasteEnvelope); |
| 114 |
QObject::connect(ui->op1Table, &FMOperatorTable::copyOperatorPressed, |
| 115 |
this, &FmInstrumentEditor::copyOperator); |
| 116 |
QObject::connect(ui->op1Table, &FMOperatorTable::pasteOperatorPressed, |
| 117 |
this, &FmInstrumentEditor::pasteOperator); |
| 118 |
QObject::connect(ui->op1Table, &FMOperatorTable::pasteEnvelopeFromPressed, |
| 119 |
this, &FmInstrumentEditor::pasteEnvelopeFrom); |
| 120 |
|
| 121 |
ui->op2Table->setOperatorNumber(1); |
| 122 |
QObject::connect(ui->op2Table, &FMOperatorTable::operatorEnableChanged, this, [&](bool enable) { |
| 123 |
if (!isIgnoreEvent_) { |
| 124 |
bt_.lock()->setEnvelopeFMOperatorEnable(ui->envNumSpinBox->value(), 1, enable); |
| 125 |
emit envelopeParameterChanged(ui->envNumSpinBox->value(), instNum_); |
| 126 |
emit modified(); |
| 127 |
} |
| 128 |
}); |
| 129 |
QObject::connect(ui->op2Table, &FMOperatorTable::operatorValueChanged, |
| 130 |
this, [&](Ui::FMOperatorParameter opParam, int value) { |
| 131 |
if (!isIgnoreEvent_) { |
| 132 |
FMEnvelopeParameter param; |
| 133 |
switch (opParam) { |
| 134 |
case Ui::FMOperatorParameter::AR: param = FMEnvelopeParameter::AR2; break; |
| 135 |
case Ui::FMOperatorParameter::DR: param = FMEnvelopeParameter::DR2; break; |
| 136 |
case Ui::FMOperatorParameter::SR: param = FMEnvelopeParameter::SR2; break; |
| 137 |
case Ui::FMOperatorParameter::RR: param = FMEnvelopeParameter::RR2; break; |
| 138 |
case Ui::FMOperatorParameter::SL: param = FMEnvelopeParameter::SL2; break; |
| 139 |
case Ui::FMOperatorParameter::TL: param = FMEnvelopeParameter::TL2; break; |
| 140 |
case Ui::FMOperatorParameter::KS: param = FMEnvelopeParameter::KS2; break; |
| 141 |
case Ui::FMOperatorParameter::ML: param = FMEnvelopeParameter::ML2; break; |
| 142 |
case Ui::FMOperatorParameter::DT: param = FMEnvelopeParameter::DT2; break; |
| 143 |
case Ui::FMOperatorParameter::SSGEG: param = FMEnvelopeParameter::SSGEG2; break; |
| 144 |
default: throw std::invalid_argument("Unexpected FMOperatorParameter."); |
| 145 |
} |
| 146 |
bt_.lock()->setEnvelopeFMParameter(ui->envNumSpinBox->value(), param, value); |
| 147 |
emit envelopeParameterChanged(ui->envNumSpinBox->value(), instNum_); |
| 148 |
emit modified(); |
| 149 |
} |
| 150 |
}); |
| 151 |
QObject::connect(ui->op2Table, &FMOperatorTable::copyEnvelopePressed, |
| 152 |
this, &FmInstrumentEditor::copyEnvelope); |
| 153 |
QObject::connect(ui->op2Table, &FMOperatorTable::pasteEnvelopePressed, |
| 154 |
this, &FmInstrumentEditor::pasteEnvelope); |
| 155 |
QObject::connect(ui->op2Table, &FMOperatorTable::copyOperatorPressed, |
| 156 |
this, &FmInstrumentEditor::copyOperator); |
| 157 |
QObject::connect(ui->op2Table, &FMOperatorTable::pasteOperatorPressed, |
| 158 |
this, &FmInstrumentEditor::pasteOperator); |
| 159 |
QObject::connect(ui->op2Table, &FMOperatorTable::pasteEnvelopeFromPressed, |
| 160 |
this, &FmInstrumentEditor::pasteEnvelopeFrom); |
| 161 |
|
| 162 |
ui->op3Table->setOperatorNumber(2); |
| 163 |
QObject::connect(ui->op3Table, &FMOperatorTable::operatorEnableChanged, this, [&](bool enable) { |
| 164 |
if (!isIgnoreEvent_) { |
| 165 |
bt_.lock()->setEnvelopeFMOperatorEnable(ui->envNumSpinBox->value(), 2, enable); |
| 166 |
emit envelopeParameterChanged(ui->envNumSpinBox->value(), instNum_); |
| 167 |
emit modified(); |
| 168 |
} |
| 169 |
}); |
| 170 |
QObject::connect(ui->op3Table, &FMOperatorTable::operatorValueChanged, |
| 171 |
this, [&](Ui::FMOperatorParameter opParam, int value) { |
| 172 |
if (!isIgnoreEvent_) { |
| 173 |
FMEnvelopeParameter param; |
| 174 |
switch (opParam) { |
| 175 |
case Ui::FMOperatorParameter::AR: param = FMEnvelopeParameter::AR3; break; |
| 176 |
case Ui::FMOperatorParameter::DR: param = FMEnvelopeParameter::DR3; break; |
| 177 |
case Ui::FMOperatorParameter::SR: param = FMEnvelopeParameter::SR3; break; |
| 178 |
case Ui::FMOperatorParameter::RR: param = FMEnvelopeParameter::RR3; break; |
| 179 |
case Ui::FMOperatorParameter::SL: param = FMEnvelopeParameter::SL3; break; |
| 180 |
case Ui::FMOperatorParameter::TL: param = FMEnvelopeParameter::TL3; break; |
| 181 |
case Ui::FMOperatorParameter::KS: param = FMEnvelopeParameter::KS3; break; |
| 182 |
case Ui::FMOperatorParameter::ML: param = FMEnvelopeParameter::ML3; break; |
| 183 |
case Ui::FMOperatorParameter::DT: param = FMEnvelopeParameter::DT3; break; |
| 184 |
case Ui::FMOperatorParameter::SSGEG: param = FMEnvelopeParameter::SSGEG3; break; |
| 185 |
default: throw std::invalid_argument("Unexpected FMOperatorParameter."); |
| 186 |
} |
| 187 |
bt_.lock()->setEnvelopeFMParameter(ui->envNumSpinBox->value(), param, value); |
| 188 |
emit envelopeParameterChanged(ui->envNumSpinBox->value(), instNum_); |
| 189 |
emit modified(); |
| 190 |
} |
| 191 |
}); |
| 192 |
QObject::connect(ui->op3Table, &FMOperatorTable::copyEnvelopePressed, |
| 193 |
this, &FmInstrumentEditor::copyEnvelope); |
| 194 |
QObject::connect(ui->op3Table, &FMOperatorTable::pasteEnvelopePressed, |
| 195 |
this, &FmInstrumentEditor::pasteEnvelope); |
| 196 |
QObject::connect(ui->op3Table, &FMOperatorTable::copyOperatorPressed, |
| 197 |
this, &FmInstrumentEditor::copyOperator); |
| 198 |
QObject::connect(ui->op3Table, &FMOperatorTable::pasteOperatorPressed, |
| 199 |
this, &FmInstrumentEditor::pasteOperator); |
| 200 |
QObject::connect(ui->op3Table, &FMOperatorTable::pasteEnvelopeFromPressed, |
| 201 |
this, &FmInstrumentEditor::pasteEnvelopeFrom); |
| 202 |
|
| 203 |
ui->op4Table->setOperatorNumber(3); |
| 204 |
QObject::connect(ui->op4Table, &FMOperatorTable::operatorEnableChanged, this, [&](bool enable) { |
| 205 |
if (!isIgnoreEvent_) { |
| 206 |
bt_.lock()->setEnvelopeFMOperatorEnable(ui->envNumSpinBox->value(), 3, enable); |
| 207 |
emit envelopeParameterChanged(ui->envNumSpinBox->value(), instNum_); |
| 208 |
emit modified(); |
| 209 |
} |
| 210 |
}); |
| 211 |
QObject::connect(ui->op4Table, &FMOperatorTable::operatorValueChanged, |
| 212 |
this, [&](Ui::FMOperatorParameter opParam, int value) { |
| 213 |
if (!isIgnoreEvent_) { |
| 214 |
FMEnvelopeParameter param; |
| 215 |
switch (opParam) { |
| 216 |
case Ui::FMOperatorParameter::AR: param = FMEnvelopeParameter::AR4; break; |
| 217 |
case Ui::FMOperatorParameter::DR: param = FMEnvelopeParameter::DR4; break; |
| 218 |
case Ui::FMOperatorParameter::SR: param = FMEnvelopeParameter::SR4; break; |
| 219 |
case Ui::FMOperatorParameter::RR: param = FMEnvelopeParameter::RR4; break; |
| 220 |
case Ui::FMOperatorParameter::SL: param = FMEnvelopeParameter::SL4; break; |
| 221 |
case Ui::FMOperatorParameter::TL: param = FMEnvelopeParameter::TL4; break; |
| 222 |
case Ui::FMOperatorParameter::KS: param = FMEnvelopeParameter::KS4; break; |
| 223 |
case Ui::FMOperatorParameter::ML: param = FMEnvelopeParameter::ML4; break; |
| 224 |
case Ui::FMOperatorParameter::DT: param = FMEnvelopeParameter::DT4; break; |
| 225 |
case Ui::FMOperatorParameter::SSGEG: param = FMEnvelopeParameter::SSGEG4; break; |
| 226 |
default: throw std::invalid_argument("Unexpected FMOperatorParameter."); |
| 227 |
} |
| 228 |
bt_.lock()->setEnvelopeFMParameter(ui->envNumSpinBox->value(), param, value); |
| 229 |
emit envelopeParameterChanged(ui->envNumSpinBox->value(), instNum_); |
| 230 |
emit modified(); |
| 231 |
} |
| 232 |
}); |
| 233 |
QObject::connect(ui->op4Table, &FMOperatorTable::copyEnvelopePressed, |
| 234 |
this, &FmInstrumentEditor::copyEnvelope); |
| 235 |
QObject::connect(ui->op4Table, &FMOperatorTable::pasteEnvelopePressed, |
| 236 |
this, &FmInstrumentEditor::pasteEnvelope); |
| 237 |
QObject::connect(ui->op4Table, &FMOperatorTable::copyOperatorPressed, |
| 238 |
this, &FmInstrumentEditor::copyOperator); |
| 239 |
QObject::connect(ui->op4Table, &FMOperatorTable::pasteOperatorPressed, |
| 240 |
this, &FmInstrumentEditor::pasteOperator); |
| 241 |
QObject::connect(ui->op4Table, &FMOperatorTable::pasteEnvelopeFromPressed, |
| 242 |
this, &FmInstrumentEditor::pasteEnvelopeFrom); |
| 243 |
|
| 244 |
/******************** LFO editor ********************/ |
| 245 |
ui->lfoGroupBox->setContextMenuPolicy(Qt::CustomContextMenu); |
| 246 |
|
| 247 |
ui->lfoFreqSlider->setText(tr("Freq")); |
| 248 |
ui->lfoFreqSlider->setMaximum(7); |
| 249 |
QObject::connect(ui->lfoFreqSlider, &LabeledVerticalSlider::valueChanged, |
| 250 |
this, [&](int v) { |
| 251 |
if (!isIgnoreEvent_) { |
| 252 |
bt_.lock()->setLFOFMParameter(ui->lfoNumSpinBox->value(), FMLFOParameter::FREQ, v); |
| 253 |
emit lfoParameterChanged(ui->lfoNumSpinBox->value(), instNum_); |
| 254 |
emit modified(); |
| 255 |
} |
| 256 |
}); |
| 257 |
|
| 258 |
ui->pmsSlider->setText("PMS"); |
| 259 |
ui->pmsSlider->setMaximum(7); |
| 260 |
QObject::connect(ui->pmsSlider, &LabeledVerticalSlider::valueChanged, |
| 261 |
this, [&](int v) { |
| 262 |
if (!isIgnoreEvent_) { |
| 263 |
bt_.lock()->setLFOFMParameter(ui->lfoNumSpinBox->value(), FMLFOParameter::PMS, v); |
| 264 |
emit lfoParameterChanged(ui->lfoNumSpinBox->value(), instNum_); |
| 265 |
emit modified(); |
| 266 |
} |
| 267 |
}); |
| 268 |
|
| 269 |
ui->amsSlider->setText("AMS"); |
| 270 |
ui->amsSlider->setMaximum(3); |
| 271 |
QObject::connect(ui->amsSlider, &LabeledVerticalSlider::valueChanged, |
| 272 |
this, [&](int v) { |
| 273 |
if (!isIgnoreEvent_) { |
| 274 |
bt_.lock()->setLFOFMParameter(ui->lfoNumSpinBox->value(), FMLFOParameter::AMS, v); |
| 275 |
emit lfoParameterChanged(ui->lfoNumSpinBox->value(), instNum_); |
| 276 |
emit modified(); |
| 277 |
} |
| 278 |
}); |
| 279 |
|
| 280 |
QObject::connect(ui->amOp1CheckBox, &QCheckBox::stateChanged, |
| 281 |
this, [&](int state) { |
| 282 |
if (!isIgnoreEvent_) { |
| 283 |
bt_.lock()->setLFOFMParameter(ui->lfoNumSpinBox->value(), FMLFOParameter::AM1, |
| 284 |
(state == Qt::Checked) ? 1 : 0); |
| 285 |
emit lfoParameterChanged(ui->lfoNumSpinBox->value(), instNum_); |
| 286 |
emit modified(); |
| 287 |
} |
| 288 |
}); |
| 289 |
QObject::connect(ui->amOp2CheckBox, &QCheckBox::stateChanged, |
| 290 |
this, [&](int state) { |
| 291 |
if (!isIgnoreEvent_) { |
| 292 |
bt_.lock()->setLFOFMParameter(ui->lfoNumSpinBox->value(), FMLFOParameter::AM2, |
| 293 |
(state == Qt::Checked) ? 1 : 0); |
| 294 |
emit lfoParameterChanged(ui->lfoNumSpinBox->value(), instNum_); |
| 295 |
emit modified(); |
| 296 |
} |
| 297 |
}); |
| 298 |
QObject::connect(ui->amOp3CheckBox, &QCheckBox::stateChanged, |
| 299 |
this, [&](int state) { |
| 300 |
if (!isIgnoreEvent_) { |
| 301 |
bt_.lock()->setLFOFMParameter(ui->lfoNumSpinBox->value(), FMLFOParameter::AM3, |
| 302 |
(state == Qt::Checked) ? 1 : 0); |
| 303 |
emit lfoParameterChanged(ui->lfoNumSpinBox->value(), instNum_); |
| 304 |
emit modified(); |
| 305 |
} |
| 306 |
}); |
| 307 |
QObject::connect(ui->amOp4CheckBox, &QCheckBox::stateChanged, |
| 308 |
this, [&](int state) { |
| 309 |
if (!isIgnoreEvent_) { |
| 310 |
bt_.lock()->setLFOFMParameter(ui->lfoNumSpinBox->value(), FMLFOParameter::AM4, |
| 311 |
(state == Qt::Checked) ? 1 : 0); |
| 312 |
emit lfoParameterChanged(ui->lfoNumSpinBox->value(), instNum_); |
| 313 |
emit modified(); |
| 314 |
} |
| 315 |
}); |
| 316 |
// Leave Before Qt5.7.0 style due to windows xp |
| 317 |
QObject::connect(ui->lfoStartSpinBox, static_cast<void(QSpinBox::*)(int)>(&QSpinBox::valueChanged), |
| 318 |
this, [&](int v) { |
| 319 |
if (!isIgnoreEvent_) { |
| 320 |
bt_.lock()->setLFOFMParameter(ui->lfoNumSpinBox->value(), FMLFOParameter::Count, v); |
| 321 |
emit lfoParameterChanged(ui->lfoNumSpinBox->value(), instNum_); |
| 322 |
emit modified(); |
| 323 |
} |
| 324 |
}); |
| 325 |
|
| 326 |
//========== OperatorSequence ==========// |
| 327 |
ui->opSeqTypeComboBox->addItem("AL", static_cast<int>(FMEnvelopeParameter::AL)); |
| 328 |
ui->opSeqTypeComboBox->addItem("FB", static_cast<int>(FMEnvelopeParameter::FB)); |
| 329 |
ui->opSeqTypeComboBox->addItem("AR1", static_cast<int>(FMEnvelopeParameter::AR1)); |
| 330 |
ui->opSeqTypeComboBox->addItem("DR1", static_cast<int>(FMEnvelopeParameter::DR1)); |
| 331 |
ui->opSeqTypeComboBox->addItem("SR1", static_cast<int>(FMEnvelopeParameter::SR1)); |
| 332 |
ui->opSeqTypeComboBox->addItem("RR1", static_cast<int>(FMEnvelopeParameter::RR1)); |
| 333 |
ui->opSeqTypeComboBox->addItem("SL1", static_cast<int>(FMEnvelopeParameter::SL1)); |
| 334 |
ui->opSeqTypeComboBox->addItem("TL1", static_cast<int>(FMEnvelopeParameter::TL1)); |
| 335 |
ui->opSeqTypeComboBox->addItem("KS1", static_cast<int>(FMEnvelopeParameter::KS1)); |
| 336 |
ui->opSeqTypeComboBox->addItem("ML1", static_cast<int>(FMEnvelopeParameter::ML1)); |
| 337 |
ui->opSeqTypeComboBox->addItem("DT1", static_cast<int>(FMEnvelopeParameter::DT1)); |
| 338 |
ui->opSeqTypeComboBox->addItem("AR2", static_cast<int>(FMEnvelopeParameter::AR2)); |
| 339 |
ui->opSeqTypeComboBox->addItem("DR2", static_cast<int>(FMEnvelopeParameter::DR2)); |
| 340 |
ui->opSeqTypeComboBox->addItem("SR2", static_cast<int>(FMEnvelopeParameter::SR2)); |
| 341 |
ui->opSeqTypeComboBox->addItem("RR2", static_cast<int>(FMEnvelopeParameter::RR2)); |
| 342 |
ui->opSeqTypeComboBox->addItem("SL2", static_cast<int>(FMEnvelopeParameter::SL2)); |
| 343 |
ui->opSeqTypeComboBox->addItem("TL2", static_cast<int>(FMEnvelopeParameter::TL2)); |
| 344 |
ui->opSeqTypeComboBox->addItem("KS2", static_cast<int>(FMEnvelopeParameter::KS2)); |
| 345 |
ui->opSeqTypeComboBox->addItem("ML2", static_cast<int>(FMEnvelopeParameter::ML2)); |
| 346 |
ui->opSeqTypeComboBox->addItem("DT2", static_cast<int>(FMEnvelopeParameter::DT2)); |
| 347 |
ui->opSeqTypeComboBox->addItem("AR3", static_cast<int>(FMEnvelopeParameter::AR3)); |
| 348 |
ui->opSeqTypeComboBox->addItem("DR3", static_cast<int>(FMEnvelopeParameter::DR3)); |
| 349 |
ui->opSeqTypeComboBox->addItem("SR3", static_cast<int>(FMEnvelopeParameter::SR3)); |
| 350 |
ui->opSeqTypeComboBox->addItem("RR3", static_cast<int>(FMEnvelopeParameter::RR3)); |
| 351 |
ui->opSeqTypeComboBox->addItem("SL3", static_cast<int>(FMEnvelopeParameter::SL3)); |
| 352 |
ui->opSeqTypeComboBox->addItem("TL3", static_cast<int>(FMEnvelopeParameter::TL3)); |
| 353 |
ui->opSeqTypeComboBox->addItem("KS3", static_cast<int>(FMEnvelopeParameter::KS3)); |
| 354 |
ui->opSeqTypeComboBox->addItem("ML3", static_cast<int>(FMEnvelopeParameter::ML3)); |
| 355 |
ui->opSeqTypeComboBox->addItem("DT3", static_cast<int>(FMEnvelopeParameter::DT3)); |
| 356 |
ui->opSeqTypeComboBox->addItem("AR4", static_cast<int>(FMEnvelopeParameter::AR4)); |
| 357 |
ui->opSeqTypeComboBox->addItem("DR4", static_cast<int>(FMEnvelopeParameter::DR4)); |
| 358 |
ui->opSeqTypeComboBox->addItem("SR4", static_cast<int>(FMEnvelopeParameter::SR4)); |
| 359 |
ui->opSeqTypeComboBox->addItem("RR4", static_cast<int>(FMEnvelopeParameter::RR4)); |
| 360 |
ui->opSeqTypeComboBox->addItem("SL4", static_cast<int>(FMEnvelopeParameter::SL4)); |
| 361 |
ui->opSeqTypeComboBox->addItem("TL4", static_cast<int>(FMEnvelopeParameter::TL4)); |
| 362 |
ui->opSeqTypeComboBox->addItem("KS4", static_cast<int>(FMEnvelopeParameter::KS4)); |
| 363 |
ui->opSeqTypeComboBox->addItem("ML4", static_cast<int>(FMEnvelopeParameter::ML4)); |
| 364 |
ui->opSeqTypeComboBox->addItem("DT4", static_cast<int>(FMEnvelopeParameter::DT4)); |
| 365 |
|
| 366 |
ui->opSeqEditor->setDefaultRow(0); |
| 367 |
ui->opSeqEditor->setLabelDiaplayMode(true); |
| 368 |
setOperatorSequenceEditor(); |
| 369 |
|
| 370 |
QObject::connect(ui->opSeqEditor, &VisualizedInstrumentMacroEditor::sequenceDataAdded, |
| 371 |
this, [&](int row, int) { |
| 372 |
if (!isIgnoreEvent_) { |
| 373 |
FMEnvelopeParameter param = getOperatorSequenceParameter(); |
| 374 |
bt_.lock()->addOperatorSequenceFMSequenceData(param, ui->opSeqNumSpinBox->value(), row); |
| 375 |
emit operatorSequenceParameterChanged(param, ui->opSeqNumSpinBox->value(), instNum_); |
| 376 |
emit modified(); |
| 377 |
} |
| 378 |
}); |
| 379 |
QObject::connect(ui->opSeqEditor, &VisualizedInstrumentMacroEditor::sequenceDataRemoved, |
| 380 |
this, [&] { |
| 381 |
if (!isIgnoreEvent_) { |
| 382 |
FMEnvelopeParameter param = getOperatorSequenceParameter(); |
| 383 |
bt_.lock()->removeOperatorSequenceFMSequenceData(param, ui->opSeqNumSpinBox->value()); |
| 384 |
emit operatorSequenceParameterChanged(param, ui->opSeqNumSpinBox->value(), instNum_); |
| 385 |
emit modified(); |
| 386 |
} |
| 387 |
}); |
| 388 |
QObject::connect(ui->opSeqEditor, &VisualizedInstrumentMacroEditor::sequenceDataChanged, |
| 389 |
this, [&](int row, int col) { |
| 390 |
if (!isIgnoreEvent_) { |
| 391 |
FMEnvelopeParameter param = getOperatorSequenceParameter(); |
| 392 |
bt_.lock()->setOperatorSequenceFMSequenceData(param, ui->opSeqNumSpinBox->value(), col, row); |
| 393 |
emit operatorSequenceParameterChanged(param, ui->opSeqNumSpinBox->value(), instNum_); |
| 394 |
emit modified(); |
| 395 |
} |
| 396 |
}); |
| 397 |
QObject::connect(ui->opSeqEditor, &VisualizedInstrumentMacroEditor::loopAdded, |
| 398 |
this, [&](InstrumentSequenceLoop loop) { |
| 399 |
if (!isIgnoreEvent_) { |
| 400 |
FMEnvelopeParameter param = getOperatorSequenceParameter(); |
| 401 |
bt_.lock()->addOperatorSequenceFMLoop(param, ui->opSeqNumSpinBox->value(), loop); |
| 402 |
emit operatorSequenceParameterChanged(param, ui->opSeqNumSpinBox->value(), instNum_); |
| 403 |
emit modified(); |
| 404 |
} |
| 405 |
}); |
| 406 |
QObject::connect(ui->opSeqEditor, &VisualizedInstrumentMacroEditor::loopRemoved, |
| 407 |
this, [&](int begin, int end) { |
| 408 |
if (!isIgnoreEvent_) { |
| 409 |
FMEnvelopeParameter param = getOperatorSequenceParameter(); |
| 410 |
bt_.lock()->removeOperatorSequenceFMLoop( |
| 411 |
param, ui->opSeqNumSpinBox->value(), begin, end); |
| 412 |
emit operatorSequenceParameterChanged(param, ui->opSeqNumSpinBox->value(), instNum_); |
| 413 |
emit modified(); |
| 414 |
} |
| 415 |
}); |
| 416 |
QObject::connect(ui->opSeqEditor, &VisualizedInstrumentMacroEditor::loopCleared, |
| 417 |
this, [&] { |
| 418 |
if (!isIgnoreEvent_) { |
| 419 |
FMEnvelopeParameter param = getOperatorSequenceParameter(); |
| 420 |
bt_.lock()->clearOperatorSequenceFMLoops(param, ui->opSeqNumSpinBox->value()); |
| 421 |
emit operatorSequenceParameterChanged(param, ui->opSeqNumSpinBox->value(), instNum_); |
| 422 |
emit modified(); |
| 423 |
} |
| 424 |
}); |
| 425 |
QObject::connect(ui->opSeqEditor, &VisualizedInstrumentMacroEditor::loopChanged, |
| 426 |
this, [&](int prevBegin, int prevEnd, InstrumentSequenceLoop loop) { |
| 427 |
if (!isIgnoreEvent_) { |
| 428 |
FMEnvelopeParameter param = getOperatorSequenceParameter(); |
| 429 |
bt_.lock()->changeOperatorSequenceFMLoop( |
| 430 |
param, ui->opSeqNumSpinBox->value(), prevBegin, prevEnd, loop); |
| 431 |
emit operatorSequenceParameterChanged(param, ui->opSeqNumSpinBox->value(), instNum_); |
| 432 |
emit modified(); |
| 433 |
} |
| 434 |
}); |
| 435 |
QObject::connect(ui->opSeqEditor, &VisualizedInstrumentMacroEditor::releaseChanged, |
| 436 |
this, [&](InstrumentSequenceRelease release) { |
| 437 |
if (!isIgnoreEvent_) { |
| 438 |
FMEnvelopeParameter param = getOperatorSequenceParameter(); |
| 439 |
bt_.lock()->setOperatorSequenceFMRelease(param, ui->opSeqNumSpinBox->value(), release); |
| 440 |
emit operatorSequenceParameterChanged(param, ui->opSeqNumSpinBox->value(), instNum_); |
| 441 |
emit modified(); |
| 442 |
} |
| 443 |
}); |
| 444 |
// Leave Before Qt5.7.0 style due to windows xp |
| 445 |
QObject::connect(ui->opSeqTypeComboBox, static_cast<void(QComboBox::*)(int)>(&QComboBox::currentIndexChanged), |
| 446 |
this, &FmInstrumentEditor::onOperatorSequenceTypeChanged); |
| 447 |
|
| 448 |
//========== Arpeggio ==========// |
| 449 |
ui->arpOpComboBox->addItem(tr("All"), static_cast<int>(FMOperatorType::All)); |
| 450 |
ui->arpOpComboBox->addItem("Op1", static_cast<int>(FMOperatorType::Op1)); |
| 451 |
ui->arpOpComboBox->addItem("Op2", static_cast<int>(FMOperatorType::Op2)); |
| 452 |
ui->arpOpComboBox->addItem("Op3", static_cast<int>(FMOperatorType::Op3)); |
| 453 |
ui->arpOpComboBox->addItem("Op4", static_cast<int>(FMOperatorType::Op4)); |
| 454 |
|
| 455 |
ui->arpTypeComboBox->addItem(tr("Absolute"), static_cast<int>(SequenceType::AbsoluteSequence)); |
| 456 |
ui->arpTypeComboBox->addItem(tr("Fixed"), static_cast<int>(SequenceType::FixedSequence)); |
| 457 |
ui->arpTypeComboBox->addItem(tr("Relative"), static_cast<int>(SequenceType::RelativeSequence)); |
| 458 |
|
| 459 |
QObject::connect(ui->arpEditor, &VisualizedInstrumentMacroEditor::sequenceDataAdded, |
| 460 |
this, [&](int row, int) { |
| 461 |
if (!isIgnoreEvent_) { |
| 462 |
bt_.lock()->addArpeggioFMSequenceData(ui->arpNumSpinBox->value(), row); |
| 463 |
emit arpeggioParameterChanged(ui->arpNumSpinBox->value(), instNum_); |
| 464 |
emit modified(); |
| 465 |
} |
| 466 |
}); |
| 467 |
QObject::connect(ui->arpEditor, &VisualizedInstrumentMacroEditor::sequenceDataRemoved, |
| 468 |
this, [&] { |
| 469 |
if (!isIgnoreEvent_) { |
| 470 |
bt_.lock()->removeArpeggioFMSequenceData(ui->arpNumSpinBox->value()); |
| 471 |
emit arpeggioParameterChanged(ui->arpNumSpinBox->value(), instNum_); |
| 472 |
emit modified(); |
| 473 |
} |
| 474 |
}); |
| 475 |
QObject::connect(ui->arpEditor, &VisualizedInstrumentMacroEditor::sequenceDataChanged, |
| 476 |
this, [&](int row, int col) { |
| 477 |
if (!isIgnoreEvent_) { |
| 478 |
bt_.lock()->setArpeggioFMSequenceData(ui->arpNumSpinBox->value(), col, row); |
| 479 |
emit arpeggioParameterChanged(ui->arpNumSpinBox->value(), instNum_); |
| 480 |
emit modified(); |
| 481 |
} |
| 482 |
}); |
| 483 |
QObject::connect(ui->arpEditor, &VisualizedInstrumentMacroEditor::loopAdded, |
| 484 |
this, [&](InstrumentSequenceLoop loop) { |
| 485 |
if (!isIgnoreEvent_) { |
| 486 |
bt_.lock()->addArpeggioFMLoop(ui->arpNumSpinBox->value(), loop); |
| 487 |
emit arpeggioParameterChanged(ui->arpNumSpinBox->value(), instNum_); |
| 488 |
emit modified(); |
| 489 |
} |
| 490 |
}); |
| 491 |
QObject::connect(ui->arpEditor, &VisualizedInstrumentMacroEditor::loopRemoved, |
| 492 |
this, [&](int begin, int end) { |
| 493 |
if (!isIgnoreEvent_) { |
| 494 |
bt_.lock()->removeArpeggioFMLoop(ui->arpNumSpinBox->value(), begin, end); |
| 495 |
emit arpeggioParameterChanged(ui->arpNumSpinBox->value(), instNum_); |
| 496 |
emit modified(); |
| 497 |
} |
| 498 |
}); |
| 499 |
QObject::connect(ui->arpEditor, &VisualizedInstrumentMacroEditor::loopCleared, |
| 500 |
this, [&] { |
| 501 |
if (!isIgnoreEvent_) { |
| 502 |
bt_.lock()->clearArpeggioFMLoops(ui->arpNumSpinBox->value()); |
| 503 |
emit arpeggioParameterChanged(ui->arpNumSpinBox->value(), instNum_); |
| 504 |
emit modified(); |
| 505 |
} |
| 506 |
}); |
| 507 |
QObject::connect(ui->arpEditor, &VisualizedInstrumentMacroEditor::loopChanged, |
| 508 |
this, [&](int prevBegin, int prevEnd, InstrumentSequenceLoop loop) { |
| 509 |
if (!isIgnoreEvent_) { |
| 510 |
bt_.lock()->changeArpeggioFMLoop(ui->arpNumSpinBox->value(), prevBegin, prevEnd, loop); |
| 511 |
emit arpeggioParameterChanged(ui->arpNumSpinBox->value(), instNum_); |
| 512 |
emit modified(); |
| 513 |
} |
| 514 |
}); |
| 515 |
QObject::connect(ui->arpEditor, &VisualizedInstrumentMacroEditor::releaseChanged, |
| 516 |
this, [&](InstrumentSequenceRelease release) { |
| 517 |
if (!isIgnoreEvent_) { |
| 518 |
bt_.lock()->setArpeggioFMRelease(ui->arpNumSpinBox->value(), release); |
| 519 |
emit arpeggioParameterChanged(ui->arpNumSpinBox->value(), instNum_); |
| 520 |
emit modified(); |
| 521 |
} |
| 522 |
}); |
| 523 |
// Leave Before Qt5.7.0 style due to windows xp |
| 524 |
QObject::connect(ui->arpTypeComboBox, static_cast<void(QComboBox::*)(int)>(&QComboBox::currentIndexChanged), |
| 525 |
this, &FmInstrumentEditor::onArpeggioTypeChanged); |
| 526 |
// Leave Before Qt5.7.0 style due to windows xp |
| 527 |
QObject::connect(ui->arpOpComboBox, static_cast<void(QComboBox::*)(int)>(&QComboBox::currentIndexChanged), |
| 528 |
this, &FmInstrumentEditor::onArpeggioOperatorChanged); |
| 529 |
|
| 530 |
//========== Pitch ==========// |
| 531 |
ui->ptOpComboBox->addItem(tr("All"), static_cast<int>(FMOperatorType::All)); |
| 532 |
ui->ptOpComboBox->addItem("Op1", static_cast<int>(FMOperatorType::Op1)); |
| 533 |
ui->ptOpComboBox->addItem("Op2", static_cast<int>(FMOperatorType::Op2)); |
| 534 |
ui->ptOpComboBox->addItem("Op3", static_cast<int>(FMOperatorType::Op3)); |
| 535 |
ui->ptOpComboBox->addItem("Op4", static_cast<int>(FMOperatorType::Op4)); |
| 536 |
|
| 537 |
ui->ptEditor->setMaximumDisplayedRowCount(15); |
| 538 |
ui->ptEditor->setDefaultRow(127); |
| 539 |
ui->ptEditor->setLabelDiaplayMode(true); |
| 540 |
for (int i = 0; i < 255; ++i) { |
| 541 |
ui->ptEditor->AddRow(QString::asprintf("%+d", i - 127), false); |
| 542 |
} |
| 543 |
ui->ptEditor->autoFitLabelWidth(); |
| 544 |
ui->ptEditor->setUpperRow(134); |
| 545 |
ui->ptEditor->setMMLDisplay0As(-127); |
| 546 |
|
| 547 |
ui->ptTypeComboBox->addItem(tr("Absolute"), static_cast<int>(SequenceType::AbsoluteSequence)); |
| 548 |
ui->ptTypeComboBox->addItem(tr("Relative"), static_cast<int>(SequenceType::RelativeSequence)); |
| 549 |
|
| 550 |
QObject::connect(ui->ptEditor, &VisualizedInstrumentMacroEditor::sequenceDataAdded, |
| 551 |
this, [&](int row, int) { |
| 552 |
if (!isIgnoreEvent_) { |
| 553 |
bt_.lock()->addPitchFMSequenceData(ui->ptNumSpinBox->value(), row); |
| 554 |
emit pitchParameterChanged(ui->ptNumSpinBox->value(), instNum_); |
| 555 |
emit modified(); |
| 556 |
} |
| 557 |
}); |
| 558 |
QObject::connect(ui->ptEditor, &VisualizedInstrumentMacroEditor::sequenceDataRemoved, |
| 559 |
this, [&]() { |
| 560 |
if (!isIgnoreEvent_) { |
| 561 |
bt_.lock()->removePitchFMSequenceData(ui->ptNumSpinBox->value()); |
| 562 |
emit pitchParameterChanged(ui->ptNumSpinBox->value(), instNum_); |
| 563 |
emit modified(); |
| 564 |
} |
| 565 |
}); |
| 566 |
QObject::connect(ui->ptEditor, &VisualizedInstrumentMacroEditor::sequenceDataChanged, |
| 567 |
this, [&](int row, int col) { |
| 568 |
if (!isIgnoreEvent_) { |
| 569 |
bt_.lock()->setPitchFMSequenceData(ui->ptNumSpinBox->value(), col, row); |
| 570 |
emit pitchParameterChanged(ui->ptNumSpinBox->value(), instNum_); |
| 571 |
emit modified(); |
| 572 |
} |
| 573 |
}); |
| 574 |
QObject::connect(ui->ptEditor, &VisualizedInstrumentMacroEditor::loopAdded, |
| 575 |
this, [&](InstrumentSequenceLoop loop) { |
| 576 |
if (!isIgnoreEvent_) { |
| 577 |
bt_.lock()->addPitchFMLoop(ui->ptNumSpinBox->value(), loop); |
| 578 |
emit pitchParameterChanged(ui->ptNumSpinBox->value(), instNum_); |
| 579 |
emit modified(); |
| 580 |
} |
| 581 |
}); |
| 582 |
QObject::connect(ui->ptEditor, &VisualizedInstrumentMacroEditor::loopRemoved, |
| 583 |
this, [&](int begin, int end) { |
| 584 |
if (!isIgnoreEvent_) { |
| 585 |
bt_.lock()->removePitchFMLoop(ui->ptNumSpinBox->value(), begin, end); |
| 586 |
emit pitchParameterChanged(ui->ptNumSpinBox->value(), instNum_); |
| 587 |
emit modified(); |
| 588 |
} |
| 589 |
}); |
| 590 |
QObject::connect(ui->ptEditor, &VisualizedInstrumentMacroEditor::loopCleared, |
| 591 |
this, [&] { |
| 592 |
if (!isIgnoreEvent_) { |
| 593 |
bt_.lock()->clearPitchFMLoops(ui->ptNumSpinBox->value()); |
| 594 |
emit pitchParameterChanged(ui->ptNumSpinBox->value(), instNum_); |
| 595 |
emit modified(); |
| 596 |
} |
| 597 |
}); |
| 598 |
QObject::connect(ui->ptEditor, &VisualizedInstrumentMacroEditor::loopChanged, |
| 599 |
this, [&](int prevBegin, int prevEnd, InstrumentSequenceLoop loop) { |
| 600 |
if (!isIgnoreEvent_) { |
| 601 |
bt_.lock()->changePitchFMLoop(ui->ptNumSpinBox->value(), prevBegin, prevEnd, loop); |
| 602 |
emit pitchParameterChanged(ui->ptNumSpinBox->value(), instNum_); |
| 603 |
emit modified(); |
| 604 |
} |
| 605 |
}); |
| 606 |
QObject::connect(ui->ptEditor, &VisualizedInstrumentMacroEditor::releaseChanged, |
| 607 |
this, [&](InstrumentSequenceRelease release) { |
| 608 |
if (!isIgnoreEvent_) { |
| 609 |
bt_.lock()->setPitchFMRelease(ui->ptNumSpinBox->value(), release); |
| 610 |
emit pitchParameterChanged(ui->ptNumSpinBox->value(), instNum_); |
| 611 |
emit modified(); |
| 612 |
} |
| 613 |
}); |
| 614 |
// Leave Before Qt5.7.0 style due to windows xp |
| 615 |
QObject::connect(ui->ptTypeComboBox, static_cast<void(QComboBox::*)(int)>(&QComboBox::currentIndexChanged), |
| 616 |
this, &FmInstrumentEditor::onPitchTypeChanged); |
| 617 |
// Leave Before Qt5.7.0 style due to windows xp |
| 618 |
QObject::connect(ui->ptOpComboBox, static_cast<void(QComboBox::*)(int)>(&QComboBox::currentIndexChanged), |
| 619 |
this, &FmInstrumentEditor::onPitchOperatorChanged); |
| 620 |
|
| 621 |
//========== Pan ==========// |
| 622 |
QObject::connect(ui->panEditor, &VisualizedInstrumentMacroEditor::sequenceDataAdded, |
| 623 |
this, [&](int row, int) { |
| 624 |
if (!isIgnoreEvent_) { |
| 625 |
bt_.lock()->addPanFMSequenceData(ui->panNumSpinBox->value(), row); |
| 626 |
emit panParameterChanged(ui->panNumSpinBox->value(), instNum_); |
| 627 |
emit modified(); |
| 628 |
} |
| 629 |
}); |
| 630 |
QObject::connect(ui->panEditor, &VisualizedInstrumentMacroEditor::sequenceDataRemoved, |
| 631 |
this, [&] { |
| 632 |
if (!isIgnoreEvent_) { |
| 633 |
bt_.lock()->removePanFMSequenceData(ui->panNumSpinBox->value()); |
| 634 |
emit panParameterChanged(ui->panNumSpinBox->value(), instNum_); |
| 635 |
emit modified(); |
| 636 |
} |
| 637 |
}); |
| 638 |
QObject::connect(ui->panEditor, &VisualizedInstrumentMacroEditor::sequenceDataChanged, |
| 639 |
this, [&](int row, int col) { |
| 640 |
if (!isIgnoreEvent_) { |
| 641 |
bt_.lock()->setPanFMSequenceData(ui->panNumSpinBox->value(), col, row); |
| 642 |
emit panParameterChanged(ui->panNumSpinBox->value(), instNum_); |
| 643 |
emit modified(); |
| 644 |
} |
| 645 |
}); |
| 646 |
QObject::connect(ui->panEditor, &VisualizedInstrumentMacroEditor::loopAdded, |
| 647 |
this, [&](InstrumentSequenceLoop loop) { |
| 648 |
if (!isIgnoreEvent_) { |
| 649 |
bt_.lock()->addPanFMLoop(ui->panNumSpinBox->value(), loop); |
| 650 |
emit panParameterChanged(ui->panNumSpinBox->value(), instNum_); |
| 651 |
emit modified(); |
| 652 |
} |
| 653 |
}); |
| 654 |
QObject::connect(ui->panEditor, &VisualizedInstrumentMacroEditor::loopRemoved, |
| 655 |
this, [&](int begin, int end) { |
| 656 |
if (!isIgnoreEvent_) { |
| 657 |
bt_.lock()->removePanFMLoop(ui->panNumSpinBox->value(), begin, end); |
| 658 |
emit panParameterChanged(ui->panNumSpinBox->value(), instNum_); |
| 659 |
emit modified(); |
| 660 |
} |
| 661 |
}); |
| 662 |
QObject::connect(ui->panEditor, &VisualizedInstrumentMacroEditor::loopCleared, |
| 663 |
this, [&] { |
| 664 |
if (!isIgnoreEvent_) { |
| 665 |
bt_.lock()->clearPanFMLoops(ui->panNumSpinBox->value()); |
| 666 |
emit panParameterChanged(ui->panNumSpinBox->value(), instNum_); |
| 667 |
emit modified(); |
| 668 |
} |
| 669 |
}); |
| 670 |
QObject::connect(ui->panEditor, &VisualizedInstrumentMacroEditor::loopChanged, |
| 671 |
this, [&](int prevBegin, int prevEnd, InstrumentSequenceLoop loop) { |
| 672 |
if (!isIgnoreEvent_) { |
| 673 |
bt_.lock()->changePanFMLoop(ui->panNumSpinBox->value(), prevBegin, prevEnd, loop); |
| 674 |
emit panParameterChanged(ui->panNumSpinBox->value(), instNum_); |
| 675 |
emit modified(); |
| 676 |
} |
| 677 |
}); |
| 678 |
QObject::connect(ui->panEditor, &VisualizedInstrumentMacroEditor::releaseChanged, |
| 679 |
this, [&](InstrumentSequenceRelease release) { |
| 680 |
if (!isIgnoreEvent_) { |
| 681 |
bt_.lock()->setPanFMRelease(ui->panNumSpinBox->value(), release); |
| 682 |
emit panParameterChanged(ui->panNumSpinBox->value(), instNum_); |
| 683 |
emit modified(); |
| 684 |
} |
| 685 |
}); |
| 686 |
|
| 687 |
//========== Others ==========// |
| 688 |
QObject::connect(ui->envResetCheckBox, &QCheckBox::stateChanged, |
| 689 |
this, [&](int state) { |
| 690 |
if (!isIgnoreEvent_) { |
| 691 |
bt_.lock()->setInstrumentFMEnvelopeResetEnabled(instNum_, FMOperatorType::All, (state == Qt::Checked)); |
| 692 |
emit modified(); |
| 693 |
} |
| 694 |
}); |
| 695 |
QObject::connect(ui->envResetOp1CheckBox, &QCheckBox::stateChanged, |
| 696 |
this, [&](int state) { |
| 697 |
if (!isIgnoreEvent_) { |
| 698 |
bt_.lock()->setInstrumentFMEnvelopeResetEnabled(instNum_, FMOperatorType::Op1, (state == Qt::Checked)); |
| 699 |
emit modified(); |
| 700 |
} |
| 701 |
}); |
| 702 |
QObject::connect(ui->envResetOp2CheckBox, &QCheckBox::stateChanged, |
| 703 |
this, [&](int state) { |
| 704 |
if (!isIgnoreEvent_) { |
| 705 |
bt_.lock()->setInstrumentFMEnvelopeResetEnabled(instNum_, FMOperatorType::Op2, (state == Qt::Checked)); |
| 706 |
emit modified(); |
| 707 |
} |
| 708 |
}); |
| 709 |
QObject::connect(ui->envResetOp3CheckBox, &QCheckBox::stateChanged, |
| 710 |
this, [&](int state) { |
| 711 |
if (!isIgnoreEvent_) { |
| 712 |
bt_.lock()->setInstrumentFMEnvelopeResetEnabled(instNum_, FMOperatorType::Op3, (state == Qt::Checked)); |
| 713 |
emit modified(); |
| 714 |
} |
| 715 |
}); |
| 716 |
QObject::connect(ui->envResetOp4CheckBox, &QCheckBox::stateChanged, |
| 717 |
this, [&](int state) { |
| 718 |
if (!isIgnoreEvent_) { |
| 719 |
bt_.lock()->setInstrumentFMEnvelopeResetEnabled(instNum_, FMOperatorType::Op4, (state == Qt::Checked)); |
| 720 |
emit modified(); |
| 721 |
} |
| 722 |
}); |
| 723 |
} |
| 724 |
|
| 725 |
FmInstrumentEditor::~FmInstrumentEditor() |
| 726 |
{ |
| 727 |
delete ui; |
| 728 |
} |
| 729 |
|
| 730 |
SoundSource FmInstrumentEditor::getSoundSource() const |
| 731 |
{ |
| 732 |
return SoundSource::FM; |
| 733 |
} |
| 734 |
|
| 735 |
InstrumentType FmInstrumentEditor::getInstrumentType() const |
| 736 |
{ |
| 737 |
return InstrumentType::FM; |
| 738 |
} |
| 739 |
|
| 740 |
void FmInstrumentEditor::updateByConfigurationChange() |
| 741 |
{ |
| 742 |
ui->op1Table->setDTDisplayType(config_.lock()->getShowFMDetuneAsSigned()); |
| 743 |
ui->op2Table->setDTDisplayType(config_.lock()->getShowFMDetuneAsSigned()); |
| 744 |
ui->op3Table->setDTDisplayType(config_.lock()->getShowFMDetuneAsSigned()); |
| 745 |
ui->op4Table->setDTDisplayType(config_.lock()->getShowFMDetuneAsSigned()); |
| 746 |
|
| 747 |
ui->arpEditor->onNoteNamesUpdated(); |
| 748 |
} |
| 749 |
|
| 750 |
void FmInstrumentEditor::updateBySettingCore() |
| 751 |
{ |
| 752 |
updateInstrumentParameters(); |
| 753 |
} |
| 754 |
|
| 755 |
void FmInstrumentEditor::updateBySettingConfiguration() |
| 756 |
{ |
| 757 |
std::vector<QString> names; |
| 758 |
for (const auto& texts : config_.lock()->getFMEnvelopeTexts()) { |
| 759 |
names.push_back(gui_utils::utf8ToQString(texts.name)); |
| 760 |
} |
| 761 |
ui->op1Table->setEnvelopeSetNames(names); |
| 762 |
ui->op2Table->setEnvelopeSetNames(names); |
| 763 |
ui->op3Table->setEnvelopeSetNames(names); |
| 764 |
ui->op4Table->setEnvelopeSetNames(names); |
| 765 |
|
| 766 |
updateByConfigurationChange(); |
| 767 |
} |
| 768 |
|
| 769 |
void FmInstrumentEditor::updateBySettingColorPalette() |
| 770 |
{ |
| 771 |
ui->op1Table->setColorPalette(palette_); |
| 772 |
ui->op2Table->setColorPalette(palette_); |
| 773 |
ui->op3Table->setColorPalette(palette_); |
| 774 |
ui->op4Table->setColorPalette(palette_); |
| 775 |
|
| 776 |
ui->opSeqEditor->setColorPalette(palette_); |
| 777 |
ui->arpEditor->setColorPalette(palette_); |
| 778 |
ui->ptEditor->setColorPalette(palette_); |
| 779 |
ui->panEditor->setColorPalette(palette_); |
| 780 |
} |
| 781 |
|
| 782 |
void FmInstrumentEditor::updateInstrumentParameters() |
| 783 |
{ |
| 784 |
Ui::EventGuard eg(isIgnoreEvent_); |
| 785 |
|
| 786 |
updateWindowTitle(); |
| 787 |
|
| 788 |
setInstrumentEnvelopeParameters(); |
| 789 |
setInstrumentLFOParameters(); |
| 790 |
setInstrumentOperatorSequenceParameters(); |
| 791 |
setInstrumentArpeggioParameters(); |
| 792 |
setInstrumentPitchParameters(); |
| 793 |
setInstrumentPanParameters(); |
| 794 |
|
| 795 |
setInstrumentEnvelopeResetParameters(); |
| 796 |
} |
| 797 |
|
| 798 |
/********** Events **********/ |
| 799 |
// MUST DIRECT CONNECTION |
| 800 |
void FmInstrumentEditor::keyPressEvent(QKeyEvent *event) |
| 801 |
{ |
| 802 |
// General keys |
| 803 |
switch (event->key()) { |
| 804 |
case Qt::Key_Escape: |
| 805 |
close(); |
| 806 |
break; |
| 807 |
default: |
| 808 |
// For jam key on |
| 809 |
if (!event->isAutoRepeat()) { |
| 810 |
// Musical keyboard |
| 811 |
Qt::Key qtKey = static_cast<Qt::Key>(event->key()); |
| 812 |
try { |
| 813 |
JamKey jk = getJamKeyFromLayoutMapping(qtKey, config_); |
| 814 |
emit jamKeyOnEvent(jk); |
| 815 |
} catch (std::invalid_argument&) {} |
| 816 |
} |
| 817 |
break; |
| 818 |
} |
| 819 |
} |
| 820 |
|
| 821 |
// MUST DIRECT CONNECTION |
| 822 |
void FmInstrumentEditor::keyReleaseEvent(QKeyEvent *event) |
| 823 |
{ |
| 824 |
// For jam key off |
| 825 |
if (!event->isAutoRepeat()) { |
| 826 |
Qt::Key qtKey = static_cast<Qt::Key>(event->key()); |
| 827 |
try { |
| 828 |
JamKey jk = getJamKeyFromLayoutMapping(qtKey, config_); |
| 829 |
emit jamKeyOffEvent(jk); |
| 830 |
} catch (std::invalid_argument&) {} |
| 831 |
} |
| 832 |
} |
| 833 |
|
| 834 |
void FmInstrumentEditor::showEvent(QShowEvent*) |
| 835 |
{ |
| 836 |
paintAlgorithmDiagram(); |
| 837 |
resizeAlgorithmDiagram(); |
| 838 |
} |
| 839 |
|
| 840 |
void FmInstrumentEditor::resizeEvent(QResizeEvent*) |
| 841 |
{ |
| 842 |
resizeAlgorithmDiagram(); |
| 843 |
} |
| 844 |
|
| 845 |
//========== Envelope ==========// |
| 846 |
void FmInstrumentEditor::setInstrumentEnvelopeParameters() |
| 847 |
{ |
| 848 |
Ui::EventGuard eg(isIgnoreEvent_); |
| 849 |
|
| 850 |
std::unique_ptr<AbstractInstrument> inst = bt_.lock()->getInstrument(instNum_); |
| 851 |
auto instFM = dynamic_cast<InstrumentFM*>(inst.get()); |
| 852 |
|
| 853 |
ui->envNumSpinBox->setValue(instFM->getEnvelopeNumber()); |
| 854 |
onEnvelopeNumberChanged(); |
| 855 |
ui->alSlider->setValue(instFM->getEnvelopeParameter(FMEnvelopeParameter::AL)); |
| 856 |
ui->fbSlider->setValue(instFM->getEnvelopeParameter(FMEnvelopeParameter::FB)); |
| 857 |
ui->op1Table->setValue(Ui::FMOperatorParameter::AR, instFM->getEnvelopeParameter(FMEnvelopeParameter::AR1)); |
| 858 |
ui->op1Table->setValue(Ui::FMOperatorParameter::DR, instFM->getEnvelopeParameter(FMEnvelopeParameter::DR1)); |
| 859 |
ui->op1Table->setValue(Ui::FMOperatorParameter::SR, instFM->getEnvelopeParameter(FMEnvelopeParameter::SR1)); |
| 860 |
ui->op1Table->setValue(Ui::FMOperatorParameter::RR, instFM->getEnvelopeParameter(FMEnvelopeParameter::RR1)); |
| 861 |
ui->op1Table->setValue(Ui::FMOperatorParameter::SL, instFM->getEnvelopeParameter(FMEnvelopeParameter::SL1)); |
| 862 |
ui->op1Table->setValue(Ui::FMOperatorParameter::TL, instFM->getEnvelopeParameter(FMEnvelopeParameter::TL1)); |
| 863 |
ui->op1Table->setValue(Ui::FMOperatorParameter::KS, instFM->getEnvelopeParameter(FMEnvelopeParameter::KS1)); |
| 864 |
ui->op1Table->setValue(Ui::FMOperatorParameter::ML, instFM->getEnvelopeParameter(FMEnvelopeParameter::ML1)); |
| 865 |
ui->op1Table->setValue(Ui::FMOperatorParameter::DT, instFM->getEnvelopeParameter(FMEnvelopeParameter::DT1)); |
| 866 |
ui->op1Table->setValue(Ui::FMOperatorParameter::SSGEG, instFM->getEnvelopeParameter(FMEnvelopeParameter::SSGEG1)); |
| 867 |
ui->op1Table->setGroupEnabled(instFM->getOperatorEnabled(0)); |
| 868 |
ui->op2Table->setValue(Ui::FMOperatorParameter::AR, instFM->getEnvelopeParameter(FMEnvelopeParameter::AR2)); |
| 869 |
ui->op2Table->setValue(Ui::FMOperatorParameter::DR, instFM->getEnvelopeParameter(FMEnvelopeParameter::DR2)); |
| 870 |
ui->op2Table->setValue(Ui::FMOperatorParameter::SR, instFM->getEnvelopeParameter(FMEnvelopeParameter::SR2)); |
| 871 |
ui->op2Table->setValue(Ui::FMOperatorParameter::RR, instFM->getEnvelopeParameter(FMEnvelopeParameter::RR2)); |
| 872 |
ui->op2Table->setValue(Ui::FMOperatorParameter::SL, instFM->getEnvelopeParameter(FMEnvelopeParameter::SL2)); |
| 873 |
ui->op2Table->setValue(Ui::FMOperatorParameter::TL, instFM->getEnvelopeParameter(FMEnvelopeParameter::TL2)); |
| 874 |
ui->op2Table->setValue(Ui::FMOperatorParameter::KS, instFM->getEnvelopeParameter(FMEnvelopeParameter::KS2)); |
| 875 |
ui->op2Table->setValue(Ui::FMOperatorParameter::ML, instFM->getEnvelopeParameter(FMEnvelopeParameter::ML2)); |
| 876 |
ui->op2Table->setValue(Ui::FMOperatorParameter::DT, instFM->getEnvelopeParameter(FMEnvelopeParameter::DT2)); |
| 877 |
ui->op2Table->setValue(Ui::FMOperatorParameter::SSGEG, instFM->getEnvelopeParameter(FMEnvelopeParameter::SSGEG2)); |
| 878 |
ui->op2Table->setGroupEnabled(instFM->getOperatorEnabled(1)); |
| 879 |
ui->op3Table->setValue(Ui::FMOperatorParameter::AR, instFM->getEnvelopeParameter(FMEnvelopeParameter::AR3)); |
| 880 |
ui->op3Table->setValue(Ui::FMOperatorParameter::DR, instFM->getEnvelopeParameter(FMEnvelopeParameter::DR3)); |
| 881 |
ui->op3Table->setValue(Ui::FMOperatorParameter::SR, instFM->getEnvelopeParameter(FMEnvelopeParameter::SR3)); |
| 882 |
ui->op3Table->setValue(Ui::FMOperatorParameter::RR, instFM->getEnvelopeParameter(FMEnvelopeParameter::RR3)); |
| 883 |
ui->op3Table->setValue(Ui::FMOperatorParameter::SL, instFM->getEnvelopeParameter(FMEnvelopeParameter::SL3)); |
| 884 |
ui->op3Table->setValue(Ui::FMOperatorParameter::TL, instFM->getEnvelopeParameter(FMEnvelopeParameter::TL3)); |
| 885 |
ui->op3Table->setValue(Ui::FMOperatorParameter::KS, instFM->getEnvelopeParameter(FMEnvelopeParameter::KS3)); |
| 886 |
ui->op3Table->setValue(Ui::FMOperatorParameter::ML, instFM->getEnvelopeParameter(FMEnvelopeParameter::ML3)); |
| 887 |
ui->op3Table->setValue(Ui::FMOperatorParameter::DT, instFM->getEnvelopeParameter(FMEnvelopeParameter::DT3)); |
| 888 |
ui->op3Table->setValue(Ui::FMOperatorParameter::SSGEG, instFM->getEnvelopeParameter(FMEnvelopeParameter::SSGEG3)); |
| 889 |
ui->op3Table->setGroupEnabled(instFM->getOperatorEnabled(2)); |
| 890 |
ui->op4Table->setValue(Ui::FMOperatorParameter::AR, instFM->getEnvelopeParameter(FMEnvelopeParameter::AR4)); |
| 891 |
ui->op4Table->setValue(Ui::FMOperatorParameter::DR, instFM->getEnvelopeParameter(FMEnvelopeParameter::DR4)); |
| 892 |
ui->op4Table->setValue(Ui::FMOperatorParameter::SR, instFM->getEnvelopeParameter(FMEnvelopeParameter::SR4)); |
| 893 |
ui->op4Table->setValue(Ui::FMOperatorParameter::RR, instFM->getEnvelopeParameter(FMEnvelopeParameter::RR4)); |
| 894 |
ui->op4Table->setValue(Ui::FMOperatorParameter::SL, instFM->getEnvelopeParameter(FMEnvelopeParameter::SL4)); |
| 895 |
ui->op4Table->setValue(Ui::FMOperatorParameter::TL, instFM->getEnvelopeParameter(FMEnvelopeParameter::TL4)); |
| 896 |
ui->op4Table->setValue(Ui::FMOperatorParameter::KS, instFM->getEnvelopeParameter(FMEnvelopeParameter::KS4)); |
| 897 |
ui->op4Table->setValue(Ui::FMOperatorParameter::ML, instFM->getEnvelopeParameter(FMEnvelopeParameter::ML4)); |
| 898 |
ui->op4Table->setValue(Ui::FMOperatorParameter::DT, instFM->getEnvelopeParameter(FMEnvelopeParameter::DT4)); |
| 899 |
ui->op4Table->setValue(Ui::FMOperatorParameter::SSGEG, instFM->getEnvelopeParameter(FMEnvelopeParameter::SSGEG4)); |
| 900 |
ui->op4Table->setGroupEnabled(instFM->getOperatorEnabled(3)); |
| 901 |
} |
| 902 |
|
| 903 |
void FmInstrumentEditor::setInstrumentEnvelopeParameters(QString data) |
| 904 |
{ |
| 905 |
QRegularExpression re("^(?<fb>\\d+),(?<al>\\d+),\\s*" |
| 906 |
"(?<ar1>\\d+),(?<dr1>\\d+),(?<sr1>\\d+),(?<rr1>\\d+),(?<sl1>\\d+)," |
| 907 |
"(?<tl1>\\d+),(?<ks1>\\d+),(?<ml1>\\d+),(?<dt1>\\d+),(?<ssgeg1>-?\\d+),\\s*" |
| 908 |
"(?<ar2>\\d+),(?<dr2>\\d+),(?<sr2>\\d+),(?<rr2>\\d+),(?<sl2>\\d+)," |
| 909 |
"(?<tl2>\\d+),(?<ks2>\\d+),(?<ml2>\\d+),(?<dt2>\\d+),(?<ssgeg2>-?\\d+),\\s*" |
| 910 |
"(?<ar3>\\d+),(?<dr3>\\d+),(?<sr3>\\d+),(?<rr3>\\d+),(?<sl3>\\d+)," |
| 911 |
"(?<tl3>\\d+),(?<ks3>\\d+),(?<ml3>\\d+),(?<dt3>\\d+),(?<ssgeg3>-?\\d+),\\s*" |
| 912 |
"(?<ar4>\\d+),(?<dr4>\\d+),(?<sr4>\\d+),(?<rr4>\\d+),(?<sl4>\\d+)," |
| 913 |
"(?<tl4>\\d+),(?<ks4>\\d+),(?<ml4>\\d+),(?<dt4>\\d+),(?<ssgeg4>-?\\d+),?\\s*"); |
| 914 |
QRegularExpressionMatch match = re.match(data); |
| 915 |
|
| 916 |
if (match.hasMatch()) { |
| 917 |
ui->fbSlider->setValue(match.captured("fb").toInt()); |
| 918 |
ui->alSlider->setValue(match.captured("al").toInt()); |
| 919 |
ui->op1Table->setValue(Ui::FMOperatorParameter::AR, match.captured("ar1").toInt()); |
| 920 |
ui->op1Table->setValue(Ui::FMOperatorParameter::DR, match.captured("dr1").toInt()); |
| 921 |
ui->op1Table->setValue(Ui::FMOperatorParameter::SR, match.captured("sr1").toInt()); |
| 922 |
ui->op1Table->setValue(Ui::FMOperatorParameter::RR, match.captured("rr1").toInt()); |
| 923 |
ui->op1Table->setValue(Ui::FMOperatorParameter::SL, match.captured("sl1").toInt()); |
| 924 |
ui->op1Table->setValue(Ui::FMOperatorParameter::TL, match.captured("tl1").toInt()); |
| 925 |
ui->op1Table->setValue(Ui::FMOperatorParameter::KS, match.captured("ks1").toInt()); |
| 926 |
ui->op1Table->setValue(Ui::FMOperatorParameter::ML, match.captured("ml1").toInt()); |
| 927 |
ui->op1Table->setValue(Ui::FMOperatorParameter::DT, match.captured("dt1").toInt()); |
| 928 |
ui->op1Table->setValue(Ui::FMOperatorParameter::SSGEG, match.captured("ssgeg1").toInt()); |
| 929 |
ui->op2Table->setValue(Ui::FMOperatorParameter::AR, match.captured("ar2").toInt()); |
| 930 |
ui->op2Table->setValue(Ui::FMOperatorParameter::DR, match.captured("dr2").toInt()); |
| 931 |
ui->op2Table->setValue(Ui::FMOperatorParameter::SR, match.captured("sr2").toInt()); |
| 932 |
ui->op2Table->setValue(Ui::FMOperatorParameter::RR, match.captured("rr2").toInt()); |
| 933 |
ui->op2Table->setValue(Ui::FMOperatorParameter::SL, match.captured("sl2").toInt()); |
| 934 |
ui->op2Table->setValue(Ui::FMOperatorParameter::TL, match.captured("tl2").toInt()); |
| 935 |
ui->op2Table->setValue(Ui::FMOperatorParameter::KS, match.captured("ks2").toInt()); |
| 936 |
ui->op2Table->setValue(Ui::FMOperatorParameter::ML, match.captured("ml2").toInt()); |
| 937 |
ui->op2Table->setValue(Ui::FMOperatorParameter::DT, match.captured("dt2").toInt()); |
| 938 |
ui->op2Table->setValue(Ui::FMOperatorParameter::SSGEG, match.captured("ssgeg2").toInt()); |
| 939 |
ui->op3Table->setValue(Ui::FMOperatorParameter::AR, match.captured("ar3").toInt()); |
| 940 |
ui->op3Table->setValue(Ui::FMOperatorParameter::DR, match.captured("dr3").toInt()); |
| 941 |
ui->op3Table->setValue(Ui::FMOperatorParameter::SR, match.captured("sr3").toInt()); |
| 942 |
ui->op3Table->setValue(Ui::FMOperatorParameter::RR, match.captured("rr3").toInt()); |
| 943 |
ui->op3Table->setValue(Ui::FMOperatorParameter::SL, match.captured("sl3").toInt()); |
| 944 |
ui->op3Table->setValue(Ui::FMOperatorParameter::TL, match.captured("tl3").toInt()); |
| 945 |
ui->op3Table->setValue(Ui::FMOperatorParameter::KS, match.captured("ks3").toInt()); |
| 946 |
ui->op3Table->setValue(Ui::FMOperatorParameter::ML, match.captured("ml3").toInt()); |
| 947 |
ui->op3Table->setValue(Ui::FMOperatorParameter::DT, match.captured("dt3").toInt()); |
| 948 |
ui->op3Table->setValue(Ui::FMOperatorParameter::SSGEG, match.captured("ssgeg3").toInt()); |
| 949 |
ui->op4Table->setValue(Ui::FMOperatorParameter::AR, match.captured("ar4").toInt()); |
| 950 |
ui->op4Table->setValue(Ui::FMOperatorParameter::DR, match.captured("dr4").toInt()); |
| 951 |
ui->op4Table->setValue(Ui::FMOperatorParameter::SR, match.captured("sr4").toInt()); |
| 952 |
ui->op4Table->setValue(Ui::FMOperatorParameter::RR, match.captured("rr4").toInt()); |
| 953 |
ui->op4Table->setValue(Ui::FMOperatorParameter::SL, match.captured("sl4").toInt()); |
| 954 |
ui->op4Table->setValue(Ui::FMOperatorParameter::TL, match.captured("tl4").toInt()); |
| 955 |
ui->op4Table->setValue(Ui::FMOperatorParameter::KS, match.captured("ks4").toInt()); |
| 956 |
ui->op4Table->setValue(Ui::FMOperatorParameter::ML, match.captured("ml4").toInt()); |
| 957 |
ui->op4Table->setValue(Ui::FMOperatorParameter::DT, match.captured("dt4").toInt()); |
| 958 |
ui->op4Table->setValue(Ui::FMOperatorParameter::SSGEG, match.captured("ssgeg4").toInt()); |
| 959 |
} |
| 960 |
} |
| 961 |
|
| 962 |
void FmInstrumentEditor::setInstrumentEnvelopeParameters(int envTypeNum, QString data) |
| 963 |
{ |
| 964 |
QStringList digits; |
| 965 |
QRegularExpression re(R"((-?\d+))"); |
| 966 |
auto it = re.globalMatch(data); |
| 967 |
while (it.hasNext()) { |
| 968 |
auto match = it.next(); |
| 969 |
digits.append(match.captured(1)); |
| 970 |
} |
| 971 |
|
| 972 |
std::vector<FMEnvelopeTextType> set |
| 973 |
= config_.lock()->getFMEnvelopeTexts().at(static_cast<size_t>(envTypeNum)).texts; |
| 974 |
if (static_cast<int>(set.size()) != digits.size()) { |
| 975 |
auto name = config_.lock()->getFMEnvelopeTexts().at(static_cast<size_t>(envTypeNum)).name; |
| 976 |
QMessageBox::critical(this, tr("Error"), |
| 977 |
tr("Did not match the clipboard text format with %1.") |
| 978 |
.arg(gui_utils::utf8ToQString(name))); |
| 979 |
return; |
| 980 |
} |
| 981 |
|
| 982 |
auto rangeCheck = [](int v, int min, int max) -> int { |
| 983 |
if (v < min || max < v) throw std::out_of_range(""); |
| 984 |
else return v; |
| 985 |
}; |
| 986 |
auto rangeCheckDT = [rangeCheck](int v) -> int { |
| 987 |
switch (v) { |
| 988 |
case -3: v = 7; break; |
| 989 |
case -2: v = 6; break; |
| 990 |
case -1: v = 5; break; |
| 991 |
default: break; |
| 992 |
} |
| 993 |
return rangeCheck(v, 0, 7); |
| 994 |
}; |
| 995 |
try { |
| 996 |
for (int i = 0; i < digits.size(); ++i) { |
| 997 |
int d = digits[i].toInt(); |
| 998 |
switch (set[static_cast<size_t>(i)]) { |
| 999 |
case FMEnvelopeTextType::Skip: break; |
| 1000 |
case FMEnvelopeTextType::AL: ui->alSlider->setValue(rangeCheck(d, 0, 7)); break; |
| 1001 |
case FMEnvelopeTextType::FB: ui->fbSlider->setValue(rangeCheck(d, 0, 7)); break; |
| 1002 |
case FMEnvelopeTextType::AR1: ui->op1Table->setValue(Ui::FMOperatorParameter::AR, rangeCheck(d, 0, 31)); break; |
| 1003 |
case FMEnvelopeTextType::DR1: ui->op1Table->setValue(Ui::FMOperatorParameter::DR, rangeCheck(d, 0, 31)); break; |
| 1004 |
case FMEnvelopeTextType::SR1: ui->op1Table->setValue(Ui::FMOperatorParameter::SR, rangeCheck(d, 0, 31)); break; |
| 1005 |
case FMEnvelopeTextType::RR1: ui->op1Table->setValue(Ui::FMOperatorParameter::RR, rangeCheck(d, 0, 15)); break; |
| 1006 |
case FMEnvelopeTextType::SL1: ui->op1Table->setValue(Ui::FMOperatorParameter::SL, rangeCheck(d, 0, 15)); break; |
| 1007 |
case FMEnvelopeTextType::TL1: ui->op1Table->setValue(Ui::FMOperatorParameter::TL, rangeCheck(d, 0, 127)); break; |
| 1008 |
case FMEnvelopeTextType::KS1: ui->op1Table->setValue(Ui::FMOperatorParameter::KS, rangeCheck(d, 0, 3)); break; |
| 1009 |
case FMEnvelopeTextType::ML1: ui->op1Table->setValue(Ui::FMOperatorParameter::ML, rangeCheck(d, 0, 15)); break; |
| 1010 |
case FMEnvelopeTextType::DT1: ui->op1Table->setValue(Ui::FMOperatorParameter::DT, rangeCheckDT(d)); break; |
| 1011 |
case FMEnvelopeTextType::AR2: ui->op2Table->setValue(Ui::FMOperatorParameter::AR, rangeCheck(d, 0, 31)); break; |
| 1012 |
case FMEnvelopeTextType::DR2: ui->op2Table->setValue(Ui::FMOperatorParameter::DR, rangeCheck(d, 0, 31)); break; |
| 1013 |
case FMEnvelopeTextType::SR2: ui->op2Table->setValue(Ui::FMOperatorParameter::SR, rangeCheck(d, 0, 31)); break; |
| 1014 |
case FMEnvelopeTextType::RR2: ui->op2Table->setValue(Ui::FMOperatorParameter::RR, rangeCheck(d, 0, 15)); break; |
| 1015 |
case FMEnvelopeTextType::SL2: ui->op2Table->setValue(Ui::FMOperatorParameter::SL, rangeCheck(d, 0, 15)); break; |
| 1016 |
case FMEnvelopeTextType::TL2: ui->op2Table->setValue(Ui::FMOperatorParameter::TL, rangeCheck(d, 0, 127)); break; |
| 1017 |
case FMEnvelopeTextType::KS2: ui->op2Table->setValue(Ui::FMOperatorParameter::KS, rangeCheck(d, 0, 3)); break; |
| 1018 |
case FMEnvelopeTextType::ML2: ui->op2Table->setValue(Ui::FMOperatorParameter::ML, rangeCheck(d, 0, 15)); break; |
| 1019 |
case FMEnvelopeTextType::DT2: ui->op2Table->setValue(Ui::FMOperatorParameter::DT, rangeCheckDT(d)); break; |
| 1020 |
case FMEnvelopeTextType::AR3: ui->op3Table->setValue(Ui::FMOperatorParameter::AR, rangeCheck(d, 0, 31)); break; |
| 1021 |
case FMEnvelopeTextType::DR3: ui->op3Table->setValue(Ui::FMOperatorParameter::DR, rangeCheck(d, 0, 31)); break; |
| 1022 |
case FMEnvelopeTextType::SR3: ui->op3Table->setValue(Ui::FMOperatorParameter::SR, rangeCheck(d, 0, 31)); break; |
| 1023 |
case FMEnvelopeTextType::RR3: ui->op3Table->setValue(Ui::FMOperatorParameter::RR, rangeCheck(d, 0, 15)); break; |
| 1024 |
case FMEnvelopeTextType::SL3: ui->op3Table->setValue(Ui::FMOperatorParameter::SL, rangeCheck(d, 0, 15)); break; |
| 1025 |
case FMEnvelopeTextType::TL3: ui->op3Table->setValue(Ui::FMOperatorParameter::TL, rangeCheck(d, 0, 127)); break; |
| 1026 |
case FMEnvelopeTextType::KS3: ui->op3Table->setValue(Ui::FMOperatorParameter::KS, rangeCheck(d, 0, 4)); break; |
| 1027 |
case FMEnvelopeTextType::ML3: ui->op3Table->setValue(Ui::FMOperatorParameter::ML, rangeCheck(d, 0, 15)); break; |
| 1028 |
case FMEnvelopeTextType::DT3: ui->op3Table->setValue(Ui::FMOperatorParameter::DT, rangeCheckDT(d)); break; |
| 1029 |
case FMEnvelopeTextType::AR4: ui->op4Table->setValue(Ui::FMOperatorParameter::AR, rangeCheck(d, 0, 31)); break; |
| 1030 |
case FMEnvelopeTextType::DR4: ui->op4Table->setValue(Ui::FMOperatorParameter::DR, rangeCheck(d, 0, 31)); break; |
| 1031 |
case FMEnvelopeTextType::SR4: ui->op4Table->setValue(Ui::FMOperatorParameter::SR, rangeCheck(d, 0, 31)); break; |
| 1032 |
case FMEnvelopeTextType::RR4: ui->op4Table->setValue(Ui::FMOperatorParameter::RR, rangeCheck(d, 0, 15)); break; |
| 1033 |
case FMEnvelopeTextType::SL4: ui->op4Table->setValue(Ui::FMOperatorParameter::SL, rangeCheck(d, 0, 15)); break; |
| 1034 |
case FMEnvelopeTextType::TL4: ui->op4Table->setValue(Ui::FMOperatorParameter::TL, rangeCheck(d, 0, 127)); break; |
| 1035 |
case FMEnvelopeTextType::KS4: ui->op4Table->setValue(Ui::FMOperatorParameter::KS, rangeCheck(d, 0, 4)); break; |
| 1036 |
case FMEnvelopeTextType::ML4: ui->op4Table->setValue(Ui::FMOperatorParameter::ML, rangeCheck(d, 0, 15)); break; |
| 1037 |
case FMEnvelopeTextType::DT4: ui->op4Table->setValue(Ui::FMOperatorParameter::DT, rangeCheckDT(d)); break; |
| 1038 |
} |
| 1039 |
} |
| 1040 |
} |
| 1041 |
catch (...) { |
| 1042 |
auto name = config_.lock()->getFMEnvelopeTexts().at(static_cast<size_t>(envTypeNum)).name; |
| 1043 |
QMessageBox::critical(this, tr("Error"), |
| 1044 |
tr("Did not match the clipboard text format with %1.") |
| 1045 |
.arg(gui_utils::utf8ToQString(name))); |
| 1046 |
return; |
| 1047 |
} |
| 1048 |
} |
| 1049 |
|
| 1050 |
void FmInstrumentEditor::setInstrumentOperatorParameters(int opNum, QString data) |
| 1051 |
{ |
| 1052 |
QRegularExpression re("^(?<ar>\\d+),(?<dr>\\d+),(?<sr>\\d+),(?<rr>\\d+),(?<sl>\\d+)," |
| 1053 |
"(?<tl>\\d+),(?<ks>\\d+),(?<ml>\\d+),(?<dt>\\d+),(?<ssgeg>-?\\d+)"); |
| 1054 |
QRegularExpressionMatch match = re.match(data); |
| 1055 |
|
| 1056 |
if (match.hasMatch()) { |
| 1057 |
switch (opNum) { |
| 1058 |
case 0: |
| 1059 |
ui->op1Table->setValue(Ui::FMOperatorParameter::AR, match.captured("ar").toInt()); |
| 1060 |
ui->op1Table->setValue(Ui::FMOperatorParameter::DR, match.captured("dr").toInt()); |
| 1061 |
ui->op1Table->setValue(Ui::FMOperatorParameter::SR, match.captured("sr").toInt()); |
| 1062 |
ui->op1Table->setValue(Ui::FMOperatorParameter::RR, match.captured("rr").toInt()); |
| 1063 |
ui->op1Table->setValue(Ui::FMOperatorParameter::SL, match.captured("sl").toInt()); |
| 1064 |
ui->op1Table->setValue(Ui::FMOperatorParameter::TL, match.captured("tl").toInt()); |
| 1065 |
ui->op1Table->setValue(Ui::FMOperatorParameter::KS, match.captured("ks").toInt()); |
| 1066 |
ui->op1Table->setValue(Ui::FMOperatorParameter::ML, match.captured("ml").toInt()); |
| 1067 |
ui->op1Table->setValue(Ui::FMOperatorParameter::DT, match.captured("dt").toInt()); |
| 1068 |
ui->op1Table->setValue(Ui::FMOperatorParameter::SSGEG, match.captured("ssgeg").toInt()); |
| 1069 |
break; |
| 1070 |
case 1: |
| 1071 |
ui->op2Table->setValue(Ui::FMOperatorParameter::AR, match.captured("ar").toInt()); |
| 1072 |
ui->op2Table->setValue(Ui::FMOperatorParameter::DR, match.captured("dr").toInt()); |
| 1073 |
ui->op2Table->setValue(Ui::FMOperatorParameter::SR, match.captured("sr").toInt()); |
| 1074 |
ui->op2Table->setValue(Ui::FMOperatorParameter::RR, match.captured("rr").toInt()); |
| 1075 |
ui->op2Table->setValue(Ui::FMOperatorParameter::SL, match.captured("sl").toInt()); |
| 1076 |
ui->op2Table->setValue(Ui::FMOperatorParameter::TL, match.captured("tl").toInt()); |
| 1077 |
ui->op2Table->setValue(Ui::FMOperatorParameter::KS, match.captured("ks").toInt()); |
| 1078 |
ui->op2Table->setValue(Ui::FMOperatorParameter::ML, match.captured("ml").toInt()); |
| 1079 |
ui->op2Table->setValue(Ui::FMOperatorParameter::DT, match.captured("dt").toInt()); |
| 1080 |
ui->op2Table->setValue(Ui::FMOperatorParameter::SSGEG, match.captured("ssgeg").toInt()); |
| 1081 |
break; |
| 1082 |
case 2: |
| 1083 |
ui->op3Table->setValue(Ui::FMOperatorParameter::AR, match.captured("ar").toInt()); |
| 1084 |
ui->op3Table->setValue(Ui::FMOperatorParameter::DR, match.captured("dr").toInt()); |
| 1085 |
ui->op3Table->setValue(Ui::FMOperatorParameter::SR, match.captured("sr").toInt()); |
| 1086 |
ui->op3Table->setValue(Ui::FMOperatorParameter::RR, match.captured("rr").toInt()); |
| 1087 |
ui->op3Table->setValue(Ui::FMOperatorParameter::SL, match.captured("sl").toInt()); |
| 1088 |
ui->op3Table->setValue(Ui::FMOperatorParameter::TL, match.captured("tl").toInt()); |
| 1089 |
ui->op3Table->setValue(Ui::FMOperatorParameter::KS, match.captured("ks").toInt()); |
| 1090 |
ui->op3Table->setValue(Ui::FMOperatorParameter::ML, match.captured("ml").toInt()); |
| 1091 |
ui->op3Table->setValue(Ui::FMOperatorParameter::DT, match.captured("dt").toInt()); |
| 1092 |
ui->op3Table->setValue(Ui::FMOperatorParameter::SSGEG, match.captured("ssgeg").toInt()); |
| 1093 |
break; |
| 1094 |
case 3: |
| 1095 |
ui->op4Table->setValue(Ui::FMOperatorParameter::AR, match.captured("ar").toInt()); |
| 1096 |
ui->op4Table->setValue(Ui::FMOperatorParameter::DR, match.captured("dr").toInt()); |
| 1097 |
ui->op4Table->setValue(Ui::FMOperatorParameter::SR, match.captured("sr").toInt()); |
| 1098 |
ui->op4Table->setValue(Ui::FMOperatorParameter::RR, match.captured("rr").toInt()); |
| 1099 |
ui->op4Table->setValue(Ui::FMOperatorParameter::SL, match.captured("sl").toInt()); |
| 1100 |
ui->op4Table->setValue(Ui::FMOperatorParameter::TL, match.captured("tl").toInt()); |
| 1101 |
ui->op4Table->setValue(Ui::FMOperatorParameter::KS, match.captured("ks").toInt()); |
| 1102 |
ui->op4Table->setValue(Ui::FMOperatorParameter::ML, match.captured("ml").toInt()); |
| 1103 |
ui->op4Table->setValue(Ui::FMOperatorParameter::DT, match.captured("dt").toInt()); |
| 1104 |
ui->op4Table->setValue(Ui::FMOperatorParameter::SSGEG, match.captured("ssgeg").toInt()); |
| 1105 |
break; |
| 1106 |
} |
| 1107 |
} |
| 1108 |
} |
| 1109 |
|
| 1110 |
void FmInstrumentEditor::paintAlgorithmDiagram() |
| 1111 |
{ |
| 1112 |
if (!palette_) return; |
| 1113 |
|
| 1114 |
ui->alGraphicsView->setBackgroundBrush(QBrush(palette_->instFMAlBackColor)); |
| 1115 |
QGraphicsScene* scene = ui->alGraphicsView->scene(); // 200 * 70 |
| 1116 |
scene->clear(); |
| 1117 |
|
| 1118 |
QPen pen(palette_->instFMAlForeColor); |
| 1119 |
QBrush brush(palette_->instFMAlForeColor); |
| 1120 |
auto one = new QGraphicsSimpleTextItem(); |
| 1121 |
one->setBrush(brush); |
| 1122 |
one->setText("1"); |
| 1123 |
auto two = new QGraphicsSimpleTextItem(); |
| 1124 |
two->setBrush(brush); |
| 1125 |
two->setText("2"); |
| 1126 |
auto three = new QGraphicsSimpleTextItem(); |
| 1127 |
three->setBrush(brush); |
| 1128 |
three->setText("3"); |
| 1129 |
auto four = new QGraphicsSimpleTextItem(); |
| 1130 |
four->setBrush(brush); |
| 1131 |
four->setText("4"); |
| 1132 |
switch (ui->alSlider->value()) { |
| 1133 |
case 0: |
| 1134 |
{ |
| 1135 |
scene->addRect(8, -4, 16, 8, pen, brush); |
| 1136 |
scene->addRect(40, -4, 16, 8, pen, brush); |
| 1137 |
scene->addRect(72, -4, 16, 8, pen, brush); |
| 1138 |
scene->addRect(104, -4, 16, 8, pen, brush); |
| 1139 |
scene->addLine(0, 0, 128, 0, pen); |
| 1140 |
scene->addLine(0, -8, 32, -8, pen); |
| 1141 |
scene->addLine(0, 0, 0, -8, pen); |
| 1142 |
scene->addLine(32, 0, 32, -8, pen); |
| 1143 |
one->setPos(14, 8); |
| 1144 |
two->setPos(46, 8); |
| 1145 |
three->setPos(78, 8); |
| 1146 |
four->setPos(110, 8); |
| 1147 |
break; |
| 1148 |
} |
| 1149 |
case 1: |
| 1150 |
{ |
| 1151 |
scene->addRect(8, -12, 16, 8, pen, brush); |
| 1152 |
scene->addRect(8, 4, 16, 8, pen, brush); |
| 1153 |
scene->addRect(40, -4, 16, 8, pen, brush); |
| 1154 |
scene->addRect(72, -4, 16, 8, pen, brush); |
| 1155 |
scene->addLine(0, -8, 35, -8, pen); |
| 1156 |
scene->addLine(24, 8, 35, 8, pen); |
| 1157 |
scene->addLine(0, -16, 29, -16, pen); |
| 1158 |
scene->addLine(0, -8, 0, -16, pen); |
| 1159 |
scene->addLine(29, -8, 29, -16, pen); |
| 1160 |
scene->addLine(35, -8, 35, 8, pen); |
| 1161 |
scene->addLine(35, 0, 96, 0, pen); |
| 1162 |
one->setPos(-8, -12); |
| 1163 |
two->setPos(-8, 4); |
| 1164 |
three->setPos(46, 8); |
| 1165 |
four->setPos(78, 8); |
| 1166 |
break; |
| 1167 |
} |
| 1168 |
case 2: |
| 1169 |
{ |
| 1170 |
scene->addRect(40, -12, 16, 8, pen, brush); |
| 1171 |
scene->addRect(8, 4, 16, 8, pen, brush); |
| 1172 |
scene->addRect(40, 4, 16, 8, pen, brush); |
| 1173 |
scene->addRect(72, -4, 16, 8, pen, brush); |
| 1174 |
scene->addLine(32, -8, 67, -8, pen); |
| 1175 |
scene->addLine(32, -8, 32, -16, pen); |
| 1176 |
scene->addLine(61, -8, 61, -16, pen); |
| 1177 |
scene->addLine(32, -16, 61, -16, pen); |
| 1178 |
scene->addLine(24, 8, 67, 8, pen); |
| 1179 |
scene->addLine(67, -8, 67, 8, pen); |
| 1180 |
scene->addLine(67, 0, 96, 0, pen); |
| 1181 |
one->setPos(24, -12); |
| 1182 |
two->setPos(14, 16); |
| 1183 |
three->setPos(46, 16); |
| 1184 |
four->setPos(78, 8); |
| 1185 |
break; |
| 1186 |
} |
| 1187 |
case 3: |
| 1188 |
{ |
| 1189 |
scene->addRect(8, -12, 16, 8, pen, brush); |
| 1190 |
scene->addRect(40, -12, 16, 8, pen, brush); |
| 1191 |
scene->addRect(40, 4, 16, 8, pen, brush); |
| 1192 |
scene->addRect(72, -4, 16, 8, pen, brush); |
| 1193 |
scene->addLine(0, -8, 64, -8, pen); |
| 1194 |
scene->addLine(0, -8, 0, -16, pen); |
| 1195 |
scene->addLine(32, -8, 32, -16, pen); |
| 1196 |
scene->addLine(0, -16, 32, -16, pen); |
| 1197 |
scene->addLine(56, 8, 64, 8, pen); |
| 1198 |
scene->addLine(64, -8, 64, 8, pen); |
| 1199 |
scene->addLine(64, 0, 96, 0, pen); |
| 1200 |
one->setPos(-8, -12); |
| 1201 |
two->setPos(46, -24); |
| 1202 |
three->setPos(46, 16); |
| 1203 |
four->setPos(78, 8); |
| 1204 |
break; |
| 1205 |
} |
| 1206 |
case 4: |
| 1207 |
{ |
| 1208 |
scene->addRect(8, -12, 16, 8, pen, brush); |
| 1209 |
scene->addRect(40, -12, 16, 8, pen, brush); |
| 1210 |
scene->addRect(8, 4, 16, 8, pen, brush); |
| 1211 |
scene->addRect(40, 4, 16, 8, pen, brush); |
| 1212 |
scene->addLine(0, -8, 64, -8, pen); |
| 1213 |
scene->addLine(0, -8, 0, -16, pen); |
| 1214 |
scene->addLine(32, -8, 32, -16, pen); |
| 1215 |
scene->addLine(0, -16, 32, -16, pen); |
| 1216 |
scene->addLine(24, 8, 64, 8, pen); |
| 1217 |
scene->addLine(64, -8, 64, 8, pen); |
| 1218 |
scene->addLine(64, 0, 72, 0, pen); |
| 1219 |
one->setPos(-8, -12); |
| 1220 |
two->setPos(46, -24); |
| 1221 |
three->setPos(14, 16); |
| 1222 |
four->setPos(46, 16); |
| 1223 |
break; |
| 1224 |
} |
| 1225 |
case 5: |
| 1226 |
{ |
| 1227 |
scene->addRect(8, -4, 16, 8, pen, brush); |
| 1228 |
scene->addRect(40, -20, 16, 8, pen, brush); |
| 1229 |
scene->addRect(40, -4, 16, 8, pen, brush); |
| 1230 |
scene->addRect(40, 12, 16, 8, pen, brush); |
| 1231 |
scene->addLine(0, 0, 72, 0, pen); |
| 1232 |
scene->addLine(0, 0, 0, -8, pen); |
| 1233 |
scene->addLine(29, 0, 29, -8, pen); |
| 1234 |
scene->addLine(0, -8, 29, -8, pen); |
| 1235 |
scene->addLine(35, -16, 35, 16, pen); |
| 1236 |
scene->addLine(64, -16, 64, 16, pen); |
| 1237 |
scene->addLine(35, -16, 64, -16, pen); |
| 1238 |
scene->addLine(35, 16, 64, 16, pen); |
| 1239 |
one->setPos(14, 8); |
| 1240 |
two->setPos(76, -20); |
| 1241 |
three->setPos(76, -4); |
| 1242 |
four->setPos(76, 12); |
| 1243 |
break; |
| 1244 |
} |
| 1245 |
case 6: |
| 1246 |
{ |
| 1247 |
scene->addRect(8, -20, 16, 8, pen, brush); |
| 1248 |
scene->addRect(40, -20, 16, 8, pen, brush); |
| 1249 |
scene->addRect(40, -4, 16, 8, pen, brush); |
| 1250 |
scene->addRect(40, 12, 16, 8, pen, brush); |
| 1251 |
scene->addLine(0, -16, 64, -16, pen); |
| 1252 |
scene->addLine(0, -16, 0, -24, pen); |
| 1253 |
scene->addLine(32, -16, 32, -24, pen); |
| 1254 |
scene->addLine(0, -24, 32, -24, pen); |
| 1255 |
scene->addLine(56, 0, 72, 0, pen); |
| 1256 |
scene->addLine(56, 16, 64, 16, pen); |
| 1257 |
scene->addLine(64, -16, 64, 16, pen); |
| 1258 |
one->setPos(14, -8); |
| 1259 |
two->setPos(76, -20); |
| 1260 |
three->setPos(76, -4); |
| 1261 |
four->setPos(76, 12); |
| 1262 |
break; |
| 1263 |
} |
| 1264 |
case 7: |
| 1265 |
{ |
| 1266 |
scene->addRect(-28, 8, 8, 16, pen, brush); |
| 1267 |
scene->addRect(-12, 8, 8, 16, pen, brush); |
| 1268 |
scene->addRect(4, 8, 8, 16, pen, brush); |
| 1269 |
scene->addRect(20, 8, 8, 16, pen, brush); |
| 1270 |
scene->addLine(-24, 0, -24, 35, pen); |
| 1271 |
scene->addLine(-24, 0, -32, 0, pen); |
| 1272 |
scene->addLine(-24, 29, -32, 29, pen); |
| 1273 |
scene->addLine(-32, 0, -32, 29, pen); |
| 1274 |
scene->addLine(-8, 24, -8, 35, pen); |
| 1275 |
scene->addLine(8, 24, 8, 35, pen); |
| 1276 |
scene->addLine(24, 24, 24, 35, pen); |
| 1277 |
scene->addLine(-24, 35, 24, 35, pen); |
| 1278 |
scene->addLine(0, 35, 0, 40, pen); |
| 1279 |
one->setPos(-26, -12); |
| 1280 |
two->setPos(-10, -12); |
| 1281 |
three->setPos(6, -12); |
| 1282 |
four->setPos(22, -12); |
| 1283 |
break; |
| 1284 |
} |
| 1285 |
} |
| 1286 |
scene->addItem(one); |
| 1287 |
scene->addItem(two); |
| 1288 |
scene->addItem(three); |
| 1289 |
scene->addItem(four); |
| 1290 |
|
| 1291 |
scene->setSceneRect(scene->itemsBoundingRect()); |
| 1292 |
} |
| 1293 |
|
| 1294 |
void FmInstrumentEditor::resizeAlgorithmDiagram() |
| 1295 |
{ |
| 1296 |
ui->alGraphicsView->fitInView(ui->alGraphicsView->scene()->itemsBoundingRect(), |
| 1297 |
Qt::AspectRatioMode::KeepAspectRatio); |
| 1298 |
} |
| 1299 |
|
| 1300 |
/********** Slots **********/ |
| 1301 |
void FmInstrumentEditor::copyEnvelope() |
| 1302 |
{ |
| 1303 |
QApplication::clipboard()->setText(QString("FM_ENVELOPE:%1,%2,\n%3,\n%4,\n%5,\n%6,") |
| 1304 |
.arg(ui->fbSlider->value()).arg(ui->alSlider->value()) |
| 1305 |
.arg(ui->op1Table->toString(), ui->op2Table->toString(), |
| 1306 |
ui->op3Table->toString(), ui->op4Table->toString())); |
| 1307 |
} |
| 1308 |
|
| 1309 |
void FmInstrumentEditor::pasteEnvelope() |
| 1310 |
{ |
| 1311 |
QString data = QApplication::clipboard()->text().remove("FM_ENVELOPE:"); |
| 1312 |
setInstrumentEnvelopeParameters(data); |
| 1313 |
} |
| 1314 |
|
| 1315 |
void FmInstrumentEditor::pasteEnvelopeFrom(int typenum) |
| 1316 |
{ |
| 1317 |
setInstrumentEnvelopeParameters(typenum, QApplication::clipboard()->text()); |
| 1318 |
} |
| 1319 |
|
| 1320 |
void FmInstrumentEditor::copyOperator(int opNum) |
| 1321 |
{ |
| 1322 |
QString text; |
| 1323 |
switch (opNum) { |
| 1324 |
case 0: text = ui->op1Table->toString(); break; |
| 1325 |
case 1: text = ui->op2Table->toString(); break; |
| 1326 |
case 2: text = ui->op3Table->toString(); break; |
| 1327 |
case 3: text = ui->op4Table->toString(); break; |
| 1328 |
} |
| 1329 |
|
| 1330 |
QApplication::clipboard()->setText(QString("FM_OPERATOR:") + text); |
| 1331 |
} |
| 1332 |
|
| 1333 |
void FmInstrumentEditor::pasteOperator(int opNum) |
| 1334 |
{ |
| 1335 |
QString data = QApplication::clipboard()->text().remove("FM_OPERATOR:"); |
| 1336 |
setInstrumentOperatorParameters(opNum, data); |
| 1337 |
} |
| 1338 |
|
| 1339 |
void FmInstrumentEditor::on_envNumSpinBox_valueChanged(int arg1) |
| 1340 |
{ |
| 1341 |
if (!isIgnoreEvent_) { |
| 1342 |
bt_.lock()->setInstrumentFMEnvelope(instNum_, arg1); |
| 1343 |
setInstrumentEnvelopeParameters(); |
| 1344 |
emit envelopeNumberChanged(); |
| 1345 |
emit modified(); |
| 1346 |
} |
| 1347 |
|
| 1348 |
onEnvelopeNumberChanged(); |
| 1349 |
} |
| 1350 |
|
| 1351 |
void FmInstrumentEditor::on_envGroupBox_customContextMenuRequested(const QPoint &pos) |
| 1352 |
{ |
| 1353 |
QPoint globalPos = ui->envGroupBox->mapToGlobal(pos); |
| 1354 |
QMenu menu; |
| 1355 |
// Leave Before Qt5.7.0 style due to windows xp |
| 1356 |
QAction* copy = menu.addAction(tr("Copy envelope")); |
| 1357 |
QObject::connect(copy, &QAction::triggered, this, &FmInstrumentEditor::copyEnvelope); |
| 1358 |
QAction* paste = menu.addAction(tr("Paste envelope")); |
| 1359 |
QObject::connect(paste, &QAction::triggered, this, &FmInstrumentEditor::pasteEnvelope); |
| 1360 |
paste->setEnabled(QApplication::clipboard()->text().startsWith("FM_ENVELOPE:")); |
| 1361 |
QMenu* pasteFrom = menu.addMenu(tr("Paste envelope From")); |
| 1362 |
std::vector<FMEnvelopeText> textsSet = config_.lock()->getFMEnvelopeTexts(); |
| 1363 |
for (size_t i = 0; i < textsSet.size(); ++i) { |
| 1364 |
QAction* act = pasteFrom->addAction(gui_utils::utf8ToQString(textsSet[i].name)); |
| 1365 |
act->setData(static_cast<int>(i)); |
| 1366 |
} |
| 1367 |
QObject::connect(pasteFrom, &QMenu::triggered, |
| 1368 |
this, [&](QAction* action) { pasteEnvelopeFrom(action->data().toInt()); }); |
| 1369 |
|
| 1370 |
menu.exec(globalPos); |
| 1371 |
} |
| 1372 |
|
| 1373 |
void FmInstrumentEditor::onEnvelopeParameterChanged(int envNum) |
| 1374 |
{ |
| 1375 |
if (ui->envNumSpinBox->value() == envNum) { |
| 1376 |
Ui::EventGuard eg(isIgnoreEvent_); |
| 1377 |
setInstrumentEnvelopeParameters(); |
| 1378 |
} |
| 1379 |
} |
| 1380 |
|
| 1381 |
void FmInstrumentEditor::onEnvelopeNumberChanged() |
| 1382 |
{ |
| 1383 |
// Change users view |
| 1384 |
std::multiset<int> users = bt_.lock()->getEnvelopeFMUsers(ui->envNumSpinBox->value()); |
| 1385 |
ui->envUsersLineEdit->setText(inst_edit_utils::generateUsersString(users)); |
| 1386 |
} |
| 1387 |
|
| 1388 |
//========== LFO ==========// |
| 1389 |
void FmInstrumentEditor::setInstrumentLFOParameters() |
| 1390 |
{ |
| 1391 |
Ui::EventGuard eg(isIgnoreEvent_); |
| 1392 |
|
| 1393 |
std::unique_ptr<AbstractInstrument> inst = bt_.lock()->getInstrument(instNum_); |
| 1394 |
auto instFM = dynamic_cast<InstrumentFM*>(inst.get()); |
| 1395 |
|
| 1396 |
ui->lfoNumSpinBox->setValue(instFM->getLFONumber()); |
| 1397 |
ui->lfoFreqSlider->setValue(instFM->getLFOParameter(FMLFOParameter::FREQ)); |
| 1398 |
ui->pmsSlider->setValue(instFM->getLFOParameter(FMLFOParameter::PMS)); |
| 1399 |
ui->amsSlider->setValue(instFM->getLFOParameter(FMLFOParameter::AMS)); |
| 1400 |
ui->amOp1CheckBox->setChecked(instFM->getLFOParameter(FMLFOParameter::AM1)); |
| 1401 |
ui->amOp2CheckBox->setChecked(instFM->getLFOParameter(FMLFOParameter::AM2)); |
| 1402 |
ui->amOp3CheckBox->setChecked(instFM->getLFOParameter(FMLFOParameter::AM3)); |
| 1403 |
ui->amOp4CheckBox->setChecked(instFM->getLFOParameter(FMLFOParameter::AM4)); |
| 1404 |
ui->lfoStartSpinBox->setValue(instFM->getLFOParameter(FMLFOParameter::Count)); |
| 1405 |
if (instFM->getLFOEnabled()) { |
| 1406 |
ui->lfoGroupBox->setChecked(true); |
| 1407 |
onLFONumberChanged(); |
| 1408 |
} |
| 1409 |
else { |
| 1410 |
ui->lfoGroupBox->setChecked(false); |
| 1411 |
} |
| 1412 |
} |
| 1413 |
|
| 1414 |
void FmInstrumentEditor::setInstrumentLFOParameters(QString data) |
| 1415 |
{ |
| 1416 |
QRegularExpression re("^(?<freq>\\d+),(?<pms>\\d+),(?<ams>\\d+),(?<cnt>\\d+)," |
| 1417 |
"(?<am1>\\d+),(?<am2>\\d+),(?<am3>\\d+),(?<am4>\\d+)"); |
| 1418 |
QRegularExpressionMatch match = re.match(data); |
| 1419 |
|
| 1420 |
if (match.hasMatch()) { |
| 1421 |
ui->lfoFreqSlider->setValue(match.captured("freq").toInt()); |
| 1422 |
ui->pmsSlider->setValue(match.captured("pms").toInt()); |
| 1423 |
ui->amsSlider->setValue(match.captured("ams").toInt()); |
| 1424 |
ui->lfoStartSpinBox->setValue(match.captured("cnt").toInt()); |
| 1425 |
ui->amOp1CheckBox->setChecked(match.captured("am1").toInt() == 1); |
| 1426 |
ui->amOp2CheckBox->setChecked(match.captured("am2").toInt() == 1); |
| 1427 |
ui->amOp3CheckBox->setChecked(match.captured("am3").toInt() == 1); |
| 1428 |
ui->amOp4CheckBox->setChecked(match.captured("am4").toInt() == 1); |
| 1429 |
} |
| 1430 |
} |
| 1431 |
|
| 1432 |
QString FmInstrumentEditor::toLFOString() const |
| 1433 |
{ |
| 1434 |
auto str = QString("%1,%2,%3,%4,%5,%6,%7,%8") |
| 1435 |
.arg(ui->lfoFreqSlider->value()) |
| 1436 |
.arg(ui->pmsSlider->value()) |
| 1437 |
.arg(ui->amsSlider->value()) |
| 1438 |
.arg(ui->lfoStartSpinBox->value()) |
| 1439 |
.arg(ui->amOp1CheckBox->isChecked() ? 1 : 0) |
| 1440 |
.arg(ui->amOp2CheckBox->isChecked() ? 1 : 0) |
| 1441 |
.arg(ui->amOp3CheckBox->isChecked() ? 1 : 0) |
| 1442 |
.arg(ui->amOp4CheckBox->isChecked() ? 1 : 0); |
| 1443 |
return str; |
| 1444 |
} |
| 1445 |
|
| 1446 |
/********** Slots **********/ |
| 1447 |
void FmInstrumentEditor::onLFOParameterChanged(int lfoNum) |
| 1448 |
{ |
| 1449 |
if (ui->lfoNumSpinBox->value() == lfoNum) { |
| 1450 |
Ui::EventGuard eg(isIgnoreEvent_); |
| 1451 |
setInstrumentLFOParameters(); |
| 1452 |
} |
| 1453 |
} |
| 1454 |
|
| 1455 |
void FmInstrumentEditor::onLFONumberChanged() |
| 1456 |
{ |
| 1457 |
// Change users view |
| 1458 |
std::multiset<int> users = bt_.lock()->getLFOFMUsers(ui->lfoNumSpinBox->value()); |
| 1459 |
ui->lfoUsersLineEdit->setText(inst_edit_utils::generateUsersString(users)); |
| 1460 |
} |
| 1461 |
|
| 1462 |
void FmInstrumentEditor::on_lfoGroupBox_customContextMenuRequested(const QPoint &pos) |
| 1463 |
{ |
| 1464 |
QClipboard* clipboard = QApplication::clipboard(); |
| 1465 |
QPoint globalPos = ui->lfoGroupBox->mapToGlobal(pos); |
| 1466 |
|
| 1467 |
QMenu menu; |
| 1468 |
// Leave Before Qt5.7.0 style due to windows xp |
| 1469 |
QAction* copy = menu.addAction(tr("Copy LFO parameters")); |
| 1470 |
QObject::connect(copy, &QAction::triggered, this, [&, clipboard]() { |
| 1471 |
clipboard->setText("FM_LFO:" + toLFOString()); |
| 1472 |
}); |
| 1473 |
QAction* paste = menu.addAction(tr("Paste LFO parameters")); |
| 1474 |
QObject::connect(paste, &QAction::triggered, this, [&, clipboard]() { |
| 1475 |
QString data = clipboard->text().remove("FM_LFO:"); |
| 1476 |
setInstrumentLFOParameters(data); |
| 1477 |
}); |
| 1478 |
if (!ui->lfoGroupBox->isChecked()) { |
| 1479 |
copy->setEnabled(false); |
| 1480 |
paste->setEnabled(false); |
| 1481 |
} |
| 1482 |
else if (!clipboard->text().startsWith("FM_LFO:")) { |
| 1483 |
paste->setEnabled(false); |
| 1484 |
} |
| 1485 |
|
| 1486 |
menu.exec(globalPos); |
| 1487 |
} |
| 1488 |
|
| 1489 |
void FmInstrumentEditor::on_lfoNumSpinBox_valueChanged(int arg1) |
| 1490 |
{ |
| 1491 |
if (!isIgnoreEvent_) { |
| 1492 |
bt_.lock()->setInstrumentFMLFO(instNum_, arg1); |
| 1493 |
setInstrumentLFOParameters(); |
| 1494 |
emit lfoNumberChanged(); |
| 1495 |
emit modified(); |
| 1496 |
} |
| 1497 |
|
| 1498 |
onLFONumberChanged(); |
| 1499 |
} |
| 1500 |
|
| 1501 |
void FmInstrumentEditor::on_lfoGroupBox_toggled(bool arg1) |
| 1502 |
{ |
| 1503 |
if (!isIgnoreEvent_) { |
| 1504 |
bt_.lock()->setInstrumentFMLFOEnabled(instNum_, arg1); |
| 1505 |
setInstrumentLFOParameters(); |
| 1506 |
emit lfoNumberChanged(); |
| 1507 |
emit modified(); |
| 1508 |
} |
| 1509 |
|
| 1510 |
onLFONumberChanged(); |
| 1511 |
} |
| 1512 |
|
| 1513 |
//--- OperatorSequence |
| 1514 |
FMEnvelopeParameter FmInstrumentEditor::getOperatorSequenceParameter() const |
| 1515 |
{ |
| 1516 |
return static_cast<FMEnvelopeParameter>(ui->opSeqTypeComboBox->currentData(Qt::UserRole).toInt()); |
| 1517 |
} |
| 1518 |
|
| 1519 |
void FmInstrumentEditor::setInstrumentOperatorSequenceParameters() |
| 1520 |
{ |
| 1521 |
Ui::EventGuard ev(isIgnoreEvent_); |
| 1522 |
|
| 1523 |
std::unique_ptr<AbstractInstrument> inst = bt_.lock()->getInstrument(instNum_); |
| 1524 |
auto instFM = dynamic_cast<InstrumentFM*>(inst.get()); |
| 1525 |
|
| 1526 |
FMEnvelopeParameter param = getOperatorSequenceParameter(); |
| 1527 |
|
| 1528 |
ui->opSeqNumSpinBox->setValue(instFM->getOperatorSequenceNumber(param)); |
| 1529 |
ui->opSeqEditor->clearData(); |
| 1530 |
setOperatorSequenceEditor(); |
| 1531 |
for (auto& unit : instFM->getOperatorSequenceSequence(param)) { |
| 1532 |
ui->opSeqEditor->addSequenceData(unit.data); |
| 1533 |
} |
| 1534 |
for (auto& loop : instFM->getOperatorSequenceLoopRoot(param).getAllLoops()) { |
| 1535 |
ui->opSeqEditor->addLoop(loop.getBeginPos(), loop.getEndPos(), loop.getTimes()); |
| 1536 |
} |
| 1537 |
ui->opSeqEditor->setRelease(instFM->getOperatorSequenceRelease(param)); |
| 1538 |
if (instFM->getOperatorSequenceEnabled(param)) { |
| 1539 |
ui->opSeqEditGroupBox->setChecked(true); |
| 1540 |
onOperatorSequenceNumberChanged(); |
| 1541 |
} |
| 1542 |
else { |
| 1543 |
ui->opSeqEditGroupBox->setChecked(false); |
| 1544 |
} |
| 1545 |
} |
| 1546 |
|
| 1547 |
void FmInstrumentEditor::setOperatorSequenceEditor() |
| 1548 |
{ |
| 1549 |
ui->opSeqEditor->clearRow(); |
| 1550 |
|
| 1551 |
FMEnvelopeParameter param = getOperatorSequenceParameter(); |
| 1552 |
switch (param) { |
| 1553 |
case FMEnvelopeParameter::AL: |
| 1554 |
case FMEnvelopeParameter::FB: |
| 1555 |
case FMEnvelopeParameter::DT1: |
| 1556 |
case FMEnvelopeParameter::DT2: |
| 1557 |
case FMEnvelopeParameter::DT3: |
| 1558 |
case FMEnvelopeParameter::DT4: |
| 1559 |
ui->opSeqEditor->setMaximumDisplayedRowCount(8); |
| 1560 |
for (int i = 0; i < 8; ++i) { |
| 1561 |
ui->opSeqEditor->AddRow(QString::number(i), false); |
| 1562 |
} |
| 1563 |
ui->opSeqEditor->autoFitLabelWidth(); |
| 1564 |
ui->opSeqEditor->setUpperRow(7); |
| 1565 |
break; |
| 1566 |
case FMEnvelopeParameter::AR1: |
| 1567 |
case FMEnvelopeParameter::AR2: |
| 1568 |
case FMEnvelopeParameter::AR3: |
| 1569 |
case FMEnvelopeParameter::AR4: |
| 1570 |
case FMEnvelopeParameter::DR1: |
| 1571 |
case FMEnvelopeParameter::DR2: |
| 1572 |
case FMEnvelopeParameter::DR3: |
| 1573 |
case FMEnvelopeParameter::DR4: |
| 1574 |
case FMEnvelopeParameter::SR1: |
| 1575 |
case FMEnvelopeParameter::SR2: |
| 1576 |
case FMEnvelopeParameter::SR3: |
| 1577 |
case FMEnvelopeParameter::SR4: |
| 1578 |
ui->opSeqEditor->setMaximumDisplayedRowCount(16); |
| 1579 |
for (int i = 0; i < 32; ++i) { |
| 1580 |
ui->opSeqEditor->AddRow(QString::number(i)); |
| 1581 |
} |
| 1582 |
ui->opSeqEditor->setUpperRow(15); |
| 1583 |
break; |
| 1584 |
case FMEnvelopeParameter::RR1: |
| 1585 |
case FMEnvelopeParameter::RR2: |
| 1586 |
case FMEnvelopeParameter::RR3: |
| 1587 |
case FMEnvelopeParameter::RR4: |
| 1588 |
case FMEnvelopeParameter::SL1: |
| 1589 |
case FMEnvelopeParameter::SL2: |
| 1590 |
case FMEnvelopeParameter::SL3: |
| 1591 |
case FMEnvelopeParameter::SL4: |
| 1592 |
case FMEnvelopeParameter::ML1: |
| 1593 |
case FMEnvelopeParameter::ML2: |
| 1594 |
case FMEnvelopeParameter::ML3: |
| 1595 |
case FMEnvelopeParameter::ML4: |
| 1596 |
ui->opSeqEditor->setMaximumDisplayedRowCount(16); |
| 1597 |
for (int i = 0; i < 16; ++i) { |
| 1598 |
ui->opSeqEditor->AddRow(QString::number(i)); |
| 1599 |
} |
| 1600 |
ui->opSeqEditor->setUpperRow(15); |
| 1601 |
break; |
| 1602 |
case FMEnvelopeParameter::KS1: |
| 1603 |
case FMEnvelopeParameter::KS2: |
| 1604 |
case FMEnvelopeParameter::KS3: |
| 1605 |
case FMEnvelopeParameter::KS4: |
| 1606 |
ui->opSeqEditor->setMaximumDisplayedRowCount(4); |
| 1607 |
for (int i = 0; i < 4; ++i) { |
| 1608 |
ui->opSeqEditor->AddRow(QString::number(i)); |
| 1609 |
} |
| 1610 |
ui->opSeqEditor->setUpperRow(3); |
| 1611 |
break; |
| 1612 |
case FMEnvelopeParameter::TL1: |
| 1613 |
case FMEnvelopeParameter::TL2: |
| 1614 |
case FMEnvelopeParameter::TL3: |
| 1615 |
case FMEnvelopeParameter::TL4: |
| 1616 |
ui->opSeqEditor->setMaximumDisplayedRowCount(16); |
| 1617 |
for (int i = 0; i < 128; ++i) { |
| 1618 |
ui->opSeqEditor->AddRow(QString::number(i)); |
| 1619 |
} |
| 1620 |
ui->opSeqEditor->setUpperRow(15); |
| 1621 |
break; |
| 1622 |
default: |
| 1623 |
break; |
| 1624 |
} |
| 1625 |
} |
| 1626 |
|
| 1627 |
/********** Slots **********/ |
| 1628 |
void FmInstrumentEditor::onOperatorSequenceNumberChanged() |
| 1629 |
{ |
| 1630 |
// Change users view |
| 1631 |
std::multiset<int> users = bt_.lock()->getOperatorSequenceFMUsers(getOperatorSequenceParameter(), ui->opSeqNumSpinBox->value()); |
| 1632 |
ui->opSeqUsersLineEdit->setText(inst_edit_utils::generateUsersString(users)); |
| 1633 |
} |
| 1634 |
|
| 1635 |
void FmInstrumentEditor::onOperatorSequenceParameterChanged(FMEnvelopeParameter param, int tnNum) |
| 1636 |
{ |
| 1637 |
if (param == getOperatorSequenceParameter() && ui->opSeqNumSpinBox->value() == tnNum) { |
| 1638 |
Ui::EventGuard eg(isIgnoreEvent_); |
| 1639 |
setInstrumentOperatorSequenceParameters(); |
| 1640 |
} |
| 1641 |
} |
| 1642 |
|
| 1643 |
void FmInstrumentEditor::onOperatorSequenceTypeChanged(int) |
| 1644 |
{ |
| 1645 |
if (!isIgnoreEvent_) setInstrumentOperatorSequenceParameters(); |
| 1646 |
} |
| 1647 |
|
| 1648 |
void FmInstrumentEditor::on_opSeqEditGroupBox_toggled(bool arg1) |
| 1649 |
{ |
| 1650 |
if (!isIgnoreEvent_) { |
| 1651 |
bt_.lock()->setInstrumentFMOperatorSequenceEnabled(instNum_, getOperatorSequenceParameter(), arg1); |
| 1652 |
setInstrumentOperatorSequenceParameters(); |
| 1653 |
emit operatorSequenceNumberChanged(); |
| 1654 |
emit modified(); |
| 1655 |
} |
| 1656 |
|
| 1657 |
onOperatorSequenceNumberChanged(); |
| 1658 |
} |
| 1659 |
|
| 1660 |
void FmInstrumentEditor::on_opSeqNumSpinBox_valueChanged(int arg1) |
| 1661 |
{ |
| 1662 |
if (!isIgnoreEvent_) { |
| 1663 |
bt_.lock()->setInstrumentFMOperatorSequence(instNum_, getOperatorSequenceParameter(), arg1); |
| 1664 |
setInstrumentOperatorSequenceParameters(); |
| 1665 |
emit operatorSequenceNumberChanged(); |
| 1666 |
emit modified(); |
| 1667 |
} |
| 1668 |
|
| 1669 |
onOperatorSequenceNumberChanged(); |
| 1670 |
} |
| 1671 |
|
| 1672 |
//--- Arpeggio |
| 1673 |
FMOperatorType FmInstrumentEditor::getArpeggioOperator() const |
| 1674 |
{ |
| 1675 |
return static_cast<FMOperatorType>(ui->arpOpComboBox->currentData(Qt::UserRole).toInt()); |
| 1676 |
} |
| 1677 |
|
| 1678 |
void FmInstrumentEditor::setInstrumentArpeggioParameters() |
| 1679 |
{ |
| 1680 |
Ui::EventGuard ev(isIgnoreEvent_); |
| 1681 |
|
| 1682 |
std::unique_ptr<AbstractInstrument> inst = bt_.lock()->getInstrument(instNum_); |
| 1683 |
auto instFM = dynamic_cast<InstrumentFM*>(inst.get()); |
| 1684 |
|
| 1685 |
FMOperatorType param = getArpeggioOperator(); |
| 1686 |
|
| 1687 |
ui->arpNumSpinBox->setValue(instFM->getArpeggioNumber(param)); |
| 1688 |
ui->arpEditor->clearData(); |
| 1689 |
for (auto& unit : instFM->getArpeggioSequence(param)) { |
| 1690 |
ui->arpEditor->addSequenceData(unit.data); |
| 1691 |
} |
| 1692 |
for (auto& loop : instFM->getArpeggioLoopRoot(param).getAllLoops()) { |
| 1693 |
ui->arpEditor->addLoop(loop.getBeginPos(), loop.getEndPos(), loop.getTimes()); |
| 1694 |
} |
| 1695 |
ui->arpEditor->setRelease(instFM->getArpeggioRelease(param)); |
| 1696 |
for (int i = 0; i < ui->arpTypeComboBox->count(); ++i) { |
| 1697 |
if (instFM->getArpeggioType(param) == static_cast<SequenceType>(ui->arpTypeComboBox->itemData(i).toInt())) { |
| 1698 |
ui->arpTypeComboBox->setCurrentIndex(i); |
| 1699 |
break; |
| 1700 |
} |
| 1701 |
} |
| 1702 |
if (instFM->getArpeggioEnabled(param)) { |
| 1703 |
ui->arpEditGroupBox->setChecked(true); |
| 1704 |
onArpeggioNumberChanged(); |
| 1705 |
} |
| 1706 |
else { |
| 1707 |
ui->arpEditGroupBox->setChecked(false); |
| 1708 |
} |
| 1709 |
} |
| 1710 |
|
| 1711 |
/********** Slots **********/ |
| 1712 |
void FmInstrumentEditor::onArpeggioNumberChanged() |
| 1713 |
{ |
| 1714 |
// Change users view |
| 1715 |
std::multiset<int> users = bt_.lock()->getArpeggioFMUsers(ui->arpNumSpinBox->value()); |
| 1716 |
ui->arpUsersLineEdit->setText(inst_edit_utils::generateUsersString(users)); |
| 1717 |
} |
| 1718 |
|
| 1719 |
void FmInstrumentEditor::onArpeggioParameterChanged(int tnNum) |
| 1720 |
{ |
| 1721 |
if (ui->arpNumSpinBox->value() == tnNum) { |
| 1722 |
Ui::EventGuard eg(isIgnoreEvent_); |
| 1723 |
setInstrumentArpeggioParameters(); |
| 1724 |
} |
| 1725 |
} |
| 1726 |
|
| 1727 |
void FmInstrumentEditor::onArpeggioOperatorChanged(int) |
| 1728 |
{ |
| 1729 |
if (!isIgnoreEvent_) setInstrumentArpeggioParameters(); |
| 1730 |
} |
| 1731 |
|
| 1732 |
void FmInstrumentEditor::onArpeggioTypeChanged(int) |
| 1733 |
{ |
| 1734 |
auto type = static_cast<SequenceType>(ui->arpTypeComboBox->currentData(Qt::UserRole).toInt()); |
| 1735 |
if (!isIgnoreEvent_) { |
| 1736 |
bt_.lock()->setArpeggioFMType(ui->arpNumSpinBox->value(), type); |
| 1737 |
emit arpeggioParameterChanged(ui->arpNumSpinBox->value(), instNum_); |
| 1738 |
emit modified(); |
| 1739 |
} |
| 1740 |
|
| 1741 |
ui->arpEditor->setSequenceType(type); |
| 1742 |
} |
| 1743 |
|
| 1744 |
void FmInstrumentEditor::on_arpEditGroupBox_toggled(bool arg1) |
| 1745 |
{ |
| 1746 |
if (!isIgnoreEvent_) { |
| 1747 |
bt_.lock()->setInstrumentFMArpeggioEnabled(instNum_, getArpeggioOperator(), arg1); |
| 1748 |
setInstrumentArpeggioParameters(); |
| 1749 |
emit arpeggioNumberChanged(); |
| 1750 |
emit modified(); |
| 1751 |
} |
| 1752 |
|
| 1753 |
onArpeggioNumberChanged(); |
| 1754 |
} |
| 1755 |
|
| 1756 |
void FmInstrumentEditor::on_arpNumSpinBox_valueChanged(int arg1) |
| 1757 |
{ |
| 1758 |
if (!isIgnoreEvent_) { |
| 1759 |
bt_.lock()->setInstrumentFMArpeggio(instNum_, getArpeggioOperator(), arg1); |
| 1760 |
setInstrumentArpeggioParameters(); |
| 1761 |
emit arpeggioNumberChanged(); |
| 1762 |
emit modified(); |
| 1763 |
} |
| 1764 |
|
| 1765 |
onArpeggioNumberChanged(); |
| 1766 |
} |
| 1767 |
|
| 1768 |
//--- Pitch |
| 1769 |
FMOperatorType FmInstrumentEditor::getPitchOperator() const |
| 1770 |
{ |
| 1771 |
return static_cast<FMOperatorType>(ui->ptOpComboBox->currentData(Qt::UserRole).toInt()); |
| 1772 |
} |
| 1773 |
|
| 1774 |
void FmInstrumentEditor::setInstrumentPitchParameters() |
| 1775 |
{ |
| 1776 |
Ui::EventGuard ev(isIgnoreEvent_); |
| 1777 |
|
| 1778 |
std::unique_ptr<AbstractInstrument> inst = bt_.lock()->getInstrument(instNum_); |
| 1779 |
auto instFM = dynamic_cast<InstrumentFM*>(inst.get()); |
| 1780 |
|
| 1781 |
FMOperatorType param = getPitchOperator(); |
| 1782 |
|
| 1783 |
ui->ptNumSpinBox->setValue(instFM->getPitchNumber(param)); |
| 1784 |
ui->ptEditor->clearData(); |
| 1785 |
for (auto& unit : instFM->getPitchSequence(param)) { |
| 1786 |
ui->ptEditor->addSequenceData(unit.data); |
| 1787 |
} |
| 1788 |
for (auto& loop : instFM->getPitchLoopRoot(param).getAllLoops()) { |
| 1789 |
ui->ptEditor->addLoop(loop.getBeginPos(), loop.getEndPos(), loop.getTimes()); |
| 1790 |
} |
| 1791 |
ui->ptEditor->setRelease(instFM->getPitchRelease(param)); |
| 1792 |
for (int i = 0; i < ui->ptTypeComboBox->count(); ++i) { |
| 1793 |
if (instFM->getPitchType(param) == static_cast<SequenceType>(ui->ptTypeComboBox->itemData(i).toInt())) { |
| 1794 |
ui->ptTypeComboBox->setCurrentIndex(i); |
| 1795 |
break; |
| 1796 |
} |
| 1797 |
} |
| 1798 |
if (instFM->getPitchEnabled(param)) { |
| 1799 |
ui->ptEditGroupBox->setChecked(true); |
| 1800 |
onPitchNumberChanged(); |
| 1801 |
} |
| 1802 |
else { |
| 1803 |
ui->ptEditGroupBox->setChecked(false); |
| 1804 |
} |
| 1805 |
} |
| 1806 |
|
| 1807 |
/********** Slots **********/ |
| 1808 |
void FmInstrumentEditor::onPitchNumberChanged() |
| 1809 |
{ |
| 1810 |
// Change users view |
| 1811 |
std::multiset<int> users = bt_.lock()->getPitchFMUsers(ui->ptNumSpinBox->value()); |
| 1812 |
ui->ptUsersLineEdit->setText(inst_edit_utils::generateUsersString(users)); |
| 1813 |
} |
| 1814 |
|
| 1815 |
void FmInstrumentEditor::onPitchParameterChanged(int ptNum) |
| 1816 |
{ |
| 1817 |
if (ui->ptNumSpinBox->value() == ptNum) { |
| 1818 |
Ui::EventGuard eg(isIgnoreEvent_); |
| 1819 |
setInstrumentPitchParameters(); |
| 1820 |
} |
| 1821 |
} |
| 1822 |
|
| 1823 |
void FmInstrumentEditor::onPitchOperatorChanged(int) |
| 1824 |
{ |
| 1825 |
if (!isIgnoreEvent_) setInstrumentPitchParameters(); |
| 1826 |
} |
| 1827 |
|
| 1828 |
void FmInstrumentEditor::onPitchTypeChanged(int) |
| 1829 |
{ |
| 1830 |
auto type = static_cast<SequenceType>(ui->ptTypeComboBox->currentData(Qt::UserRole).toInt()); |
| 1831 |
if (!isIgnoreEvent_) { |
| 1832 |
bt_.lock()->setPitchFMType(ui->ptNumSpinBox->value(), type); |
| 1833 |
emit pitchParameterChanged(ui->ptNumSpinBox->value(), instNum_); |
| 1834 |
emit modified(); |
| 1835 |
} |
| 1836 |
|
| 1837 |
ui->ptEditor->setSequenceType(type); |
| 1838 |
} |
| 1839 |
|
| 1840 |
void FmInstrumentEditor::on_ptEditGroupBox_toggled(bool arg1) |
| 1841 |
{ |
| 1842 |
if (!isIgnoreEvent_) { |
| 1843 |
bt_.lock()->setInstrumentFMPitchEnabled(instNum_, getPitchOperator(), arg1); |
| 1844 |
setInstrumentPitchParameters(); |
| 1845 |
emit pitchNumberChanged(); |
| 1846 |
emit modified(); |
| 1847 |
} |
| 1848 |
|
| 1849 |
onPitchNumberChanged(); |
| 1850 |
} |
| 1851 |
|
| 1852 |
void FmInstrumentEditor::on_ptNumSpinBox_valueChanged(int arg1) |
| 1853 |
{ |
| 1854 |
if (!isIgnoreEvent_) { |
| 1855 |
bt_.lock()->setInstrumentFMPitch(instNum_, getPitchOperator(), arg1); |
| 1856 |
setInstrumentPitchParameters(); |
| 1857 |
emit pitchNumberChanged(); |
| 1858 |
emit modified(); |
| 1859 |
} |
| 1860 |
|
| 1861 |
onPitchNumberChanged(); |
| 1862 |
} |
| 1863 |
|
| 1864 |
//--- Pan |
| 1865 |
void FmInstrumentEditor::setInstrumentPanParameters() |
| 1866 |
{ |
| 1867 |
Ui::EventGuard ev(isIgnoreEvent_); |
| 1868 |
|
| 1869 |
std::unique_ptr<AbstractInstrument> inst = bt_.lock()->getInstrument(instNum_); |
| 1870 |
auto instFM = dynamic_cast<InstrumentFM*>(inst.get()); |
| 1871 |
|
| 1872 |
ui->panNumSpinBox->setValue(instFM->getPanNumber()); |
| 1873 |
ui->panEditor->clearData(); |
| 1874 |
for (auto& unit : instFM->getPanSequence()) { |
| 1875 |
ui->panEditor->addSequenceData(unit.data); |
| 1876 |
} |
| 1877 |
for (auto& loop : instFM->getPanLoopRoot().getAllLoops()) { |
| 1878 |
ui->panEditor->addLoop(loop.getBeginPos(), loop.getEndPos(), loop.getTimes()); |
| 1879 |
} |
| 1880 |
ui->panEditor->setRelease(instFM->getPanRelease()); |
| 1881 |
|
| 1882 |
if (instFM->getPanEnabled()) { |
| 1883 |
ui->panEditGroupBox->setChecked(true); |
| 1884 |
onPanNumberChanged(); |
| 1885 |
} |
| 1886 |
else { |
| 1887 |
ui->panEditGroupBox->setChecked(false); |
| 1888 |
} |
| 1889 |
} |
| 1890 |
|
| 1891 |
/********** Slots **********/ |
| 1892 |
void FmInstrumentEditor::onPanNumberChanged() |
| 1893 |
{ |
| 1894 |
// Change users view |
| 1895 |
std::multiset<int> users = bt_.lock()->getPanFMUsers(ui->panNumSpinBox->value()); |
| 1896 |
ui->panUsersLineEdit->setText(inst_edit_utils::generateUsersString(users)); |
| 1897 |
} |
| 1898 |
|
| 1899 |
void FmInstrumentEditor::onPanParameterChanged(int panNum) |
| 1900 |
{ |
| 1901 |
if (ui->panNumSpinBox->value() == panNum) { |
| 1902 |
Ui::EventGuard eg(isIgnoreEvent_); |
| 1903 |
setInstrumentPanParameters(); |
| 1904 |
} |
| 1905 |
} |
| 1906 |
|
| 1907 |
void FmInstrumentEditor::on_panEditGroupBox_toggled(bool arg1) |
| 1908 |
{ |
| 1909 |
if (!isIgnoreEvent_) { |
| 1910 |
bt_.lock()->setInstrumentFMPanEnabled(instNum_, arg1); |
| 1911 |
setInstrumentPanParameters(); |
| 1912 |
emit panNumberChanged(); |
| 1913 |
emit modified(); |
| 1914 |
} |
| 1915 |
|
| 1916 |
onPanNumberChanged(); |
| 1917 |
} |
| 1918 |
|
| 1919 |
void FmInstrumentEditor::on_panNumSpinBox_valueChanged(int arg1) |
| 1920 |
{ |
| 1921 |
if (!isIgnoreEvent_) { |
| 1922 |
bt_.lock()->setInstrumentFMPan(instNum_, arg1); |
| 1923 |
setInstrumentPanParameters(); |
| 1924 |
emit panNumberChanged(); |
| 1925 |
emit modified(); |
| 1926 |
} |
| 1927 |
|
| 1928 |
onPanNumberChanged(); |
| 1929 |
} |
| 1930 |
|
| 1931 |
//========== Others ==========// |
| 1932 |
void FmInstrumentEditor::setInstrumentEnvelopeResetParameters() |
| 1933 |
{ |
| 1934 |
Ui::EventGuard ev(isIgnoreEvent_); |
| 1935 |
|
| 1936 |
std::unique_ptr<AbstractInstrument> inst = bt_.lock()->getInstrument(instNum_); |
| 1937 |
auto instFM = dynamic_cast<InstrumentFM*>(inst.get()); |
| 1938 |
|
| 1939 |
ui->envResetCheckBox->setChecked(instFM->getEnvelopeResetEnabled(FMOperatorType::All)); |
| 1940 |
ui->envResetOp1CheckBox->setChecked(instFM->getEnvelopeResetEnabled(FMOperatorType::Op1)); |
| 1941 |
ui->envResetOp2CheckBox->setChecked(instFM->getEnvelopeResetEnabled(FMOperatorType::Op2)); |
| 1942 |
ui->envResetOp3CheckBox->setChecked(instFM->getEnvelopeResetEnabled(FMOperatorType::Op3)); |
| 1943 |
ui->envResetOp4CheckBox->setChecked(instFM->getEnvelopeResetEnabled(FMOperatorType::Op4)); |
| 1944 |
} |