/[svn]/liblscp/trunk/src/client.c
ViewVC logotype

Diff of /liblscp/trunk/src/client.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1806 by schoenebeck, Thu Dec 11 01:28:42 2008 UTC revision 3666 by schoenebeck, Sun Dec 22 13:10:04 2019 UTC
# Line 2  Line 2 
2  //  //
3  /****************************************************************************  /****************************************************************************
4     liblscp - LinuxSampler Control Protocol API     liblscp - LinuxSampler Control Protocol API
5     Copyright (C) 2004-2008, rncbc aka Rui Nuno Capela. All rights reserved.     Copyright (C) 2004-2019, 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
# Line 22  Line 22 
22    
23  #include <locale.h>  #include <locale.h>
24  #include "common.h"  #include "common.h"
25    #include <sys/time.h>
26    #ifdef WIN32
27    # include <errno.h>
28    #else
29    # include <sys/errno.h>
30    #endif
31    
32    
33  // Default timeout value (in milliseconds).  // Default timeout value (in milliseconds).
34  #define LSCP_TIMEOUT_MSECS  500  #define LSCP_TIMEOUT_MSECS  500
35    
36    
37    // Whether to use getaddrinfo() instead
38    // of deprecated gethostbyname()
39    #if !defined(WIN32)
40    #define USE_GETADDRINFO 1
41    #endif
42    
43    
44  // Local prototypes.  // Local prototypes.
45    
46  static void             _lscp_client_evt_proc       (void *pvClient);  static void _lscp_client_evt_proc (void *pvClient);
47    
48  static lscp_status_t    _lscp_client_evt_connect    (lscp_client_t *pClient);  static lscp_status_t _lscp_client_evt_connect (lscp_client_t *pClient);
49  static lscp_status_t    _lscp_client_evt_request    (lscp_client_t *pClient, int iSubscribe, lscp_event_t event);  static lscp_status_t _lscp_client_evt_request (lscp_client_t *pClient,
50            int iSubscribe, lscp_event_t event);
51    
52    
53  //-------------------------------------------------------------------------  //-------------------------------------------------------------------------
54  // General helper functions.  // General helper functions.
55    
56  struct _locale_t {  struct _locale_t {
57          char numeric[32];          char numeric[32+1];
58          char ctype[32];          char ctype[32+1];
59  };  };
60    
61  // we need to ensure a constant locale setting e.g. for parsing  // we need to ensure a constant locale setting e.g. for parsing
# Line 48  struct _locale_t { Line 63  struct _locale_t {
63  // character varies by the invidual locale settings  // character varies by the invidual locale settings
64  static void _save_and_set_c_locale(struct _locale_t* locale)  static void _save_and_set_c_locale(struct _locale_t* locale)
65  {  {
66            locale->numeric[32] = locale->ctype[32] = 0;
67          strncpy(locale->numeric, setlocale(LC_NUMERIC, NULL), 32);          strncpy(locale->numeric, setlocale(LC_NUMERIC, NULL), 32);
68          strncpy(locale->ctype, setlocale(LC_CTYPE, NULL), 32);          strncpy(locale->ctype, setlocale(LC_CTYPE, NULL), 32);
69          setlocale(LC_NUMERIC, "C");          setlocale(LC_NUMERIC, "C");
# Line 86  static void _lscp_client_evt_proc ( void Line 102  static void _lscp_client_evt_proc ( void
102          char   achBuffer[LSCP_BUFSIZ];          char   achBuffer[LSCP_BUFSIZ];
103          int    cchBuffer;          int    cchBuffer;
104          const char *pszSeps = ":\r\n";          const char *pszSeps = ":\r\n";
105          char * pszToken;          char  *pszToken;
106          char * pch;          char  *pch;
107          int     cchToken;          int    cchToken;
108    
109          lscp_event_t event;          lscp_event_t event;
110    
111  #ifdef DEBUG  #ifdef DEBUG
# Line 147  static void _lscp_client_evt_proc ( void Line 164  static void _lscp_client_evt_proc ( void
164                          } else {                          } else {
165                                  lscp_socket_perror("_lscp_client_evt_proc: recv");                                  lscp_socket_perror("_lscp_client_evt_proc: recv");
166                                  pClient->evt.iState = 0;                                  pClient->evt.iState = 0;
167                                    pClient->iErrno = -errno;
168                          }                          }
169                  }   // Check if select has in error.                  }   // Check if select has in error.
170                  else if (iSelect < 0) {                  else if (iSelect < 0) {
171                          lscp_socket_perror("_lscp_client_evt_proc: select");                          lscp_socket_perror("_lscp_client_evt_proc: select");
172                          pClient->evt.iState = 0;                          pClient->evt.iState = 0;
173                            pClient->iErrno = -errno;
174                  }                  }
175    
176                  // Finally, always signal the event.                  // Finally, always signal the event.
# Line 185  static lscp_status_t _lscp_client_evt_co Line 204  static lscp_status_t _lscp_client_evt_co
204          }          }
205    
206  #if defined(WIN32)  #if defined(WIN32)
207          if (setsockopt(sock, SOL_SOCKET, SO_DONTLINGER, (char *) &iSockOpt, sizeof(int)) == SOCKET_ERROR)          if (setsockopt(sock, SOL_SOCKET, SO_DONTLINGER,
208                            (char *) &iSockOpt, sizeof(int)) == SOCKET_ERROR)
209                  lscp_socket_perror("lscp_client_evt_connect: setsockopt(SO_DONTLINGER)");                  lscp_socket_perror("lscp_client_evt_connect: setsockopt(SO_DONTLINGER)");
210  #endif  #endif
211    
# Line 213  static lscp_status_t _lscp_client_evt_co Line 233  static lscp_status_t _lscp_client_evt_co
233    
234    
235  // Subscribe to a single event.  // Subscribe to a single event.
236  static lscp_status_t _lscp_client_evt_request ( lscp_client_t *pClient, int iSubscribe, lscp_event_t event )  static lscp_status_t _lscp_client_evt_request ( lscp_client_t *pClient,
237            int iSubscribe, lscp_event_t event )
238  {  {
239          const char *pszEvent;          const char *pszEvent;
240          char  szQuery[LSCP_BUFSIZ];          char  szQuery[LSCP_BUFSIZ];
# Line 228  static lscp_status_t _lscp_client_evt_re Line 249  static lscp_status_t _lscp_client_evt_re
249                  return LSCP_FAILED;                  return LSCP_FAILED;
250    
251          // Build the query string...          // Build the query string...
252          cchQuery = sprintf(szQuery, "%sSUBSCRIBE %s\n\n", (iSubscribe == 0 ? "UN" : ""), pszEvent);          cchQuery = sprintf(szQuery, "%sSUBSCRIBE %s\n\n",
253                    (iSubscribe == 0 ? "UN" : ""), pszEvent);
254          // Just send data, forget result...          // Just send data, forget result...
255          if (send(pClient->evt.sock, szQuery, cchQuery, 0) < cchQuery) {          if (send(pClient->evt.sock, szQuery, cchQuery, 0) < cchQuery) {
256                  lscp_socket_perror("_lscp_client_evt_request: send");                  lscp_socket_perror("_lscp_client_evt_request: send");
# Line 258  const char* lscp_client_package (void) { Line 280  const char* lscp_client_package (void) {
280  /** Retrieve the current client library version string. */  /** Retrieve the current client library version string. */
281  const char* lscp_client_version (void) { return LSCP_VERSION; }  const char* lscp_client_version (void) { return LSCP_VERSION; }
282    
283  /** Retrieve the current client library build timestamp string. */  /** Retrieve the current client library build string. */
284  const char* lscp_client_build   (void) { return __DATE__ " " __TIME__; }  const char* lscp_client_build   (void) { return LSCP_BUILD; }
285    
286    
287  //-------------------------------------------------------------------------  //-------------------------------------------------------------------------
# Line 279  const char* lscp_client_build   (void) { Line 301  const char* lscp_client_build   (void) {
301   *  @returns The new client instance pointer if successfull, which shall be   *  @returns The new client instance pointer if successfull, which shall be
302   *  used on all subsequent client calls, NULL otherwise.   *  used on all subsequent client calls, NULL otherwise.
303   */   */
304  lscp_client_t* lscp_client_create ( const char *pszHost, int iPort, lscp_client_proc_t pfnCallback, void *pvData )  lscp_client_t* lscp_client_create ( const char *pszHost, int iPort,
305            lscp_client_proc_t pfnCallback, void *pvData )
306  {  {
307          lscp_client_t  *pClient;          lscp_client_t  *pClient;
308    #if defined(USE_GETADDRINFO)
309            char szPort[33];
310            struct addrinfo hints;
311            struct addrinfo *result, *res;
312    #else
313          struct hostent *pHost;          struct hostent *pHost;
         lscp_socket_t sock;  
314          struct sockaddr_in addr;          struct sockaddr_in addr;
315          int cAddr;          int cAddr;
316    #endif  /* !USE_GETADDRINFO */
317            lscp_socket_t sock;
318  #if defined(WIN32)  #if defined(WIN32)
319          int iSockOpt = (-1);          int iSockOpt = (-1);
320  #endif  #endif
# Line 295  lscp_client_t* lscp_client_create ( cons Line 324  lscp_client_t* lscp_client_create ( cons
324                  return NULL;                  return NULL;
325          }          }
326    
327    #if defined(USE_GETADDRINFO)
328    
329            // Convert port number to string/name...
330            snprintf(szPort, sizeof(szPort), "%d", iPort);
331    
332            // Obtain address(es) matching host/port...
333            memset(&hints, 0, sizeof(struct addrinfo));
334            hints.ai_family = AF_INET;
335            hints.ai_socktype = SOCK_STREAM;
336    
337            result = NULL;
338    
339            if (getaddrinfo(pszHost, szPort, &hints, &result)) {
340                    lscp_socket_herror("lscp_client_create: getaddrinfo");
341                    return NULL;
342            }
343    
344    #else
345    
346            // Obtain host matching name...
347          pHost = gethostbyname(pszHost);          pHost = gethostbyname(pszHost);
348          if (pHost == NULL) {          if (pHost == NULL) {
349                  lscp_socket_herror("lscp_client_create: gethostbyname");                  lscp_socket_herror("lscp_client_create: gethostbyname");
350                  return NULL;                  return NULL;
351          }          }
352    
353    #endif  /* !USE_GETADDRINFO */
354    
355          // Allocate client descriptor...          // Allocate client descriptor...
356    
357          pClient = (lscp_client_t *) malloc(sizeof(lscp_client_t));          pClient = (lscp_client_t *) malloc(sizeof(lscp_client_t));
# Line 314  lscp_client_t* lscp_client_create ( cons Line 365  lscp_client_t* lscp_client_create ( cons
365          pClient->pvData = pvData;          pClient->pvData = pvData;
366    
367  #ifdef DEBUG  #ifdef DEBUG
368          fprintf(stderr, "lscp_client_create: pClient=%p: pszHost=%s iPort=%d.\n", pClient, pszHost, iPort);          fprintf(stderr,
369                    "lscp_client_create: pClient=%p: pszHost=%s iPort=%d.\n",
370                     pClient, pszHost, iPort);
371  #endif  #endif
372    
373          // Prepare the command connection socket...          // Prepare the command connection socket...
374    
375    #if defined(USE_GETADDRINFO)
376    
377            // getaddrinfo() returns a list of address structures;
378            // try each address until we successfully connect(2);
379            // if socket or connect fails, we close the socket and
380            // try the next address...
381            sock = INVALID_SOCKET;
382    
383            for (res = result; res; res = res->ai_next) {
384                    sock = socket(res->ai_family, res->ai_socktype, res->ai_protocol);
385                    if (sock == INVALID_SOCKET)
386                            continue;
387            #if defined(WIN32)
388                    if (setsockopt(sock, SOL_SOCKET, SO_DONTLINGER,
389                                    (char *) &iSockOpt, sizeof(int)) == SOCKET_ERROR)
390                            lscp_socket_perror("lscp_client_create: cmd: setsockopt(SO_DONTLINGER)");
391            #endif
392            #ifdef DEBUG
393                    lscp_socket_getopts("lscp_client_create: cmd", sock);
394            #endif
395                    if (connect(sock, res->ai_addr, res->ai_addrlen) != SOCKET_ERROR)
396                            break;
397                    closesocket(sock);
398            }
399    
400            if (sock == INVALID_SOCKET) {
401                    lscp_socket_perror("lscp_client_create: cmd: socket");
402                    free(pClient);
403                    return NULL;
404            }
405    
406            if (res == NULL) {
407                    lscp_socket_perror("lscp_client_create: cmd: connect");
408                    free(pClient);
409                    return NULL;
410            }
411    
412            // Initialize the command socket agent struct...
413            lscp_socket_agent_init(&(pClient->cmd), sock,
414                    (struct sockaddr_in *) res->ai_addr, res->ai_addrlen);
415    
416            // No longer needed...
417            freeaddrinfo(result);
418    
419    #else
420    
421          sock = socket(AF_INET, SOCK_STREAM, 0);          sock = socket(AF_INET, SOCK_STREAM, 0);
422          if (sock == INVALID_SOCKET) {          if (sock == INVALID_SOCKET) {
423                  lscp_socket_perror("lscp_client_create: cmd: socket");                  lscp_socket_perror("lscp_client_create: cmd: socket");
# Line 327  lscp_client_t* lscp_client_create ( cons Line 426  lscp_client_t* lscp_client_create ( cons
426          }          }
427    
428  #if defined(WIN32)  #if defined(WIN32)
429          if (setsockopt(sock, SOL_SOCKET, SO_DONTLINGER, (char *) &iSockOpt, sizeof(int)) == SOCKET_ERROR)          if (setsockopt(sock, SOL_SOCKET, SO_DONTLINGER,
430                            (char *) &iSockOpt, sizeof(int)) == SOCKET_ERROR)
431                  lscp_socket_perror("lscp_client_create: cmd: setsockopt(SO_DONTLINGER)");                  lscp_socket_perror("lscp_client_create: cmd: setsockopt(SO_DONTLINGER)");
432  #endif  #endif
433    
# Line 351  lscp_client_t* lscp_client_create ( cons Line 451  lscp_client_t* lscp_client_create ( cons
451          // Initialize the command socket agent struct...          // Initialize the command socket agent struct...
452          lscp_socket_agent_init(&(pClient->cmd), sock, &addr, cAddr);          lscp_socket_agent_init(&(pClient->cmd), sock, &addr, cAddr);
453    
454    #endif  /* !USE_GETADDRINFO */
455    
456  #ifdef DEBUG  #ifdef DEBUG
457          fprintf(stderr, "lscp_client_create: cmd: pClient=%p: sock=%d addr=%s port=%d.\n", pClient, pClient->cmd.sock, inet_ntoa(pClient->cmd.addr.sin_addr), ntohs(pClient->cmd.addr.sin_port));          fprintf(stderr,
458                    "lscp_client_create: cmd: pClient=%p: sock=%d addr=%s port=%d.\n",
459                    pClient, pClient->cmd.sock,
460                    inet_ntoa(pClient->cmd.addr.sin_addr),
461                    ntohs(pClient->cmd.addr.sin_port));
462  #endif  #endif
463    
464          // Initialize the event service socket struct...          // Initialize the event service socket struct...
# Line 542  int lscp_client_get_timeout ( lscp_clien Line 648  int lscp_client_get_timeout ( lscp_clien
648          return pClient->iTimeout;          return pClient->iTimeout;
649  }  }
650    
651    /**
652     *  Check whether connection to server is lost.
653     *
654     *  @param pClient  Pointer to client instance structure.
655     *
656     *  @returns @c true if client lost connection to server, @c false otherwise.
657     */
658    bool lscp_client_connection_lost ( lscp_client_t *pClient )
659    {
660        int err = lscp_client_get_errno(pClient);
661        if (err >= 0) return false;
662        return err == -EPIPE || err == -ECONNRESET || err == -ECONNABORTED;
663    }
664    
665    
666  //-------------------------------------------------------------------------  //-------------------------------------------------------------------------
667  // Client common protocol functions.  // Client common protocol functions.
# Line 837  lscp_event_t lscp_client_get_events ( ls Line 957  lscp_event_t lscp_client_get_events ( ls
957   *   *
958   *  @returns LSCP_OK on success, LSCP_FAILED otherwise.   *  @returns LSCP_OK on success, LSCP_FAILED otherwise.
959   */   */
960  lscp_status_t lscp_load_instrument ( lscp_client_t *pClient, const char *pszFileName, int iInstrIndex, int iSamplerChannel )  lscp_status_t lscp_load_instrument ( lscp_client_t *pClient,
961            const char *pszFileName, int iInstrIndex, int iSamplerChannel )
962  {  {
963          char szQuery[LSCP_BUFSIZ];          char szQuery[LSCP_BUFSIZ];
964    
965          if (pszFileName == NULL || iSamplerChannel < 0)          if (pszFileName == NULL || iSamplerChannel < 0)
966                  return LSCP_FAILED;                  return LSCP_FAILED;
967    
968          sprintf(szQuery, "LOAD INSTRUMENT '%s' %d %d\r\n", pszFileName, iInstrIndex, iSamplerChannel);          sprintf(szQuery, "LOAD INSTRUMENT '%s' %d %d\r\n",
969                    pszFileName, iInstrIndex, iSamplerChannel);
970          return lscp_client_query(pClient, szQuery);          return lscp_client_query(pClient, szQuery);
971  }  }
972    
# Line 860  lscp_status_t lscp_load_instrument ( lsc Line 982  lscp_status_t lscp_load_instrument ( lsc
982   *   *
983   *  @returns LSCP_OK on success, LSCP_FAILED otherwise.   *  @returns LSCP_OK on success, LSCP_FAILED otherwise.
984   */   */
985  lscp_status_t lscp_load_instrument_non_modal ( lscp_client_t *pClient, const char *pszFileName, int iInstrIndex, int iSamplerChannel )  lscp_status_t lscp_load_instrument_non_modal ( lscp_client_t *pClient,
986            const char *pszFileName, int iInstrIndex, int iSamplerChannel )
987  {  {
988          char szQuery[LSCP_BUFSIZ];          char szQuery[LSCP_BUFSIZ];
989    
990          if (pszFileName == NULL || iSamplerChannel < 0)          if (pszFileName == NULL || iSamplerChannel < 0)
991                  return LSCP_FAILED;                  return LSCP_FAILED;
992    
993          sprintf(szQuery, "LOAD INSTRUMENT NON_MODAL '%s' %d %d\r\n", pszFileName, iInstrIndex, iSamplerChannel);          sprintf(szQuery, "LOAD INSTRUMENT NON_MODAL '%s' %d %d\r\n",
994                    pszFileName, iInstrIndex, iSamplerChannel);
995          return lscp_client_query(pClient, szQuery);          return lscp_client_query(pClient, szQuery);
996  }  }
997    
# Line 889  lscp_status_t lscp_load_engine ( lscp_cl Line 1013  lscp_status_t lscp_load_engine ( lscp_cl
1013          if (pszEngineName == NULL || iSamplerChannel < 0)          if (pszEngineName == NULL || iSamplerChannel < 0)
1014                  return LSCP_FAILED;                  return LSCP_FAILED;
1015    
1016          sprintf(szQuery, "LOAD ENGINE %s %d\r\n", pszEngineName, iSamplerChannel);          sprintf(szQuery, "LOAD ENGINE %s %d\r\n",
1017                    pszEngineName, iSamplerChannel);
1018          return lscp_client_query(pClient, szQuery);          return lscp_client_query(pClient, szQuery);
1019  }  }
1020    
# Line 1080  const char **lscp_list_available_engines Line 1205  const char **lscp_list_available_engines
1205   *  @returns A pointer to a @ref lscp_engine_info_t structure, with all the   *  @returns A pointer to a @ref lscp_engine_info_t structure, with all the
1206   *  information of the given sampler engine, or NULL in case of failure.   *  information of the given sampler engine, or NULL in case of failure.
1207   */   */
1208  lscp_engine_info_t *lscp_get_engine_info ( lscp_client_t *pClient, const char *pszEngineName )  lscp_engine_info_t *lscp_get_engine_info ( lscp_client_t *pClient,
1209            const char *pszEngineName )
1210  {  {
1211          lscp_engine_info_t *pEngineInfo;          lscp_engine_info_t *pEngineInfo;
1212          char szQuery[LSCP_BUFSIZ];          char szQuery[LSCP_BUFSIZ];
# Line 1408  int lscp_get_channel_stream_usage ( lscp Line 1534  int lscp_get_channel_stream_usage ( lscp
1534   *  information of the current disk stream buffer fill usage, for the given   *  information of the current disk stream buffer fill usage, for the given
1535   *  sampler channel, or NULL in case of failure.   *  sampler channel, or NULL in case of failure.
1536   */   */
1537  lscp_buffer_fill_t *lscp_get_channel_buffer_fill ( lscp_client_t *pClient, lscp_usage_t usage_type, int iSamplerChannel )  lscp_buffer_fill_t *lscp_get_channel_buffer_fill ( lscp_client_t *pClient,
1538            lscp_usage_t usage_type, int iSamplerChannel )
1539  {  {
1540          lscp_buffer_fill_t *pBufferFill;          lscp_buffer_fill_t *pBufferFill;
1541          char szQuery[LSCP_BUFSIZ];          char szQuery[LSCP_BUFSIZ];
# Line 1481  lscp_buffer_fill_t *lscp_get_channel_buf Line 1608  lscp_buffer_fill_t *lscp_get_channel_buf
1608   *   *
1609   *  @returns LSCP_OK on success, LSCP_FAILED otherwise.   *  @returns LSCP_OK on success, LSCP_FAILED otherwise.
1610   */   */
1611  lscp_status_t lscp_set_channel_audio_type ( lscp_client_t *pClient, int iSamplerChannel, const char *pszAudioDriver )  lscp_status_t lscp_set_channel_audio_type ( lscp_client_t *pClient,
1612            int iSamplerChannel, const char *pszAudioDriver )
1613  {  {
1614          char szQuery[LSCP_BUFSIZ];          char szQuery[LSCP_BUFSIZ];
1615    
1616          if (iSamplerChannel < 0 || pszAudioDriver == NULL)          if (iSamplerChannel < 0 || pszAudioDriver == NULL)
1617                  return LSCP_FAILED;                  return LSCP_FAILED;
1618    
1619          sprintf(szQuery, "SET CHANNEL AUDIO_OUTPUT_TYPE %d %s\r\n", iSamplerChannel, pszAudioDriver);          sprintf(szQuery, "SET CHANNEL AUDIO_OUTPUT_TYPE %d %s\r\n",
1620                    iSamplerChannel, pszAudioDriver);
1621          return lscp_client_query(pClient, szQuery);          return lscp_client_query(pClient, szQuery);
1622  }  }
1623    
# Line 1503  lscp_status_t lscp_set_channel_audio_typ Line 1632  lscp_status_t lscp_set_channel_audio_typ
1632   *   *
1633   *  @returns LSCP_OK on success, LSCP_FAILED otherwise.   *  @returns LSCP_OK on success, LSCP_FAILED otherwise.
1634   */   */
1635  lscp_status_t lscp_set_channel_audio_device ( lscp_client_t *pClient, int iSamplerChannel, int iAudioDevice )  lscp_status_t lscp_set_channel_audio_device ( lscp_client_t *pClient,
1636            int iSamplerChannel, int iAudioDevice )
1637  {  {
1638          char szQuery[LSCP_BUFSIZ];          char szQuery[LSCP_BUFSIZ];
1639    
1640          if (iSamplerChannel < 0 || iAudioDevice < 0)          if (iSamplerChannel < 0 || iAudioDevice < 0)
1641                  return LSCP_FAILED;                  return LSCP_FAILED;
1642    
1643          sprintf(szQuery, "SET CHANNEL AUDIO_OUTPUT_DEVICE %d %d\r\n", iSamplerChannel, iAudioDevice);          sprintf(szQuery, "SET CHANNEL AUDIO_OUTPUT_DEVICE %d %d\r\n",
1644                    iSamplerChannel, iAudioDevice);
1645          return lscp_client_query(pClient, szQuery);          return lscp_client_query(pClient, szQuery);
1646  }  }
1647    
# Line 1526  lscp_status_t lscp_set_channel_audio_dev Line 1657  lscp_status_t lscp_set_channel_audio_dev
1657   *   *
1658   *  @returns LSCP_OK on success, LSCP_FAILED otherwise.   *  @returns LSCP_OK on success, LSCP_FAILED otherwise.
1659   */   */
1660  lscp_status_t lscp_set_channel_audio_channel ( lscp_client_t *pClient, int iSamplerChannel, int iAudioOut, int iAudioIn )  lscp_status_t lscp_set_channel_audio_channel ( lscp_client_t *pClient,
1661            int iSamplerChannel, int iAudioOut, int iAudioIn )
1662  {  {
1663          char szQuery[LSCP_BUFSIZ];          char szQuery[LSCP_BUFSIZ];
1664    
1665          if (iSamplerChannel < 0 || iAudioOut < 0 || iAudioIn < 0)          if (iSamplerChannel < 0 || iAudioOut < 0 || iAudioIn < 0)
1666                  return LSCP_FAILED;                  return LSCP_FAILED;
1667    
1668          sprintf(szQuery, "SET CHANNEL AUDIO_OUTPUT_CHANNEL %d %d %d\r\n", iSamplerChannel, iAudioOut, iAudioIn);          sprintf(szQuery, "SET CHANNEL AUDIO_OUTPUT_CHANNEL %d %d %d\r\n",
1669                    iSamplerChannel, iAudioOut, iAudioIn);
1670          return lscp_client_query(pClient, szQuery);          return lscp_client_query(pClient, szQuery);
1671  }  }
1672    
# Line 1548  lscp_status_t lscp_set_channel_audio_cha Line 1681  lscp_status_t lscp_set_channel_audio_cha
1681   *   *
1682   *  @returns LSCP_OK on success, LSCP_FAILED otherwise.   *  @returns LSCP_OK on success, LSCP_FAILED otherwise.
1683   */   */
1684  lscp_status_t lscp_set_channel_midi_type ( lscp_client_t *pClient, int iSamplerChannel, const char *pszMidiDriver )  lscp_status_t lscp_set_channel_midi_type ( lscp_client_t *pClient,
1685            int iSamplerChannel, const char *pszMidiDriver )
1686  {  {
1687          char szQuery[LSCP_BUFSIZ];          char szQuery[LSCP_BUFSIZ];
1688    
1689          if (iSamplerChannel < 0 || pszMidiDriver == NULL)          if (iSamplerChannel < 0 || pszMidiDriver == NULL)
1690                  return LSCP_FAILED;                  return LSCP_FAILED;
1691    
1692          sprintf(szQuery, "SET CHANNEL MIDI_INPUT_TYPE %d %s\r\n", iSamplerChannel, pszMidiDriver);          sprintf(szQuery, "SET CHANNEL MIDI_INPUT_TYPE %d %s\r\n",
1693                    iSamplerChannel, pszMidiDriver);
1694          return lscp_client_query(pClient, szQuery);          return lscp_client_query(pClient, szQuery);
1695  }  }
1696    
# Line 1570  lscp_status_t lscp_set_channel_midi_type Line 1705  lscp_status_t lscp_set_channel_midi_type
1705   *   *
1706   *  @returns LSCP_OK on success, LSCP_FAILED otherwise.   *  @returns LSCP_OK on success, LSCP_FAILED otherwise.
1707   */   */
1708  lscp_status_t lscp_set_channel_midi_device ( lscp_client_t *pClient, int iSamplerChannel, int iMidiDevice )  lscp_status_t lscp_set_channel_midi_device ( lscp_client_t *pClient,
1709            int iSamplerChannel, int iMidiDevice )
1710  {  {
1711          char szQuery[LSCP_BUFSIZ];          char szQuery[LSCP_BUFSIZ];
1712    
1713          if (iSamplerChannel < 0 || iMidiDevice < 0)          if (iSamplerChannel < 0 || iMidiDevice < 0)
1714                  return LSCP_FAILED;                  return LSCP_FAILED;
1715    
1716          sprintf(szQuery, "SET CHANNEL MIDI_INPUT_DEVICE %d %d\r\n", iSamplerChannel, iMidiDevice);          sprintf(szQuery, "SET CHANNEL MIDI_INPUT_DEVICE %d %d\r\n",
1717                    iSamplerChannel, iMidiDevice);
1718          return lscp_client_query(pClient, szQuery);          return lscp_client_query(pClient, szQuery);
1719  }  }
1720    
# Line 1592  lscp_status_t lscp_set_channel_midi_devi Line 1729  lscp_status_t lscp_set_channel_midi_devi
1729   *   *
1730   *  @returns LSCP_OK on success, LSCP_FAILED otherwise.   *  @returns LSCP_OK on success, LSCP_FAILED otherwise.
1731   */   */
1732  lscp_status_t lscp_set_channel_midi_port ( lscp_client_t *pClient, int iSamplerChannel, int iMidiPort )  lscp_status_t lscp_set_channel_midi_port ( lscp_client_t *pClient,
1733            int iSamplerChannel, int iMidiPort )
1734  {  {
1735          char szQuery[LSCP_BUFSIZ];          char szQuery[LSCP_BUFSIZ];
1736    
1737          if (iSamplerChannel < 0 || iMidiPort < 0)          if (iSamplerChannel < 0 || iMidiPort < 0)
1738                  return LSCP_FAILED;                  return LSCP_FAILED;
1739    
1740          sprintf(szQuery, "SET CHANNEL MIDI_INPUT_PORT %d %d\r\n", iSamplerChannel, iMidiPort);          sprintf(szQuery, "SET CHANNEL MIDI_INPUT_PORT %d %d\r\n",
1741                    iSamplerChannel, iMidiPort);
1742          return lscp_client_query(pClient, szQuery);          return lscp_client_query(pClient, szQuery);
1743  }  }
1744    
# Line 1615  lscp_status_t lscp_set_channel_midi_port Line 1754  lscp_status_t lscp_set_channel_midi_port
1754   *   *
1755   *  @returns LSCP_OK on success, LSCP_FAILED otherwise.   *  @returns LSCP_OK on success, LSCP_FAILED otherwise.
1756   */   */
1757  lscp_status_t lscp_set_channel_midi_channel ( lscp_client_t *pClient, int iSamplerChannel, int iMidiChannel )  lscp_status_t lscp_set_channel_midi_channel ( lscp_client_t *pClient,
1758            int iSamplerChannel, int iMidiChannel )
1759  {  {
1760          char szQuery[LSCP_BUFSIZ];          char szQuery[LSCP_BUFSIZ];
1761    
# Line 1623  lscp_status_t lscp_set_channel_midi_chan Line 1763  lscp_status_t lscp_set_channel_midi_chan
1763                  return LSCP_FAILED;                  return LSCP_FAILED;
1764    
1765          if (iMidiChannel == LSCP_MIDI_CHANNEL_ALL)          if (iMidiChannel == LSCP_MIDI_CHANNEL_ALL)
1766                  sprintf(szQuery, "SET CHANNEL MIDI_INPUT_CHANNEL %d ALL\r\n", iSamplerChannel);                  sprintf(szQuery, "SET CHANNEL MIDI_INPUT_CHANNEL %d ALL\r\n",
1767                            iSamplerChannel);
1768          else          else
1769                  sprintf(szQuery, "SET CHANNEL MIDI_INPUT_CHANNEL %d %d\r\n", iSamplerChannel, iMidiChannel);                  sprintf(szQuery, "SET CHANNEL MIDI_INPUT_CHANNEL %d %d\r\n",
1770                            iSamplerChannel, iMidiChannel);
1771          return lscp_client_query(pClient, szQuery);          return lscp_client_query(pClient, szQuery);
1772  }  }
1773    
# Line 1642  lscp_status_t lscp_set_channel_midi_chan Line 1784  lscp_status_t lscp_set_channel_midi_chan
1784   *   *
1785   *  @returns LSCP_OK on success, LSCP_FAILED otherwise.   *  @returns LSCP_OK on success, LSCP_FAILED otherwise.
1786   */   */
1787  lscp_status_t lscp_set_channel_midi_map ( lscp_client_t *pClient, int iSamplerChannel, int iMidiMap )  lscp_status_t lscp_set_channel_midi_map ( lscp_client_t *pClient,
1788            int iSamplerChannel, int iMidiMap )
1789  {  {
1790          char szQuery[LSCP_BUFSIZ];          char szQuery[LSCP_BUFSIZ];
1791    
# Line 1676  lscp_status_t lscp_set_channel_midi_map Line 1819  lscp_status_t lscp_set_channel_midi_map
1819   *   *
1820   *  @returns LSCP_OK on success, LSCP_FAILED otherwise.   *  @returns LSCP_OK on success, LSCP_FAILED otherwise.
1821   */   */
1822  lscp_status_t lscp_set_channel_volume ( lscp_client_t *pClient, int iSamplerChannel, float fVolume )  lscp_status_t lscp_set_channel_volume ( lscp_client_t *pClient,
1823            int iSamplerChannel, float fVolume )
1824  {  {
1825          char szQuery[LSCP_BUFSIZ];          char szQuery[LSCP_BUFSIZ];
1826          struct _locale_t locale;          struct _locale_t locale;
# Line 1685  lscp_status_t lscp_set_channel_volume ( Line 1829  lscp_status_t lscp_set_channel_volume (
1829                  return LSCP_FAILED;                  return LSCP_FAILED;
1830    
1831          _save_and_set_c_locale(&locale);          _save_and_set_c_locale(&locale);
1832          sprintf(szQuery, "SET CHANNEL VOLUME %d %g\r\n", iSamplerChannel, fVolume);          sprintf(szQuery, "SET CHANNEL VOLUME %d %g\r\n",
1833                    iSamplerChannel, fVolume);
1834          _restore_locale(&locale);          _restore_locale(&locale);
1835    
1836          return lscp_client_query(pClient, szQuery);          return lscp_client_query(pClient, szQuery);
# Line 1704  lscp_status_t lscp_set_channel_volume ( Line 1849  lscp_status_t lscp_set_channel_volume (
1849   *   *
1850   *  @returns LSCP_OK on success, LSCP_FAILED otherwise.   *  @returns LSCP_OK on success, LSCP_FAILED otherwise.
1851   */   */
1852  lscp_status_t lscp_set_channel_mute ( lscp_client_t *pClient, int iSamplerChannel, int iMute )  lscp_status_t lscp_set_channel_mute ( lscp_client_t *pClient,
1853            int iSamplerChannel, int iMute )
1854  {  {
1855          char szQuery[LSCP_BUFSIZ];          char szQuery[LSCP_BUFSIZ];
1856    
1857          if (iSamplerChannel < 0 || iMute < 0 || iMute > 1)          if (iSamplerChannel < 0 || iMute < 0 || iMute > 1)
1858                  return LSCP_FAILED;                  return LSCP_FAILED;
1859    
1860          sprintf(szQuery, "SET CHANNEL MUTE %d %d\r\n", iSamplerChannel, iMute);          sprintf(szQuery, "SET CHANNEL MUTE %d %d\r\n",
1861                    iSamplerChannel, iMute);
1862          return lscp_client_query(pClient, szQuery);          return lscp_client_query(pClient, szQuery);
1863  }  }
1864    
# Line 1728  lscp_status_t lscp_set_channel_mute ( ls Line 1875  lscp_status_t lscp_set_channel_mute ( ls
1875   *   *
1876   *  @returns LSCP_OK on success, LSCP_FAILED otherwise.   *  @returns LSCP_OK on success, LSCP_FAILED otherwise.
1877   */   */
1878  lscp_status_t lscp_set_channel_solo ( lscp_client_t *pClient, int iSamplerChannel, int iSolo )  lscp_status_t lscp_set_channel_solo ( lscp_client_t *pClient,
1879            int iSamplerChannel, int iSolo )
1880  {  {
1881          char szQuery[LSCP_BUFSIZ];          char szQuery[LSCP_BUFSIZ];
1882    
1883          if (iSamplerChannel < 0 || iSolo < 0 || iSolo > 1)          if (iSamplerChannel < 0 || iSolo < 0 || iSolo > 1)
1884                  return LSCP_FAILED;                  return LSCP_FAILED;
1885    
1886          sprintf(szQuery, "SET CHANNEL SOLO %d %d\r\n", iSamplerChannel, iSolo);          sprintf(szQuery, "SET CHANNEL SOLO %d %d\r\n",
1887                    iSamplerChannel, iSolo);
1888          return lscp_client_query(pClient, szQuery);          return lscp_client_query(pClient, szQuery);
1889  }  }
1890    
# Line 1952  lscp_status_t lscp_set_volume ( lscp_cli Line 2101  lscp_status_t lscp_set_volume ( lscp_cli
2101          return lscp_client_query(pClient, szQuery);          return lscp_client_query(pClient, szQuery);
2102  }  }
2103    
2104    
2105  /**  /**
2106   *  Get global voice limit setting:   *  Get global voice limit setting:
2107   *  @code   *  @code
# Line 1966  lscp_status_t lscp_set_volume ( lscp_cli Line 2116  lscp_status_t lscp_set_volume ( lscp_cli
2116   *           negative value on error (e.g. if sampler doesn't support   *           negative value on error (e.g. if sampler doesn't support
2117   *           this command).   *           this command).
2118   */   */
2119  int lscp_get_voices(lscp_client_t *pClient)  int lscp_get_voices ( lscp_client_t *pClient )
2120  {  {
2121          int iVoices = -1;          int iVoices = -1;
2122    
# Line 1985  int lscp_get_voices(lscp_client_t *pClie Line 2135  int lscp_get_voices(lscp_client_t *pClie
2135          return iVoices;          return iVoices;
2136  }  }
2137    
2138    
2139  /**  /**
2140   *  Setting global voice limit setting:   *  Setting global voice limit setting:
2141   *  @code   *  @code
# Line 2003  int lscp_get_voices(lscp_client_t *pClie Line 2154  int lscp_get_voices(lscp_client_t *pClie
2154   *   *
2155   *  @returns LSCP_OK on success, LSCP_FAILED otherwise.   *  @returns LSCP_OK on success, LSCP_FAILED otherwise.
2156   */   */
2157  lscp_status_t lscp_set_voices(lscp_client_t *pClient, int iMaxVoices)  lscp_status_t lscp_set_voices ( lscp_client_t *pClient, int iMaxVoices )
2158  {  {
2159          char szQuery[LSCP_BUFSIZ];          char szQuery[LSCP_BUFSIZ];
2160    
# Line 2014  lscp_status_t lscp_set_voices(lscp_clien Line 2165  lscp_status_t lscp_set_voices(lscp_clien
2165          return lscp_client_query(pClient, szQuery);          return lscp_client_query(pClient, szQuery);
2166  }  }
2167    
2168    
2169  /**  /**
2170   *  Get global disk streams limit setting:   *  Get global disk streams limit setting:
2171   *  @code   *  @code
# Line 2028  lscp_status_t lscp_set_voices(lscp_clien Line 2180  lscp_status_t lscp_set_voices(lscp_clien
2180   *           or a negative value on error (e.g. if sampler doesn't   *           or a negative value on error (e.g. if sampler doesn't
2181   *           support this command).   *           support this command).
2182   */   */
2183  int lscp_get_streams(lscp_client_t *pClient)  int lscp_get_streams ( lscp_client_t *pClient )
2184  {  {
2185          int iStreams = -1;          int iStreams = -1;
2186    
# Line 2047  int lscp_get_streams(lscp_client_t *pCli Line 2199  int lscp_get_streams(lscp_client_t *pCli
2199          return iStreams;          return iStreams;
2200  }  }
2201    
2202    
2203  /**  /**
2204   *  Setting global disk streams limit setting:   *  Setting global disk streams limit setting:
2205   *  @code   *  @code
# Line 2065  int lscp_get_streams(lscp_client_t *pCli Line 2218  int lscp_get_streams(lscp_client_t *pCli
2218   *   *
2219   *  @returns LSCP_OK on success, LSCP_FAILED otherwise.   *  @returns LSCP_OK on success, LSCP_FAILED otherwise.
2220   */   */
2221  lscp_status_t lscp_set_streams(lscp_client_t *pClient, int iMaxStreams)  lscp_status_t lscp_set_streams ( lscp_client_t *pClient, int iMaxStreams )
2222  {  {
2223          char szQuery[LSCP_BUFSIZ];          char szQuery[LSCP_BUFSIZ];
2224    
# Line 2076  lscp_status_t lscp_set_streams(lscp_clie Line 2229  lscp_status_t lscp_set_streams(lscp_clie
2229          return lscp_client_query(pClient, szQuery);          return lscp_client_query(pClient, szQuery);
2230  }  }
2231    
2232    
2233  /**  /**
2234   *  Add an effect send to a sampler channel:   *  Add an effect send to a sampler channel:
2235   *  CREATE FX_SEND <sampler-channel> <midi-ctrl> [<name>]   *  CREATE FX_SEND <sampler-channel> <midi-ctrl> [<fx-name>]
2236   *   *
2237   *  @param pClient          Pointer to client instance structure.   *  @param pClient          Pointer to client instance structure.
2238   *  @param iSamplerChannel  Sampler channel number.   *  @param iSamplerChannel  Sampler channel number.
2239   *  @param iMidiController  MIDI controller used to alter the effect,   *  @param iMidiController  MIDI controller used to alter the effect,
2240   *                          usually a number between 0 and 127.   *                          usually a number between 0 and 127.
2241   *  @param pszName          Optional name for the effect send entity,   *  @param pszFxName        Optional name for the effect send entity,
2242   *                          does not have to be unique.   *                          does not have to be unique.
2243   *   *
2244   *  @returns The new effect send number identifier, or -1 in case of failure.   *  @returns The new effect send number identifier, or -1 in case of failure.
2245   */   */
2246  int lscp_create_fxsend ( lscp_client_t *pClient, int iSamplerChannel, int iMidiController, const char *pszFxName )  int lscp_create_fxsend ( lscp_client_t *pClient,
2247            int iSamplerChannel, int iMidiController, const char *pszFxName )
2248  {  {
2249          int iFxSend = -1;          int iFxSend = -1;
2250          char szQuery[LSCP_BUFSIZ];          char szQuery[LSCP_BUFSIZ];
# Line 2102  int lscp_create_fxsend ( lscp_client_t * Line 2257  int lscp_create_fxsend ( lscp_client_t *
2257          // Lock this section up.          // Lock this section up.
2258          lscp_mutex_lock(pClient->mutex);          lscp_mutex_lock(pClient->mutex);
2259    
2260          sprintf(szQuery, "CREATE FX_SEND %d %d", iSamplerChannel, iMidiController);          sprintf(szQuery, "CREATE FX_SEND %d %d",
2261                    iSamplerChannel, iMidiController);
2262    
2263          if (pszFxName)          if (pszFxName)
2264                  sprintf(szQuery + strlen(szQuery), " '%s'", pszFxName);                  sprintf(szQuery + strlen(szQuery), " '%s'", pszFxName);
# Line 2129  int lscp_create_fxsend ( lscp_client_t * Line 2285  int lscp_create_fxsend ( lscp_client_t *
2285   *   *
2286   *  @returns LSCP_OK on success, LSCP_FAILED otherwise.   *  @returns LSCP_OK on success, LSCP_FAILED otherwise.
2287   */   */
2288  lscp_status_t lscp_destroy_fxsend ( lscp_client_t *pClient, int iSamplerChannel, int iFxSend )  lscp_status_t lscp_destroy_fxsend ( lscp_client_t *pClient,
2289            int iSamplerChannel, int iFxSend )
2290  {  {
2291          char szQuery[LSCP_BUFSIZ];          char szQuery[LSCP_BUFSIZ];
2292    
2293          if (iSamplerChannel < 0 || iFxSend < 0)          if (iSamplerChannel < 0 || iFxSend < 0)
2294                  return LSCP_FAILED;                  return LSCP_FAILED;
2295    
2296          sprintf(szQuery, "DESTROY FX_SEND %d %d\r\n", iSamplerChannel, iFxSend);          sprintf(szQuery, "DESTROY FX_SEND %d %d\r\n",
2297                    iSamplerChannel, iFxSend);
2298    
2299          return lscp_client_query(pClient, szQuery);          return lscp_client_query(pClient, szQuery);
2300  }  }
# Line 2226  int *lscp_list_fxsends ( lscp_client_t * Line 2384  int *lscp_list_fxsends ( lscp_client_t *
2384   *  @returns A pointer to a @ref lscp_fxsend_info_t structure, with the   *  @returns A pointer to a @ref lscp_fxsend_info_t structure, with the
2385   *  information of the given FX send, or NULL in case of failure.   *  information of the given FX send, or NULL in case of failure.
2386   */   */
2387  lscp_fxsend_info_t *lscp_get_fxsend_info ( lscp_client_t *pClient, int iSamplerChannel, int iFxSend )  lscp_fxsend_info_t *lscp_get_fxsend_info ( lscp_client_t *pClient,
2388            int iSamplerChannel, int iFxSend )
2389  {  {
2390          lscp_fxsend_info_t *pFxSendInfo;          lscp_fxsend_info_t *pFxSendInfo;
2391          char szQuery[LSCP_BUFSIZ];          char szQuery[LSCP_BUFSIZ];
# Line 2291  lscp_fxsend_info_t *lscp_get_fxsend_info Line 2450  lscp_fxsend_info_t *lscp_get_fxsend_info
2450          return pFxSendInfo;          return pFxSendInfo;
2451  }  }
2452    
2453    
2454  /**  /**
2455   *  Alter effect send's name:   *  Alter effect send's name:
2456   *  @code   *  @code
# Line 2304  lscp_fxsend_info_t *lscp_get_fxsend_info Line 2464  lscp_fxsend_info_t *lscp_get_fxsend_info
2464   *   *
2465   *  @returns LSCP_OK on success, LSCP_FAILED otherwise.   *  @returns LSCP_OK on success, LSCP_FAILED otherwise.
2466   */   */
2467  lscp_status_t lscp_set_fxsend_name ( lscp_client_t *pClient, int iSamplerChannel, int iFxSend, const char *pszFxName )  lscp_status_t lscp_set_fxsend_name ( lscp_client_t *pClient,
2468            int iSamplerChannel, int iFxSend, const char *pszFxName )
2469  {  {
2470          char szQuery[LSCP_BUFSIZ];          char szQuery[LSCP_BUFSIZ];
2471    
2472          if (!pClient || iSamplerChannel < 0 || iFxSend < 0 || !pszFxName)          if (!pClient || iSamplerChannel < 0 || iFxSend < 0 || !pszFxName)
2473                  return LSCP_FAILED;                  return LSCP_FAILED;
2474    
2475          snprintf(szQuery, LSCP_BUFSIZ, "SET FX_SEND NAME %d %d '%s'\r\n", iSamplerChannel, iFxSend, pszFxName);          snprintf(szQuery, LSCP_BUFSIZ, "SET FX_SEND NAME %d %d '%s'\r\n",
2476                    iSamplerChannel, iFxSend, pszFxName);
2477          return lscp_client_query(pClient, szQuery);          return lscp_client_query(pClient, szQuery);
2478  }  }
2479    
2480    
2481  /**  /**
2482   *  Alter effect send's audio routing:   *  Alter effect send's audio routing:
2483   *  SET FX_SEND AUDIO_OUTPUT_CHANNEL <sampler-chan> <fx-send-id>   *  SET FX_SEND AUDIO_OUTPUT_CHANNEL <sampler-chan> <fx-send-id>
# Line 2328  lscp_status_t lscp_set_fxsend_name ( lsc Line 2491  lscp_status_t lscp_set_fxsend_name ( lsc
2491   *   *
2492   *  @returns LSCP_OK on success, LSCP_FAILED otherwise.   *  @returns LSCP_OK on success, LSCP_FAILED otherwise.
2493   */   */
2494  lscp_status_t lscp_set_fxsend_audio_channel ( lscp_client_t *pClient, int iSamplerChannel, int iFxSend, int iAudioSrc, int iAudioDst )  lscp_status_t lscp_set_fxsend_audio_channel ( lscp_client_t *pClient,
2495            int iSamplerChannel, int iFxSend, int iAudioSrc, int iAudioDst )
2496  {  {
2497          char szQuery[LSCP_BUFSIZ];          char szQuery[LSCP_BUFSIZ];
2498    
2499          if (iSamplerChannel < 0 || iFxSend < 0 || iAudioSrc < 0 || iAudioDst < 0)          if (iSamplerChannel < 0 || iFxSend < 0 || iAudioSrc < 0 || iAudioDst < 0)
2500                  return LSCP_FAILED;                  return LSCP_FAILED;
2501    
2502          sprintf(szQuery, "SET FX_SEND AUDIO_OUTPUT_CHANNEL %d %d %d %d\r\n", iSamplerChannel, iFxSend, iAudioSrc, iAudioDst);          sprintf(szQuery, "SET FX_SEND AUDIO_OUTPUT_CHANNEL %d %d %d %d\r\n",
2503                    iSamplerChannel, iFxSend, iAudioSrc, iAudioDst);
2504          return lscp_client_query(pClient, szQuery);          return lscp_client_query(pClient, szQuery);
2505  }  }
2506    
# Line 2352  lscp_status_t lscp_set_fxsend_audio_chan Line 2517  lscp_status_t lscp_set_fxsend_audio_chan
2517   *   *
2518   *  @returns LSCP_OK on success, LSCP_FAILED otherwise.   *  @returns LSCP_OK on success, LSCP_FAILED otherwise.
2519   */   */
2520  lscp_status_t lscp_set_fxsend_midi_controller ( lscp_client_t *pClient, int iSamplerChannel, int iFxSend, int iMidiController )  lscp_status_t lscp_set_fxsend_midi_controller ( lscp_client_t *pClient,
2521            int iSamplerChannel, int iFxSend, int iMidiController )
2522  {  {
2523          char szQuery[LSCP_BUFSIZ];          char szQuery[LSCP_BUFSIZ];
2524    
2525          if (iSamplerChannel < 0 || iFxSend < 0 || iMidiController < 0 || iMidiController > 127)          if (iSamplerChannel < 0 || iFxSend < 0 ||
2526                    iMidiController < 0 || iMidiController > 127)
2527                  return LSCP_FAILED;                  return LSCP_FAILED;
2528    
2529          sprintf(szQuery, "SET FX_SEND MIDI_CONTROLLER %d %d %d\r\n", iSamplerChannel, iFxSend, iMidiController);          sprintf(szQuery, "SET FX_SEND MIDI_CONTROLLER %d %d %d\r\n",
2530                    iSamplerChannel, iFxSend, iMidiController);
2531          return lscp_client_query(pClient, szQuery);          return lscp_client_query(pClient, szQuery);
2532  }  }
2533    
# Line 2375  lscp_status_t lscp_set_fxsend_midi_contr Line 2543  lscp_status_t lscp_set_fxsend_midi_contr
2543   *   *
2544   *  @returns LSCP_OK on success, LSCP_FAILED otherwise.   *  @returns LSCP_OK on success, LSCP_FAILED otherwise.
2545   */   */
2546  lscp_status_t lscp_set_fxsend_level ( lscp_client_t *pClient, int iSamplerChannel, int iFxSend, float fLevel )  lscp_status_t lscp_set_fxsend_level ( lscp_client_t *pClient,
2547            int iSamplerChannel, int iFxSend, float fLevel )
2548  {  {
2549          char szQuery[LSCP_BUFSIZ];          char szQuery[LSCP_BUFSIZ];
2550          struct _locale_t locale;          struct _locale_t locale;
# Line 2384  lscp_status_t lscp_set_fxsend_level ( ls Line 2553  lscp_status_t lscp_set_fxsend_level ( ls
2553                  return LSCP_FAILED;                  return LSCP_FAILED;
2554    
2555          _save_and_set_c_locale(&locale);          _save_and_set_c_locale(&locale);
2556          sprintf(szQuery, "SET FX_SEND LEVEL %d %d %f\r\n", iSamplerChannel, iFxSend, fLevel);          sprintf(szQuery, "SET FX_SEND LEVEL %d %d %f\r\n",
2557                    iSamplerChannel, iFxSend, fLevel);
2558          _restore_locale(&locale);          _restore_locale(&locale);
2559    
2560          return lscp_client_query(pClient, szQuery);          return lscp_client_query(pClient, szQuery);
# Line 2615  lscp_status_t lscp_set_midi_instrument_m Line 2785  lscp_status_t lscp_set_midi_instrument_m
2785   *   *
2786   *  @returns LSCP_OK on success, LSCP_FAILED otherwise.   *  @returns LSCP_OK on success, LSCP_FAILED otherwise.
2787   */   */
2788  lscp_status_t lscp_map_midi_instrument ( lscp_client_t *pClient, lscp_midi_instrument_t *pMidiInstr, const char *pszEngineName, const char *pszFileName, int iInstrIndex, float fVolume, lscp_load_mode_t load_mode, const char *pszName )  lscp_status_t lscp_map_midi_instrument ( lscp_client_t *pClient,
2789            lscp_midi_instrument_t *pMidiInstr, const char *pszEngineName,
2790            const char *pszFileName, int iInstrIndex, float fVolume,
2791            lscp_load_mode_t load_mode, const char *pszName )
2792  {  {
2793          char szQuery[LSCP_BUFSIZ];          char szQuery[LSCP_BUFSIZ];
2794          struct _locale_t locale;          struct _locale_t locale;
# Line 2671  lscp_status_t lscp_map_midi_instrument ( Line 2844  lscp_status_t lscp_map_midi_instrument (
2844   *   *
2845   *  @returns LSCP_OK on success, LSCP_FAILED otherwise.   *  @returns LSCP_OK on success, LSCP_FAILED otherwise.
2846   */   */
2847  lscp_status_t lscp_unmap_midi_instrument ( lscp_client_t *pClient, lscp_midi_instrument_t *pMidiInstr )  lscp_status_t lscp_unmap_midi_instrument ( lscp_client_t *pClient,
2848            lscp_midi_instrument_t *pMidiInstr )
2849  {  {
2850          char szQuery[LSCP_BUFSIZ];          char szQuery[LSCP_BUFSIZ];
2851    
# Line 2764  lscp_midi_instrument_t *lscp_list_midi_i Line 2938  lscp_midi_instrument_t *lscp_list_midi_i
2938          strcat(szQuery, "\r\n");          strcat(szQuery, "\r\n");
2939    
2940          if (lscp_client_call(pClient, szQuery, 0) == LSCP_OK)          if (lscp_client_call(pClient, szQuery, 0) == LSCP_OK)
2941                  pClient->midi_instruments = lscp_midi_instruments_create(lscp_client_get_result(pClient));                  pClient->midi_instruments = lscp_midi_instruments_create(
2942                            lscp_client_get_result(pClient));
2943    
2944          // Unlock this section down.          // Unlock this section down.
2945          lscp_mutex_unlock(pClient->mutex);          lscp_mutex_unlock(pClient->mutex);
# Line 2784  lscp_midi_instrument_t *lscp_list_midi_i Line 2959  lscp_midi_instrument_t *lscp_list_midi_i
2959   *  with all the information of the given MIDI instrument map entry,   *  with all the information of the given MIDI instrument map entry,
2960   *  or NULL in case of failure.   *  or NULL in case of failure.
2961   */   */
2962  lscp_midi_instrument_info_t *lscp_get_midi_instrument_info ( lscp_client_t *pClient, lscp_midi_instrument_t *pMidiInstr )  lscp_midi_instrument_info_t *lscp_get_midi_instrument_info ( lscp_client_t *pClient,
2963            lscp_midi_instrument_t *pMidiInstr )
2964  {  {
2965          lscp_midi_instrument_info_t *pInstrInfo;          lscp_midi_instrument_info_t *pInstrInfo;
2966          char szQuery[LSCP_BUFSIZ];          char szQuery[LSCP_BUFSIZ];
# Line 2903  lscp_status_t lscp_clear_midi_instrument Line 3079  lscp_status_t lscp_clear_midi_instrument
3079          return lscp_client_query(pClient, szQuery);          return lscp_client_query(pClient, szQuery);
3080  }  }
3081    
3082    
3083  /**  /**
3084   * Open an instrument editor application for the instrument   * Open an instrument editor application for the instrument
3085   * on the given sampler channel:   * on the given sampler channel:

Legend:
Removed from v.1806  
changed lines
  Added in v.3666

  ViewVC Help
Powered by ViewVC