summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--drumgizmo/enginefactory.cc31
-rw-r--r--drumgizmo/enginefactory.h5
-rw-r--r--drumgizmo/input/inputdummy.h3
-rw-r--r--drumgizmo/input/jackmidi.cc30
-rw-r--r--drumgizmo/input/jackmidi.h4
-rw-r--r--drumgizmo/input/midifile.cc56
-rw-r--r--drumgizmo/jackclient.cc29
-rw-r--r--drumgizmo/jackclient.h14
-rw-r--r--drumgizmo/output/alsa.cc54
-rw-r--r--drumgizmo/output/jackaudio.cc21
-rw-r--r--drumgizmo/output/jackaudio.h6
-rw-r--r--drumgizmo/output/outputdummy.cc38
-rw-r--r--drumgizmo/output/wavfile.cc50
13 files changed, 195 insertions, 146 deletions
diff --git a/drumgizmo/enginefactory.cc b/drumgizmo/enginefactory.cc
index e88f679..63a17ba 100644
--- a/drumgizmo/enginefactory.cc
+++ b/drumgizmo/enginefactory.cc
@@ -31,9 +31,14 @@
EngineFactory::EngineFactory()
: input{}
- , output{}
+ , output
+{
+}
#ifdef USE_JACK
- , jack { nullptr }
+, jack
+{
+ nullptr
+}
#endif
{
// list available input engines
@@ -65,7 +70,7 @@ EngineFactory::EngineFactory()
#ifdef USE_JACK
void EngineFactory::prepareJack()
{
- if (jack == nullptr)
+ if(jack == nullptr)
{
jack = std::make_unique<JackClient>();
}
@@ -82,23 +87,22 @@ const std::list<std::string>& EngineFactory::getOutputEngines() const
return output;
}
-std::unique_ptr<AudioInputEngine>
-EngineFactory::createInput(const std::string& name)
+std::unique_ptr<AudioInputEngine> EngineFactory::createInput(const std::string& name)
{
#ifdef HAVE_INPUT_DUMMY
- if (name == "dummy")
+ if(name == "dummy")
{
return std::make_unique<DummyInputEngine>();
}
#endif
#ifdef HAVE_INPUT_MIDIFILE
- if (name == "midifile")
+ if(name == "midifile")
{
return std::make_unique<MidifileInputEngine>();
}
#endif
#ifdef HAVE_INPUT_JACKMIDI
- if (name == "jackmidi")
+ if(name == "jackmidi")
{
prepareJack();
return std::make_unique<JackMidiInputEngine>(*jack);
@@ -111,29 +115,28 @@ EngineFactory::createInput(const std::string& name)
return nullptr;
}
-std::unique_ptr<AudioOutputEngine>
-EngineFactory::createOutput(const std::string& name)
+std::unique_ptr<AudioOutputEngine> EngineFactory::createOutput(const std::string& name)
{
#ifdef HAVE_OUTPUT_DUMMY
- if (name == "dummy")
+ if(name == "dummy")
{
return std::make_unique<DummyOutputEngine>();
}
#endif
#ifdef HAVE_OUTPUT_WAVFILE
- if (name == "wavfile")
+ if(name == "wavfile")
{
return std::make_unique<WavfileOutputEngine>();
}
#endif
#ifdef HAVE_OUTPUT_ALSA
- if (name == "alsa")
+ if(name == "alsa")
{
return std::make_unique<AlsaOutputEngine>();
}
#endif
#ifdef HAVE_OUTPUT_JACKAUDIO
- if (name == "jackaudio")
+ if(name == "jackaudio")
{
prepareJack();
return std::make_unique<JackAudioOutputEngine>(*jack);
diff --git a/drumgizmo/enginefactory.h b/drumgizmo/enginefactory.h
index d7e63ee..01e2610 100644
--- a/drumgizmo/enginefactory.h
+++ b/drumgizmo/enginefactory.h
@@ -75,7 +75,7 @@ public:
//! Query list of available input engines' names
//! \return const reference to the list
const std::list<std::string>& getInputEngines() const;
-
+
//! Query list of available output engines' names
//! \return const reference to the list
const std::list<std::string>& getOutputEngines() const;
@@ -84,7 +84,7 @@ public:
//! \param name Name of the input engine that should be initialized
//! \return unique_ptr to input engine or nullptr if engine is not supported
std::unique_ptr<AudioInputEngine> createInput(const std::string& name);
-
+
//! Create input engine by name
//! \param name Name of the output engine that should be initialized
//! \return unique_ptr to input engine or nullptr if engine is not supported
@@ -100,5 +100,4 @@ protected:
// Utility to initialize jack (once)
void prepareJack();
#endif
-
};
diff --git a/drumgizmo/input/inputdummy.h b/drumgizmo/input/inputdummy.h
index 30d0599..27c5a43 100644
--- a/drumgizmo/input/inputdummy.h
+++ b/drumgizmo/input/inputdummy.h
@@ -27,7 +27,8 @@
#pragma once
#include <audioinputengine.h>
-class DummyInputEngine : public AudioInputEngine
+class DummyInputEngine
+ : public AudioInputEngine
{
public:
DummyInputEngine();
diff --git a/drumgizmo/input/jackmidi.cc b/drumgizmo/input/jackmidi.cc
index 4aebf69..23c0ff1 100644
--- a/drumgizmo/input/jackmidi.cc
+++ b/drumgizmo/input/jackmidi.cc
@@ -32,7 +32,7 @@
static int const NOTE_ON = 0x90;
-JackMidiInputEngine::JackMidiInputEngine(JackClient &client)
+JackMidiInputEngine::JackMidiInputEngine(JackClient& client)
: AudioInputEngineMidi{}
, JackProcess{}
, client(client)
@@ -51,19 +51,21 @@ JackMidiInputEngine::~JackMidiInputEngine()
bool JackMidiInputEngine::init(Instruments& instruments)
{
- if (!loadMidiMap(midimap, instruments)) {
- std::cerr << "[MidifileInputEngine] Failed to parse midimap '" << midimap
- << "'\n";
+ if(!loadMidiMap(midimap, instruments))
+ {
+ std::cerr << "[MidifileInputEngine] Failed to parse midimap '"
+ << midimap << "'\n";
return false;
}
port = std::make_unique<JackPort>(client, "drumgizmo_midiin",
- JACK_DEFAULT_MIDI_TYPE, JackPortIsInput);
+ JACK_DEFAULT_MIDI_TYPE,
+ JackPortIsInput);
return true;
}
void JackMidiInputEngine::setParm(std::string parm, std::string value)
{
- if (parm == "midimap")
+ if(parm == "midimap")
{
// apply midimap filename
midimap = value;
@@ -89,12 +91,12 @@ void JackMidiInputEngine::pre()
{
}
-event_t *JackMidiInputEngine::run(size_t pos, size_t len, size_t *nevents)
+event_t* JackMidiInputEngine::run(size_t pos, size_t len, size_t* nevents)
{
*nevents = listsize;
- event_t *l = list;
+ event_t* l = list;
// todo: get rid of malloc
- list = (event_t *)malloc(sizeof(event_t) * 1000);
+ list = (event_t*)malloc(sizeof(event_t) * 1000);
listsize = 0;
return l;
}
@@ -106,18 +108,18 @@ void JackMidiInputEngine::post()
void JackMidiInputEngine::process(jack_nframes_t num_frames)
{
assert(port != nullptr);
- void *buffer = jack_port_get_buffer(port->port, num_frames);
+ void* buffer = jack_port_get_buffer(port->port, num_frames);
jack_nframes_t num_events = jack_midi_get_event_count(buffer);
- for (jack_nframes_t i = 0; i < num_events; ++i)
+ for(jack_nframes_t i = 0; i < num_events; ++i)
{
jack_midi_event_t event;
jack_midi_event_get(&event, buffer, i);
- if (event.size != 3)
+ if(event.size != 3)
{
continue;
}
- if ((event.buffer[0] & NOTE_ON) != NOTE_ON)
+ if((event.buffer[0] & NOTE_ON) != NOTE_ON)
{
continue;
}
@@ -125,7 +127,7 @@ void JackMidiInputEngine::process(jack_nframes_t num_frames)
int velocity = event.buffer[2];
printf("Event key:%d vel:%d\n", key, velocity);
int k = mmap.lookup(key);
- if (k != -1 && velocity)
+ if(k != -1 && velocity)
{
list[listsize].type = TYPE_ONSET;
list[listsize].instrument = k;
diff --git a/drumgizmo/input/jackmidi.h b/drumgizmo/input/jackmidi.h
index 10111a4..da8d670 100644
--- a/drumgizmo/input/jackmidi.h
+++ b/drumgizmo/input/jackmidi.h
@@ -39,7 +39,7 @@ class JackMidiInputEngine
, public JackProcess
{
public:
- JackMidiInputEngine(JackClient &client);
+ JackMidiInputEngine(JackClient& client);
~JackMidiInputEngine();
// based on AudioInputEngineMidi
@@ -55,7 +55,7 @@ public:
void process(jack_nframes_t num_frames) override;
private:
- JackClient &client;
+ JackClient& client;
std::unique_ptr<JackPort> port;
std::size_t pos;
diff --git a/drumgizmo/input/midifile.cc b/drumgizmo/input/midifile.cc
index 7d27998..9e342e9 100644
--- a/drumgizmo/input/midifile.cc
+++ b/drumgizmo/input/midifile.cc
@@ -44,7 +44,7 @@ MidifileInputEngine::MidifileInputEngine()
MidifileInputEngine::~MidifileInputEngine()
{
- if (smf != nullptr)
+ if(smf != nullptr)
{
smf_delete(smf);
}
@@ -52,26 +52,27 @@ MidifileInputEngine::~MidifileInputEngine()
bool MidifileInputEngine::init(Instruments& instruments)
{
- if (file == "")
+ if(file == "")
{
std::cerr << "[MidifileInputEngine] Missing midi filename\n";
return false;
}
- if (midimap == "")
+ if(midimap == "")
{
std::cerr << "[MidifileInputEngine] Missing midimap filename\n";
return false;
}
smf = smf_load(file.c_str());
- if (smf == nullptr)
+ if(smf == nullptr)
{
std::cerr << "[MidifileInputEngine] Failed to load midifile '" << file
<< "'\n";
return false;
}
- if (!loadMidiMap(midimap, instruments)) {
- std::cerr << "[MidifileInputEngine] Failed to parse midimap '" << midimap
- << "'\n";
+ if(!loadMidiMap(midimap, instruments))
+ {
+ std::cerr << "[MidifileInputEngine] Failed to parse midimap '"
+ << midimap << "'\n";
return false;
}
return true;
@@ -79,29 +80,30 @@ bool MidifileInputEngine::init(Instruments& instruments)
void MidifileInputEngine::setParm(std::string parm, std::string value)
{
- if (parm == "file")
+ if(parm == "file")
{
// apply midi input filename
file = value;
}
- else if (parm == "speed")
+ else if(parm == "speed")
{
// try to apply speed
try
{
speed = std::stof(value);
}
- catch (...)
+ catch(...)
{
- std::cerr << "[MidifileInputEngine] Invalid speed " << value << "\n";
+ std::cerr << "[MidifileInputEngine] Invalid speed " << value
+ << "\n";
}
}
- else if (parm == "midimap")
+ else if(parm == "midimap")
{
// apply midimap filename
midimap = value;
}
- else if (parm == "loop")
+ else if(parm == "loop")
{
// apply looping
loop = true;
@@ -126,34 +128,34 @@ void MidifileInputEngine::pre()
{
}
-event_t *MidifileInputEngine::run(size_t pos, size_t len, size_t *nevents)
+event_t* MidifileInputEngine::run(size_t pos, size_t len, size_t* nevents)
{
- event_t *evs{nullptr};
+ event_t* evs{nullptr};
size_t num_events{0u};
double current_max_time = (1.0 + pos + len) / (44100.0 / speed);
current_max_time -= offset;
// double cur_min_time = (double)(pos) / (44100.0 / speed);
- if (!current_event)
+ if(!current_event)
{
current_event = smf_get_next_event(smf);
}
- while (current_event && current_event->time_seconds < current_max_time)
+ while(current_event && current_event->time_seconds < current_max_time)
{
- if (!smf_event_is_metadata(current_event))
+ if(!smf_event_is_metadata(current_event))
{
- if ((current_event->midi_buffer_length == 3) &&
+ if((current_event->midi_buffer_length == 3) &&
((current_event->midi_buffer[0] & NOTE_ON) == NOTE_ON) &&
(track == -1 || current_event->track_number == track) &&
current_event->midi_buffer[2] > 0)
{
- if (evs == nullptr)
+ if(evs == nullptr)
{
// todo: get rid of malloc
- evs = (event_t *)malloc(sizeof(event_t) * 1000);
+ evs = (event_t*)malloc(sizeof(event_t) * 1000);
}
int key = current_event->midi_buffer[1];
@@ -164,13 +166,13 @@ event_t *MidifileInputEngine::run(size_t pos, size_t len, size_t *nevents)
evs[num_events].offset = evpos - pos;
int i = mmap.lookup(key);
- if (i != -1)
+ if(i != -1)
{
evs[num_events].instrument = i;
evs[num_events].velocity = velocity / 127.0;
++num_events;
- if (num_events > 999)
+ if(num_events > 999)
{
fprintf(stderr, "PANIC!\n");
break;
@@ -182,19 +184,19 @@ event_t *MidifileInputEngine::run(size_t pos, size_t len, size_t *nevents)
current_event = smf_get_next_event(smf);
}
- if (!current_event)
+ if(!current_event)
{
- if (loop)
+ if(loop)
{
smf_rewind(smf);
offset += current_max_time;
}
else
{
- if (evs == nullptr)
+ if(evs == nullptr)
{
// todo: get rid of malloc
- evs = (event_t *)malloc(sizeof(event_t) * 1000);
+ evs = (event_t*)malloc(sizeof(event_t) * 1000);
}
evs[num_events].type = TYPE_STOP;
evs[num_events].offset = len - 1;
diff --git a/drumgizmo/jackclient.cc b/drumgizmo/jackclient.cc
index 042329c..7277296 100644
--- a/drumgizmo/jackclient.cc
+++ b/drumgizmo/jackclient.cc
@@ -28,12 +28,14 @@
#include "jackclient.h"
-JackProcess::~JackProcess() {}
+JackProcess::~JackProcess()
+{
+}
// --------------------------------------------------------------------
-JackPort::JackPort(JackClient &client, const std::string &name,
- const char *type, JackPortFlags flags)
+JackPort::JackPort(JackClient& client, const std::string& name,
+ const char* type, JackPortFlags flags)
: client{client.client} // register jack port for given client
, port{jack_port_register(this->client, name.c_str(), type, flags, 0)}
{
@@ -41,7 +43,7 @@ JackPort::JackPort(JackClient &client, const std::string &name,
JackPort::~JackPort()
{
- if (port != nullptr)
+ if(port != nullptr)
{
assert(client != nullptr);
jack_port_unregister(client, port);
@@ -50,15 +52,12 @@ JackPort::~JackPort()
// --------------------------------------------------------------------
-static int _wrap_jack_process(jack_nframes_t nframes, void *arg)
+static int _wrap_jack_process(jack_nframes_t nframes, void* arg)
{
- return static_cast<JackClient *>(arg)->process(nframes);
+ return static_cast<JackClient*>(arg)->process(nframes);
}
-JackClient::JackClient()
- : client{nullptr}
- , processes{}
- , is_active{false}
+JackClient::JackClient() : client{nullptr}, processes{}, is_active{false}
{
jack_status_t status;
client = jack_client_open("DrumGizmo", JackNullOption, &status);
@@ -67,25 +66,25 @@ JackClient::JackClient()
JackClient::~JackClient()
{
- if (client != nullptr)
+ if(client != nullptr)
{
jack_client_close(client);
}
}
-void JackClient::add(JackProcess &process)
+void JackClient::add(JackProcess& process)
{
processes.insert(&process);
}
-void JackClient::remove(JackProcess &process)
+void JackClient::remove(JackProcess& process)
{
processes.erase(&process);
}
void JackClient::activate()
{
- if (!is_active)
+ if(!is_active)
{
jack_activate(client);
}
@@ -94,7 +93,7 @@ void JackClient::activate()
int JackClient::process(jack_nframes_t num_frames)
{
- for (auto& ptr : processes)
+ for(auto& ptr : processes)
{
ptr->process(num_frames);
}
diff --git a/drumgizmo/jackclient.h b/drumgizmo/jackclient.h
index b35c978..ea181c8 100644
--- a/drumgizmo/jackclient.h
+++ b/drumgizmo/jackclient.h
@@ -47,12 +47,12 @@ public:
// RAII-wrapper for jack_port_t
struct JackPort
{
- JackPort(JackClient &client, const std::string &name, const char *type,
+ JackPort(JackClient& client, const std::string& name, const char* type,
JackPortFlags flags);
~JackPort();
- jack_client_t *const client;
- jack_port_t *const port;
+ jack_client_t* const client;
+ jack_port_t* const port;
};
// --------------------------------------------------------------------
@@ -65,15 +65,15 @@ public:
JackClient();
~JackClient();
- void add(JackProcess &process);
- void remove(JackProcess &process);
+ void add(JackProcess& process);
+ void remove(JackProcess& process);
void activate();
int process(jack_nframes_t num_frames);
std::size_t getBufferSize() const;
std::size_t getSampleRate() const;
private:
- jack_client_t *client;
- std::set<JackProcess *> processes;
+ jack_client_t* client;
+ std::set<JackProcess*> processes;
bool is_active;
};
diff --git a/drumgizmo/output/alsa.cc b/drumgizmo/output/alsa.cc
index c577c72..8e6e4a9 100644
--- a/drumgizmo/output/alsa.cc
+++ b/drumgizmo/output/alsa.cc
@@ -35,11 +35,15 @@ struct AlsaInitError
int const code;
const std::string msg;
- AlsaInitError(int op_code, const std::string &msg) : code{code}, msg{msg} {}
+ AlsaInitError(int op_code, const std::string& msg)
+ : code{code}
+ , msg{msg}
+ {
+ }
- static inline void test(int code, const std::string &msg)
+ static inline void test(int code, const std::string& msg)
{
- if (code < 0)
+ if(code < 0)
{
throw AlsaInitError(code, msg);
}
@@ -61,7 +65,7 @@ AlsaOutputEngine::~AlsaOutputEngine()
{
// note: do NOT release `params`, it was allocated by `alloca()`
- if (handle != nullptr)
+ if(handle != nullptr)
{
snd_pcm_close(handle);
}
@@ -72,10 +76,11 @@ bool AlsaOutputEngine::init(Channels channels)
// try to initialize alsa
try
{
- int value = snd_pcm_open(&handle, dev.c_str(), SND_PCM_STREAM_PLAYBACK, 0);
+ int value =
+ snd_pcm_open(&handle, dev.c_str(), SND_PCM_STREAM_PLAYBACK, 0);
AlsaInitError::test(value, "snd_pcm_open");
num_channels = channels.size();
- if (handle == nullptr)
+ if(handle == nullptr)
{
std::cerr << "[AlsaOutputEngine] Failed to acquire "
<< "hardware handle\n";
@@ -86,21 +91,23 @@ bool AlsaOutputEngine::init(Channels channels)
value = snd_pcm_hw_params_any(handle, params);
AlsaInitError::test(value, "snd_pcm_hw_params_any");
- value = snd_pcm_hw_params_set_access(handle, params,
- SND_PCM_ACCESS_RW_INTERLEAVED);
+ value = snd_pcm_hw_params_set_access(
+ handle, params, SND_PCM_ACCESS_RW_INTERLEAVED);
AlsaInitError::test(value, "snd_pcm_hw_params_set_access");
- value = snd_pcm_hw_params_set_format(handle, params, SND_PCM_FORMAT_FLOAT);
+ value =
+ snd_pcm_hw_params_set_format(handle, params, SND_PCM_FORMAT_FLOAT);
AlsaInitError::test(value, "snd_pcm_hw_params_set_format");
value = snd_pcm_hw_params_set_channels(handle, params, num_channels);
AlsaInitError::test(value, "snd_pcm_hw_params_set_channels");
value = snd_pcm_hw_params_set_rate_near(handle, params, &srate, 0);
AlsaInitError::test(value, "snd_pcm_hw_params_set_rate_near");
- value = snd_pcm_hw_params_set_period_size_near(handle, params, &frames, 0);
+ value =
+ snd_pcm_hw_params_set_period_size_near(handle, params, &frames, 0);
AlsaInitError::test(value, "snd_pcm_hw_params_set_period_size_near");
value = snd_pcm_hw_params(handle, params);
AlsaInitError::test(value, "snd_pcm_hw_params");
}
- catch (AlsaInitError const &error)
+ catch(AlsaInitError const& error)
{
std::cerr << "[AlsaOutputEngine] " << error.msg
<< " failed: " << snd_strerror(error.code) << std::endl;
@@ -115,42 +122,45 @@ bool AlsaOutputEngine::init(Channels channels)
void AlsaOutputEngine::setParm(std::string parm, std::string value)
{
- if (parm == "dev")
+ if(parm == "dev")
{
// apply hardware device name
dev = value;
}
- else if (parm == "frames")
+ else if(parm == "frames")
{
// try to apply hardware buffer size
try
{
frames = std::stoi(value);
}
- catch (...)
+ catch(...)
{
- std::cerr << "[AlsaOutputEngine] Invalid buffer size " << value << "\n";
+ std::cerr << "[AlsaOutputEngine] Invalid buffer size " << value
+ << "\n";
}
}
- else if (parm == "srate")
+ else if(parm == "srate")
{
try
{
srate = std::stoi(value);
}
- catch (...)
+ catch(...)
{
- std::cerr << "[AlsaOutputEngine] Invalid samplerate " << value << "\n";
+ std::cerr << "[AlsaOutputEngine] Invalid samplerate " << value
+ << "\n";
}
}
else
{
- std::cerr << "[AlsaOutputEngine] Unsupported parameter '" << parm << "'\n";
+ std::cerr << "[AlsaOutputEngine] Unsupported parameter '" << parm
+ << "'\n";
}
}
bool AlsaOutputEngine::start()
-{
+{
return true;
}
@@ -162,10 +172,10 @@ void AlsaOutputEngine::pre(size_t nsamples)
{
}
-void AlsaOutputEngine::run(int ch, sample_t *samples, size_t nsamples)
+void AlsaOutputEngine::run(int ch, sample_t* samples, size_t nsamples)
{
// Write channel data in interleaved buffer
- for (auto i = 0u; i < nsamples; ++i)
+ for(auto i = 0u; i < nsamples; ++i)
{
data[i * num_channels + ch] = samples[i];
}
diff --git a/drumgizmo/output/jackaudio.cc b/drumgizmo/output/jackaudio.cc
index fd60a2a..53ea330 100644
--- a/drumgizmo/output/jackaudio.cc
+++ b/drumgizmo/output/jackaudio.cc
@@ -29,7 +29,7 @@
#include "jackaudio.h"
-JackAudioOutputEngine::JackAudioOutputEngine(JackClient &client)
+JackAudioOutputEngine::JackAudioOutputEngine(JackClient& client)
: AudioOutputEngine{}
, client(client)
, channels{}
@@ -50,13 +50,13 @@ bool JackAudioOutputEngine::init(Channels data)
auto i = 0u;
auto const buffer_size = getBufferSize();
- for (auto const &elem : data)
+ for(auto const& elem : data)
{
auto name = std::to_string(i) + "-" + elem.name;
// initialize new channel
channels.emplace_back(client, name, buffer_size);
- if (channels.back().port.port == nullptr)
+ if(channels.back().port.port == nullptr)
{
std::cerr << "[JackAudioOutputEngine] Cannot create jack "
<< "port for channel #" << i << "\n";
@@ -85,9 +85,9 @@ void JackAudioOutputEngine::pre(size_t nsamples)
{
}
-void JackAudioOutputEngine::run(int ch, sample_t *samples, size_t nsamples)
+void JackAudioOutputEngine::run(int ch, sample_t* samples, size_t nsamples)
{
- for (auto i = 0u; i < nsamples; ++i)
+ for(auto i = 0u; i < nsamples; ++i)
{
channels[ch].samples[i] = samples[i];
}
@@ -102,11 +102,10 @@ void JackAudioOutputEngine::process(jack_nframes_t num_frames)
{
assert(num_frames == getBufferSize());
- for (auto &channel : channels)
+ for(auto& channel : channels)
{
- auto ptr = static_cast<jack_default_audio_sample_t *>(
- jack_port_get_buffer(channel.port.port, num_frames));
- for (auto i = 0u; i < num_frames; ++i)
+ auto ptr = static_cast<jack_default_audio_sample_t*>(jack_port_get_buffer(channel.port.port, num_frames));
+ for(auto i = 0u; i < num_frames; ++i)
{
ptr[i] = channel.samples[i];
}
@@ -124,8 +123,8 @@ size_t JackAudioOutputEngine::samplerate()
return client.getSampleRate();
}
-JackAudioOutputEngine::Channel::Channel(JackClient &client,
- const std::string &name,
+JackAudioOutputEngine::Channel::Channel(JackClient& client,
+ const std::string& name,
std::size_t buffer_size)
: port{client, name, JACK_DEFAULT_AUDIO_TYPE, JackPortIsOutput}
, samples{}
diff --git a/drumgizmo/output/jackaudio.h b/drumgizmo/output/jackaudio.h
index e15dede..3408272 100644
--- a/drumgizmo/output/jackaudio.h
+++ b/drumgizmo/output/jackaudio.h
@@ -36,7 +36,7 @@ class JackAudioOutputEngine
, public JackProcess
{
public:
- JackAudioOutputEngine(JackClient &client);
+ JackAudioOutputEngine(JackClient& client);
~JackAudioOutputEngine();
// based on AudioOutputEngine
@@ -59,8 +59,8 @@ private:
JackPort port;
std::vector<sample_t> samples;
- Channel(JackClient& client, const std::string &name,
- std::size_t buffer_size);
+ Channel(JackClient& client, const std::string& name,
+ std::size_t buffer_size);
};
JackClient& client;
diff --git a/drumgizmo/output/outputdummy.cc b/drumgizmo/output/outputdummy.cc
index 3a3d6a0..2a01cd8 100644
--- a/drumgizmo/output/outputdummy.cc
+++ b/drumgizmo/output/outputdummy.cc
@@ -26,20 +26,40 @@
*/
#include "outputdummy.h"
-DummyOutputEngine::DummyOutputEngine() {}
+DummyOutputEngine::DummyOutputEngine()
+{
+}
-DummyOutputEngine::~DummyOutputEngine() {}
+DummyOutputEngine::~DummyOutputEngine()
+{
+}
-bool DummyOutputEngine::init(Channels data) { return true; }
+bool DummyOutputEngine::init(Channels data)
+{
+ return true;
+}
-void DummyOutputEngine::setParm(std::string parm, std::string value) {}
+void DummyOutputEngine::setParm(std::string parm, std::string value)
+{
+}
-bool DummyOutputEngine::start() { return true; }
+bool DummyOutputEngine::start()
+{
+ return true;
+}
-void DummyOutputEngine::stop() {}
+void DummyOutputEngine::stop()
+{
+}
-void DummyOutputEngine::pre(size_t nsamples) {}
+void DummyOutputEngine::pre(size_t nsamples)
+{
+}
-void DummyOutputEngine::run(int ch, sample_t *samples, size_t nsamples) {}
+void DummyOutputEngine::run(int ch, sample_t* samples, size_t nsamples)
+{
+}
-void DummyOutputEngine::post(size_t nsamples) {}
+void DummyOutputEngine::post(size_t nsamples)
+{
+}
diff --git a/drumgizmo/output/wavfile.cc b/drumgizmo/output/wavfile.cc
index faba69d..7035080 100644
--- a/drumgizmo/output/wavfile.cc
+++ b/drumgizmo/output/wavfile.cc
@@ -44,9 +44,9 @@ WavfileOutputEngine::WavfileOutputEngine()
WavfileOutputEngine::~WavfileOutputEngine()
{
- for (auto &ptr : channels)
+ for(auto& ptr : channels)
{
- if (ptr != nullptr)
+ if(ptr != nullptr)
{
sf_close(ptr);
}
@@ -55,13 +55,14 @@ WavfileOutputEngine::~WavfileOutputEngine()
bool WavfileOutputEngine::init(Channels data)
{
- channels.clear(), channels.resize(data.size()); // value-initialized with null
- for (auto i = 0u; i < data.size(); ++i)
+ channels.clear();
+ channels.resize(data.size()); // value-initialized with null
+ for(auto i = 0u; i < data.size(); ++i)
{
// write channel to file
auto fname = file + data[i].name + "-" + std::to_string(i) + ".wav";
channels[i] = sf_open(fname.c_str(), SFM_WRITE, &info);
- if (channels[i] == nullptr)
+ if(channels[i] == nullptr)
{
std::cerr << "[WaffileOutputEngine] Failed to initialize "
<< "channel #" << i << "\n";
@@ -73,21 +74,22 @@ bool WavfileOutputEngine::init(Channels data)
void WavfileOutputEngine::setParm(std::string parm, std::string value)
{
- if (parm == "file")
+ if(parm == "file")
{
// apply output filename prefix
file = value;
}
- else if (parm == "srate")
+ else if(parm == "srate")
{
// try to apply samplerate
try
{
info.samplerate = std::stoi(value);
}
- catch (...)
+ catch(...)
{
- std::cerr << "[WavfileOutputEngine] Invalid samplerate " << value << "\n";
+ std::cerr << "[WavfileOutputEngine] Invalid samplerate " << value
+ << "\n";
}
}
else
@@ -97,24 +99,36 @@ void WavfileOutputEngine::setParm(std::string parm, std::string value)
}
}
-bool WavfileOutputEngine::start() { return true; }
+bool WavfileOutputEngine::start()
+{
+ return true;
+}
-void WavfileOutputEngine::stop() {}
+void WavfileOutputEngine::stop()
+{
+}
-void WavfileOutputEngine::pre(size_t nsamples) {}
+void WavfileOutputEngine::pre(size_t nsamples)
+{
+}
-void WavfileOutputEngine::run(int ch, sample_t *samples, size_t nsamples)
+void WavfileOutputEngine::run(int ch, sample_t* samples, size_t nsamples)
{
- if (static_cast<unsigned int>(ch) >= channels.size())
+ if(static_cast<unsigned int>(ch) >= channels.size())
{
- std::cerr << "[WavfileOutputEngine] cannot access channel #" << ch << " ("
- << channels.size() << " channels available)\n";
+ std::cerr << "[WavfileOutputEngine] cannot access channel #" << ch
+ << " (" << channels.size() << " channels available)\n";
return;
}
sf_writef_float(channels[ch], samples, nsamples);
}
-void WavfileOutputEngine::post(size_t nsamples) {}
+void WavfileOutputEngine::post(size_t nsamples)
+{
+}
-size_t WavfileOutputEngine::samplerate() { return info.samplerate; }
+size_t WavfileOutputEngine::samplerate()
+{
+ return info.samplerate;
+}