| 21 | } |
| 22 | |
| 23 | void ModMatrixRow::applyModulation() { |
| 24 | |
| 25 | if (m_active_1) { |
| 26 | // poly destination -> #VOICES modulations |
| 27 | if (m_destination_1_poly) { |
| 28 | for (int voice = 0; voice < VOICES; ++voice) { |
| 29 | if (m_scale) { |
| 30 | if (m_scale_amount >= 0) { |
| 31 | *(m_destination_1_value[voice]) += (*m_source_value[voice]) * m_mod_amount_1 * |
| 32 | fabs(m_mod_amount_1) * |
| 33 | (1 + (*m_scale_value[voice] - 1) * m_scale_amount); |
| 34 | } else { |
| 35 | *(m_destination_1_value[voice]) += (*m_source_value[voice]) * m_mod_amount_1 * |
| 36 | fabs(m_mod_amount_1) * |
| 37 | (1 + fabs(*m_scale_value[voice]) * m_scale_amount); |
| 38 | } |
| 39 | } else { |
| 40 | // DBG("MOD SLOT ACTIVE"); |
| 41 | *(m_destination_1_value[voice]) += (*m_source_value[voice]) * m_mod_amount_1 * fabs(m_mod_amount_1); |
| 42 | } |
| 43 | } |
| 44 | } else // mono destination |
| 45 | { |
| 46 | // use most recent voice for poly, for mono all #VOICES are identical so it |
| 47 | // doesnt matter |
| 48 | if (m_scale) { |
| 49 | if (m_scale_amount >= 0) { |
| 50 | *(m_destination_1_value[0]) += (*m_source_value[m_most_recent_voice]) * m_mod_amount_1 * |
| 51 | fabs(m_mod_amount_1) * |
| 52 | (1 + (*m_scale_value[m_most_recent_voice] - 1) * m_scale_amount); |
| 53 | } else { |
| 54 | *(m_destination_1_value[0]) += (*m_source_value[m_most_recent_voice]) * m_mod_amount_1 * |
| 55 | fabs(m_mod_amount_1) * |
| 56 | (1 + fabs(*m_scale_value[m_most_recent_voice]) * m_scale_amount); |
| 57 | } |
| 58 | } else { |
| 59 | //DBG("dest before: " + std::to_string(*(m_destination_1_value[0]))); |
| 60 | //DBG("mod amount: " + std::to_string(m_mod_amount_1)); |
| 61 | //DBG("rec voice: " + std::to_string(m_most_recent_voice)); |
| 62 | //DBG("source: " + std::to_string((*m_source_value[m_most_recent_voice]))); |
| 63 | |
| 64 | *(m_destination_1_value[0]) += |
| 65 | (*m_source_value[m_most_recent_voice]) * m_mod_amount_1 * fabs(m_mod_amount_1); |
| 66 | //DBG("dest after: " + std::to_string(*(m_destination_1_value[0]))); |
| 67 | } |
| 68 | } |
| 69 | } |
| 70 | |
| 71 | if (m_active_2) { |
| 72 | // poly destination -> #VOICES modulations |
| 73 | if (m_destination_2_poly) { |
| 74 | for (int voice = 0; voice < VOICES; ++voice) { |
| 75 | if (m_scale) { |
| 76 | if (m_scale_amount >= 0) { |
| 77 | *(m_destination_2_value[voice]) += (*m_source_value[voice]) * m_mod_amount_2 * |
| 78 | fabs(m_mod_amount_2) * |
| 79 | (1 + (*m_scale_value[voice] - 1) * m_scale_amount); |
| 80 | } else { |