summaryrefslogtreecommitdiff
path: root/plugin
diff options
context:
space:
mode:
authorChristian Glöckner <cgloeckner@freenet.de>2016-03-22 00:22:14 +0100
committerChristian Glöckner <cgloeckner@freenet.de>2016-03-22 00:22:14 +0100
commitbc26b2ffd80890003948c2f1c7f50acb5a9dfc87 (patch)
tree78cbc082d8144f4270a400b33028e6e3bef35b61 /plugin
parent4871ba69d6b0e2338f07b9bc8077f8899d7d8842 (diff)
Modernized InputEngine::run()
Diffstat (limited to 'plugin')
-rw-r--r--plugin/drumgizmo_plugin.cc21
-rw-r--r--plugin/drumgizmo_plugin.h2
2 files changed, 6 insertions, 17 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()
diff --git a/plugin/drumgizmo_plugin.h b/plugin/drumgizmo_plugin.h
index acefbf2..a0ce8b9 100644
--- a/plugin/drumgizmo_plugin.h
+++ b/plugin/drumgizmo_plugin.h
@@ -116,7 +116,7 @@ private:
void stop() override;
void pre() override;
- event_t *run(size_t pos, size_t len, size_t* nevents) override;
+ void run(size_t pos, size_t len, std::vector<event_t>& events) override;
void post() override;
protected: