diff options
author | Christian Glöckner <cgloeckner@freenet.de> | 2016-01-25 14:14:22 +0100 |
---|---|---|
committer | André Nusser <andre.nusser@googlemail.com> | 2016-02-09 09:03:17 +0100 |
commit | 100e2d3bd46f64df730c8a375559680c577036ef (patch) | |
tree | 952e0ce0a1c5b6efb792c50617baa1484ba51e39 /drumgizmo/input/jackmidi.cc | |
parent | e5a773e80bee619987aacd40cc3205acfe146e9c (diff) |
applied clang-format
Diffstat (limited to 'drumgizmo/input/jackmidi.cc')
-rw-r--r-- | drumgizmo/input/jackmidi.cc | 99 |
1 files changed, 50 insertions, 49 deletions
diff --git a/drumgizmo/input/jackmidi.cc b/drumgizmo/input/jackmidi.cc index ba4e8b3..5ae6add 100644 --- a/drumgizmo/input/jackmidi.cc +++ b/drumgizmo/input/jackmidi.cc @@ -32,101 +32,103 @@ int const NOTE_ON = 0x90; -JackMidiInputEngine::JackMidiInputEngine(JackClient& client) - : AudioInputEngine{} - , JackProcess{} - , client(client) - , port{nullptr} - , midimap{} - , midi_mapper{} - , pos{0u} - , list{nullptr} - , listsize{0u} { +JackMidiInputEngine::JackMidiInputEngine(JackClient &client) + : AudioInputEngine{}, JackProcess{}, client(client), port{nullptr}, + midimap{}, midi_mapper{}, pos{0u}, list{nullptr}, listsize{0u} +{ client.add(*this); } -JackMidiInputEngine::~JackMidiInputEngine() { - client.remove(*this); -} +JackMidiInputEngine::~JackMidiInputEngine() { client.remove(*this); } -bool JackMidiInputEngine::isMidiEngine() { - return true; -} +bool JackMidiInputEngine::isMidiEngine() { return true; } -bool JackMidiInputEngine::init(Instruments& instruments) { - if (midimap == "") { +bool JackMidiInputEngine::init(Instruments &instruments) +{ + if (midimap == "") + { std::cerr << "[JackMidiInputEngine] Missing midimap filename\n"; return false; } MidiMapParser p{midimap}; - if (p.parse()) { - std::cerr << "[JackmidiInputEngine] Failed to parse midimap '" - << midimap << "'\n"; + if (p.parse()) + { + std::cerr << "[JackmidiInputEngine] Failed to parse midimap '" << midimap + << "'\n"; return false; } midi_mapper.midimap = p.midimap; - for (auto i = 0u; i < instruments.size(); ++i) { + for (auto i = 0u; i < instruments.size(); ++i) + { auto name = instruments[i]->name(); midi_mapper.instrmap[name] = i; } 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") { +void JackMidiInputEngine::setParm(std::string parm, std::string value) +{ + if (parm == "midimap") + { // apply midimap filename midimap = value; - - } else { - std::cerr << "[JackMidiInputEngine] Unsupported parameter '" - << parm << "'\n"; + } + else + { + std::cerr << "[JackMidiInputEngine] Unsupported parameter '" << parm + << "'\n"; } } -bool JackMidiInputEngine::start() { +bool JackMidiInputEngine::start() +{ client.activate(); return true; } -void JackMidiInputEngine::stop() { -} +void JackMidiInputEngine::stop() {} -void JackMidiInputEngine::pre() { -} +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; - printf("Owning raw pointer at drumgizmo/input/jackmidiinput.cc - GET RID OF THEM!\n"); + event_t *l = list; + printf("Owning raw pointer at drumgizmo/input/jackmidi.cc - GET RID OF " + "THEM!\n"); list = (event_t *)malloc(sizeof(event_t) * 1000); listsize = 0; return l; } -void JackMidiInputEngine::post() { -} +void JackMidiInputEngine::post() {} -void JackMidiInputEngine::process(jack_nframes_t num_frames) { +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; } int key = event.buffer[1]; int velocity = event.buffer[2]; printf("Event key:%d vel:%d\n", key, velocity); int k = midi_mapper.lookup(key); - if(k != -1 && velocity) { + if (k != -1 && velocity) + { list[listsize].type = TYPE_ONSET; list[listsize].instrument = k; list[listsize].velocity = velocity / 127.0; @@ -139,8 +141,7 @@ void JackMidiInputEngine::process(jack_nframes_t num_frames) { } /* - DrumKit* kit; - size_t pos; - EventQueue *eventqueue; + DrumKit* kit; + size_t pos; + EventQueue *eventqueue; */ - |