Add initial bits for Qt6 support
[carla.git] / source / native-plugins / midi-through.c
blobc1548ac2ad42dcc13a3a096209473177ddf3962b
1 /*
2 * Carla Native Plugins
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"
21 #include <stdlib.h>
23 // -----------------------------------------------------------------------
25 typedef struct {
26 const NativeHostDescriptor* host;
27 } MidiThroughHandle;
29 // -----------------------------------------------------------------------
31 static NativePluginHandle midithrough_instantiate(const NativeHostDescriptor* host)
33 MidiThroughHandle* const handle = (MidiThroughHandle*)malloc(sizeof(MidiThroughHandle));
35 if (handle == NULL)
36 return NULL;
38 handle->host = host;
39 return handle;
42 #define handlePtr ((MidiThroughHandle*)handle)
44 static void midithrough_cleanup(NativePluginHandle handle)
46 free(handlePtr);
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]);
59 return;
61 // unused
62 (void)inBuffer;
63 (void)outBuffer;
64 (void)frames;
67 #undef handlePtr
69 // -----------------------------------------------------------------------
71 static const NativePluginDescriptor midithroughDesc = {
72 .category = NATIVE_PLUGIN_CATEGORY_UTILITY,
73 .hints = NATIVE_PLUGIN_IS_RTSAFE,
74 .supports = NATIVE_PLUGIN_SUPPORTS_EVERYTHING,
75 .audioIns = 0,
76 .audioOuts = 0,
77 .cvIns = 0,
78 .cvOuts = 0,
79 .midiIns = 1,
80 .midiOuts = 1,
81 .paramIns = 0,
82 .paramOuts = 0,
83 .name = "MIDI Through",
84 .label = "midithrough",
85 .maker = "falkTX",
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,
102 .ui_show = NULL,
103 .ui_idle = NULL,
105 .ui_set_parameter_value = NULL,
106 .ui_set_midi_program = NULL,
107 .ui_set_custom_data = NULL,
109 .activate = NULL,
110 .deactivate = NULL,
111 .process = midithrough_process,
113 .get_state = NULL,
114 .set_state = NULL,
116 .dispatcher = NULL
119 // -----------------------------------------------------------------------
121 void carla_register_native_plugin_midithrough(void);
123 void carla_register_native_plugin_midithrough(void)
125 carla_register_native_plugin(&midithroughDesc);
128 // -----------------------------------------------------------------------