From 2faf4657dc858831b7c86646b1ecec05519a3b52 Mon Sep 17 00:00:00 2001 From: heck Date: Sun, 22 Sep 2024 20:09:51 +0200 Subject: [PATCH] globals.hh - group audio related constants by prefix --- src/globals.hh | 5 +++-- src/instr_abstract.hh | 2 +- src/main_perkons.cc | 9 ++++----- src/track.hh | 4 ++-- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/globals.hh b/src/globals.hh index 74620dd..34723ce 100644 --- a/src/globals.hh +++ b/src/globals.hh @@ -13,8 +13,9 @@ namespace Heck { constexpr int PIN_BUTTON_CLEAR = 27; } - constexpr int BUFFERSIZE = 4; - constexpr int SAMPLERATE = 48000; + + constexpr int AUDIO_BUFFERSIZE = 4; + constexpr int AUDIO_SAMPLERATE = 48000; constexpr int TRACK_COUNT = 4; namespace MIDI_Mapping { diff --git a/src/instr_abstract.hh b/src/instr_abstract.hh index 0a2d45e..40c9769 100644 --- a/src/instr_abstract.hh +++ b/src/instr_abstract.hh @@ -5,7 +5,7 @@ namespace Heck { namespace Instrument { - static int samplerate = Constants::SAMPLERATE; + static int samplerate = Constants::AUDIO_SAMPLERATE; class AbstractInstrument { public: diff --git a/src/main_perkons.cc b/src/main_perkons.cc index 28e45c4..bd1c9a6 100644 --- a/src/main_perkons.cc +++ b/src/main_perkons.cc @@ -66,11 +66,11 @@ namespace Heck { but_rec.Init(hw.GetPin(Constants::Hardware::PIN_BUTTON_RECORD), 0); but_clear.Init(hw.GetPin(Constants::Hardware::PIN_BUTTON_CLEAR), 0); - hw.PrintLine("Setting Blocksize: %i", Constants::BUFFERSIZE); - hw.SetAudioBlockSize(Constants::BUFFERSIZE); + hw.PrintLine("Setting Blocksize: %i", Constants::AUDIO_BUFFERSIZE); + hw.SetAudioBlockSize(Constants::AUDIO_BUFFERSIZE); - hw.PrintLine("Setting Samplerate: %i", Constants::SAMPLERATE); - switch (Constants::SAMPLERATE) { + hw.PrintLine("Setting Samplerate: %i", Constants::AUDIO_SAMPLERATE); + switch (Constants::AUDIO_SAMPLERATE) { case 8000: hw.SetAudioSampleRate(ld::SaiHandle::Config::SampleRate::SAI_8KHZ); break; @@ -95,7 +95,6 @@ namespace Heck { hw.PrintLine("Initializing MIDI"); ld::MidiUartHandler::Config midi_config{}; midi.Init(midi_config); -// midi.realtime_callback = &midi_realtime_handler; init_tracks(); diff --git a/src/track.hh b/src/track.hh index 2479743..362f32c 100644 --- a/src/track.hh +++ b/src/track.hh @@ -16,7 +16,7 @@ namespace Heck { instrument.reset(&instr); // Env - decay_.Init(Constants::SAMPLERATE); + decay_.Init(Constants::AUDIO_SAMPLERATE); decay_.SetTime(dsp::ADENV_SEG_ATTACK, .0001); decay_.SetTime(dsp::ADENV_SEG_DECAY, 0.1); decay_.SetMax(1); @@ -27,7 +27,7 @@ namespace Heck { ctl_volume_ = 0.; // Filter - ladder_.Init(Constants::SAMPLERATE); + ladder_.Init(Constants::AUDIO_SAMPLERATE); ladder_.SetFilterMode(daisysp::LadderFilter::FilterMode::LP24); ladder_.SetRes(0.4); ladder_.SetInputDrive(1.3);