3 * Copyright (C) 2012-2019 Filipe Coelho <falktx@falktx.com>
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License as
7 * published by the Free Software Foundation; either version 2 of
8 * the License, or any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * For a full copy of the GNU General Public License see the doc/GPL.txt file.
18 #include "CarlaNative.h"
19 #include "CarlaMIDI.h"
23 // -----------------------------------------------------------------------
26 const NativeHostDescriptor
* host
;
29 // -----------------------------------------------------------------------
31 static NativePluginHandle
midithrough_instantiate(const NativeHostDescriptor
* host
)
33 MidiThroughHandle
* const handle
= (MidiThroughHandle
*)malloc(sizeof(MidiThroughHandle
));
42 #define handlePtr ((MidiThroughHandle*)handle)
44 static void midithrough_cleanup(NativePluginHandle handle
)
49 // FIXME for v3.0, use const for the input buffer
50 static void midithrough_process(NativePluginHandle handle
,
51 float** inBuffer
, float** outBuffer
, uint32_t frames
,
52 const NativeMidiEvent
* midiEvents
, uint32_t midiEventCount
)
54 const NativeHostDescriptor
* const host
= handlePtr
->host
;
56 for (uint32_t i
=0; i
< midiEventCount
; ++i
)
57 host
->write_midi_event(host
->handle
, &midiEvents
[i
]);
69 // -----------------------------------------------------------------------
71 static const NativePluginDescriptor midithroughDesc
= {
72 .category
= NATIVE_PLUGIN_CATEGORY_UTILITY
,
73 .hints
= NATIVE_PLUGIN_IS_RTSAFE
,
74 .supports
= NATIVE_PLUGIN_SUPPORTS_EVERYTHING
,
83 .name
= "MIDI Through",
84 .label
= "midithrough",
86 .copyright
= "GNU GPL v2+",
88 .instantiate
= midithrough_instantiate
,
89 .cleanup
= midithrough_cleanup
,
91 .get_parameter_count
= NULL
,
92 .get_parameter_info
= NULL
,
93 .get_parameter_value
= NULL
,
95 .get_midi_program_count
= NULL
,
96 .get_midi_program_info
= NULL
,
98 .set_parameter_value
= NULL
,
99 .set_midi_program
= NULL
,
100 .set_custom_data
= NULL
,
105 .ui_set_parameter_value
= NULL
,
106 .ui_set_midi_program
= NULL
,
107 .ui_set_custom_data
= NULL
,
111 .process
= midithrough_process
,
119 // -----------------------------------------------------------------------
121 void carla_register_native_plugin_midithrough(void);
123 void carla_register_native_plugin_midithrough(void)
125 carla_register_native_plugin(&midithroughDesc
);
128 // -----------------------------------------------------------------------