diff options
Diffstat (limited to 'drumgizmo/output')
-rw-r--r-- | drumgizmo/output/alsa.cc | 33 | ||||
-rw-r--r-- | drumgizmo/output/alsa.h | 9 | ||||
-rw-r--r-- | drumgizmo/output/jackaudio.cc | 41 | ||||
-rw-r--r-- | drumgizmo/output/jackaudio.h | 10 | ||||
-rw-r--r-- | drumgizmo/output/outputdummy.h | 5 | ||||
-rw-r--r-- | drumgizmo/output/wavfile.cc | 5 | ||||
-rw-r--r-- | drumgizmo/output/wavfile.h | 7 |
7 files changed, 77 insertions, 33 deletions
diff --git a/drumgizmo/output/alsa.cc b/drumgizmo/output/alsa.cc index 26cb0cf..c577c72 100644 --- a/drumgizmo/output/alsa.cc +++ b/drumgizmo/output/alsa.cc @@ -33,11 +33,11 @@ int const BUFFER_SIZE = 40960; struct AlsaInitError { int const code; - std::string const msg; + const std::string msg; - AlsaInitError(int op_code, std::string const &msg) : code{code}, msg{msg} {} + AlsaInitError(int op_code, const std::string &msg) : code{code}, msg{msg} {} - static inline void test(int code, std::string const &msg) + static inline void test(int code, const std::string &msg) { if (code < 0) { @@ -47,8 +47,13 @@ struct AlsaInitError }; AlsaOutputEngine::AlsaOutputEngine() - : handle{nullptr}, params{nullptr}, data{}, num_channels{0u}, - dev{"default"}, srate{44100}, frames{32} + : handle{nullptr} + , params{nullptr} + , data{} + , num_channels{0u} + , dev{"default"} + , srate{44100} + , frames{32} { } @@ -144,11 +149,18 @@ void AlsaOutputEngine::setParm(std::string parm, std::string value) } } -bool AlsaOutputEngine::start() { return true; } +bool AlsaOutputEngine::start() +{ + return true; +} -void AlsaOutputEngine::stop() {} +void AlsaOutputEngine::stop() +{ +} -void AlsaOutputEngine::pre(size_t nsamples) {} +void AlsaOutputEngine::pre(size_t nsamples) +{ +} void AlsaOutputEngine::run(int ch, sample_t *samples, size_t nsamples) { @@ -165,4 +177,7 @@ void AlsaOutputEngine::post(size_t nsamples) snd_pcm_writei(handle, data.data(), nsamples); } -size_t AlsaOutputEngine::samplerate() { return srate; } +size_t AlsaOutputEngine::samplerate() +{ + return srate; +} diff --git a/drumgizmo/output/alsa.h b/drumgizmo/output/alsa.h index 81d83cc..70b3f1f 100644 --- a/drumgizmo/output/alsa.h +++ b/drumgizmo/output/alsa.h @@ -34,7 +34,8 @@ #include "audiooutputengine.h" -class AlsaOutputEngine : public AudioOutputEngine +class AlsaOutputEngine + : public AudioOutputEngine { public: AlsaOutputEngine(); @@ -46,13 +47,13 @@ public: bool start() override; void stop() override; void pre(size_t nsamples) override; - void run(int ch, sample_t *samples, size_t nsamples) override; + void run(int ch, sample_t* samples, size_t nsamples) override; void post(size_t nsamples) override; size_t samplerate() override; private: - snd_pcm_t *handle; - snd_pcm_hw_params_t *params; + snd_pcm_t* handle; + snd_pcm_hw_params_t* params; std::vector<sample_t> data; size_t num_channels; diff --git a/drumgizmo/output/jackaudio.cc b/drumgizmo/output/jackaudio.cc index 2c80080..f92f186 100644 --- a/drumgizmo/output/jackaudio.cc +++ b/drumgizmo/output/jackaudio.cc @@ -30,12 +30,17 @@ #include "jackaudio.h" JackAudioOutputEngine::JackAudioOutputEngine(JackClient &client) - : client(client), channels{}, sema{"jackaudio"} + : client(client) + , channels{} + , sema{"jackaudio"} { client.add(*this); } -JackAudioOutputEngine::~JackAudioOutputEngine() { client.remove(*this); } +JackAudioOutputEngine::~JackAudioOutputEngine() +{ + client.remove(*this); +} bool JackAudioOutputEngine::init(Channels data) { @@ -61,7 +66,9 @@ bool JackAudioOutputEngine::init(Channels data) return true; } -void JackAudioOutputEngine::setParm(std::string parm, std::string value) {} +void JackAudioOutputEngine::setParm(std::string parm, std::string value) +{ +} bool JackAudioOutputEngine::start() { @@ -69,9 +76,13 @@ bool JackAudioOutputEngine::start() return true; } -void JackAudioOutputEngine::stop() {} +void JackAudioOutputEngine::stop() +{ +} -void JackAudioOutputEngine::pre(size_t nsamples) {} +void JackAudioOutputEngine::pre(size_t nsamples) +{ +} void JackAudioOutputEngine::run(int ch, sample_t *samples, size_t nsamples) { @@ -81,7 +92,10 @@ void JackAudioOutputEngine::run(int ch, sample_t *samples, size_t nsamples) } } -void JackAudioOutputEngine::post(size_t nsamples) { sema.wait(); } +void JackAudioOutputEngine::post(size_t nsamples) +{ + sema.wait(); +} void JackAudioOutputEngine::process(jack_nframes_t num_frames) { @@ -99,14 +113,21 @@ void JackAudioOutputEngine::process(jack_nframes_t num_frames) sema.post(); } -size_t JackAudioOutputEngine::getBufferSize() { return client.getBufferSize(); } +size_t JackAudioOutputEngine::getBufferSize() +{ + return client.getBufferSize(); +} -size_t JackAudioOutputEngine::samplerate() { return client.getSampleRate(); } +size_t JackAudioOutputEngine::samplerate() +{ + return client.getSampleRate(); +} JackAudioOutputEngine::Channel::Channel(JackClient &client, - std::string const &name, + const std::string &name, std::size_t buffer_size) - : port{client, name, JACK_DEFAULT_AUDIO_TYPE, JackPortIsOutput}, samples{} + : port{client, name, JACK_DEFAULT_AUDIO_TYPE, JackPortIsOutput} + , samples{} { samples.resize(buffer_size); } diff --git a/drumgizmo/output/jackaudio.h b/drumgizmo/output/jackaudio.h index dc66978..e15dede 100644 --- a/drumgizmo/output/jackaudio.h +++ b/drumgizmo/output/jackaudio.h @@ -31,7 +31,9 @@ #include "audiooutputengine.h" #include "../jackclient.h" -class JackAudioOutputEngine : public AudioOutputEngine, public JackProcess +class JackAudioOutputEngine + : public AudioOutputEngine + , public JackProcess { public: JackAudioOutputEngine(JackClient &client); @@ -43,7 +45,7 @@ public: bool start() override; void stop() override; void pre(size_t nsamples) override; - void run(int ch, sample_t *samples, size_t nsamples) override; + void run(int ch, sample_t* samples, size_t nsamples) override; void post(size_t nsamples) override; size_t getBufferSize() override; size_t samplerate() override; @@ -57,11 +59,11 @@ private: JackPort port; std::vector<sample_t> samples; - Channel(JackClient &client, std::string const &name, + Channel(JackClient& client, const std::string &name, std::size_t buffer_size); }; - JackClient &client; + JackClient& client; std::vector<Channel> channels; Semaphore sema; }; diff --git a/drumgizmo/output/outputdummy.h b/drumgizmo/output/outputdummy.h index cfb3754..a5ac6c9 100644 --- a/drumgizmo/output/outputdummy.h +++ b/drumgizmo/output/outputdummy.h @@ -27,7 +27,8 @@ #pragma once #include "audiooutputengine.h" -class DummyOutputEngine : public AudioOutputEngine +class DummyOutputEngine + : public AudioOutputEngine { public: DummyOutputEngine(); @@ -39,6 +40,6 @@ public: bool start() override; void stop() override; void pre(size_t nsamples) override; - void run(int ch, sample_t *samples, size_t nsamples) override; + void run(int ch, sample_t* samples, size_t nsamples) override; void post(size_t nsamples) override; }; diff --git a/drumgizmo/output/wavfile.cc b/drumgizmo/output/wavfile.cc index 9d4deb1..678bbe3 100644 --- a/drumgizmo/output/wavfile.cc +++ b/drumgizmo/output/wavfile.cc @@ -28,7 +28,10 @@ #include "wavfile.h" -WavfileOutputEngine::WavfileOutputEngine() : info{}, channels{}, file{"output"} +WavfileOutputEngine::WavfileOutputEngine() + : info{} + , channels{} + , file{"output"} { info.frames = 0; info.samplerate = 44100; diff --git a/drumgizmo/output/wavfile.h b/drumgizmo/output/wavfile.h index 7bc7666..9ed8ca7 100644 --- a/drumgizmo/output/wavfile.h +++ b/drumgizmo/output/wavfile.h @@ -32,7 +32,8 @@ #include "audiooutputengine.h" -class WavfileOutputEngine : public AudioOutputEngine +class WavfileOutputEngine + : public AudioOutputEngine { public: WavfileOutputEngine(); @@ -44,13 +45,13 @@ public: bool start() override; void stop() override; void pre(size_t nsamples) override; - void run(int ch, sample_t *samples, size_t nsamples) override; + void run(int ch, sample_t* samples, size_t nsamples) override; void post(size_t nsamples) override; size_t samplerate() override; private: SF_INFO info; - std::vector<SNDFILE *> channels; + std::vector<SNDFILE*> channels; size_t num_channels; std::string file; |