| 43 | } |
| 44 | |
| 45 | void VoiceParam::initialize(InstPrst * prst, Division * prstDiv, InstPrst * inst, Division * instDiv, |
| 46 | Smpl * smpl, qint8 channel, qint8 key, qint8 vel, qint8 type) |
| 47 | { |
| 48 | _channel = channel; |
| 49 | _key = key; |
| 50 | _type = type; |
| 51 | _sf2Id = smpl->getId().indexSf2; |
| 52 | _presetId = (prst != nullptr ? prst->getId().indexElt : -1); |
| 53 | _wPresetNumber = (prst != nullptr ? prst->getExtraField(champ_wPreset) : -1); |
| 54 | |
| 55 | // Reset the parameters |
| 56 | for (int i = 0; i < champ_endOper; i++) |
| 57 | _parameters[i].resetComputation(); |
| 58 | |
| 59 | // Read sample properties and specify the default key / vel |
| 60 | readSmpl(smpl); |
| 61 | AttributeValue value; |
| 62 | if (_key < 0) |
| 63 | value.wValue = static_cast<quint16>(_parameters[champ_overridingRootKey].getIntValue()); |
| 64 | else |
| 65 | value.wValue = static_cast<quint16>(_key); |
| 66 | _parameters[champ_keynum].initValue(value, false); |
| 67 | if (vel < 0) |
| 68 | value.wValue = 127; |
| 69 | else |
| 70 | value.wValue = static_cast<quint16>(vel); |
| 71 | _parameters[champ_velocity].initValue(value, false); |
| 72 | |
| 73 | // Possibly add the configuration of the instrument level |
| 74 | Division * instGlobalDiv = (inst != nullptr ? inst->getGlobalDivision() : nullptr); |
| 75 | if (instDiv) |
| 76 | readDivisionAttributes(instGlobalDiv, instDiv, false); |
| 77 | |
| 78 | // Possibly add the configuration of the preset level |
| 79 | Division * prstGlobalDiv = (prst != nullptr ? prst->getGlobalDivision() : nullptr); |
| 80 | if (prstDiv) |
| 81 | readDivisionAttributes(prstGlobalDiv, prstDiv, true); |
| 82 | |
| 83 | // Initialize the modulator groups |
| 84 | if (instDiv) |
| 85 | { |
| 86 | int keyForComputation = _parameters[champ_keynum].getIntValue(); |
| 87 | int velForComputation = _parameters[champ_velocity].getIntValue(); |
| 88 | _modulatorGroupInst.initialize(_channel, _key, keyForComputation, velForComputation); |
| 89 | _modulatorGroupPrst.initialize(_channel, _key, keyForComputation, velForComputation); |
| 90 | } |
| 91 | else |
| 92 | { |
| 93 | // Sample level: no modulators |
| 94 | _modulatorGroupInst.clear(); |
| 95 | _modulatorGroupPrst.clear(); |
| 96 | } |
| 97 | |
| 98 | // Possibly load modulators from the instrument and preset levels |
| 99 | if (instDiv) |
| 100 | readDivisionModulators(instGlobalDiv, instDiv, false); |
| 101 | if (prstDiv) |
| 102 | readDivisionModulators(prstGlobalDiv, prstDiv, true); |
nothing calls this directly
no test coverage detected