Add initial bits for Qt6 support
[carla.git] / source / tests / ansi-pedantic-test.c
blob248f1d932cda58dc25641570e2d819cb1bcfd054
1 /*
2 * ANSI pedantic test for the Carla Backend & Host API
3 * Copyright (C) 2013-2020 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 "CarlaBackend.h"
19 #include "CarlaHost.h"
20 #include "CarlaUtils.h"
22 #include "CarlaMIDI.h"
23 #include "CarlaNative.h"
24 #include "CarlaNativePlugin.h"
26 #ifdef __cplusplus
27 # include "CarlaEngine.hpp"
28 # include "CarlaPlugin.hpp"
29 # include <cassert>
30 # include <cstdio>
31 # ifndef nullptr
32 # undef NULL
33 # define NULL nullptr
34 # endif
35 #else
36 # include <assert.h>
37 # include <stdio.h>
38 #endif
40 #define BOOLEAN_AS_STRING(cond) ((cond) ? "true" : "false")
42 int main(int argc, char* argv[])
44 #ifdef __cplusplus
45 CARLA_BACKEND_USE_NAMESPACE
46 #endif
48 ParameterData a;
49 ParameterRanges b;
50 MidiProgramData c;
51 CustomData d;
52 EngineDriverDeviceInfo e;
54 CarlaPluginInfo f;
55 /*CarlaCachedPluginInfo g;*/
56 CarlaPortCountInfo h;
57 CarlaParameterInfo i;
58 CarlaScalePointInfo j;
59 CarlaTransportInfo k;
60 CarlaHostHandle handle;
62 const char* licenseText;
63 const char* const* fileExtensions;
65 uint l, count;
67 licenseText = carla_get_complete_license_text();
68 printf("LICENSE:\n%s\n", licenseText);
70 fileExtensions = carla_get_supported_file_extensions();
71 printf("FILE EXTENSIONS:\n ");
72 for (l=0; fileExtensions[l] != NULL; ++l)
73 printf(" %s", fileExtensions[l]);
74 printf("\n");
76 count = carla_get_engine_driver_count();
77 printf("DRIVER COUNT: %i\n", count);
79 for (l=0; l < count; ++l)
81 const char* driverName;
82 const char* const* driverDeviceNames;
83 const EngineDriverDeviceInfo* driverDeviceInfo;
84 uint m, m2, count2;
86 driverName = carla_get_engine_driver_name(l);
87 driverDeviceNames = carla_get_engine_driver_device_names(l);
88 printf("DRIVER %i/%i: \"%s\" : DEVICES:\n", l+1, count, driverName);
90 count2 = 0;
91 while (driverDeviceNames[count2] != NULL)
92 ++count2;
94 for (m = 0; m < count2; ++m)
96 driverDeviceInfo = carla_get_engine_driver_device_info(l, driverDeviceNames[m]);
97 printf("DRIVER DEVICE %i/%i: \"%s\"\n", m+1, count2, driverDeviceNames[m]);
98 printf(" Has control panel: %s\n", BOOLEAN_AS_STRING(driverDeviceInfo->hints & ENGINE_DRIVER_DEVICE_HAS_CONTROL_PANEL));
99 printf(" Can triple buffer: %s\n", BOOLEAN_AS_STRING(driverDeviceInfo->hints & ENGINE_DRIVER_DEVICE_CAN_TRIPLE_BUFFER));
100 printf(" Variable buffer size: %s\n", BOOLEAN_AS_STRING(driverDeviceInfo->hints & ENGINE_DRIVER_DEVICE_VARIABLE_BUFFER_SIZE));
101 printf(" Variable sample rate: %s\n", BOOLEAN_AS_STRING(driverDeviceInfo->hints & ENGINE_DRIVER_DEVICE_VARIABLE_SAMPLE_RATE));
103 if (driverDeviceInfo->bufferSizes != NULL && driverDeviceInfo->bufferSizes[0] != 0)
105 printf(" Buffer sizes:");
107 m2 = 0;
108 while (driverDeviceInfo->bufferSizes[m2] != 0)
109 printf(" %i", driverDeviceInfo->bufferSizes[m2++]);
111 printf("\n");
113 else
115 printf(" Buffer sizes: (null)\n");
118 if (driverDeviceInfo->sampleRates != NULL && driverDeviceInfo->sampleRates[0] > 0.1)
120 printf(" Sample rates:");
122 m2 = 0;
123 while (driverDeviceInfo->sampleRates[m2] > 0.1)
124 printf(" %.1f", driverDeviceInfo->sampleRates[m2++]);
126 printf("\n");
128 else
130 printf(" Sample rates: (null)\n");
135 handle = carla_standalone_host_init();
137 carla_set_engine_option(handle, ENGINE_OPTION_PROCESS_MODE, ENGINE_PROCESS_MODE_PATCHBAY, NULL);
138 carla_set_engine_option(handle, ENGINE_OPTION_TRANSPORT_MODE, ENGINE_TRANSPORT_MODE_INTERNAL, NULL);
140 if (carla_engine_init(handle, "Dummy", "ansi-test"))
142 #ifdef __cplusplus
143 CarlaEngine* const engine(carla_get_engine_from_handle(handle));
144 assert(engine != nullptr);
145 engine->getLastError();
146 #endif
147 if (carla_add_plugin(handle, BINARY_NATIVE, PLUGIN_INTERNAL, NULL, NULL, "audiofile", 0, NULL, 0x0))
149 #ifdef __cplusplus
150 const std::shared_ptr<CarlaPlugin> plugin(engine->getPlugin(0));
151 assert(plugin.get() != nullptr);
152 plugin->getId();
153 #endif
154 /* carla_set_custom_data(0, CUSTOM_DATA_TYPE_STRING, "file", "/home/falktx/Music/test.wav"); */
155 carla_transport_play(handle);
157 else
159 printf("%s\n", carla_get_last_error(handle));
161 #ifdef __cplusplus
162 engine->setAboutToClose();
163 #endif
164 carla_engine_close(handle);
167 #ifdef __cplusplus
168 EngineControlEvent e1;
169 EngineMidiEvent e2;
170 EngineEvent e3;
171 e3.fillFromMidiData(0, nullptr, 0);
172 EngineOptions e4;
173 EngineTimeInfoBBT e5;
174 EngineTimeInfo e6;
175 #endif
177 /* unused C */
178 (void)argc;
179 (void)argv;
180 (void)a; (void)b; (void)c; (void)d; (void)e;
181 (void)f; /*(void)g;*/ (void)h; (void)i; (void)j; (void)k;
182 #ifdef __cplusplus
183 (void)e1; (void)e2; (void)e4; (void)e5; (void)e6;
184 #endif
186 return 0;