| 1 |
/* |
| 2 |
* Copyright (C) 2018-2023 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 "instrument.hpp" |
| 27 |
#include "instruments_manager.hpp" |
| 28 |
#include "utils.hpp" |
| 29 |
|
| 30 |
AbstractInstrument::AbstractInstrument(int number, SoundSource src, InstrumentType type, const std::string& name, InstrumentsManager* owner) |
| 31 |
: owner_(owner), |
| 32 |
number_(number), |
| 33 |
name_(name), |
| 34 |
sndSrc_(src), |
| 35 |
instType_(type) |
| 36 |
{ |
| 37 |
} |
| 38 |
|
| 39 |
bool AbstractInstrument::isRegisteredWithManager() const |
| 40 |
{ |
| 41 |
return (this == owner_->getInstrumentSharedPtr(number_).get()); |
| 42 |
} |
| 43 |
|
| 44 |
/****************************************/ |
| 45 |
|
| 46 |
InstrumentFM::InstrumentFM(int number, const std::string& name, InstrumentsManager* owner) : |
| 47 |
AbstractInstrument(number, SoundSource::FM, InstrumentType::FM, name, owner), |
| 48 |
envNum_(0), |
| 49 |
lfoEnabled_(false), |
| 50 |
lfoNum_(0), |
| 51 |
panEnabled_(false), |
| 52 |
panNum_(0) |
| 53 |
{ |
| 54 |
opSeqEnabled_ = { |
| 55 |
{ FMEnvelopeParameter::AL, false }, |
| 56 |
{ FMEnvelopeParameter::FB, false }, |
| 57 |
{ FMEnvelopeParameter::AR1, false }, |
| 58 |
{ FMEnvelopeParameter::DR1, false }, |
| 59 |
{ FMEnvelopeParameter::SR1, false }, |
| 60 |
{ FMEnvelopeParameter::RR1, false }, |
| 61 |
{ FMEnvelopeParameter::SL1, false }, |
| 62 |
{ FMEnvelopeParameter::TL1, false }, |
| 63 |
{ FMEnvelopeParameter::KS1, false }, |
| 64 |
{ FMEnvelopeParameter::ML1, false }, |
| 65 |
{ FMEnvelopeParameter::DT1, false }, |
| 66 |
{ FMEnvelopeParameter::AR2, false }, |
| 67 |
{ FMEnvelopeParameter::DR2, false }, |
| 68 |
{ FMEnvelopeParameter::SR2, false }, |
| 69 |
{ FMEnvelopeParameter::RR2, false }, |
| 70 |
{ FMEnvelopeParameter::SL2, false }, |
| 71 |
{ FMEnvelopeParameter::TL2, false }, |
| 72 |
{ FMEnvelopeParameter::KS2, false }, |
| 73 |
{ FMEnvelopeParameter::ML2, false }, |
| 74 |
{ FMEnvelopeParameter::DT2, false }, |
| 75 |
{ FMEnvelopeParameter::AR3, false }, |
| 76 |
{ FMEnvelopeParameter::DR3, false }, |
| 77 |
{ FMEnvelopeParameter::SR3, false }, |
| 78 |
{ FMEnvelopeParameter::RR3, false }, |
| 79 |
{ FMEnvelopeParameter::SL3, false }, |
| 80 |
{ FMEnvelopeParameter::TL3, false }, |
| 81 |
{ FMEnvelopeParameter::KS3, false }, |
| 82 |
{ FMEnvelopeParameter::ML3, false }, |
| 83 |
{ FMEnvelopeParameter::DT3, false }, |
| 84 |
{ FMEnvelopeParameter::AR4, false }, |
| 85 |
{ FMEnvelopeParameter::DR4, false }, |
| 86 |
{ FMEnvelopeParameter::SR4, false }, |
| 87 |
{ FMEnvelopeParameter::RR4, false }, |
| 88 |
{ FMEnvelopeParameter::SL4, false }, |
| 89 |
{ FMEnvelopeParameter::TL4, false }, |
| 90 |
{ FMEnvelopeParameter::KS4, false }, |
| 91 |
{ FMEnvelopeParameter::ML4, false }, |
| 92 |
{ FMEnvelopeParameter::DT4, false } |
| 93 |
}; |
| 94 |
opSeqNum_ = { |
| 95 |
{ FMEnvelopeParameter::AL, 0 }, |
| 96 |
{ FMEnvelopeParameter::FB, 0 }, |
| 97 |
{ FMEnvelopeParameter::AR1, 0 }, |
| 98 |
{ FMEnvelopeParameter::DR1, 0 }, |
| 99 |
{ FMEnvelopeParameter::SR1, 0 }, |
| 100 |
{ FMEnvelopeParameter::RR1, 0 }, |
| 101 |
{ FMEnvelopeParameter::SL1, 0 }, |
| 102 |
{ FMEnvelopeParameter::TL1, 0 }, |
| 103 |
{ FMEnvelopeParameter::KS1, 0 }, |
| 104 |
{ FMEnvelopeParameter::ML1, 0 }, |
| 105 |
{ FMEnvelopeParameter::DT1, 0 }, |
| 106 |
{ FMEnvelopeParameter::AR2, 0 }, |
| 107 |
{ FMEnvelopeParameter::DR2, 0 }, |
| 108 |
{ FMEnvelopeParameter::SR2, 0 }, |
| 109 |
{ FMEnvelopeParameter::RR2, 0 }, |
| 110 |
{ FMEnvelopeParameter::SL2, 0 }, |
| 111 |
{ FMEnvelopeParameter::TL2, 0 }, |
| 112 |
{ FMEnvelopeParameter::KS2, 0 }, |
| 113 |
{ FMEnvelopeParameter::ML2, 0 }, |
| 114 |
{ FMEnvelopeParameter::DT2, 0 }, |
| 115 |
{ FMEnvelopeParameter::AR3, 0 }, |
| 116 |
{ FMEnvelopeParameter::DR3, 0 }, |
| 117 |
{ FMEnvelopeParameter::SR3, 0 }, |
| 118 |
{ FMEnvelopeParameter::RR3, 0 }, |
| 119 |
{ FMEnvelopeParameter::SL3, 0 }, |
| 120 |
{ FMEnvelopeParameter::TL3, 0 }, |
| 121 |
{ FMEnvelopeParameter::KS3, 0 }, |
| 122 |
{ FMEnvelopeParameter::ML3, 0 }, |
| 123 |
{ FMEnvelopeParameter::DT3, 0 }, |
| 124 |
{ FMEnvelopeParameter::AR4, 0 }, |
| 125 |
{ FMEnvelopeParameter::DR4, 0 }, |
| 126 |
{ FMEnvelopeParameter::SR4, 0 }, |
| 127 |
{ FMEnvelopeParameter::RR4, 0 }, |
| 128 |
{ FMEnvelopeParameter::SL4, 0 }, |
| 129 |
{ FMEnvelopeParameter::TL4, 0 }, |
| 130 |
{ FMEnvelopeParameter::KS4, 0 }, |
| 131 |
{ FMEnvelopeParameter::ML4, 0 }, |
| 132 |
{ FMEnvelopeParameter::DT4, 0 } |
| 133 |
}; |
| 134 |
arpEnabled_ = { |
| 135 |
{ FMOperatorType::All, false }, |
| 136 |
{ FMOperatorType::Op1, false }, |
| 137 |
{ FMOperatorType::Op2, false }, |
| 138 |
{ FMOperatorType::Op3, false }, |
| 139 |
{ FMOperatorType::Op4, false } |
| 140 |
}; |
| 141 |
arpNum_ = { |
| 142 |
{ FMOperatorType::All, 0 }, |
| 143 |
{ FMOperatorType::Op1, 0 }, |
| 144 |
{ FMOperatorType::Op2, 0 }, |
| 145 |
{ FMOperatorType::Op3, 0 }, |
| 146 |
{ FMOperatorType::Op4, 0 } |
| 147 |
}; |
| 148 |
ptEnabled_ = { |
| 149 |
{ FMOperatorType::All, false }, |
| 150 |
{ FMOperatorType::Op1, false }, |
| 151 |
{ FMOperatorType::Op2, false }, |
| 152 |
{ FMOperatorType::Op3, false }, |
| 153 |
{ FMOperatorType::Op4, false } |
| 154 |
}; |
| 155 |
ptNum_ = { |
| 156 |
{ FMOperatorType::All, 0 }, |
| 157 |
{ FMOperatorType::Op1, 0 }, |
| 158 |
{ FMOperatorType::Op2, 0 }, |
| 159 |
{ FMOperatorType::Op3, 0 }, |
| 160 |
{ FMOperatorType::Op4, 0 } |
| 161 |
}; |
| 162 |
envResetEnabled_ = { |
| 163 |
{ FMOperatorType::All, false }, |
| 164 |
{ FMOperatorType::Op1, false }, |
| 165 |
{ FMOperatorType::Op2, false }, |
| 166 |
{ FMOperatorType::Op3, false }, |
| 167 |
{ FMOperatorType::Op4, false } |
| 168 |
}; |
| 169 |
} |
| 170 |
|
| 171 |
AbstractInstrument* InstrumentFM::clone() |
| 172 |
{ |
| 173 |
return new InstrumentFM(*this); |
| 174 |
} |
| 175 |
|
| 176 |
int InstrumentFM::getEnvelopeParameter(FMEnvelopeParameter param) const |
| 177 |
{ |
| 178 |
return owner_->getEnvelopeFMParameter(envNum_, param); |
| 179 |
} |
| 180 |
|
| 181 |
bool InstrumentFM::getOperatorEnabled(int n) const |
| 182 |
{ |
| 183 |
return owner_->getEnvelopeFMOperatorEnabled(envNum_, n); |
| 184 |
} |
| 185 |
|
| 186 |
int InstrumentFM::getLFOParameter(FMLFOParameter param) const |
| 187 |
{ |
| 188 |
return owner_->getLFOFMparameter(lfoNum_, param); |
| 189 |
} |
| 190 |
|
| 191 |
void InstrumentFM::setOperatorSequenceEnabled(FMEnvelopeParameter param, bool enabled) |
| 192 |
{ |
| 193 |
opSeqEnabled_.at(param) = enabled; |
| 194 |
} |
| 195 |
|
| 196 |
bool InstrumentFM::getOperatorSequenceEnabled(FMEnvelopeParameter param) const |
| 197 |
{ |
| 198 |
return opSeqEnabled_.at(param); |
| 199 |
} |
| 200 |
|
| 201 |
void InstrumentFM::setOperatorSequenceNumber(FMEnvelopeParameter param, int n) |
| 202 |
{ |
| 203 |
opSeqNum_.at(param) = n; |
| 204 |
} |
| 205 |
|
| 206 |
int InstrumentFM::getOperatorSequenceNumber(FMEnvelopeParameter param) const |
| 207 |
{ |
| 208 |
return opSeqNum_.at(param); |
| 209 |
} |
| 210 |
|
| 211 |
std::vector<FMOperatorSequenceUnit> InstrumentFM::getOperatorSequenceSequence(FMEnvelopeParameter param) const |
| 212 |
{ |
| 213 |
return owner_->getOperatorSequenceFMSequence(param, opSeqNum_.at(param)); |
| 214 |
} |
| 215 |
|
| 216 |
InstrumentSequenceLoopRoot InstrumentFM::getOperatorSequenceLoopRoot(FMEnvelopeParameter param) const |
| 217 |
{ |
| 218 |
return owner_->getOperatorSequenceFMLoopRoot(param, opSeqNum_.at(param)); |
| 219 |
} |
| 220 |
|
| 221 |
InstrumentSequenceRelease InstrumentFM::getOperatorSequenceRelease(FMEnvelopeParameter param) const |
| 222 |
{ |
| 223 |
return owner_->getOperatorSequenceFMRelease(param, opSeqNum_.at(param)); |
| 224 |
} |
| 225 |
|
| 226 |
FMOperatorSequenceIter InstrumentFM::getOperatorSequenceSequenceIterator(FMEnvelopeParameter param) const |
| 227 |
{ |
| 228 |
return owner_->getOperatorSequenceFMIterator(param, opSeqNum_.at(param)); |
| 229 |
} |
| 230 |
|
| 231 |
void InstrumentFM::setArpeggioEnabled(FMOperatorType op, bool enabled) |
| 232 |
{ |
| 233 |
arpEnabled_.at(op) = enabled; |
| 234 |
} |
| 235 |
|
| 236 |
bool InstrumentFM::getArpeggioEnabled(FMOperatorType op) const |
| 237 |
{ |
| 238 |
return arpEnabled_.at(op); |
| 239 |
} |
| 240 |
|
| 241 |
void InstrumentFM::setArpeggioNumber(FMOperatorType op, int n) |
| 242 |
{ |
| 243 |
arpNum_.at(op) = n; |
| 244 |
} |
| 245 |
|
| 246 |
int InstrumentFM::getArpeggioNumber(FMOperatorType op) const |
| 247 |
{ |
| 248 |
return arpNum_.at(op); |
| 249 |
} |
| 250 |
|
| 251 |
SequenceType InstrumentFM::getArpeggioType(FMOperatorType op) const |
| 252 |
{ |
| 253 |
return owner_->getArpeggioFMType(arpNum_.at(op)); |
| 254 |
} |
| 255 |
|
| 256 |
std::vector<ArpeggioUnit> InstrumentFM::getArpeggioSequence(FMOperatorType op) const |
| 257 |
{ |
| 258 |
return owner_->getArpeggioFMSequence(arpNum_.at(op)); |
| 259 |
} |
| 260 |
|
| 261 |
InstrumentSequenceLoopRoot InstrumentFM::getArpeggioLoopRoot(FMOperatorType op) const |
| 262 |
{ |
| 263 |
return owner_->getArpeggioFMLoopRoot(arpNum_.at(op)); |
| 264 |
} |
| 265 |
|
| 266 |
InstrumentSequenceRelease InstrumentFM::getArpeggioRelease(FMOperatorType op) const |
| 267 |
{ |
| 268 |
return owner_->getArpeggioFMRelease(arpNum_.at(op)); |
| 269 |
} |
| 270 |
|
| 271 |
ArpeggioIter InstrumentFM::getArpeggioSequenceIterator(FMOperatorType op) const |
| 272 |
{ |
| 273 |
return owner_->getArpeggioFMIterator(arpNum_.at(op)); |
| 274 |
} |
| 275 |
|
| 276 |
void InstrumentFM::setPitchEnabled(FMOperatorType op, bool enabled) |
| 277 |
{ |
| 278 |
ptEnabled_.at(op) = enabled; |
| 279 |
} |
| 280 |
|
| 281 |
bool InstrumentFM::getPitchEnabled(FMOperatorType op) const |
| 282 |
{ |
| 283 |
return ptEnabled_.at(op); |
| 284 |
} |
| 285 |
|
| 286 |
void InstrumentFM::setPitchNumber(FMOperatorType op, int n) |
| 287 |
{ |
| 288 |
ptNum_.at(op) = n; |
| 289 |
} |
| 290 |
|
| 291 |
int InstrumentFM::getPitchNumber(FMOperatorType op) const |
| 292 |
{ |
| 293 |
return ptNum_.at(op); |
| 294 |
} |
| 295 |
|
| 296 |
SequenceType InstrumentFM::getPitchType(FMOperatorType op) const |
| 297 |
{ |
| 298 |
return owner_->getPitchFMType(ptNum_.at(op)); |
| 299 |
} |
| 300 |
|
| 301 |
std::vector<PitchUnit> InstrumentFM::getPitchSequence(FMOperatorType op) const |
| 302 |
{ |
| 303 |
return owner_->getPitchFMSequence(ptNum_.at(op)); |
| 304 |
} |
| 305 |
|
| 306 |
InstrumentSequenceLoopRoot InstrumentFM::getPitchLoopRoot(FMOperatorType op) const |
| 307 |
{ |
| 308 |
return owner_->getPitchFMLoopRoot(ptNum_.at(op)); |
| 309 |
} |
| 310 |
|
| 311 |
InstrumentSequenceRelease InstrumentFM::getPitchRelease(FMOperatorType op) const |
| 312 |
{ |
| 313 |
return owner_->getPitchFMRelease(ptNum_.at(op)); |
| 314 |
} |
| 315 |
|
| 316 |
PitchIter InstrumentFM::getPitchSequenceIterator(FMOperatorType op) const |
| 317 |
{ |
| 318 |
return owner_->getPitchFMIterator(ptNum_.at(op)); |
| 319 |
} |
| 320 |
|
| 321 |
void InstrumentFM::setPanEnabled(bool enabled) |
| 322 |
{ |
| 323 |
panEnabled_ = enabled; |
| 324 |
} |
| 325 |
|
| 326 |
bool InstrumentFM::getPanEnabled() const |
| 327 |
{ |
| 328 |
return panEnabled_; |
| 329 |
} |
| 330 |
|
| 331 |
void InstrumentFM::setPanNumber(int n) |
| 332 |
{ |
| 333 |
panNum_ = n; |
| 334 |
} |
| 335 |
|
| 336 |
int InstrumentFM::getPanNumber() const |
| 337 |
{ |
| 338 |
return panNum_; |
| 339 |
} |
| 340 |
|
| 341 |
std::vector<PanUnit> InstrumentFM::getPanSequence() const |
| 342 |
{ |
| 343 |
return owner_->getPanFMSequence(panNum_); |
| 344 |
} |
| 345 |
|
| 346 |
InstrumentSequenceLoopRoot InstrumentFM::getPanLoopRoot() const |
| 347 |
{ |
| 348 |
return owner_->getPanFMLoopRoot(panNum_); |
| 349 |
} |
| 350 |
|
| 351 |
InstrumentSequenceRelease InstrumentFM::getPanRelease() const |
| 352 |
{ |
| 353 |
return owner_->getPanFMRelease(panNum_); |
| 354 |
} |
| 355 |
|
| 356 |
PanIter InstrumentFM::getPanSequenceIterator() const |
| 357 |
{ |
| 358 |
return owner_->getPanFMIterator(panNum_); |
| 359 |
} |
| 360 |
|
| 361 |
void InstrumentFM::setEnvelopeResetEnabled(FMOperatorType op, bool enabled) |
| 362 |
{ |
| 363 |
envResetEnabled_.at(op) = enabled; |
| 364 |
} |
| 365 |
|
| 366 |
bool InstrumentFM::getEnvelopeResetEnabled(FMOperatorType op) const |
| 367 |
{ |
| 368 |
return envResetEnabled_.at(op); |
| 369 |
} |
| 370 |
|
| 371 |
/****************************************/ |
| 372 |
|
| 373 |
InstrumentSSG::InstrumentSSG(int number, const std::string& name, InstrumentsManager* owner) |
| 374 |
: AbstractInstrument(number, SoundSource::SSG, InstrumentType::SSG, name, owner), |
| 375 |
wfEnabled_(false), |
| 376 |
wfNum_(0), |
| 377 |
tnEnabled_(false), |
| 378 |
tnNum_(0), |
| 379 |
envEnabled_(false), |
| 380 |
envNum_(0), |
| 381 |
arpEnabled_(false), |
| 382 |
arpNum_(0), |
| 383 |
ptEnabled_(false), |
| 384 |
ptNum_(0) |
| 385 |
{ |
| 386 |
} |
| 387 |
|
| 388 |
AbstractInstrument* InstrumentSSG::clone() |
| 389 |
{ |
| 390 |
return new InstrumentSSG(*this); |
| 391 |
} |
| 392 |
|
| 393 |
std::vector<SSGWaveformUnit> InstrumentSSG::getWaveformSequence() const |
| 394 |
{ |
| 395 |
return owner_->getWaveformSSGSequence(wfNum_); |
| 396 |
} |
| 397 |
|
| 398 |
InstrumentSequenceLoopRoot InstrumentSSG::getWaveformLoopRoot() const |
| 399 |
{ |
| 400 |
return owner_->getWaveformSSGLoopRoot(wfNum_); |
| 401 |
} |
| 402 |
|
| 403 |
InstrumentSequenceRelease InstrumentSSG::getWaveformRelease() const |
| 404 |
{ |
| 405 |
return owner_->getWaveformSSGRelease(wfNum_); |
| 406 |
} |
| 407 |
|
| 408 |
SSGWaveformIter InstrumentSSG::getWaveformSequenceIterator() const |
| 409 |
{ |
| 410 |
return owner_->getWaveformSSGIterator(wfNum_); |
| 411 |
} |
| 412 |
|
| 413 |
std::vector<SSGToneNoiseUnit> InstrumentSSG::getToneNoiseSequence() const |
| 414 |
{ |
| 415 |
return owner_->getToneNoiseSSGSequence(tnNum_); |
| 416 |
} |
| 417 |
|
| 418 |
InstrumentSequenceLoopRoot InstrumentSSG::getToneNoiseLoopRoot() const |
| 419 |
{ |
| 420 |
return owner_->getToneNoiseSSGLoopRoot(tnNum_); |
| 421 |
} |
| 422 |
|
| 423 |
InstrumentSequenceRelease InstrumentSSG::getToneNoiseRelease() const |
| 424 |
{ |
| 425 |
return owner_->getToneNoiseSSGRelease(tnNum_); |
| 426 |
} |
| 427 |
|
| 428 |
SSGToneNoiseIter InstrumentSSG::getToneNoiseSequenceIterator() const |
| 429 |
{ |
| 430 |
return owner_->getToneNoiseSSGIterator(tnNum_); |
| 431 |
} |
| 432 |
|
| 433 |
std::vector<SSGEnvelopeUnit> InstrumentSSG::getEnvelopeSequence() const |
| 434 |
{ |
| 435 |
return owner_->getEnvelopeSSGSequence(envNum_); |
| 436 |
} |
| 437 |
|
| 438 |
InstrumentSequenceLoopRoot InstrumentSSG::getEnvelopeLoopRoot() const |
| 439 |
{ |
| 440 |
return owner_->getEnvelopeSSGLoopRoot(envNum_); |
| 441 |
} |
| 442 |
|
| 443 |
InstrumentSequenceRelease InstrumentSSG::getEnvelopeRelease() const |
| 444 |
{ |
| 445 |
return owner_->getEnvelopeSSGRelease(envNum_); |
| 446 |
} |
| 447 |
|
| 448 |
SSGEnvelopeIter InstrumentSSG::getEnvelopeSequenceIterator() const |
| 449 |
{ |
| 450 |
return owner_->getEnvelopeSSGIterator(envNum_); |
| 451 |
} |
| 452 |
|
| 453 |
SequenceType InstrumentSSG::getArpeggioType() const |
| 454 |
{ |
| 455 |
return owner_->getArpeggioSSGType(arpNum_); |
| 456 |
} |
| 457 |
|
| 458 |
std::vector<ArpeggioUnit> InstrumentSSG::getArpeggioSequence() const |
| 459 |
{ |
| 460 |
return owner_->getArpeggioSSGSequence(arpNum_); |
| 461 |
} |
| 462 |
|
| 463 |
InstrumentSequenceLoopRoot InstrumentSSG::getArpeggioLoopRoot() const |
| 464 |
{ |
| 465 |
return owner_->getArpeggioSSGLoopRoot(arpNum_); |
| 466 |
} |
| 467 |
|
| 468 |
InstrumentSequenceRelease InstrumentSSG::getArpeggioRelease() const |
| 469 |
{ |
| 470 |
return owner_->getArpeggioSSGRelease(arpNum_); |
| 471 |
} |
| 472 |
|
| 473 |
ArpeggioIter InstrumentSSG::getArpeggioSequenceIterator() const |
| 474 |
{ |
| 475 |
return owner_->getArpeggioSSGIterator(arpNum_); |
| 476 |
} |
| 477 |
|
| 478 |
SequenceType InstrumentSSG::getPitchType() const |
| 479 |
{ |
| 480 |
return owner_->getPitchSSGType(ptNum_); |
| 481 |
} |
| 482 |
|
| 483 |
std::vector<PitchUnit> InstrumentSSG::getPitchSequence() const |
| 484 |
{ |
| 485 |
return owner_->getPitchSSGSequence(ptNum_); |
| 486 |
} |
| 487 |
|
| 488 |
InstrumentSequenceLoopRoot InstrumentSSG::getPitchLoopRoot() const |
| 489 |
{ |
| 490 |
return owner_->getPitchSSGLoopRoot(ptNum_); |
| 491 |
} |
| 492 |
|
| 493 |
InstrumentSequenceRelease InstrumentSSG::getPitchRelease() const |
| 494 |
{ |
| 495 |
return owner_->getPitchSSGRelease(ptNum_); |
| 496 |
} |
| 497 |
|
| 498 |
PitchIter InstrumentSSG::getPitchSequenceIterator() const |
| 499 |
{ |
| 500 |
return owner_->getPitchSSGIterator(ptNum_); |
| 501 |
} |
| 502 |
|
| 503 |
/****************************************/ |
| 504 |
|
| 505 |
InstrumentADPCM::InstrumentADPCM(int number, const std::string& name, InstrumentsManager* owner) |
| 506 |
: AbstractInstrument(number, SoundSource::ADPCM, InstrumentType::ADPCM, name, owner), |
| 507 |
sampNum_(0), |
| 508 |
envEnabled_(false), |
| 509 |
envNum_(0), |
| 510 |
arpEnabled_(false), |
| 511 |
arpNum_(0), |
| 512 |
ptEnabled_(false), |
| 513 |
ptNum_(0), |
| 514 |
panEnabled_(false), |
| 515 |
panNum_(0) |
| 516 |
{ |
| 517 |
} |
| 518 |
|
| 519 |
AbstractInstrument* InstrumentADPCM::clone() |
| 520 |
{ |
| 521 |
return new InstrumentADPCM(*this); |
| 522 |
} |
| 523 |
|
| 524 |
int InstrumentADPCM::getSampleRootKeyNumber() const |
| 525 |
{ |
| 526 |
return owner_->getSampleADPCMRootKeyNumber(sampNum_); |
| 527 |
} |
| 528 |
|
| 529 |
int InstrumentADPCM::getSampleRootDeltaN() const |
| 530 |
{ |
| 531 |
return owner_->getSampleADPCMRootDeltaN(sampNum_); |
| 532 |
} |
| 533 |
|
| 534 |
bool InstrumentADPCM::isSampleRepeatable() const |
| 535 |
{ |
| 536 |
return owner_->isSampleADPCMRepeatable(sampNum_); |
| 537 |
} |
| 538 |
|
| 539 |
SampleRepeatFlag InstrumentADPCM::getSampleRepeatFlag() const |
| 540 |
{ |
| 541 |
return owner_->getSampleADPCMRepeatFlag(sampNum_); |
| 542 |
} |
| 543 |
|
| 544 |
SampleRepeatRange InstrumentADPCM::getSampleRepeatRange() const |
| 545 |
{ |
| 546 |
return owner_->getSampleADPCMRepeatRange(sampNum_); |
| 547 |
} |
| 548 |
|
| 549 |
std::vector<uint8_t> InstrumentADPCM::getRawSample() const |
| 550 |
{ |
| 551 |
return owner_->getSampleADPCMRawSample(sampNum_); |
| 552 |
} |
| 553 |
|
| 554 |
size_t InstrumentADPCM::getSampleStartAddress() const |
| 555 |
{ |
| 556 |
return owner_->getSampleADPCMStartAddress(sampNum_); |
| 557 |
} |
| 558 |
|
| 559 |
size_t InstrumentADPCM::getSampleStopAddress() const |
| 560 |
{ |
| 561 |
return owner_->getSampleADPCMStopAddress(sampNum_); |
| 562 |
} |
| 563 |
|
| 564 |
std::vector<ADPCMEnvelopeUnit> InstrumentADPCM::getEnvelopeSequence() const |
| 565 |
{ |
| 566 |
return owner_->getEnvelopeADPCMSequence(envNum_); |
| 567 |
} |
| 568 |
|
| 569 |
InstrumentSequenceLoopRoot InstrumentADPCM::getEnvelopeLoopRoot() const |
| 570 |
{ |
| 571 |
return owner_->getEnvelopeADPCMLoopRoot(envNum_); |
| 572 |
} |
| 573 |
|
| 574 |
InstrumentSequenceRelease InstrumentADPCM::getEnvelopeRelease() const |
| 575 |
{ |
| 576 |
return owner_->getEnvelopeADPCMRelease(envNum_); |
| 577 |
} |
| 578 |
|
| 579 |
ADPCMEnvelopeIter InstrumentADPCM::getEnvelopeSequenceIterator() const |
| 580 |
{ |
| 581 |
return owner_->getEnvelopeADPCMIterator(envNum_); |
| 582 |
} |
| 583 |
|
| 584 |
SequenceType InstrumentADPCM::getArpeggioType() const |
| 585 |
{ |
| 586 |
return owner_->getArpeggioADPCMType(arpNum_); |
| 587 |
} |
| 588 |
|
| 589 |
std::vector<ArpeggioUnit> InstrumentADPCM::getArpeggioSequence() const |
| 590 |
{ |
| 591 |
return owner_->getArpeggioADPCMSequence(arpNum_); |
| 592 |
} |
| 593 |
|
| 594 |
InstrumentSequenceLoopRoot InstrumentADPCM::getArpeggioLoopRoot() const |
| 595 |
{ |
| 596 |
return owner_->getArpeggioADPCMLoopRoot(arpNum_); |
| 597 |
} |
| 598 |
|
| 599 |
InstrumentSequenceRelease InstrumentADPCM::getArpeggioRelease() const |
| 600 |
{ |
| 601 |
return owner_->getArpeggioADPCMRelease(arpNum_); |
| 602 |
} |
| 603 |
|
| 604 |
ArpeggioIter InstrumentADPCM::getArpeggioSequenceIterator() const |
| 605 |
{ |
| 606 |
return owner_->getArpeggioADPCMIterator(arpNum_); |
| 607 |
} |
| 608 |
|
| 609 |
SequenceType InstrumentADPCM::getPitchType() const |
| 610 |
{ |
| 611 |
return owner_->getPitchADPCMType(ptNum_); |
| 612 |
} |
| 613 |
|
| 614 |
std::vector<PitchUnit> InstrumentADPCM::getPitchSequence() const |
| 615 |
{ |
| 616 |
return owner_->getPitchADPCMSequence(ptNum_); |
| 617 |
} |
| 618 |
|
| 619 |
InstrumentSequenceLoopRoot InstrumentADPCM::getPitchLoopRoot() const |
| 620 |
{ |
| 621 |
return owner_->getPitchADPCMLoopRoot(ptNum_); |
| 622 |
} |
| 623 |
|
| 624 |
InstrumentSequenceRelease InstrumentADPCM::getPitchRelease() const |
| 625 |
{ |
| 626 |
return owner_->getPitchADPCMRelease(ptNum_); |
| 627 |
} |
| 628 |
|
| 629 |
PitchIter InstrumentADPCM::getPitchSequenceIterator() const |
| 630 |
{ |
| 631 |
return owner_->getPitchADPCMIterator(ptNum_); |
| 632 |
} |
| 633 |
|
| 634 |
std::vector<PanUnit> InstrumentADPCM::getPanSequence() const |
| 635 |
{ |
| 636 |
return owner_->getPanADPCMSequence(panNum_); |
| 637 |
} |
| 638 |
|
| 639 |
InstrumentSequenceLoopRoot InstrumentADPCM::getPanLoopRoot() const |
| 640 |
{ |
| 641 |
return owner_->getPanADPCMLoopRoot(panNum_); |
| 642 |
} |
| 643 |
|
| 644 |
InstrumentSequenceRelease InstrumentADPCM::getPanRelease() const |
| 645 |
{ |
| 646 |
return owner_->getPanADPCMRelease(panNum_); |
| 647 |
} |
| 648 |
|
| 649 |
PanIter InstrumentADPCM::getPanSequenceIterator() const |
| 650 |
{ |
| 651 |
return owner_->getPanADPCMIterator(panNum_); |
| 652 |
} |
| 653 |
|
| 654 |
/****************************************/ |
| 655 |
|
| 656 |
InstrumentDrumkit::InstrumentDrumkit(int number, const std::string& name, InstrumentsManager* owner) |
| 657 |
: AbstractInstrument(number, SoundSource::ADPCM, InstrumentType::Drumkit, name, owner) |
| 658 |
{ |
| 659 |
} |
| 660 |
|
| 661 |
AbstractInstrument* InstrumentDrumkit::clone() |
| 662 |
{ |
| 663 |
return new InstrumentDrumkit(*this); |
| 664 |
} |
| 665 |
|
| 666 |
std::vector<int> InstrumentDrumkit::getAssignedKeys() const |
| 667 |
{ |
| 668 |
return utils::getMapKeys(kit_); |
| 669 |
} |
| 670 |
|
| 671 |
void InstrumentDrumkit::setSampleEnabled(int key, bool enabled) |
| 672 |
{ |
| 673 |
if (enabled) kit_[key] = { 0, 0, PanType::CENTER }; |
| 674 |
else kit_.erase(key); |
| 675 |
} |
| 676 |
|
| 677 |
bool InstrumentDrumkit::getSampleEnabled(int key) const |
| 678 |
{ |
| 679 |
return kit_.count(key); |
| 680 |
} |
| 681 |
|
| 682 |
void InstrumentDrumkit::setSampleNumber(int key, int n) |
| 683 |
{ |
| 684 |
if (kit_.count(key)) kit_.at(key).sampNum = n; |
| 685 |
} |
| 686 |
|
| 687 |
int InstrumentDrumkit::getSampleNumber(int key) const |
| 688 |
{ |
| 689 |
return kit_.at(key).sampNum; |
| 690 |
} |
| 691 |
|
| 692 |
int InstrumentDrumkit::getSampleRootKeyNumber(int key) const |
| 693 |
{ |
| 694 |
return owner_->getSampleADPCMRootKeyNumber(kit_.at(key).sampNum); |
| 695 |
} |
| 696 |
|
| 697 |
int InstrumentDrumkit::getSampleRootDeltaN(int key) const |
| 698 |
{ |
| 699 |
return owner_->getSampleADPCMRootDeltaN(kit_.at(key).sampNum); |
| 700 |
} |
| 701 |
|
| 702 |
bool InstrumentDrumkit::isSampleRepeatable(int key) const |
| 703 |
{ |
| 704 |
return owner_->isSampleADPCMRepeatable(kit_.at(key).sampNum); |
| 705 |
} |
| 706 |
|
| 707 |
SampleRepeatFlag InstrumentDrumkit::getSampleRepeatFlag(int key) const |
| 708 |
{ |
| 709 |
return owner_->getSampleADPCMRepeatFlag(kit_.at(key).sampNum); |
| 710 |
} |
| 711 |
|
| 712 |
SampleRepeatRange InstrumentDrumkit::getSampleRepeatRange(int key) const |
| 713 |
{ |
| 714 |
return owner_->getSampleADPCMRepeatRange(kit_.at(key).sampNum); |
| 715 |
} |
| 716 |
|
| 717 |
std::vector<uint8_t> InstrumentDrumkit::getRawSample(int key) const |
| 718 |
{ |
| 719 |
return owner_->getSampleADPCMRawSample(kit_.at(key).sampNum); |
| 720 |
} |
| 721 |
|
| 722 |
size_t InstrumentDrumkit::getSampleStartAddress(int key) const |
| 723 |
{ |
| 724 |
return owner_->getSampleADPCMStartAddress(kit_.at(key).sampNum); |
| 725 |
} |
| 726 |
|
| 727 |
size_t InstrumentDrumkit::getSampleStopAddress(int key) const |
| 728 |
{ |
| 729 |
return owner_->getSampleADPCMStopAddress(kit_.at(key).sampNum); |
| 730 |
} |
| 731 |
|
| 732 |
void InstrumentDrumkit::setPitch(int key, int pitch) |
| 733 |
{ |
| 734 |
if (kit_.count(key)) kit_.at(key).pitch = pitch; |
| 735 |
} |
| 736 |
|
| 737 |
int InstrumentDrumkit::getPitch(int key) const |
| 738 |
{ |
| 739 |
return kit_.at(key).pitch; |
| 740 |
} |
| 741 |
|
| 742 |
void InstrumentDrumkit::setPan(int key, int pan) |
| 743 |
{ |
| 744 |
if (kit_.count(key)) kit_.at(key).pan = pan; |
| 745 |
} |
| 746 |
|
| 747 |
int InstrumentDrumkit::getPan(int key) const |
| 748 |
{ |
| 749 |
return kit_.at(key).pan; |
| 750 |
} |