From 100e2d3bd46f64df730c8a375559680c577036ef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20Gl=C3=B6ckner?= Date: Mon, 25 Jan 2016 14:14:22 +0100 Subject: applied clang-format --- drumgizmo/output/wavfile.cc | 88 +++++++++++++++++++++++---------------------- 1 file changed, 46 insertions(+), 42 deletions(-) (limited to 'drumgizmo/output/wavfile.cc') diff --git a/drumgizmo/output/wavfile.cc b/drumgizmo/output/wavfile.cc index d8b8d99..9d4deb1 100644 --- a/drumgizmo/output/wavfile.cc +++ b/drumgizmo/output/wavfile.cc @@ -28,10 +28,8 @@ #include "wavfile.h" -WavfileOutputEngine::WavfileOutputEngine() - : info{} - , channels{} - , file{"output"} { +WavfileOutputEngine::WavfileOutputEngine() : info{}, channels{}, file{"output"} +{ info.frames = 0; info.samplerate = 44100; info.channels = 1; @@ -40,73 +38,79 @@ WavfileOutputEngine::WavfileOutputEngine() info.seekable = 0; } -WavfileOutputEngine::~WavfileOutputEngine() { - for (auto& ptr: channels) { - if (ptr != nullptr) { +WavfileOutputEngine::~WavfileOutputEngine() +{ + for (auto &ptr : channels) + { + if (ptr != nullptr) + { sf_close(ptr); } } } -bool WavfileOutputEngine::init(Channels data) { - channels.clear(), - channels.resize(data.size()); // value-initialized with null - for (auto i = 0u; i < data.size(); ++i) { +bool WavfileOutputEngine::init(Channels data) +{ + 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"; + << "channel #" << i << "\n"; return false; } } return true; } -void WavfileOutputEngine::setParm(std::string parm, std::string value) { - if (parm == "file") { +void WavfileOutputEngine::setParm(std::string parm, std::string value) +{ + if (parm == "file") + { // apply output filename prefix file = value; - - } else if (parm == "srate") { + } + else if (parm == "srate") + { // try to apply samplerate - try { + try + { info.samplerate = std::stoi(value); - } catch (...) { - std::cerr << "[WavfileOutputEngine] Invalid samplerate " - << value << "\n"; } - - } else { - std::cerr << "[WavfileOutputEngine] Unsupported parameter '" - << parm << "'\n"; + catch (...) + { + std::cerr << "[WavfileOutputEngine] Invalid samplerate " << value << "\n"; + } + } + else + { + std::cerr << "[WavfileOutputEngine] Unsupported parameter '" << parm + << "'\n"; } } -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) { - if (static_cast(ch) >= channels.size()) { - std::cerr << "[WavfileOutputEngine] cannot access channel #" - << ch << " (" << channels.size() << " channels available)\n"; +void WavfileOutputEngine::run(int ch, sample_t *samples, size_t nsamples) +{ + if (static_cast(ch) >= channels.size()) + { + 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; } -- cgit v1.2.3