diff options
author | Christian Glöckner <cgloeckner@freenet.de> | 2016-03-22 00:22:14 +0100 |
---|---|---|
committer | Christian Glöckner <cgloeckner@freenet.de> | 2016-03-22 00:22:14 +0100 |
commit | bc26b2ffd80890003948c2f1c7f50acb5a9dfc87 (patch) | |
tree | 78cbc082d8144f4270a400b33028e6e3bef35b61 /plugin/drumgizmo_plugin.cc | |
parent | 4871ba69d6b0e2338f07b9bc8077f8899d7d8842 (diff) |
Modernized InputEngine::run()
Diffstat (limited to 'plugin/drumgizmo_plugin.cc')
-rw-r--r-- | plugin/drumgizmo_plugin.cc | 21 |
1 files changed, 5 insertions, 16 deletions
diff --git a/plugin/drumgizmo_plugin.cc b/plugin/drumgizmo_plugin.cc index 150d13e..61c0b17 100644 --- a/plugin/drumgizmo_plugin.cc +++ b/plugin/drumgizmo_plugin.cc @@ -205,16 +205,12 @@ void DrumGizmoPlugin::Input::pre() { } -event_t *DrumGizmoPlugin::Input::run(size_t pos, size_t len, size_t* nevents) +void DrumGizmoPlugin::Input::run(size_t pos, size_t len, std::vector<event_t>& events) { - + assert(events.empty()); assert(plugin.input_events); - event_t* list; - size_t listsize; - - list = (event_t*)malloc(sizeof(event_t) * plugin.input_events->size()); - listsize = 0; + events.reserve(plugin.input_events->size()); for(auto& event : *plugin.input_events) { @@ -226,16 +222,9 @@ event_t *DrumGizmoPlugin::Input::run(size_t pos, size_t len, size_t* nevents) int i = mmap.lookup(event.key); if(event.velocity && (i != -1)) { - list[listsize].type = TYPE_ONSET; - list[listsize].instrument = i; - list[listsize].velocity = (float)event.velocity / 127.0f; - list[listsize].offset = event.getTime(); - ++listsize; - } + events.push_back({TYPE_ONSET, (size_t)i, (size_t)event.getTime(), event.velocity / 127.0f}); + } } - - *nevents = listsize; - return list; } void DrumGizmoPlugin::Input::post() |