2 |
// |
// |
3 |
/**************************************************************************** |
/**************************************************************************** |
4 |
liblscp - LinuxSampler Control Protocol API |
liblscp - LinuxSampler Control Protocol API |
5 |
Copyright (C) 2004, rncbc aka Rui Nuno Capela. All rights reserved. |
Copyright (C) 2004-2005, rncbc aka Rui Nuno Capela. All rights reserved. |
6 |
|
|
7 |
This library is free software; you can redistribute it and/or |
This library is free software; you can redistribute it and/or |
8 |
modify it under the terms of the GNU Lesser General Public |
modify it under the terms of the GNU Lesser General Public |
111 |
} |
} |
112 |
} // Check if select has in error. |
} // Check if select has in error. |
113 |
else if (iSelect < 0) { |
else if (iSelect < 0) { |
114 |
lscp_socket_perror("_lscp_client_call: select"); |
lscp_socket_perror("_lscp_client_evt_proc: select"); |
115 |
pClient->evt.iState = 0; |
pClient->evt.iState = 0; |
116 |
} |
} |
117 |
|
|
641 |
} |
} |
642 |
|
|
643 |
|
|
644 |
|
/** |
645 |
|
* Getting current subscribed events. |
646 |
|
* |
647 |
|
* @param pClient Pointer to client instance structure. |
648 |
|
* |
649 |
|
* @returns The current subscrived bit-wise OR'ed event flags. |
650 |
|
*/ |
651 |
|
lscp_event_t lscp_client_get_events ( lscp_client_t *pClient ) |
652 |
|
{ |
653 |
|
if (pClient == NULL) |
654 |
|
return LSCP_EVENT_NONE; |
655 |
|
|
656 |
|
return pClient->events; |
657 |
|
} |
658 |
|
|
659 |
|
|
660 |
//------------------------------------------------------------------------- |
//------------------------------------------------------------------------- |
661 |
// Client command protocol functions. |
// Client command protocol functions. |
662 |
|
|
836 |
|
|
837 |
|
|
838 |
/** |
/** |
839 |
* Getting all available engines: |
* Getting all available engines count: |
840 |
* GET AVAILABLE_ENGINES |
* GET AVAILABLE_ENGINES |
841 |
* |
* |
842 |
* @param pClient Pointer to client instance structure. |
* @param pClient Pointer to client instance structure. |
843 |
* |
* |
844 |
|
* @returns The current total number of sampler engines on success, |
845 |
|
* -1 otherwise. |
846 |
|
*/ |
847 |
|
int lscp_get_available_engines ( lscp_client_t *pClient ) |
848 |
|
{ |
849 |
|
int iAvailableEngines = -1; |
850 |
|
|
851 |
|
// Lock this section up. |
852 |
|
lscp_mutex_lock(pClient->mutex); |
853 |
|
|
854 |
|
if (lscp_client_call(pClient, "GET AVAILABLE_ENGINES\r\n") == LSCP_OK) |
855 |
|
iAvailableEngines = atoi(lscp_client_get_result(pClient)); |
856 |
|
|
857 |
|
// Unlock this section down. |
858 |
|
lscp_mutex_unlock(pClient->mutex); |
859 |
|
|
860 |
|
return iAvailableEngines; |
861 |
|
} |
862 |
|
|
863 |
|
|
864 |
|
/** |
865 |
|
* Getting all available engines: |
866 |
|
* LIST AVAILABLE_ENGINES |
867 |
|
* |
868 |
|
* @param pClient Pointer to client instance structure. |
869 |
|
* |
870 |
* @returns A NULL terminated array of engine name strings, |
* @returns A NULL terminated array of engine name strings, |
871 |
* or NULL in case of failure. |
* or NULL in case of failure. |
872 |
*/ |
*/ |
873 |
const char **lscp_get_available_engines ( lscp_client_t *pClient ) |
const char **lscp_list_available_engines ( lscp_client_t *pClient ) |
874 |
{ |
{ |
875 |
const char *pszSeps = ","; |
const char *pszSeps = ","; |
876 |
|
|
882 |
pClient->engines = NULL; |
pClient->engines = NULL; |
883 |
} |
} |
884 |
|
|
885 |
if (lscp_client_call(pClient, "GET AVAILABLE_ENGINES\r\n") == LSCP_OK) |
if (lscp_client_call(pClient, "LIST AVAILABLE_ENGINES\r\n") == LSCP_OK) |
886 |
pClient->engines = lscp_szsplit_create(lscp_client_get_result(pClient), pszSeps); |
pClient->engines = lscp_szsplit_create(lscp_client_get_result(pClient), pszSeps); |
887 |
|
|
888 |
// Unlock this section down. |
// Unlock this section down. |
1015 |
if (pszToken) |
if (pszToken) |
1016 |
pChannelInfo->instrument_nr = atoi(lscp_ltrim(pszToken)); |
pChannelInfo->instrument_nr = atoi(lscp_ltrim(pszToken)); |
1017 |
} |
} |
1018 |
|
else if (strcasecmp(pszToken, "INSTRUMENT_NAME") == 0) { |
1019 |
|
pszToken = lscp_strtok(NULL, pszCrlf, &(pch)); |
1020 |
|
if (pszToken) |
1021 |
|
lscp_unquote_dup(&(pChannelInfo->instrument_name), &pszToken); |
1022 |
|
} |
1023 |
else if (strcasecmp(pszToken, "INSTRUMENT_STATUS") == 0) { |
else if (strcasecmp(pszToken, "INSTRUMENT_STATUS") == 0) { |
1024 |
pszToken = lscp_strtok(NULL, pszCrlf, &(pch)); |
pszToken = lscp_strtok(NULL, pszCrlf, &(pch)); |
1025 |
if (pszToken) |
if (pszToken) |
1037 |
} |
} |
1038 |
else if (strcasecmp(pszToken, "MIDI_INPUT_CHANNEL") == 0) { |
else if (strcasecmp(pszToken, "MIDI_INPUT_CHANNEL") == 0) { |
1039 |
pszToken = lscp_strtok(NULL, pszCrlf, &(pch)); |
pszToken = lscp_strtok(NULL, pszCrlf, &(pch)); |
1040 |
if (pszToken) |
if (pszToken) { |
1041 |
pChannelInfo->midi_channel = atoi(lscp_ltrim(pszToken)); |
pszToken = lscp_ltrim(pszToken); |
1042 |
|
if (strcasecmp(pszToken, "ALL") == 0) |
1043 |
|
pChannelInfo->midi_channel = LSCP_MIDI_CHANNEL_ALL; |
1044 |
|
else |
1045 |
|
pChannelInfo->midi_channel = atoi(pszToken); |
1046 |
|
} |
1047 |
} |
} |
1048 |
else if (strcasecmp(pszToken, "VOLUME") == 0) { |
else if (strcasecmp(pszToken, "VOLUME") == 0) { |
1049 |
pszToken = lscp_strtok(NULL, pszCrlf, &(pch)); |
pszToken = lscp_strtok(NULL, pszCrlf, &(pch)); |
1388 |
* |
* |
1389 |
* @param pClient Pointer to client instance structure. |
* @param pClient Pointer to client instance structure. |
1390 |
* @param iSamplerChannel Sampler channel number. |
* @param iSamplerChannel Sampler channel number. |
1391 |
* @param iMidiChannel MIDI channel number to listen (1-16) or |
* @param iMidiChannel MIDI channel address number to listen (0-15) or |
1392 |
* zero (0) to listen on all channels. |
* LSCP_MIDI_CHANNEL_ALL (16) to listen on all channels. |
1393 |
* |
* |
1394 |
* @returns LSCP_OK on success, LSCP_FAILED otherwise. |
* @returns LSCP_OK on success, LSCP_FAILED otherwise. |
1395 |
*/ |
*/ |
1400 |
if (iSamplerChannel < 0 || iMidiChannel < 0 || iMidiChannel > 16) |
if (iSamplerChannel < 0 || iMidiChannel < 0 || iMidiChannel > 16) |
1401 |
return LSCP_FAILED; |
return LSCP_FAILED; |
1402 |
|
|
1403 |
if (iMidiChannel > 0) |
if (iMidiChannel == LSCP_MIDI_CHANNEL_ALL) |
|
sprintf(szQuery, "SET CHANNEL MIDI_INPUT_CHANNEL %d %d\r\n", iSamplerChannel, iMidiChannel); |
|
|
else |
|
1404 |
sprintf(szQuery, "SET CHANNEL MIDI_INPUT_CHANNEL %d ALL\r\n", iSamplerChannel); |
sprintf(szQuery, "SET CHANNEL MIDI_INPUT_CHANNEL %d ALL\r\n", iSamplerChannel); |
1405 |
|
else |
1406 |
|
sprintf(szQuery, "SET CHANNEL MIDI_INPUT_CHANNEL %d %d\r\n", iSamplerChannel, iMidiChannel); |
1407 |
return lscp_client_query(pClient, szQuery); |
return lscp_client_query(pClient, szQuery); |
1408 |
} |
} |
1409 |
|
|
1453 |
} |
} |
1454 |
|
|
1455 |
|
|
1456 |
|
/** |
1457 |
|
* Resetting the sampler: |
1458 |
|
* RESET |
1459 |
|
* |
1460 |
|
* @param pClient Pointer to client instance structure. |
1461 |
|
* |
1462 |
|
* @returns LSCP_OK on success, LSCP_FAILED otherwise. |
1463 |
|
*/ |
1464 |
|
lscp_status_t lscp_reset_sampler ( lscp_client_t *pClient ) |
1465 |
|
{ |
1466 |
|
return lscp_client_query(pClient, "RESET\r\n"); |
1467 |
|
} |
1468 |
|
|
1469 |
|
|
1470 |
// end of client.c |
// end of client.c |