| 386 | } |
| 387 | |
| 388 | void Synth::configure(SynthConfig * configuration) |
| 389 | { |
| 390 | this->stop(true, true); |
| 391 | _configuration.copy(configuration); |
| 392 | |
| 393 | // Update reverb and chorus |
| 394 | |
| 395 | // Possibly wait if another thread is using the reverb or the chorus |
| 396 | _internalConfiguration.reverbOn = false; |
| 397 | _internalConfiguration.chorusOn = false; |
| 398 | while (!_effectsInUse.testAndSetRelaxed(0, 1)) |
| 399 | QThread::msleep(2); |
| 400 | |
| 401 | _internalConfiguration.reverbOn = _configuration.revLevel > 0; |
| 402 | _reverb.setEffectMix(0.01 * _configuration.revLevel); |
| 403 | _reverb.setRoomSize(0.01 * _configuration.revSize); |
| 404 | _reverb.setWidth(0.01 * _configuration.revWidth); |
| 405 | _reverb.setDamping(0.01 * _configuration.revDamping); |
| 406 | |
| 407 | _internalConfiguration.chorusOn = _configuration.choLevel > 0; |
| 408 | _chorusRevL.setEffectMix(0.005 * _configuration.choLevel); |
| 409 | _chorusRevL.setModDepth(0.00025 * _configuration.choDepth); |
| 410 | _chorusRevL.setModFrequency(0.06667 * _configuration.choFrequency); |
| 411 | _chorusRevR.setEffectMix(0.005 * _configuration.choLevel); |
| 412 | _chorusRevR.setModDepth(0.00025 * _configuration.choDepth); |
| 413 | _chorusRevR.setModFrequency(0.06667 * _configuration.choFrequency); |
| 414 | _chorusL.setEffectMix(0.005 * _configuration.choLevel); |
| 415 | _chorusL.setModDepth(0.00025 * _configuration.choDepth); |
| 416 | _chorusL.setModFrequency(0.06667 * _configuration.choFrequency); |
| 417 | _chorusR.setEffectMix(0.005 * _configuration.choLevel); |
| 418 | _chorusR.setModDepth(0.00025 * _configuration.choDepth); |
| 419 | _chorusR.setModFrequency(0.06667 * _configuration.choFrequency); |
| 420 | _effectsInUse.storeRelaxed(0); |
| 421 | |
| 422 | // Update the reference pitch and temperament |
| 423 | Voice::setReferencePitch(_configuration.referencePitch); |
| 424 | |
| 425 | if (_configuration.temperament.count() == 14) |
| 426 | { |
| 427 | float temperament[12]; |
| 428 | for (int i = 1; i < 13; i++) |
| 429 | temperament[i - 1] = _configuration.temperament[i].toFloat(); |
| 430 | int temperamentRelativeKey = _configuration.temperament[13].toInt() % 12; |
| 431 | Voice::setTemperament(temperament, temperamentRelativeKey); |
| 432 | } |
| 433 | else |
| 434 | { |
| 435 | float temperament[12]; |
| 436 | memset(temperament, 0, 12 * sizeof(float)); |
| 437 | Voice::setTemperament(temperament, 0); |
| 438 | } |
| 439 | } |
| 440 | |
| 441 | void Synth::setIMidiValues(IMidiValues * midiValues) |
| 442 | { |
no test coverage detected