1 /*
2  * ANSI pedantic test for the Carla Backend & Host API
3  * Copyright (C) 2013-2014 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 "CarlaBackend.h"
19 #include "CarlaHost.h"
20 #include "CarlaNative.h"
21 #include "CarlaMIDI.h"
22 
23 #ifdef __cplusplus
24 # include "CarlaEngine.hpp"
25 # include "CarlaPlugin.hpp"
26 # include <cassert>
27 # include <cstdio>
28 # ifdef CARLA_PROPER_CPP11_SUPPORT
29 #  undef NULL
30 #  define NULL nullptr
31 # endif
32 #else
33 # include <assert.h>
34 # include <stdio.h>
35 #endif
36 
main(int argc,char * argv[])37 int main(int argc, char* argv[])
38 {
39 #ifdef __cplusplus
40     CARLA_BACKEND_USE_NAMESPACE
41 #endif
42 
43     ParameterData a;
44     ParameterRanges b;
45     MidiProgramData c;
46     CustomData d;
47     EngineDriverDeviceInfo e;
48 
49     CarlaPluginInfo f;
50     /*CarlaCachedPluginInfo g;*/
51     CarlaPortCountInfo h;
52     CarlaParameterInfo i;
53     CarlaScalePointInfo j;
54     CarlaTransportInfo k;
55 
56     /*const char* licenseText;
57     const char* fileExtensions;*/
58 
59     uint l, count;
60 
61     /*licenseText = carla_get_complete_license_text();
62     printf("LICENSE:\n%s\n", licenseText);
63 
64     fileExtensions = carla_get_supported_file_extensions();
65     printf("FILE EXTENSIONS:\n%s\n", fileExtensions);*/
66 
67     count = carla_get_engine_driver_count();
68     printf("DRIVER COUNT: %i\n", count);
69 
70     for (l=0; l < count; ++l)
71     {
72         const char*        driverName;
73         const char* const* driverDeviceNames;
74         uint m, count2;
75 
76         driverName        = carla_get_engine_driver_name(l);
77         driverDeviceNames = carla_get_engine_driver_device_names(l);
78         printf("DRIVER %i/%i: \"%s\" : DEVICES:\n", l+1, count, driverName);
79 
80         count2 = 0;
81         while (driverDeviceNames[count2] != NULL)
82             ++count2;
83 
84         for (m = 0; m < count2; ++m)
85         {
86             printf("DRIVER DEVICE %i/%i: \"%s\"\n", m+1, count2, driverDeviceNames[m]);
87         }
88     }
89 
90     if (carla_engine_init("JACK", "ansi-test"))
91     {
92 #ifdef __cplusplus
93         CarlaEngine* const engine(carla_get_engine());
94         assert(engine != nullptr);
95         engine->getLastError();
96 #endif
97         if (carla_add_plugin(BINARY_NATIVE, PLUGIN_INTERNAL, NULL, NULL, "audiofile", 0, NULL, 0x0))
98         {
99 #ifdef __cplusplus
100             CarlaPlugin* const plugin(engine->getPlugin(0));
101             assert(plugin != nullptr);
102             plugin->getId();
103 #endif
104             carla_set_custom_data(0, CUSTOM_DATA_TYPE_STRING, "file", "/home/falktx/Music/test.wav");
105             carla_transport_play();
106         }
107         else
108         {
109             printf("%s\n", carla_get_last_error());
110         }
111 #ifdef __cplusplus
112         engine->setAboutToClose();
113 #endif
114         carla_engine_close();
115     }
116 
117 #ifdef __cplusplus
118     EngineControlEvent e1;
119     EngineMidiEvent e2;
120     EngineEvent e3;
121     e3.fillFromMidiData(0, nullptr);
122     EngineOptions e4;
123     EngineTimeInfoBBT e5;
124     EngineTimeInfo e6;
125 #endif
126 
127     /* unused C */
128     (void)argc;
129     (void)argv;
130     (void)a; (void)b; (void)c; (void)d; (void)e;
131     (void)f; /*(void)g;*/ (void)h; (void)i; (void)j; (void)k;
132 #ifdef __cplusplus
133     (void)e1; (void)e2; (void)e4; (void)e5; (void)e6;
134 #endif
135 
136     return 0;
137 }
138