1 /*
2  * Carla Native Plugins
3  * Copyright (C) 2012-2019 Filipe Coelho <falktx@falktx.com>
4  *
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.
9  *
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.
14  *
15  * For a full copy of the GNU General Public License see the doc/GPL.txt file.
16  */
17 
18 #include "CarlaNative.h"
19 
20 #include <string.h>
21 
22 // -----------------------------------------------------------------------
23 
bypass_instantiate(const NativeHostDescriptor * host)24 static NativePluginHandle bypass_instantiate(const NativeHostDescriptor* host)
25 {
26     // dummy, return non-NULL
27     return (NativePluginHandle)0x1;
28 
29     // unused
30     (void)host;
31 }
32 
33 // FIXME for v3.0, use const for the input buffer
bypass_process(NativePluginHandle handle,float ** inBuffer,float ** outBuffer,uint32_t frames,const NativeMidiEvent * midiEvents,uint32_t midiEventCount)34 static void bypass_process(NativePluginHandle handle,
35                            float** inBuffer, float** outBuffer, uint32_t frames,
36                            const NativeMidiEvent* midiEvents, uint32_t midiEventCount)
37 {
38     if (outBuffer[0] != inBuffer[0])
39         memcpy(outBuffer[0], inBuffer[0], sizeof(float)*frames);
40     return;
41 
42     // unused
43     (void)handle;
44     (void)midiEvents;
45     (void)midiEventCount;
46 }
47 
48 // -----------------------------------------------------------------------
49 
50 static const NativePluginDescriptor bypassDesc = {
51     .category  = NATIVE_PLUGIN_CATEGORY_NONE,
52     .hints     = NATIVE_PLUGIN_IS_RTSAFE,
53     .supports  = NATIVE_PLUGIN_SUPPORTS_NOTHING,
54     .audioIns  = 1,
55     .audioOuts = 1,
56     .cvIns     = 0,
57     .cvOuts    = 0,
58     .midiIns   = 0,
59     .midiOuts  = 0,
60     .paramIns  = 0,
61     .paramOuts = 0,
62     .name      = "Bypass",
63     .label     = "bypass",
64     .maker     = "falkTX",
65     .copyright = "GNU GPL v2+",
66 
67     .instantiate = bypass_instantiate,
68     .cleanup     = NULL,
69 
70     .get_parameter_count = NULL,
71     .get_parameter_info  = NULL,
72     .get_parameter_value = NULL,
73 
74     .get_midi_program_count = NULL,
75     .get_midi_program_info  = NULL,
76 
77     .set_parameter_value = NULL,
78     .set_midi_program    = NULL,
79     .set_custom_data     = NULL,
80 
81     .ui_show = NULL,
82     .ui_idle = NULL,
83 
84     .ui_set_parameter_value = NULL,
85     .ui_set_midi_program    = NULL,
86     .ui_set_custom_data     = NULL,
87 
88     .activate   = NULL,
89     .deactivate = NULL,
90     .process    = bypass_process,
91 
92     .get_state = NULL,
93     .set_state = NULL,
94 
95     .dispatcher = NULL
96 };
97 
98 // -----------------------------------------------------------------------
99 
100 void carla_register_native_plugin_bypass(void);
101 
carla_register_native_plugin_bypass(void)102 void carla_register_native_plugin_bypass(void)
103 {
104     carla_register_native_plugin(&bypassDesc);
105 }
106 
107 // -----------------------------------------------------------------------
108