2 |
// |
// |
3 |
/**************************************************************************** |
/**************************************************************************** |
4 |
liblscp - LinuxSampler Control Protocol API |
liblscp - LinuxSampler Control Protocol API |
5 |
Copyright (C) 2004-2005, rncbc aka Rui Nuno Capela. All rights reserved. |
Copyright (C) 2004-2006, 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 |
14 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
15 |
Lesser General Public License for more details. |
Lesser General Public License for more details. |
16 |
|
|
17 |
You should have received a copy of the GNU Lesser General Public |
You should have received a copy of the GNU General Public License along |
18 |
License along with this library; 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 |
|
|
69 |
|
|
70 |
// Use the timeout (x10) select feature ... |
// Use the timeout (x10) select feature ... |
71 |
iTimeout = 10 * pClient->iTimeout; |
iTimeout = 10 * pClient->iTimeout; |
72 |
if (iTimeout > 1000) { |
if (iTimeout >= 1000) { |
73 |
tv.tv_sec = iTimeout / 1000; |
tv.tv_sec = iTimeout / 1000; |
74 |
iTimeout -= tv.tv_sec * 1000; |
iTimeout -= tv.tv_sec * 1000; |
75 |
} |
} |
348 |
pClient->iStreamCount = 0; |
pClient->iStreamCount = 0; |
349 |
// Default timeout value. |
// Default timeout value. |
350 |
pClient->iTimeout = LSCP_TIMEOUT_MSECS; |
pClient->iTimeout = LSCP_TIMEOUT_MSECS; |
351 |
|
pClient->iTimeoutCount = 0; |
352 |
|
|
353 |
// Initialize the transaction mutex. |
// Initialize the transaction mutex. |
354 |
lscp_mutex_init(pClient->mutex); |
lscp_mutex_init(pClient->mutex); |
1053 |
if (pszToken) |
if (pszToken) |
1054 |
pChannelInfo->volume = (float) atof(lscp_ltrim(pszToken)); |
pChannelInfo->volume = (float) atof(lscp_ltrim(pszToken)); |
1055 |
} |
} |
1056 |
|
else if (strcasecmp(pszToken, "MUTE") == 0) { |
1057 |
|
pszToken = lscp_strtok(NULL, pszCrlf, &(pch)); |
1058 |
|
if (pszToken) |
1059 |
|
pChannelInfo->mute = (strcasecmp(lscp_unquote(&pszToken, 0), "TRUE") == 0); |
1060 |
|
} |
1061 |
|
else if (strcasecmp(pszToken, "SOLO") == 0) { |
1062 |
|
pszToken = lscp_strtok(NULL, pszCrlf, &(pch)); |
1063 |
|
if (pszToken) |
1064 |
|
pChannelInfo->solo = (strcasecmp(lscp_unquote(&pszToken, 0), "TRUE") == 0); |
1065 |
|
} |
1066 |
pszToken = lscp_strtok(NULL, pszSeps, &(pch)); |
pszToken = lscp_strtok(NULL, pszSeps, &(pch)); |
1067 |
} |
} |
1068 |
} |
} |
1446 |
|
|
1447 |
|
|
1448 |
/** |
/** |
1449 |
|
* Muting a sampler channel: |
1450 |
|
* SET CHANNEL MUTE <sampler-channel> <mute> |
1451 |
|
* |
1452 |
|
* @param pClient Pointer to client instance structure. |
1453 |
|
* @param iSamplerChannel Sampler channel number. |
1454 |
|
* @param iMute Sampler channel mute state as a boolean value, |
1455 |
|
* either 1 (one) to mute the channel or 0 (zero) |
1456 |
|
* to unmute the channel. |
1457 |
|
* |
1458 |
|
* @returns LSCP_OK on success, LSCP_FAILED otherwise. |
1459 |
|
*/ |
1460 |
|
lscp_status_t lscp_set_channel_mute ( lscp_client_t *pClient, int iSamplerChannel, int iMute ) |
1461 |
|
{ |
1462 |
|
char szQuery[LSCP_BUFSIZ]; |
1463 |
|
|
1464 |
|
if (iSamplerChannel < 0 || iMute < 0 || iMute > 1) |
1465 |
|
return LSCP_FAILED; |
1466 |
|
|
1467 |
|
sprintf(szQuery, "SET CHANNEL MUTE %d %d\r\n", iSamplerChannel, iMute); |
1468 |
|
return lscp_client_query(pClient, szQuery); |
1469 |
|
} |
1470 |
|
|
1471 |
|
|
1472 |
|
/** |
1473 |
|
* Soloing a sampler channel: |
1474 |
|
* SET CHANNEL SOLO <sampler-channel> <solo> |
1475 |
|
* |
1476 |
|
* @param pClient Pointer to client instance structure. |
1477 |
|
* @param iSamplerChannel Sampler channel number. |
1478 |
|
* @param iSolo Sampler channel solo state as a boolean value, |
1479 |
|
* either 1 (one) to solo the channel or 0 (zero) |
1480 |
|
* to unsolo the channel. |
1481 |
|
* |
1482 |
|
* @returns LSCP_OK on success, LSCP_FAILED otherwise. |
1483 |
|
*/ |
1484 |
|
lscp_status_t lscp_set_channel_solo ( lscp_client_t *pClient, int iSamplerChannel, int iSolo ) |
1485 |
|
{ |
1486 |
|
char szQuery[LSCP_BUFSIZ]; |
1487 |
|
|
1488 |
|
if (iSamplerChannel < 0 || iSolo < 0 || iSolo > 1) |
1489 |
|
return LSCP_FAILED; |
1490 |
|
|
1491 |
|
sprintf(szQuery, "SET CHANNEL SOLO %d %d\r\n", iSamplerChannel, iSolo); |
1492 |
|
return lscp_client_query(pClient, szQuery); |
1493 |
|
} |
1494 |
|
|
1495 |
|
|
1496 |
|
/** |
1497 |
* Resetting a sampler channel: |
* Resetting a sampler channel: |
1498 |
* RESET CHANNEL <sampler-channel> |
* RESET CHANNEL <sampler-channel> |
1499 |
* |
* |
1550 |
lscp_mutex_lock(pClient->mutex); |
lscp_mutex_lock(pClient->mutex); |
1551 |
|
|
1552 |
pServerInfo = &(pClient->server_info); |
pServerInfo = &(pClient->server_info); |
1553 |
lscp_engine_info_reset(pServerInfo); |
lscp_server_info_reset(pServerInfo); |
1554 |
|
|
1555 |
if (lscp_client_call(pClient, "GET SERVER INFO\r\n") == LSCP_OK) { |
if (lscp_client_call(pClient, "GET SERVER INFO\r\n") == LSCP_OK) { |
1556 |
pszResult = lscp_client_get_result(pClient); |
pszResult = lscp_client_get_result(pClient); |