From 8cd0a2a7dfb1e984a0c030318151524fc596ff9b Mon Sep 17 00:00:00 2001 From: Christopher Herb Date: Sat, 8 Jul 2023 07:25:13 +0200 Subject: [PATCH] stripped samplerate from constructors --- synth/midi_synth.h | 11 +++-------- synth/tx_envelope.h | 4 ++-- synth/tx_operator.h | 4 +--- synth/tx_sineosc.h | 4 ++-- synth/tx_voice.h | 7 +------ synth/voice_allocator.h | 7 ++----- 6 files changed, 11 insertions(+), 26 deletions(-) diff --git a/synth/midi_synth.h b/synth/midi_synth.h index 26064a4..6be2fd4 100644 --- a/synth/midi_synth.h +++ b/synth/midi_synth.h @@ -10,17 +10,13 @@ namespace trnr { template class midi_synth : public voice_allocator { public: - midi_synth(int _n_voices, double _samplerate, int _block_size) - : voice_allocator { _samplerate } - , m_samplerate { _samplerate } - , m_block_size { _block_size } - , m_voices_active { false } + midi_synth(int _n_voices) + : m_voices_active { false } { } - void set_samplerate(double _samplerate, int _block_size) + void set_samplerate_blocksize(double _samplerate, int _block_size) { - m_samplerate = _samplerate; m_block_size = _block_size; voice_allocator::set_samplerate(_samplerate); } @@ -87,7 +83,6 @@ public: private: std::vector m_event_queue; - double m_samplerate; int m_block_size; bool m_voices_active; }; diff --git a/synth/tx_envelope.h b/synth/tx_envelope.h index 4492be7..6cf2fe6 100644 --- a/synth/tx_envelope.h +++ b/synth/tx_envelope.h @@ -30,8 +30,8 @@ public: float release1_level; float release2_rate; - tx_envelope(double _samplerate) - : samplerate { _samplerate } + tx_envelope() + : samplerate { 44100. } , attack1_rate { 0 } , attack1_level { 0 } , attack2_rate { 0 } diff --git a/synth/tx_operator.h b/synth/tx_operator.h index 275da33..65b30da 100644 --- a/synth/tx_operator.h +++ b/synth/tx_operator.h @@ -5,11 +5,9 @@ namespace trnr { class tx_operator { public: - tx_operator(double samplerate) + tx_operator() : ratio { 1 } , amplitude { 1.0f } - , envelope(samplerate) - , oscillator(samplerate) { } diff --git a/synth/tx_sineosc.h b/synth/tx_sineosc.h index e175d4a..27ca80d 100644 --- a/synth/tx_sineosc.h +++ b/synth/tx_sineosc.h @@ -7,8 +7,8 @@ class tx_sineosc { public: bool phase_reset; - tx_sineosc(double _samplerate) - : samplerate { _samplerate } + tx_sineosc() + : samplerate { 44100 } , phase_resolution { 16.f } , phase { 0. } , history { 0. } diff --git a/synth/tx_voice.h b/synth/tx_voice.h index 214473b..8f7a6b1 100644 --- a/synth/tx_voice.h +++ b/synth/tx_voice.h @@ -8,15 +8,10 @@ namespace trnr { class tx_voice { public: - tx_voice(double samplerate) + tx_voice() : algorithm { 0 } , pitch_env_amt { 0.f } , feedback_amt { 0.f } - , pitch_env(samplerate) - , feedback_osc(samplerate) - , op1(samplerate) - , op2(samplerate) - , op3(samplerate) , bit_resolution(12.f) { } diff --git a/synth/voice_allocator.h b/synth/voice_allocator.h index c707ace..f47edbb 100644 --- a/synth/voice_allocator.h +++ b/synth/voice_allocator.h @@ -9,9 +9,8 @@ class voice_allocator { public: std::vector voices; - voice_allocator(const double& _samplerate) - : samplerate { _samplerate } - , voices(8, t_voice(_samplerate)) + voice_allocator() + : voices(8, t_voice()) { } @@ -83,14 +82,12 @@ public: void set_samplerate(double _samplerate) { - this->samplerate = _samplerate; for (int i = 0; i < voices.size(); i++) { voices.at(i).set_samplerate(_samplerate); } } private: - double samplerate; std::vector input_queue; t_voice* get_free_voice(float frequency)