1 |
// example_client.c |
// example_client.c |
2 |
// |
// |
3 |
/**************************************************************************** |
/**************************************************************************** |
4 |
Copyright (C) 2004, rncbc aka Rui Nuno Capela. All rights reserved. |
liblscp - LinuxSampler Control Protocol API |
5 |
|
Copyright (C) 2004-2006, rncbc aka Rui Nuno Capela. All rights reserved. |
6 |
|
|
7 |
This program is free software; you can redistribute it and/or |
This program is free software; you can redistribute it and/or |
8 |
modify it under the terms of the GNU General Public License |
modify it under the terms of the GNU General Public License |
14 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
15 |
GNU General Public License for more details. |
GNU General Public License for more details. |
16 |
|
|
17 |
You should have received a copy of the GNU General Public License |
You should have received a copy of the GNU General Public License along |
18 |
along with this program; if not, write to the Free Software |
with this program; if not, write to the Free Software Foundation, Inc., |
19 |
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
20 |
|
|
21 |
*****************************************************************************/ |
*****************************************************************************/ |
22 |
|
|
51 |
|
|
52 |
//////////////////////////////////////////////////////////////////////// |
//////////////////////////////////////////////////////////////////////// |
53 |
|
|
54 |
void client_test_int ( int i ) |
int client_test_int ( int i ) |
55 |
{ |
{ |
56 |
printf("%d\n", i); |
printf("%d\n", i); |
57 |
|
return (i >= 0 ? 0 : 1); |
58 |
} |
} |
59 |
|
|
60 |
void client_test_status ( lscp_status_t s ) |
|
61 |
|
int client_test_status ( lscp_status_t s ) |
62 |
{ |
{ |
63 |
const char *pszStatus; |
const char *pszStatus; |
64 |
|
|
65 |
switch (s) { |
switch (s) { |
66 |
case LSCP_OK: pszStatus = "OK"; break; |
case LSCP_OK: pszStatus = "OK"; break; |
67 |
case LSCP_FAILED: pszStatus = "FAILED"; break; |
case LSCP_FAILED: pszStatus = "FAILED"; break; |
71 |
case LSCP_QUIT: pszStatus = "QUIT"; break; |
case LSCP_QUIT: pszStatus = "QUIT"; break; |
72 |
default: pszStatus = "NONE"; break; |
default: pszStatus = "NONE"; break; |
73 |
} |
} |
|
|
|
74 |
printf("%s\n", pszStatus); |
printf("%s\n", pszStatus); |
75 |
|
return (s == LSCP_OK ? 0 : 1); |
76 |
} |
} |
77 |
|
|
78 |
|
|
79 |
void client_test_isplit ( int *piSplit ) |
int client_test_isplit ( int *piSplit ) |
80 |
{ |
{ |
81 |
int i; |
int i; |
82 |
|
|
87 |
printf(" %d", piSplit[i]); |
printf(" %d", piSplit[i]); |
88 |
} |
} |
89 |
printf(" }\n"); |
printf(" }\n"); |
90 |
|
return 0; |
91 |
} |
} |
92 |
|
|
93 |
void client_test_szsplit ( char **ppszSplit ) |
|
94 |
|
int client_test_szsplit ( char **ppszSplit ) |
95 |
{ |
{ |
96 |
int i; |
int i; |
97 |
|
|
102 |
printf(" %s", ppszSplit[i]); |
printf(" %s", ppszSplit[i]); |
103 |
} |
} |
104 |
printf(" }\n"); |
printf(" }\n"); |
105 |
|
return 0; |
106 |
} |
} |
107 |
|
|
108 |
void client_test_params ( lscp_param_t *pParams ) |
|
109 |
|
int client_test_params ( lscp_param_t *pParams ) |
110 |
{ |
{ |
111 |
int i; |
int i; |
112 |
|
|
117 |
printf(" %s='%s'", pParams[i].key, pParams[i].value); |
printf(" %s='%s'", pParams[i].key, pParams[i].value); |
118 |
} |
} |
119 |
printf(" }\n"); |
printf(" }\n"); |
120 |
|
return 0; |
121 |
} |
} |
122 |
|
|
123 |
void client_test_param_info ( lscp_param_info_t *pParamInfo ) |
|
124 |
|
int client_test_param_info ( lscp_param_info_t *pParamInfo ) |
125 |
{ |
{ |
126 |
const char *pszType; |
const char *pszType; |
127 |
|
|
128 |
if (pParamInfo == NULL) { |
if (pParamInfo == NULL) { |
129 |
printf("(nil)\n"); |
printf("(nil)\n"); |
130 |
return; |
return 1; |
131 |
} |
} |
132 |
switch (pParamInfo->type) { |
switch (pParamInfo->type) { |
133 |
case LSCP_TYPE_BOOL: pszType = "BOOL"; break; |
case LSCP_TYPE_BOOL: pszType = "BOOL"; break; |
137 |
default: pszType = "NONE"; break; |
default: pszType = "NONE"; break; |
138 |
} |
} |
139 |
printf("{\n"); |
printf("{\n"); |
140 |
printf(" param_info.type = %d (%s)\n", (int) pParamInfo->type, pszType); |
printf(" param_info.type = %d (%s)\n", (int) pParamInfo->type, pszType); |
141 |
printf(" param_info.description = %s\n", pParamInfo->description); |
printf(" param_info.description = %s\n", pParamInfo->description); |
142 |
printf(" param_info.mandatory = %d\n", pParamInfo->mandatory); |
printf(" param_info.mandatory = %d\n", pParamInfo->mandatory); |
143 |
printf(" param_info.fix = %d\n", pParamInfo->fix); |
printf(" param_info.fix = %d\n", pParamInfo->fix); |
144 |
printf(" param_info.multiplicity = %d\n", pParamInfo->multiplicity); |
printf(" param_info.multiplicity = %d\n", pParamInfo->multiplicity); |
145 |
printf(" param_info.depends = "); client_test_szsplit(pParamInfo->depends); |
printf(" param_info.depends = "); client_test_szsplit(pParamInfo->depends); |
146 |
printf(" param_info.defaultv = %s\n", pParamInfo->defaultv); |
printf(" param_info.defaultv = %s\n", pParamInfo->defaultv); |
147 |
printf(" param_info.range_min = %s\n", pParamInfo->range_min); |
printf(" param_info.range_min = %s\n", pParamInfo->range_min); |
148 |
printf(" param_info.range_max = %s\n", pParamInfo->range_max); |
printf(" param_info.range_max = %s\n", pParamInfo->range_max); |
149 |
printf(" param_info.possibilities = "); client_test_szsplit(pParamInfo->possibilities); |
printf(" param_info.possibilities = "); client_test_szsplit(pParamInfo->possibilities); |
150 |
printf(" }\n"); |
printf(" }\n"); |
151 |
|
return 0; |
152 |
} |
} |
153 |
|
|
154 |
void client_test_driver_info ( lscp_driver_info_t *pDriverInfo ) |
|
155 |
|
int client_test_driver_info ( lscp_driver_info_t *pDriverInfo ) |
156 |
{ |
{ |
157 |
if (pDriverInfo == NULL) { |
if (pDriverInfo == NULL) { |
158 |
printf("(nil)\n"); |
printf("(nil)\n"); |
159 |
return; |
return 1; |
160 |
} |
} |
161 |
printf("{\n"); |
printf("{\n"); |
162 |
printf(" driver_info.description = %s\n", pDriverInfo->description); |
printf(" driver_info.description = %s\n", pDriverInfo->description); |
163 |
printf(" driver_info.version = %s\n", pDriverInfo->version); |
printf(" driver_info.version = %s\n", pDriverInfo->version); |
164 |
printf(" driver_info.parameters = "); client_test_szsplit(pDriverInfo->parameters); |
printf(" driver_info.parameters = "); client_test_szsplit(pDriverInfo->parameters); |
165 |
printf(" }\n"); |
printf(" }\n"); |
166 |
|
return 0; |
167 |
} |
} |
168 |
|
|
169 |
void client_test_device_info ( lscp_device_info_t *pDeviceInfo ) |
|
170 |
|
int client_test_device_info ( lscp_device_info_t *pDeviceInfo ) |
171 |
{ |
{ |
172 |
if (pDeviceInfo == NULL) { |
if (pDeviceInfo == NULL) { |
173 |
printf("(nil)\n"); |
printf("(nil)\n"); |
174 |
return; |
return 1; |
175 |
} |
} |
176 |
printf("{\n"); |
printf("{\n"); |
177 |
printf(" device_info.driver = %s\n", pDeviceInfo->driver); |
printf(" device_info.driver = %s\n", pDeviceInfo->driver); |
178 |
printf(" device_info.params = "); client_test_params(pDeviceInfo->params); |
printf(" device_info.params = "); client_test_params(pDeviceInfo->params); |
179 |
printf(" }\n"); |
printf(" }\n"); |
180 |
|
return 0; |
181 |
} |
} |
182 |
|
|
183 |
void client_test_device_port_info ( lscp_device_port_info_t *pDevicePortInfo ) |
|
184 |
|
int client_test_device_port_info ( lscp_device_port_info_t *pDevicePortInfo ) |
185 |
{ |
{ |
186 |
if (pDevicePortInfo == NULL) { |
if (pDevicePortInfo == NULL) { |
187 |
printf("(nil)\n"); |
printf("(nil)\n"); |
188 |
return; |
return 1; |
189 |
} |
} |
190 |
printf("{\n"); |
printf("{\n"); |
191 |
printf(" device_port_info.name = %s\n", pDevicePortInfo->name); |
printf(" device_port_info.name = %s\n", pDevicePortInfo->name); |
192 |
printf(" device_port_info.params = "); client_test_params(pDevicePortInfo->params); |
printf(" device_port_info.params = "); client_test_params(pDevicePortInfo->params); |
193 |
printf(" }\n"); |
printf(" }\n"); |
194 |
|
return 0; |
195 |
} |
} |
196 |
|
|
197 |
void client_test_engine_info ( lscp_engine_info_t *pEngineInfo ) |
|
198 |
|
int client_test_server_info ( lscp_server_info_t *pServerInfo ) |
199 |
|
{ |
200 |
|
if (pServerInfo == NULL) { |
201 |
|
printf("(nil)\n"); |
202 |
|
return 1; |
203 |
|
} |
204 |
|
printf("{\n"); |
205 |
|
printf(" server_info.description = %s\n", pServerInfo->description); |
206 |
|
printf(" server_info.version = %s\n", pServerInfo->version); |
207 |
|
printf(" }\n"); |
208 |
|
return 0; |
209 |
|
} |
210 |
|
|
211 |
|
|
212 |
|
int client_test_engine_info ( lscp_engine_info_t *pEngineInfo ) |
213 |
{ |
{ |
214 |
if (pEngineInfo == NULL) { |
if (pEngineInfo == NULL) { |
215 |
printf("(nil)\n"); |
printf("(nil)\n"); |
216 |
return; |
return 1; |
217 |
} |
} |
218 |
printf("{\n"); |
printf("{\n"); |
219 |
printf(" engine_info.description = %s\n", pEngineInfo->description); |
printf(" engine_info.description = %s\n", pEngineInfo->description); |
220 |
printf(" engine_info.version = %s\n", pEngineInfo->version); |
printf(" engine_info.version = %s\n", pEngineInfo->version); |
221 |
printf(" }\n"); |
printf(" }\n"); |
222 |
|
return 0; |
223 |
} |
} |
224 |
|
|
225 |
void client_test_channel_info ( lscp_channel_info_t *pChannelInfo ) |
|
226 |
|
int client_test_channel_info ( lscp_channel_info_t *pChannelInfo ) |
227 |
{ |
{ |
228 |
if (pChannelInfo == NULL) { |
if (pChannelInfo == NULL) { |
229 |
printf("(nil)\n"); |
printf("(nil)\n"); |
230 |
return; |
return 1; |
231 |
} |
} |
232 |
printf("{\n"); |
printf("{\n"); |
233 |
printf(" channel_info.engine_name = %s\n", pChannelInfo->engine_name); |
printf(" channel_info.engine_name = %s\n", pChannelInfo->engine_name); |
236 |
printf(" channel_info.audio_routing = "); client_test_szsplit(pChannelInfo->audio_routing); |
printf(" channel_info.audio_routing = "); client_test_szsplit(pChannelInfo->audio_routing); |
237 |
printf(" channel_info.instrument_file = %s\n", pChannelInfo->instrument_file); |
printf(" channel_info.instrument_file = %s\n", pChannelInfo->instrument_file); |
238 |
printf(" channel_info.instrument_nr = %d\n", pChannelInfo->instrument_nr); |
printf(" channel_info.instrument_nr = %d\n", pChannelInfo->instrument_nr); |
239 |
|
printf(" channel_info.instrument_name = %s\n", pChannelInfo->instrument_name); |
240 |
printf(" channel_info.instrument_status = %d\n", pChannelInfo->instrument_status); |
printf(" channel_info.instrument_status = %d\n", pChannelInfo->instrument_status); |
241 |
printf(" channel_info.midi_device = %d\n", pChannelInfo->midi_device); |
printf(" channel_info.midi_device = %d\n", pChannelInfo->midi_device); |
242 |
printf(" channel_info.midi_port = %d\n", pChannelInfo->midi_port); |
printf(" channel_info.midi_port = %d\n", pChannelInfo->midi_port); |
243 |
printf(" channel_info.midi_channel = %d\n", pChannelInfo->midi_channel); |
printf(" channel_info.midi_channel = %d\n", pChannelInfo->midi_channel); |
244 |
printf(" channel_info.volume = %g\n", pChannelInfo->volume); |
printf(" channel_info.volume = %g\n", pChannelInfo->volume); |
245 |
|
printf(" channel_info.mute = %d\n", pChannelInfo->mute); |
246 |
|
printf(" channel_info.solo = %d\n", pChannelInfo->solo); |
247 |
printf(" }\n"); |
printf(" }\n"); |
248 |
|
return 0; |
249 |
} |
} |
250 |
|
|
251 |
void client_test_buffer_fill ( lscp_buffer_fill_t *pBufferFill ) |
|
252 |
|
int client_test_buffer_fill ( lscp_buffer_fill_t *pBufferFill ) |
253 |
{ |
{ |
254 |
|
if (pBufferFill == NULL) { |
255 |
|
printf("(nil)\n"); |
256 |
|
return 1; |
257 |
|
} |
258 |
printf("{ <%p> }\n", pBufferFill); |
printf("{ <%p> }\n", pBufferFill); |
259 |
|
return 0; |
260 |
|
} |
261 |
|
|
262 |
|
|
263 |
|
int client_test_load_mode ( lscp_load_mode_t load_mode ) |
264 |
|
{ |
265 |
|
const char *pszLoadMode; |
266 |
|
|
267 |
|
switch (load_mode) { |
268 |
|
case LSCP_LOAD_ON_DEMAND: pszLoadMode = "ON_DEMAND"; break; |
269 |
|
case LSCP_LOAD_ON_DEMAND_HOLD: pszLoadMode = "ON_DEMAND_HOLD"; break; |
270 |
|
case LSCP_LOAD_PERSISTENT: pszLoadMode = "PERSISTENT"; break; |
271 |
|
default: pszLoadMode = "DEFAULT"; break; |
272 |
|
} |
273 |
|
printf("%s\n", pszLoadMode); |
274 |
|
return 0; |
275 |
|
} |
276 |
|
|
277 |
|
|
278 |
|
int client_test_midi_instrument_info ( lscp_midi_instrument_info_t *pInstrInfo ) |
279 |
|
{ |
280 |
|
if (pInstrInfo == NULL) { |
281 |
|
printf("(nil)\n"); |
282 |
|
return 1; |
283 |
|
} |
284 |
|
printf("{\n"); |
285 |
|
printf(" midi_instrument_info.name = %s\n", pInstrInfo->name); |
286 |
|
printf(" midi_instrument_info.engine_name = %s\n", pInstrInfo->engine_name); |
287 |
|
printf(" midi_instrument_info.instrument_file = %s\n", pInstrInfo->instrument_file); |
288 |
|
printf(" midi_instrument_info.instrument_nr = %d\n", pInstrInfo->instrument_nr); |
289 |
|
printf(" midi_instrument_info.instrument_name = %s\n", pInstrInfo->instrument_name); |
290 |
|
printf(" midi_instrument_info.load_mode = "); client_test_load_mode(pInstrInfo->load_mode); |
291 |
|
printf(" midi_instrument_info.volume = %g\n", pInstrInfo->volume); |
292 |
|
printf(" }\n"); |
293 |
|
return 0; |
294 |
} |
} |
295 |
|
|
296 |
|
|
297 |
//////////////////////////////////////////////////////////////////////// |
//////////////////////////////////////////////////////////////////////// |
298 |
|
|
299 |
static int g_teststep = 0; |
static int g_test_step = 0; |
300 |
|
static int g_test_count = 0; |
301 |
|
static int g_test_fails = 0; |
302 |
|
|
303 |
|
|
304 |
void client_test_start ( clock_t *pclk ) { *pclk = clock(); } |
void client_test_start ( clock_t *pclk ) { *pclk = clock(); } |
305 |
float client_test_elapsed ( clock_t *pclk ) { return (float) ((long) clock() - *pclk) / (float) CLOCKS_PER_SEC; } |
float client_test_elapsed ( clock_t *pclk ) { return (float) ((long) clock() - *pclk) / (float) CLOCKS_PER_SEC; } |
306 |
|
|
307 |
typedef int * isplit; |
typedef int * isplit; |
308 |
typedef char ** szsplit; |
typedef char ** szsplit; |
309 |
typedef lscp_status_t status; |
typedef lscp_status_t status; |
310 |
typedef lscp_driver_info_t * driver_info; |
typedef lscp_driver_info_t * driver_info; |
311 |
typedef lscp_device_info_t * device_info; |
typedef lscp_device_info_t * device_info; |
312 |
typedef lscp_device_port_info_t * device_port_info; |
typedef lscp_device_port_info_t * device_port_info; |
313 |
typedef lscp_param_info_t * param_info; |
typedef lscp_param_info_t * param_info; |
314 |
typedef lscp_engine_info_t * engine_info; |
typedef lscp_server_info_t * server_info; |
315 |
typedef lscp_channel_info_t * channel_info; |
typedef lscp_engine_info_t * engine_info; |
316 |
typedef lscp_buffer_fill_t * buffer_fill; |
typedef lscp_channel_info_t * channel_info; |
317 |
|
typedef lscp_buffer_fill_t * buffer_fill; |
318 |
|
typedef lscp_midi_instrument_info_t *midi_instrument_info; |
319 |
|
|
320 |
#define CLIENT_TEST(p, t, x) { clock_t c; void *v; \ |
#define CLIENT_TEST(p, t, x) { clock_t c; void *v; g_test_count++; \ |
321 |
printf("\n" #x ":\n"); client_test_start(&c); v = (void *) (x); \ |
printf("\n" #x ":\n"); client_test_start(&c); v = (void *) (x); \ |
322 |
printf(" elapsed=%gs errno=%d result='%s...' ret=", \ |
printf(" elapsed=%gs errno=%d result='%s...' ret=", \ |
323 |
client_test_elapsed(&c), \ |
client_test_elapsed(&c), \ |
324 |
lscp_client_get_errno(p), \ |
lscp_client_get_errno(p), \ |
325 |
lscp_client_get_result(p)); \ |
lscp_client_get_result(p)); \ |
326 |
client_test_##t((t)(v)); \ |
if (client_test_##t((t)(v))) { g_test_fails++; getchar(); } \ |
327 |
if (g_teststep) getchar(); } |
else if (g_test_step) getchar(); } |
328 |
|
|
329 |
|
|
330 |
|
void client_test_engine ( lscp_client_t *pClient, const char *pszEngine, const char *pszAudioDriver, int iAudioDevice, const char *pszMidiDriver, int iMidiDevice ) |
331 |
|
{ |
332 |
|
int iSamplerChannel; |
333 |
|
lscp_midi_instrument_t midi_instr; |
334 |
|
|
335 |
|
printf("\n--- pszEngine=\"%s\" pszAudioDevice=\"%s\" iAudioDevice=%d pszMidiDevice=\"%s\" iMidiDevice=%d ---\n", pszEngine, pszAudioDriver, iAudioDevice, pszMidiDriver, iMidiDevice); |
336 |
|
CLIENT_TEST(pClient, engine_info, lscp_get_engine_info(pClient, pszEngine)); |
337 |
|
CLIENT_TEST(pClient, int, lscp_get_total_voice_count(pClient)); |
338 |
|
CLIENT_TEST(pClient, int, lscp_get_total_voice_count_max(pClient)); |
339 |
|
CLIENT_TEST(pClient, int, lscp_get_channels(pClient)); |
340 |
|
CLIENT_TEST(pClient, isplit, lscp_list_channels(pClient)); |
341 |
|
CLIENT_TEST(pClient, int, iSamplerChannel = lscp_add_channel(pClient)); |
342 |
|
printf("\n--- iSamplerChannel=%d ---\n", iSamplerChannel); |
343 |
|
CLIENT_TEST(pClient, channel_info, lscp_get_channel_info(pClient, iSamplerChannel)); |
344 |
|
CLIENT_TEST(pClient, status, lscp_load_engine(pClient, pszEngine, iSamplerChannel)); |
345 |
|
CLIENT_TEST(pClient, status, lscp_load_instrument(pClient, "DefaultInstrument.gig", 0, iSamplerChannel)); |
346 |
|
CLIENT_TEST(pClient, int, lscp_get_channel_voice_count(pClient, iSamplerChannel)); |
347 |
|
CLIENT_TEST(pClient, int, lscp_get_channel_stream_count(pClient, iSamplerChannel)); |
348 |
|
CLIENT_TEST(pClient, int, lscp_get_channel_stream_usage(pClient, iSamplerChannel)); |
349 |
|
CLIENT_TEST(pClient, buffer_fill, lscp_get_channel_buffer_fill(pClient, LSCP_USAGE_BYTES, iSamplerChannel)); |
350 |
|
CLIENT_TEST(pClient, buffer_fill, lscp_get_channel_buffer_fill(pClient, LSCP_USAGE_PERCENTAGE, iSamplerChannel)); |
351 |
|
CLIENT_TEST(pClient, status, lscp_set_channel_audio_type(pClient, iSamplerChannel, pszAudioDriver)); |
352 |
|
CLIENT_TEST(pClient, status, lscp_set_channel_audio_device(pClient, iSamplerChannel, 0)); |
353 |
|
CLIENT_TEST(pClient, status, lscp_set_channel_audio_channel(pClient, iSamplerChannel, 0, 1)); |
354 |
|
CLIENT_TEST(pClient, status, lscp_set_channel_midi_type(pClient, iSamplerChannel, pszMidiDriver)); |
355 |
|
CLIENT_TEST(pClient, status, lscp_set_channel_midi_device(pClient, iSamplerChannel, 0)); |
356 |
|
CLIENT_TEST(pClient, status, lscp_set_channel_midi_channel(pClient, iSamplerChannel, 0)); |
357 |
|
CLIENT_TEST(pClient, status, lscp_set_channel_midi_port(pClient, iSamplerChannel, 0)); |
358 |
|
CLIENT_TEST(pClient, status, lscp_set_channel_volume(pClient, iSamplerChannel, 0.5)); |
359 |
|
CLIENT_TEST(pClient, status, lscp_set_channel_mute(pClient, iSamplerChannel, 1)); |
360 |
|
CLIENT_TEST(pClient, status, lscp_set_channel_solo(pClient, iSamplerChannel, 1)); |
361 |
|
CLIENT_TEST(pClient, channel_info, lscp_get_channel_info(pClient, iSamplerChannel)); |
362 |
|
CLIENT_TEST(pClient, status, lscp_reset_channel(pClient, iSamplerChannel)); |
363 |
|
CLIENT_TEST(pClient, status, lscp_remove_channel(pClient, iSamplerChannel)); |
364 |
|
|
365 |
|
midi_instr.bank_msb = 0; |
366 |
|
midi_instr.bank_lsb = 0; |
367 |
|
midi_instr.program = 0; |
368 |
|
printf("\n--- midi_instr={%d,%d,%d} ---\n", midi_instr.bank_msb, midi_instr.bank_lsb, midi_instr.program); |
369 |
|
CLIENT_TEST(pClient, status, lscp_map_midi_instrument(pClient, &midi_instr, pszEngine, "DefaultInstrument.gig", 0, 1.0f, LSCP_LOAD_ON_DEMAND, "DummyName")); |
370 |
|
CLIENT_TEST(pClient, int, lscp_get_midi_instruments(pClient)); |
371 |
|
CLIENT_TEST(pClient, midi_instrument_info, lscp_get_midi_instrument_info(pClient, &midi_instr)); |
372 |
|
CLIENT_TEST(pClient, status, lscp_unmap_midi_instrument(pClient, &midi_instr)); |
373 |
|
CLIENT_TEST(pClient, status, lscp_clear_midi_instruments(pClient)); |
374 |
|
} |
375 |
|
|
376 |
|
|
377 |
void client_test ( lscp_client_t *pClient ) |
void client_test_midi_port ( lscp_client_t *pClient, int iMidiDevice, int iMidiPort ) |
378 |
|
{ |
379 |
|
lscp_device_port_info_t *pMidiPortInfo; |
380 |
|
const char *pszParam; |
381 |
|
int i; |
382 |
|
|
383 |
|
printf("\n--- iMidiDevice=%d iMidiPort=%d ---\n", iMidiDevice, iMidiPort); |
384 |
|
CLIENT_TEST(pClient, device_port_info, pMidiPortInfo = lscp_get_midi_port_info(pClient, iMidiDevice, iMidiPort)); |
385 |
|
if (pMidiPortInfo && pMidiPortInfo->params) { |
386 |
|
for (i = 0; pMidiPortInfo->params[i].key; i++) { |
387 |
|
pszParam = pMidiPortInfo->params[i].key; |
388 |
|
printf("\n--- iMidiDevice=%d iMidiPort=%d pszParam=\"%s\" ---\n", iMidiDevice, iMidiPort, pszParam); |
389 |
|
CLIENT_TEST(pClient, param_info, lscp_get_midi_port_param_info(pClient, iMidiDevice, iMidiPort, pszParam)); |
390 |
|
} |
391 |
|
} |
392 |
|
} |
393 |
|
|
394 |
|
|
395 |
|
void client_test_audio_channel ( lscp_client_t *pClient, int iAudioDevice, int iAudioChannel ) |
396 |
|
{ |
397 |
|
lscp_device_port_info_t *pAudioChannelInfo; |
398 |
|
const char *pszParam; |
399 |
|
int i; |
400 |
|
|
401 |
|
printf("\n--- iAudioDevice=%d iAudioChannel=%d ---\n", iAudioDevice, iAudioChannel); |
402 |
|
CLIENT_TEST(pClient, device_port_info, pAudioChannelInfo = lscp_get_audio_channel_info(pClient, iAudioDevice, iAudioChannel)); |
403 |
|
if (pAudioChannelInfo && pAudioChannelInfo->params) { |
404 |
|
for (i = 0; pAudioChannelInfo->params[i].key; i++) { |
405 |
|
pszParam = pAudioChannelInfo->params[i].key; |
406 |
|
printf("\n--- iAudioDevice=%d iAudioChannel=%d pszParam=\"%s\" ---\n", iAudioDevice, iAudioChannel, pszParam); |
407 |
|
CLIENT_TEST(pClient, param_info, lscp_get_audio_channel_param_info(pClient, iAudioDevice, iAudioChannel, pszParam)); |
408 |
|
} |
409 |
|
} |
410 |
|
} |
411 |
|
|
412 |
|
|
413 |
|
void client_test_midi_device ( lscp_client_t *pClient, int iMidiDevice ) |
414 |
|
{ |
415 |
|
lscp_device_info_t *pDeviceInfo; |
416 |
|
const char *pszValue; |
417 |
|
int iMidiPort, iMidiPorts; |
418 |
|
|
419 |
|
printf("\n--- iMidiDevice=%d ---\n", iMidiDevice); |
420 |
|
CLIENT_TEST(pClient, device_info, pDeviceInfo = lscp_get_midi_device_info(pClient, iMidiDevice)); |
421 |
|
if (pDeviceInfo && pDeviceInfo->params) { |
422 |
|
pszValue = lscp_get_param_value(pDeviceInfo->params, "ports"); |
423 |
|
if (pszValue) { |
424 |
|
iMidiPorts = atoi(pszValue); |
425 |
|
for (iMidiPort = 0; iMidiPort < iMidiPorts; iMidiPort++) |
426 |
|
client_test_midi_port(pClient, iMidiDevice, iMidiPort); |
427 |
|
} |
428 |
|
} |
429 |
|
} |
430 |
|
|
431 |
|
|
432 |
|
void client_test_audio_device ( lscp_client_t *pClient, int iAudioDevice ) |
433 |
|
{ |
434 |
|
lscp_device_info_t *pDeviceInfo; |
435 |
|
const char *pszValue; |
436 |
|
int iAudioChannel, iAudioChannels; |
437 |
|
|
438 |
|
printf("\n--- iAudioDevice=%d ---\n", iAudioDevice); |
439 |
|
CLIENT_TEST(pClient, device_info, pDeviceInfo = lscp_get_audio_device_info(pClient, iAudioDevice)); |
440 |
|
if (pDeviceInfo && pDeviceInfo->params) { |
441 |
|
pszValue = lscp_get_param_value(pDeviceInfo->params, "channels"); |
442 |
|
if (pszValue) { |
443 |
|
iAudioChannels = atoi(pszValue); |
444 |
|
for (iAudioChannel = 0; iAudioChannel < iAudioChannels; iAudioChannel++) |
445 |
|
client_test_audio_channel(pClient, iAudioDevice, iAudioChannel); |
446 |
|
} |
447 |
|
} |
448 |
|
} |
449 |
|
|
450 |
|
|
451 |
|
void client_test_midi_driver ( lscp_client_t *pClient, const char *pszMidiDriver ) |
452 |
|
{ |
453 |
|
lscp_driver_info_t *pDriverInfo; |
454 |
|
const char *pszParam; |
455 |
|
int i; |
456 |
|
|
457 |
|
printf("\n--- pszMidiDriver=\"%s\" ---\n", pszMidiDriver); |
458 |
|
CLIENT_TEST(pClient, driver_info, pDriverInfo = lscp_get_midi_driver_info(pClient, pszMidiDriver)); |
459 |
|
if (pDriverInfo && pDriverInfo->parameters) { |
460 |
|
for (i = 0; pDriverInfo->parameters[i]; i++) { |
461 |
|
pszParam = pDriverInfo->parameters[i]; |
462 |
|
printf("\n--- pszMidiDriver=\"%s\" pszParam=\"%s\" ---\n", pszMidiDriver, pszParam); |
463 |
|
CLIENT_TEST(pClient, param_info, lscp_get_midi_driver_param_info(pClient, pszMidiDriver, pszParam, NULL)); |
464 |
|
} |
465 |
|
} |
466 |
|
} |
467 |
|
|
468 |
|
|
469 |
|
void client_test_audio_driver ( lscp_client_t *pClient, const char *pszAudioDriver ) |
470 |
|
{ |
471 |
|
lscp_driver_info_t *pDriverInfo; |
472 |
|
const char *pszParam; |
473 |
|
int i; |
474 |
|
|
475 |
|
printf("\n--- pszAudioDriver=\"%s\" ---\n", pszAudioDriver); |
476 |
|
CLIENT_TEST(pClient, driver_info, pDriverInfo = lscp_get_audio_driver_info(pClient, pszAudioDriver)); |
477 |
|
if (pDriverInfo && pDriverInfo->parameters) { |
478 |
|
for (i = 0; pDriverInfo->parameters[i]; i++) { |
479 |
|
pszParam = pDriverInfo->parameters[i]; |
480 |
|
printf("\n--- pszAudioDriver=\"%s\" pszParam=\"%s\" ---\n", pszAudioDriver, pszParam); |
481 |
|
CLIENT_TEST(pClient, param_info, lscp_get_audio_driver_param_info(pClient, pszAudioDriver, pszParam, NULL)); |
482 |
|
} |
483 |
|
} |
484 |
|
} |
485 |
|
|
486 |
|
|
487 |
|
void client_test_all ( lscp_client_t *pClient, int step ) |
488 |
{ |
{ |
489 |
const char **ppszAudioDrivers, **ppszMidiDrivers, **ppszEngines; |
const char **ppszAudioDrivers, **ppszMidiDrivers, **ppszEngines; |
490 |
const char *pszAudioDriver, *pszMidiDriver, *pszEngine; |
const char *pszAudioDriver, *pszMidiDriver, *pszEngine; |
491 |
int iAudioDriver, iMidiDriver, iEngine; |
int iAudioDriver, iMidiDriver, iEngine; |
492 |
int iAudioDevice, iMidiDevice; |
int iAudio, iAudioDevice, iMidi, iMidiDevice; |
493 |
int iSamplerChannel; |
int iNewAudioDevice, iNewMidiDevice; |
494 |
|
int *piAudioDevices, *piMidiDevices; |
495 |
|
|
496 |
|
g_test_step = step; |
497 |
|
g_test_count = 0; |
498 |
|
g_test_fails = 0; |
499 |
|
|
500 |
|
CLIENT_TEST(pClient, server_info, lscp_get_server_info(pClient)); |
501 |
|
|
502 |
CLIENT_TEST(pClient, szsplit, ppszAudioDrivers = lscp_get_available_audio_drivers(pClient)); |
CLIENT_TEST(pClient, int, lscp_get_available_audio_drivers(pClient)); |
503 |
|
CLIENT_TEST(pClient, szsplit, ppszAudioDrivers = lscp_list_available_audio_drivers(pClient)); |
504 |
if (ppszAudioDrivers == NULL) { |
if (ppszAudioDrivers == NULL) { |
505 |
fprintf(stderr, "client_test: No audio drivers available.\n"); |
fprintf(stderr, "client_test: No audio drivers available.\n"); |
506 |
return; |
return; |
507 |
} |
} |
508 |
|
|
509 |
CLIENT_TEST(pClient, szsplit, ppszMidiDrivers = lscp_get_available_midi_drivers(pClient)); |
CLIENT_TEST(pClient, int, lscp_get_available_midi_drivers(pClient)); |
510 |
|
CLIENT_TEST(pClient, szsplit, ppszMidiDrivers = lscp_list_available_midi_drivers(pClient)); |
511 |
if (ppszMidiDrivers == NULL) { |
if (ppszMidiDrivers == NULL) { |
512 |
fprintf(stderr, "client_test: No MIDI drivers available.\n"); |
fprintf(stderr, "client_test: No MIDI drivers available.\n"); |
513 |
return; |
return; |
514 |
} |
} |
515 |
|
|
516 |
CLIENT_TEST(pClient, szsplit, ppszEngines = lscp_get_available_engines(pClient)); |
CLIENT_TEST(pClient, int, lscp_get_available_engines(pClient)); |
517 |
|
CLIENT_TEST(pClient, szsplit, ppszEngines = lscp_list_available_engines(pClient)); |
518 |
if (ppszEngines == NULL) { |
if (ppszEngines == NULL) { |
519 |
fprintf(stderr, "client_test: No engines available.\n"); |
fprintf(stderr, "client_test: No engines available.\n"); |
520 |
return; |
return; |
521 |
} |
} |
522 |
|
|
|
CLIENT_TEST(pClient, int, lscp_get_audio_devices(pClient)); |
|
|
CLIENT_TEST(pClient, isplit, lscp_list_audio_devices(pClient)); |
|
|
|
|
|
CLIENT_TEST(pClient, int, lscp_get_midi_devices(pClient)); |
|
|
CLIENT_TEST(pClient, isplit, lscp_list_midi_devices(pClient)); |
|
|
|
|
523 |
for (iAudioDriver = 0; ppszAudioDrivers[iAudioDriver]; iAudioDriver++) { |
for (iAudioDriver = 0; ppszAudioDrivers[iAudioDriver]; iAudioDriver++) { |
524 |
pszAudioDriver = ppszAudioDrivers[iAudioDriver]; |
pszAudioDriver = ppszAudioDrivers[iAudioDriver]; |
525 |
printf("\n--- pszAudioDriver=\"%s\" ---\n", pszAudioDriver); |
client_test_audio_driver(pClient, pszAudioDriver); |
526 |
CLIENT_TEST(pClient, driver_info, lscp_get_audio_driver_info(pClient, pszAudioDriver)); |
CLIENT_TEST(pClient, int, iNewAudioDevice = lscp_create_audio_device(pClient, pszAudioDriver, NULL)); |
527 |
CLIENT_TEST(pClient, param_info, lscp_get_audio_driver_param_info(pClient, pszAudioDriver, "active", NULL)); |
CLIENT_TEST(pClient, int, lscp_get_audio_devices(pClient)); |
528 |
CLIENT_TEST(pClient, int, iAudioDevice = lscp_create_audio_device(pClient, pszAudioDriver, NULL)); |
CLIENT_TEST(pClient, isplit, piAudioDevices = lscp_list_audio_devices(pClient)); |
529 |
CLIENT_TEST(pClient, device_info, lscp_get_audio_device_info(pClient, iAudioDevice)); |
for (iAudio = 0; piAudioDevices && piAudioDevices[iAudio] >= 0; iAudio++) { |
530 |
for (iMidiDriver = 0; ppszMidiDrivers[iMidiDriver]; iMidiDriver++) { |
iAudioDevice = piAudioDevices[iAudio]; |
531 |
pszMidiDriver = ppszMidiDrivers[iMidiDriver]; |
client_test_audio_device(pClient, iAudioDevice); |
532 |
printf("\n--- pszMidiDriver=\"%s\" ---\n", pszMidiDriver); |
for (iMidiDriver = 0; ppszMidiDrivers[iMidiDriver]; iMidiDriver++) { |
533 |
CLIENT_TEST(pClient, driver_info, lscp_get_midi_driver_info(pClient, pszMidiDriver)); |
pszMidiDriver = ppszMidiDrivers[iMidiDriver]; |
534 |
CLIENT_TEST(pClient, param_info, lscp_get_midi_driver_param_info(pClient, pszMidiDriver, "active", NULL)); |
client_test_midi_driver(pClient, pszMidiDriver); |
535 |
CLIENT_TEST(pClient, int, iMidiDevice = lscp_create_midi_device(pClient, pszMidiDriver, NULL)); |
CLIENT_TEST(pClient, int, iNewMidiDevice = lscp_create_midi_device(pClient, pszMidiDriver, NULL)); |
536 |
CLIENT_TEST(pClient, device_info, lscp_get_midi_device_info(pClient, iMidiDevice)); |
CLIENT_TEST(pClient, int, lscp_get_midi_devices(pClient)); |
537 |
for (iEngine = 0; ppszEngines[iEngine]; iEngine++) { |
CLIENT_TEST(pClient, isplit, piMidiDevices = lscp_list_midi_devices(pClient)); |
538 |
pszEngine = ppszEngines[iEngine]; |
for (iMidi = 0; piMidiDevices && piMidiDevices[iMidi] >= 0; iMidi++) { |
539 |
printf("\n--- pszEngine=\"%s\" ---\n", pszEngine); |
iMidiDevice = piMidiDevices[iMidi]; |
540 |
CLIENT_TEST(pClient, engine_info, lscp_get_engine_info(pClient, pszEngine)); |
client_test_midi_device(pClient, iMidiDevice); |
541 |
CLIENT_TEST(pClient, int, lscp_get_channels(pClient)); |
for (iEngine = 0; ppszEngines[iEngine]; iEngine++) { |
542 |
CLIENT_TEST(pClient, isplit, lscp_list_channels(pClient)); |
pszEngine = ppszEngines[iEngine]; |
543 |
CLIENT_TEST(pClient, int, iSamplerChannel = lscp_add_channel(pClient)); |
client_test_engine(pClient, pszEngine, pszAudioDriver, iAudioDevice, pszMidiDriver, iMidiDevice); |
544 |
CLIENT_TEST(pClient, channel_info, lscp_get_channel_info(pClient, iSamplerChannel)); |
} |
545 |
CLIENT_TEST(pClient, status, lscp_load_engine(pClient, pszEngine, iSamplerChannel)); |
} |
546 |
CLIENT_TEST(pClient, status, lscp_load_instrument(pClient, "DefaultInstrument.gig", 0, iSamplerChannel)); |
CLIENT_TEST(pClient, status, lscp_destroy_midi_device(pClient, iNewMidiDevice)); |
547 |
CLIENT_TEST(pClient, int, lscp_get_channel_voice_count(pClient, iSamplerChannel)); |
} |
548 |
CLIENT_TEST(pClient, int, lscp_get_channel_stream_count(pClient, iSamplerChannel)); |
} |
549 |
CLIENT_TEST(pClient, int, lscp_get_channel_stream_usage(pClient, iSamplerChannel)); |
CLIENT_TEST(pClient, status, lscp_destroy_audio_device(pClient, iNewAudioDevice)); |
|
CLIENT_TEST(pClient, buffer_fill, lscp_get_channel_buffer_fill(pClient, LSCP_USAGE_BYTES, iSamplerChannel)); |
|
|
CLIENT_TEST(pClient, buffer_fill, lscp_get_channel_buffer_fill(pClient, LSCP_USAGE_PERCENTAGE, iSamplerChannel)); |
|
|
CLIENT_TEST(pClient, status, lscp_set_channel_audio_type(pClient, iSamplerChannel, pszAudioDriver)); |
|
|
CLIENT_TEST(pClient, status, lscp_set_channel_audio_device(pClient, iSamplerChannel, 0)); |
|
|
CLIENT_TEST(pClient, status, lscp_set_channel_audio_channel(pClient, iSamplerChannel, 0, 1)); |
|
|
CLIENT_TEST(pClient, status, lscp_set_channel_midi_type(pClient, iSamplerChannel, pszMidiDriver)); |
|
|
CLIENT_TEST(pClient, status, lscp_set_channel_midi_device(pClient, iSamplerChannel, 0)); |
|
|
CLIENT_TEST(pClient, status, lscp_set_channel_midi_channel(pClient, iSamplerChannel, 0)); |
|
|
CLIENT_TEST(pClient, status, lscp_set_channel_midi_port(pClient, iSamplerChannel, 0)); |
|
|
CLIENT_TEST(pClient, status, lscp_set_channel_volume(pClient, iSamplerChannel, 0.5)); |
|
|
CLIENT_TEST(pClient, channel_info, lscp_get_channel_info(pClient, iSamplerChannel)); |
|
|
CLIENT_TEST(pClient, status, lscp_reset_channel(pClient, iSamplerChannel)); |
|
|
CLIENT_TEST(pClient, status, lscp_remove_channel(pClient, iSamplerChannel)); |
|
|
} |
|
|
CLIENT_TEST(pClient, status, lscp_destroy_midi_device(pClient, iMidiDevice)); |
|
|
} |
|
|
CLIENT_TEST(pClient, status, lscp_destroy_audio_device(pClient, iAudioDevice)); |
|
550 |
} |
} |
551 |
|
|
552 |
|
CLIENT_TEST(pClient, status, lscp_reset_sampler(pClient)); |
553 |
|
|
554 |
|
printf("\n\n"); |
555 |
|
printf(" Total: %d tests, %d failed.\n\n", g_test_count, g_test_fails); |
556 |
} |
} |
557 |
|
|
558 |
|
|
559 |
//////////////////////////////////////////////////////////////////////// |
//////////////////////////////////////////////////////////////////////// |
560 |
|
|
561 |
void client_usage (void) |
void client_usage (void) |
562 |
{ |
{ |
563 |
printf("\n %s %s (Build: %s)\n", lscp_client_package(), lscp_client_version(), lscp_client_build()); |
printf("\n %s %s (Build: %s)\n", lscp_client_package(), lscp_client_version(), lscp_client_build()); |
564 |
|
|
565 |
fputs("\n Available client commands: help, test, exit, quit, subscribe, unsubscribe", stdout); |
fputs("\n Available commands: help, test[step], exit, quit, subscribe, unsubscribe", stdout); |
566 |
fputs("\n (all else are sent verbatim to server)\n\n", stdout); |
fputs("\n (all else are sent verbatim to server)\n\n", stdout); |
567 |
|
|
568 |
} |
} |
614 |
lscp_client_unsubscribe(pClient, LSCP_EVENT_MISCELLANEOUS); |
lscp_client_unsubscribe(pClient, LSCP_EVENT_MISCELLANEOUS); |
615 |
else |
else |
616 |
if (strcmp(szLine, "test") == 0) |
if (strcmp(szLine, "test") == 0) |
617 |
client_test(pClient); |
client_test_all(pClient, 0); |
618 |
else |
else |
619 |
if (strcmp(szLine, "teststep") == 0) { |
if (strcmp(szLine, "teststep") == 0 || strcmp(szLine, "test step") == 0) |
620 |
g_teststep = 1; |
client_test_all(pClient, 1); |
|
client_test(pClient); |
|
|
g_teststep = 0; |
|
|
} |
|
621 |
else |
else |
622 |
if (cchLine > 0 && strcmp(szLine, "help") != 0) { |
if (cchLine > 0 && strcmp(szLine, "help") != 0) { |
623 |
szLine[cchLine++] = '\r'; |
szLine[cchLine++] = '\r'; |