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"
27 # include "CarlaEngine.hpp"
28 # include "CarlaPlugin.hpp"
40 #define BOOLEAN_AS_STRING(cond) ((cond) ? "true" : "false")
42 int main(int argc
, char* argv
[])
45 CARLA_BACKEND_USE_NAMESPACE
52 EngineDriverDeviceInfo e
;
55 /*CarlaCachedPluginInfo g;*/
58 CarlaScalePointInfo j
;
60 CarlaHostHandle handle
;
62 const char* licenseText
;
63 const char* const* fileExtensions
;
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
]);
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
;
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
);
91 while (driverDeviceNames
[count2
] != NULL
)
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:");
108 while (driverDeviceInfo
->bufferSizes
[m2
] != 0)
109 printf(" %i", driverDeviceInfo
->bufferSizes
[m2
++]);
115 printf(" Buffer sizes: (null)\n");
118 if (driverDeviceInfo
->sampleRates
!= NULL
&& driverDeviceInfo
->sampleRates
[0] > 0.1)
120 printf(" Sample rates:");
123 while (driverDeviceInfo
->sampleRates
[m2
] > 0.1)
124 printf(" %.1f", driverDeviceInfo
->sampleRates
[m2
++]);
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"))
143 CarlaEngine
* const engine(carla_get_engine_from_handle(handle
));
144 assert(engine
!= nullptr);
145 engine
->getLastError();
147 if (carla_add_plugin(handle
, BINARY_NATIVE
, PLUGIN_INTERNAL
, NULL
, NULL
, "audiofile", 0, NULL
, 0x0))
150 const std::shared_ptr
<CarlaPlugin
> plugin(engine
->getPlugin(0));
151 assert(plugin
.get() != nullptr);
154 /* carla_set_custom_data(0, CUSTOM_DATA_TYPE_STRING, "file", "/home/falktx/Music/test.wav"); */
155 carla_transport_play(handle
);
159 printf("%s\n", carla_get_last_error(handle
));
162 engine
->setAboutToClose();
164 carla_engine_close(handle
);
168 EngineControlEvent e1
;
171 e3
.fillFromMidiData(0, nullptr, 0);
173 EngineTimeInfoBBT e5
;
180 (void)a
; (void)b
; (void)c
; (void)d
; (void)e
;
181 (void)f
; /*(void)g;*/ (void)h
; (void)i
; (void)j
; (void)k
;
183 (void)e1
; (void)e2
; (void)e4
; (void)e5
; (void)e6
;