access pitch modulation through function

This commit is contained in:
Christopher Herb
2023-07-10 17:25:50 +02:00
parent bc213362f0
commit f954c5b47c
2 changed files with 9 additions and 4 deletions

View File

@@ -20,8 +20,7 @@ public:
bool trigger = false;
int midi_note = 0;
float velocity = 1.f;
float pitch_mod = 0.f; // modulates pitch in semi-tones
float pitch_mod2 = 0.f; // modulates pitch in frequency
float additional_pitch_mod = 0.f; // modulates pitch in frequency
int algorithm;
float pitch_env_amt;
@@ -44,9 +43,14 @@ public:
this->gate = false;
}
// modulates the pitch in semitones
void modulate_pitch(float pitch) {
this->pitch_mod = pitch;
}
float process_sample() {
float pitch_env_signal = pitch_env.process_sample(gate, trigger) * pitch_env_amt;
float pitched_freq = midi_to_frequency(midi_note + pitch_mod) + pitch_env_signal + pitch_mod2;
float pitched_freq = midi_to_frequency(midi_note + pitch_mod) + pitch_env_signal + additional_pitch_mod;
float output = 0.f;
@@ -94,6 +98,7 @@ public:
private:
const float MOD_INDEX_COEFF = 4.f;
float pitch_mod = 0.f; // modulates pitch in semi-tones
float calc_algo1(const float frequency) {
float fb_freq = frequency * op3.ratio;

View File

@@ -137,7 +137,7 @@ private:
note_off(event);
break;
case midi_event_type::pitch_wheel:
access([&event](t_voice& voice) { voice.pitch_mod = event.data; });
access([&event](t_voice& voice) { voice.modulate_pitch(event.data); });
break;
default:
break;