diff options
author | Christian Glöckner <cgloeckner@freenet.de> | 2016-01-22 09:39:50 +0100 |
---|---|---|
committer | André Nusser <andre.nusser@googlemail.com> | 2016-02-09 09:03:16 +0100 |
commit | 06d43e27c412083cf704af48ea40e5c589504240 (patch) | |
tree | 37b5cc357eaa6cdad9b599fcad472866a51e6137 /drumgizmo/input | |
parent | 5b8b9365bab673aae6dea10b7c231fcff5fea665 (diff) |
stdcerr output overhaul
Diffstat (limited to 'drumgizmo/input')
-rw-r--r-- | drumgizmo/input/midifile.cc | 30 |
1 files changed, 23 insertions, 7 deletions
diff --git a/drumgizmo/input/midifile.cc b/drumgizmo/input/midifile.cc index d1748dc..323a198 100644 --- a/drumgizmo/input/midifile.cc +++ b/drumgizmo/input/midifile.cc @@ -24,6 +24,8 @@ * along with DrumGizmo; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ +#include <iostream> + #include "midifile.h" int const NOTE_ON = 0x90; @@ -51,27 +53,28 @@ bool MidifileInputEngine::isMidiEngine() { bool MidifileInputEngine::init(Instruments& instruments) { if (file == "") { - fprintf(stderr, "Missing midifile argument 'file'\n"); + std::cerr << "[MidifileInputEngine] Missing midi filename\n"; return false; } if (midimap == "") { - fprintf(stderr, "Missing midimapfile argument 'midimap'.\n"); + std::cerr << "[MidifileInputEngine] Missing midimap filename\n"; return false; } smf = smf_load(file.c_str()); if (smf == nullptr) { - fprintf(stderr, "Could not open midifile '%s'.\n", file.c_str()); + std::cerr << "[MidifileInputEngine] Failed to load midifile '" + << file << "'\n"; return false; } MidiMapParser p{midimap}; if (p.parse()) { - fprintf(stderr, "Could not parse midimapfile '%s'.\n", midimap.c_str()); + std::cerr << "[MidifileInputEngine] Failed to parse midimap '" + << midimap << "'\n"; return false; } midi_mapper.midimap = p.midimap; for (auto i = 0u; i < instruments.size(); ++i) { auto name = instruments[i]->name(); - printf("%d : %s\n", i, name.c_str()); midi_mapper.instrmap[name] = i; } return true; @@ -79,15 +82,28 @@ bool MidifileInputEngine::init(Instruments& instruments) { void MidifileInputEngine::setParm(std::string parm, std::string value) { if(parm == "file") { + // apply midi input filename file = value; + } else if(parm == "speed") { - speed = std::stof(value); + // try to apply speed + try { + speed = std::stof(value); + } catch (...) { + std::cerr << "[MidifileInputEngine] Invalid speed " + << value << "\n"; + } } else if (parm == "midimap") { + // apply midimap filename midimap = value; + } else if (parm == "loop") { + // apply looping loop = true; + } else { - printf("Unsupported midifile parameter '%s'\n", parm.c_str()); + std::cerr << "[MidifileInputEngine] Unsupported parameter '" + << parm << "'\n"; } } |