From 25b398ea000b5529084d985bd14ed066a81578d3 Mon Sep 17 00:00:00 2001 From: Bent Bisballe Nyeng Date: Sun, 16 Jun 2019 10:47:33 +0200 Subject: Make max channnel count controllable through the configure script to make it possible to exceed the default 16. --- configure.ac | 8 ++++++++ drumgizmo/output/oss.cc | 3 ++- plugin/drumgizmo_plugin.cc | 6 ++++-- src/drumgizmo.cc | 2 +- src/drumgizmo.h | 9 +++++---- test/lv2.cc | 6 ++++-- 6 files changed, 24 insertions(+), 10 deletions(-) diff --git a/configure.ac b/configure.ac index ff226d0..5d8652a 100644 --- a/configure.ac +++ b/configure.ac @@ -203,6 +203,14 @@ AM_CONDITIONAL([ENABLE_PUGL_X11], [test "x$enable_gui" = "xpugl-x11"]) AM_CONDITIONAL([ENABLE_PUGL_WIN32], [test "x$enable_gui" = "xpugl-win32"]) AM_CONDITIONAL([ENABLE_PUGL_COCOA], [test "x$enable_gui" = "xpugl-cocoa"]) +dnl =========================== +dnl Custom number of outputs? +dnl =========================== +AC_ARG_ENABLE([custom-channel-count], + AS_HELP_STRING([--enable-custom-channel-count[=count]], [Compile with specified number of output channels [default=16]]),, + [enable_custom_channel_count="16"]) +AC_DEFINE_UNQUOTED([NUM_CHANNELS], [$enable_custom_channel_count], [Number of output channels]) + dnl ====================== dnl Compile unit tests dnl ====================== diff --git a/drumgizmo/output/oss.cc b/drumgizmo/output/oss.cc index 80d8d2b..cb0b896 100644 --- a/drumgizmo/output/oss.cc +++ b/drumgizmo/output/oss.cc @@ -31,10 +31,11 @@ #include #include +#include OSSOutputEngine::OSSOutputEngine() : dev{"/dev/dsp"} - , num_channels{16} + , num_channels{NUM_CHANNELS} , srate{44100} , format{AFMT_S32_NE} , data{} diff --git a/plugin/drumgizmo_plugin.cc b/plugin/drumgizmo_plugin.cc index 1d03fd2..e7bc29e 100644 --- a/plugin/drumgizmo_plugin.cc +++ b/plugin/drumgizmo_plugin.cc @@ -26,6 +26,8 @@ */ #include "drumgizmo_plugin.h" +#include + #include #include #include @@ -110,7 +112,7 @@ size_t DrumGizmoPlugin::getNumberOfAudioInputs() size_t DrumGizmoPlugin::getNumberOfAudioOutputs() { - return 16; + return NUM_CHANNELS; } std::string DrumGizmoPlugin::getId() @@ -148,7 +150,7 @@ PluginCategory DrumGizmoPlugin::getPluginCategory() return PluginCategory::Synth; } -static float g_samples[16* 4096]; +static float g_samples[NUM_CHANNELS * 4096]; void DrumGizmoPlugin::process(size_t pos, const std::vector& input_events, diff --git a/src/drumgizmo.cc b/src/drumgizmo.cc index 1e1974f..dcbb7bd 100644 --- a/src/drumgizmo.cc +++ b/src/drumgizmo.cc @@ -446,7 +446,7 @@ void DrumGizmo::setSamplerate(float samplerate) buf.reset(new sample_t[MAX_RESAMPLER_BUFFER_SIZE]); } - for(int c = 0; c < MAX_NUM_CHANNELS; ++c) + for(int c = 0; c < NUM_CHANNELS; ++c) { zita[c].reset(); auto nchan = 1u; // mono diff --git a/src/drumgizmo.h b/src/drumgizmo.h index 4592143..9d2e661 100644 --- a/src/drumgizmo.h +++ b/src/drumgizmo.h @@ -26,6 +26,8 @@ */ #pragma once +#include + #include #include #include @@ -74,7 +76,6 @@ public: void setRandomSeed(unsigned int seed); private: - static constexpr int MAX_NUM_CHANNELS = 64; static constexpr int MAX_RESAMPLER_BUFFER_SIZE = 4096 * 8; protected: @@ -83,7 +84,7 @@ protected: AudioOutputEngine& oe; AudioInputEngine& ie; - std::list< Event* > activeevents[MAX_NUM_CHANNELS]; + std::list< Event* > activeevents[NUM_CHANNELS]; bool enable_resampling{true}; @@ -101,8 +102,8 @@ protected: SettingsGetter settings_getter; Random rand; - std::array zita; - std::array, MAX_NUM_CHANNELS> resampler_input_buffer; + std::array zita; + std::array, NUM_CHANNELS> resampler_input_buffer; double ratio = 1.0; }; diff --git a/test/lv2.cc b/test/lv2.cc index 0f80dea..0c86ad2 100644 --- a/test/lv2.cc +++ b/test/lv2.cc @@ -26,6 +26,8 @@ */ #include "dgunit.h" +#include + #include #include #include @@ -379,7 +381,7 @@ public: // Port buffers: char sequence_buffer[4096]; - float pcm_buffer[16][10]; + float pcm_buffer[NUM_CHANNELS][10]; bool freeWheel = true; // Free wheel port @@ -389,7 +391,7 @@ public: res = h.connectPort((int)Ports::MidiPort, seq.data()); DGUNIT_ASSERT_EQUAL(0, res); - for(int i = 0; i < 16; ++i) + for(int i = 0; i < NUM_CHANNELS; ++i) { for(int j = 0; j < 10; ++j) { -- cgit v1.2.3