From ec9f9cfe169f7fca3083b5792f9d72dbf3af7f08 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Nusser?= Date: Fri, 22 Apr 2016 10:58:40 +0200 Subject: A little refactoring for drumgizmo.cc (premium non-breaking changes) --- src/drumgizmo.cc | 8 ++++---- src/drumgizmo.h | 9 ++++++--- 2 files changed, 10 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/drumgizmo.cc b/src/drumgizmo.cc index aa6be23..85f251b 100644 --- a/src/drumgizmo.cc +++ b/src/drumgizmo.cc @@ -107,9 +107,9 @@ bool DrumGizmo::loadkit(std::string file) loader.loadKit(&kit); #ifdef WITH_RESAMPLER - for(int i = 0; i < MAX_NUM_CHANNELS; ++i) + for(auto& chresampler: resampler) { - resampler[i].setup(kit.getSamplerate(), settings.samplerate.load()); + chresampler.setup(kit.getSamplerate(), settings.samplerate.load()); } #endif/*WITH_RESAMPLER*/ @@ -602,9 +602,9 @@ void DrumGizmo::setSamplerate(int samplerate) DEBUG(dgeditor, "%s samplerate: %d\n", __PRETTY_FUNCTION__, samplerate); settings.samplerate.store(samplerate); #ifdef WITH_RESAMPLER - for(int i = 0; i < MAX_NUM_CHANNELS; ++i) + for(auto& chresampler: resampler) { - resampler[i].setup(kit.getSamplerate(), settings.samplerate.load()); + chresampler.setup(kit.getSamplerate(), settings.samplerate.load()); } if(resampler[0].getRatio() != 1) { diff --git a/src/drumgizmo.h b/src/drumgizmo.h index 7af5dbb..13c657d 100644 --- a/src/drumgizmo.h +++ b/src/drumgizmo.h @@ -42,9 +42,7 @@ #include "configfile.h" #include "settings.h" -#define MAX_NUM_CHANNELS 64 #define REFSFILE "refs.conf" -#define RESAMPLER_INPUT_BUFFER 64 class DrumGizmo { @@ -73,6 +71,11 @@ public: void setFreeWheel(bool freewheel); +private: + static const int MAX_NUM_CHANNELS = 64; + static const int RESAMPLER_OUTPUT_BUFFER = 4096; + static const int RESAMPLER_INPUT_BUFFER = 64; + protected: DrumKitLoader loader; @@ -85,7 +88,7 @@ protected: std::list< Event* > activeevents[MAX_NUM_CHANNELS]; CHResampler resampler[MAX_NUM_CHANNELS]; - sample_t resampler_output_buffer[MAX_NUM_CHANNELS][4096]; + sample_t resampler_output_buffer[MAX_NUM_CHANNELS][RESAMPLER_OUTPUT_BUFFER]; sample_t resampler_input_buffer[MAX_NUM_CHANNELS][RESAMPLER_INPUT_BUFFER]; std::map audiofiles; -- cgit v1.2.3