diff options
Diffstat (limited to 'plugin')
| -rw-r--r-- | plugin/drumgizmo_plugin.cc | 21 | ||||
| -rw-r--r-- | plugin/drumgizmo_plugin.h | 2 | 
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: | 
