From d0fcc225a1821cd76263462a194661d598e8e6e1 Mon Sep 17 00:00:00 2001 From: Christopher Herb Date: Mon, 10 Jul 2023 18:11:42 +0200 Subject: [PATCH] formatting --- synth/midi_event.h | 6 ++++-- synth/midi_synth.h | 6 +++--- synth/tx_voice.h | 38 ++++++++++++++++++++++++-------------- synth/voice_allocator.h | 2 +- 4 files changed, 32 insertions(+), 20 deletions(-) diff --git a/synth/midi_event.h b/synth/midi_event.h index cd17e30..3fa8e3b 100644 --- a/synth/midi_event.h +++ b/synth/midi_event.h @@ -33,12 +33,14 @@ public: offset = _offset; } - void make_pitch_weel(double _pitch, int _offset = 0) { + void make_pitch_weel(double _pitch, int _offset = 0) + { type = midi_event_type::pitch_wheel; data = _pitch; } - void make_mod_weel(double _mod, int _offset = 0) { + void make_mod_weel(double _mod, int _offset = 0) + { type = midi_event_type::pitch_wheel; data = _mod; } diff --git a/synth/midi_synth.h b/synth/midi_synth.h index 6524df2..01c50b1 100644 --- a/synth/midi_synth.h +++ b/synth/midi_synth.h @@ -1,9 +1,9 @@ #pragma once -#include -#include #include "ivoice.h" #include "midi_event.h" #include "voice_allocator.h" +#include +#include namespace trnr { @@ -69,7 +69,7 @@ public: } } } - + void add_event(midi_event event) { if (event.type == midi_event_type::note_on) diff --git a/synth/tx_voice.h b/synth/tx_voice.h index b2f8b00..098c6a7 100644 --- a/synth/tx_voice.h +++ b/synth/tx_voice.h @@ -1,15 +1,15 @@ #pragma once -#include "tx_sineosc.h" +#include "../util/audio_math.h" +#include "ivoice.h" #include "tx_envelope.h" #include "tx_operator.h" -#include "ivoice.h" -#include "../util/audio_math.h" +#include "tx_sineosc.h" namespace trnr { class tx_voice : public ivoice { public: - tx_voice() + tx_voice() : algorithm { 0 } , pitch_env_amt { 0.f } , feedback_amt { 0.f } @@ -33,23 +33,27 @@ public: tx_operator op2; tx_operator op3; - void note_on(int _note, float _velocity) override { + void note_on(int _note, float _velocity) override + { this->gate = true; this->trigger = true; midi_note = _note; velocity = _velocity; } - void note_off() override { + void note_off() override + { this->gate = false; } // modulates the pitch in semitones - void modulate_pitch(float _pitch) override { + void modulate_pitch(float _pitch) override + { this->pitch_mod = _pitch; } - float process_sample() override { + float process_sample() override + { float pitch_env_signal = pitch_env.process_sample(gate, trigger) * pitch_env_amt; float pitched_freq = midi_to_frequency(midi_note + pitch_mod + additional_pitch_mod) + pitch_env_signal; @@ -82,7 +86,8 @@ public: bool is_busy() override { return gate || op1.envelope.is_busy() || op2.envelope.is_busy() || op3.envelope.is_busy(); } - void set_samplerate(double samplerate) override { + void set_samplerate(double samplerate) override + { pitch_env.set_samplerate(samplerate); feedback_osc.set_samplerate(samplerate); op1.set_samplerate(samplerate); @@ -90,7 +95,8 @@ public: op3.set_samplerate(samplerate); } - void set_phase_reset(bool phase_reset) { + void set_phase_reset(bool phase_reset) + { op1.oscillator.phase_reset = phase_reset; op2.oscillator.phase_reset = phase_reset; op3.oscillator.phase_reset = phase_reset; @@ -101,7 +107,8 @@ 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 calc_algo1(const float frequency) + { float fb_freq = frequency * op3.ratio; float fb_mod_index = (feedback_amt * MOD_INDEX_COEFF); float fb_signal = feedback_osc.process_sample(trigger, fb_freq) * fb_mod_index; @@ -118,7 +125,8 @@ private: return op1.process_sample(gate, trigger, op1_freq, velocity, op2_signal) * op1.amplitude; } - float calc_algo2(const float frequency) { + float calc_algo2(const float frequency) + { float fb_freq = frequency * op3.ratio; float fb_mod_index = (feedback_amt * MOD_INDEX_COEFF); float fb_signal = feedback_osc.process_sample(trigger, fb_freq) * fb_mod_index; @@ -136,7 +144,8 @@ private: return op1_signal + op3_signal; } - float calc_algo3(const float frequency) { + float calc_algo3(const float frequency) + { float fb_freq = frequency * op3.ratio; float fb_mod_index = (feedback_amt * MOD_INDEX_COEFF); float fb_signal = feedback_osc.process_sample(trigger, fb_freq) * fb_mod_index; @@ -153,7 +162,8 @@ private: return op1_signal + op2_signal + op3_signal; } - float calc_algo4(const float frequency) { + float calc_algo4(const float frequency) + { float fb_freq = frequency * op3.ratio; float fb_mod_index = (feedback_amt * MOD_INDEX_COEFF); float fb_signal = feedback_osc.process_sample(trigger, fb_freq) * fb_mod_index; diff --git a/synth/voice_allocator.h b/synth/voice_allocator.h index aea76a2..12b2a80 100644 --- a/synth/voice_allocator.h +++ b/synth/voice_allocator.h @@ -1,6 +1,6 @@ #pragma once -#include "midi_event.h" #include "ivoice.h" +#include "midi_event.h" #include namespace trnr {