/[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 963 by capela, Sun Dec 3 18:30:04 2006 UTC revision 1697 by schoenebeck, Sat Feb 16 19:31:32 2008 UTC
# Line 2  Line 2 
2  //  //
3  /****************************************************************************  /****************************************************************************
4     liblscp - LinuxSampler Control Protocol API     liblscp - LinuxSampler Control Protocol API
5     Copyright (C) 2004-2006, rncbc aka Rui Nuno Capela. All rights reserved.     Copyright (C) 2004-2008, 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 84  static void _lscp_client_evt_proc ( void Line 84  static void _lscp_client_evt_proc ( void
84                          if (cchBuffer > 0) {                          if (cchBuffer > 0) {
85                                  // Make sure received buffer it's null terminated.                                  // Make sure received buffer it's null terminated.
86                                  achBuffer[cchBuffer] = (char) 0;                                  achBuffer[cchBuffer] = (char) 0;
87                                  // Parse for the notification event message...                                  pch = achBuffer;
88                                  pszToken = lscp_strtok(achBuffer, pszSeps, &(pch)); // Have "NOTIFY".                                  do {
89                                  if (strcasecmp(pszToken, "NOTIFY") == 0) {                                          // Parse for the notification event message...
90                                          pszToken = lscp_strtok(NULL, pszSeps, &(pch));                                          pszToken = lscp_strtok(NULL, pszSeps, &(pch)); // Have "NOTIFY"
91                                          event    = lscp_event_from_text(pszToken);                                          if (strcasecmp(pszToken, "NOTIFY") == 0) {
92                                          // And pick the rest of data...                                                  pszToken = lscp_strtok(NULL, pszSeps, &(pch));
93                                          pszToken = lscp_strtok(NULL, pszSeps, &(pch));                                                  event    = lscp_event_from_text(pszToken);
94                                          cchToken = (pszToken == NULL ? 0 : strlen(pszToken));                                                  // And pick the rest of data...
95                                          // Double-check if we're really up to it...                                                  pszToken = lscp_strtok(NULL, pszSeps, &(pch));
96                                          if (pClient->events & event) {                                                  cchToken = (pszToken == NULL ? 0 : strlen(pszToken));
97                                                  // Invoke the client event callback...                                                  // Double-check if we're really up to it...
98                                                  if ((*pClient->pfnCallback)(                                                  if (pClient->events & event) {
99                                                                  pClient,                                                          // Invoke the client event callback...
100                                                                  event,                                                          if ((*pClient->pfnCallback)(
101                                                                  pszToken,                                                                          pClient,
102                                                                  cchToken,                                                                          event,
103                                                                  pClient->pvData) != LSCP_OK) {                                                                          pszToken,
104                                                          pClient->evt.iState = 0;                                                                          cchToken,
105                                                                            pClient->pvData) != LSCP_OK) {
106                                                                    pClient->evt.iState = 0;
107                                                            }
108                                                  }                                                  }
109                                          }                                          }
110                                  }                                  } while (*pch);
111                          } else {                          } else {
112                                  lscp_socket_perror("_lscp_client_evt_proc: recv");                                  lscp_socket_perror("_lscp_client_evt_proc: recv");
113                                  pClient->evt.iState = 0;                                  pClient->evt.iState = 0;
# Line 327  lscp_client_t* lscp_client_create ( cons Line 330  lscp_client_t* lscp_client_create ( cons
330          pClient->midi_devices = NULL;          pClient->midi_devices = NULL;
331          pClient->engines = NULL;          pClient->engines = NULL;
332          pClient->channels = NULL;          pClient->channels = NULL;
333            pClient->fxsends = NULL;
334          pClient->midi_instruments = NULL;          pClient->midi_instruments = NULL;
335            pClient->midi_maps = NULL;
336            pClient->midi_map_name = NULL;
337          lscp_driver_info_init(&(pClient->audio_driver_info));          lscp_driver_info_init(&(pClient->audio_driver_info));
338          lscp_driver_info_init(&(pClient->midi_driver_info));          lscp_driver_info_init(&(pClient->midi_driver_info));
339          lscp_device_info_init(&(pClient->audio_device_info));          lscp_device_info_init(&(pClient->audio_device_info));
# Line 341  lscp_client_t* lscp_client_create ( cons Line 347  lscp_client_t* lscp_client_create ( cons
347          lscp_server_info_init(&(pClient->server_info));          lscp_server_info_init(&(pClient->server_info));
348          lscp_engine_info_init(&(pClient->engine_info));          lscp_engine_info_init(&(pClient->engine_info));
349          lscp_channel_info_init(&(pClient->channel_info));          lscp_channel_info_init(&(pClient->channel_info));
350            lscp_fxsend_info_init(&(pClient->fxsend_info));
351          lscp_midi_instrument_info_init(&(pClient->midi_instrument_info));          lscp_midi_instrument_info_init(&(pClient->midi_instrument_info));
352          // Initialize error stuff.          // Initialize error stuff.
353          pClient->pszResult = NULL;          pClient->pszResult = NULL;
# Line 403  lscp_status_t lscp_client_destroy ( lscp Line 410  lscp_status_t lscp_client_destroy ( lscp
410    
411          // Free up all cached members.          // Free up all cached members.
412          lscp_midi_instrument_info_free(&(pClient->midi_instrument_info));          lscp_midi_instrument_info_free(&(pClient->midi_instrument_info));
413            lscp_fxsend_info_free(&(pClient->fxsend_info));
414          lscp_channel_info_free(&(pClient->channel_info));          lscp_channel_info_free(&(pClient->channel_info));
415          lscp_engine_info_free(&(pClient->engine_info));          lscp_engine_info_free(&(pClient->engine_info));
416          lscp_server_info_free(&(pClient->server_info));          lscp_server_info_free(&(pClient->server_info));
# Line 423  lscp_status_t lscp_client_destroy ( lscp Line 431  lscp_status_t lscp_client_destroy ( lscp
431          lscp_isplit_destroy(pClient->midi_devices);          lscp_isplit_destroy(pClient->midi_devices);
432          lscp_szsplit_destroy(pClient->engines);          lscp_szsplit_destroy(pClient->engines);
433          lscp_isplit_destroy(pClient->channels);          lscp_isplit_destroy(pClient->channels);
434            lscp_isplit_destroy(pClient->fxsends);
435          lscp_midi_instruments_destroy(pClient->midi_instruments);          lscp_midi_instruments_destroy(pClient->midi_instruments);
436            lscp_isplit_destroy(pClient->midi_maps);
437            if (pClient->midi_map_name)
438                    free(pClient->midi_map_name);
439          // Make them null.          // Make them null.
440          pClient->audio_drivers = NULL;          pClient->audio_drivers = NULL;
441          pClient->midi_drivers = NULL;          pClient->midi_drivers = NULL;
# Line 431  lscp_status_t lscp_client_destroy ( lscp Line 443  lscp_status_t lscp_client_destroy ( lscp
443          pClient->midi_devices = NULL;          pClient->midi_devices = NULL;
444          pClient->engines = NULL;          pClient->engines = NULL;
445          pClient->channels = NULL;          pClient->channels = NULL;
446            pClient->fxsends = NULL;
447          pClient->midi_instruments = NULL;          pClient->midi_instruments = NULL;
448            pClient->midi_maps = NULL;
449            pClient->midi_map_name = NULL;
450          // Free result error stuff.          // Free result error stuff.
451          lscp_client_set_result(pClient, NULL, 0);          lscp_client_set_result(pClient, NULL, 0);
452          // Free stream usage stuff.          // Free stream usage stuff.
# Line 512  lscp_status_t lscp_client_query ( lscp_c Line 527  lscp_status_t lscp_client_query ( lscp_c
527  {  {
528          lscp_status_t ret;          lscp_status_t ret;
529    
530            if (pClient == NULL)
531                    return LSCP_FAILED;
532    
533          // Lock this section up.          // Lock this section up.
534          lscp_mutex_lock(pClient->mutex);          lscp_mutex_lock(pClient->mutex);
535    
# Line 563  int lscp_client_get_errno ( lscp_client_ Line 581  int lscp_client_get_errno ( lscp_client_
581  // Client registration protocol functions.  // Client registration protocol functions.
582    
583  /**  /**
584   *  Register frontend for receiving event messages:   *  Register frontend for receiving event messages by the sampler backend.
585   *  SUBSCRIBE CHANNEL_COUNT | VOICE_COUNT | STREAM_COUNT | BUFFER_FILL   *  @e Caution: since liblscp v0.5.5.4 you have to call lscp_client_subscribe()
586   *      | CHANNEL_INFO | MISCELLANEOUS   *  for @e each event you want to subscribe. That is the old bitflag approach
587     *  was abondoned at this point. You can however still register all older
588     *  events with one lscp_client_subscribe() call at once. Thus, the old
589     *  behavior of this functions was not broken. Those older events are namely:
590     *  @code
591     *  SUBSCRIBE CHANNEL_COUNT | VOICE_COUNT | STREAM_COUNT
592     *      | BUFFER_FILL | CHANNEL_INFO | TOTAL_VOICE_COUNT
593     *      | AUDIO_OUTPUT_DEVICE_COUNT | AUDIO_OUTPUT_DEVICE_INFO
594     *      | MIDI_INPUT_DEVICE_COUNT | MIDI_INPUT_DEVICE_INFO
595     *      | MIDI_INSTRUMENT_MAP_COUNT | MIDI_INSTRUMENT_MAP_INFO
596     *      | MIDI_INSTRUMENT_COUNT | MIDI_INSTRUMENT_INFO
597     *      | MISCELLANEOUS
598     *  @endcode
599     *  The old events occupy the lower 16 bits (as bit flags), and all younger
600     *  events enumerate the whole upper 16 bits range. The new, enumerated
601     *  events are namely:
602     *  @code
603     *  SUBSCRIBE CHANNEL_MIDI
604     *  @endcode
605   *   *
606   *  @param pClient  Pointer to client instance structure.   *  @param pClient  Pointer to client instance structure.
607   *  @param events   Bit-wise OR'ed event flags to subscribe.   *  @param events   LSCP event to subscribe.
608   *   *
609   *  @returns LSCP_OK on success, LSCP_FAILED otherwise.   *  @returns LSCP_OK on success, LSCP_FAILED otherwise.
610   */   */
611  lscp_status_t lscp_client_subscribe ( lscp_client_t *pClient, lscp_event_t events )  lscp_status_t lscp_client_subscribe ( lscp_client_t *pClient, lscp_event_t events )
612  {  {
613          lscp_status_t ret = LSCP_FAILED;          lscp_status_t ret = LSCP_OK;
614            lscp_event_t currentEvent;
615    
616          if (pClient == NULL)          if (pClient == NULL)
617                  return LSCP_FAILED;                  return LSCP_FAILED;
# Line 597  lscp_status_t lscp_client_subscribe ( ls Line 634  lscp_status_t lscp_client_subscribe ( ls
634                  ret = _lscp_client_evt_request(pClient, 1, LSCP_EVENT_BUFFER_FILL);                  ret = _lscp_client_evt_request(pClient, 1, LSCP_EVENT_BUFFER_FILL);
635          if (ret == LSCP_OK && (events & LSCP_EVENT_CHANNEL_INFO))          if (ret == LSCP_OK && (events & LSCP_EVENT_CHANNEL_INFO))
636                  ret = _lscp_client_evt_request(pClient, 1, LSCP_EVENT_CHANNEL_INFO);                  ret = _lscp_client_evt_request(pClient, 1, LSCP_EVENT_CHANNEL_INFO);
637            if (ret == LSCP_OK && (events & LSCP_EVENT_TOTAL_VOICE_COUNT))
638                    ret = _lscp_client_evt_request(pClient, 1, LSCP_EVENT_TOTAL_VOICE_COUNT);
639            if (ret == LSCP_OK && (events & LSCP_EVENT_AUDIO_OUTPUT_DEVICE_COUNT))
640                    ret = _lscp_client_evt_request(pClient, 1, LSCP_EVENT_AUDIO_OUTPUT_DEVICE_COUNT);
641            if (ret == LSCP_OK && (events & LSCP_EVENT_AUDIO_OUTPUT_DEVICE_INFO))
642                    ret = _lscp_client_evt_request(pClient, 1, LSCP_EVENT_AUDIO_OUTPUT_DEVICE_INFO);
643            if (ret == LSCP_OK && (events & LSCP_EVENT_MIDI_INPUT_DEVICE_COUNT))
644                    ret = _lscp_client_evt_request(pClient, 1, LSCP_EVENT_MIDI_INPUT_DEVICE_COUNT);
645            if (ret == LSCP_OK && (events & LSCP_EVENT_MIDI_INPUT_DEVICE_INFO))
646                    ret = _lscp_client_evt_request(pClient, 1, LSCP_EVENT_MIDI_INPUT_DEVICE_INFO);
647            if (ret == LSCP_OK && (events & LSCP_EVENT_MIDI_INSTRUMENT_MAP_COUNT))
648                    ret = _lscp_client_evt_request(pClient, 1, LSCP_EVENT_MIDI_INSTRUMENT_MAP_COUNT);
649            if (ret == LSCP_OK && (events & LSCP_EVENT_MIDI_INSTRUMENT_MAP_INFO))
650                    ret = _lscp_client_evt_request(pClient, 1, LSCP_EVENT_MIDI_INSTRUMENT_MAP_INFO);
651            if (ret == LSCP_OK && (events & LSCP_EVENT_MIDI_INSTRUMENT_COUNT))
652                    ret = _lscp_client_evt_request(pClient, 1, LSCP_EVENT_MIDI_INSTRUMENT_COUNT);
653            if (ret == LSCP_OK && (events & LSCP_EVENT_MIDI_INSTRUMENT_INFO))
654                    ret = _lscp_client_evt_request(pClient, 1, LSCP_EVENT_MIDI_INSTRUMENT_INFO);
655          if (ret == LSCP_OK && (events & LSCP_EVENT_MISCELLANEOUS))          if (ret == LSCP_OK && (events & LSCP_EVENT_MISCELLANEOUS))
656                  ret = _lscp_client_evt_request(pClient, 1, LSCP_EVENT_MISCELLANEOUS);                  ret = _lscp_client_evt_request(pClient, 1, LSCP_EVENT_MISCELLANEOUS);
657            // Caution: for the upper 16 bits, we don't use bit flags anymore ...
658            currentEvent = events & 0xffff0000;
659            if (ret == LSCP_OK && currentEvent) {
660                    switch (currentEvent) {
661                            case LSCP_EVENT_CHANNEL_MIDI:
662                            case LSCP_EVENT_DEVICE_MIDI:
663                                    ret = _lscp_client_evt_request(pClient, 1, currentEvent);
664                                    break;
665                            default: // unknown "upper" event type
666                                    ret = LSCP_FAILED;
667                                    break;
668                    }
669            }
670    
671          // Unlock this section down.          // Unlock this section down.
672          lscp_mutex_unlock(pClient->mutex);          lscp_mutex_unlock(pClient->mutex);
# Line 608  lscp_status_t lscp_client_subscribe ( ls Line 676  lscp_status_t lscp_client_subscribe ( ls
676    
677    
678  /**  /**
679   *  Deregister frontend from receiving UDP event messages anymore:   *  Deregister frontend from receiving UDP event messages anymore.
680   *  SUBSCRIBE CHANNEL_COUNT | VOICE_COUNT | STREAM_COUNT | BUFFER_FILL   *  @e Caution: since liblscp v0.5.5.4 you have to call
681   *      | CHANNEL_INFO | MISCELLANEOUS   *  lscp_client_unsubscribe() for @e each event you want to unsubscribe.
682     *  That is the old bitflag approach was abondoned at this point. You can
683     *  however still register all older events with one lscp_client_subscribe()
684     *  call at once. Thus, the old behavior of this functions was not broken.
685     *  Those older events are namely:
686     *  @code
687     *  UNSUBSCRIBE CHANNEL_COUNT | VOICE_COUNT | STREAM_COUNT
688     *      | BUFFER_FILL | CHANNEL_INFO | TOTAL_VOICE_COUNT
689     *      | AUDIO_OUTPUT_DEVICE_COUNT | AUDIO_OUTPUT_DEVICE_INFO
690     *      | MIDI_INPUT_DEVICE_COUNT | MIDI_INPUT_DEVICE_INFO
691     *      | MIDI_INSTRUMENT_MAP_COUNT | MIDI_INSTRUMENT_MAP_INFO
692     *      | MIDI_INSTRUMENT_COUNT | MIDI_INSTRUMENT_INFO
693     *      | MISCELLANEOUS
694     *  @endcode
695     *  The old events occupy the lower 16 bits (as bit flags), and all younger
696     *  events enumerate the whole upper 16 bits range. The new, enumerated
697     *  events are namely:
698     *  @code
699     *  UNSUBSCRIBE CHANNEL_MIDI
700     *  @endcode
701   *   *
702   *  @param pClient  Pointer to client instance structure.   *  @param pClient  Pointer to client instance structure.
703   *  @param events   Bit-wise OR'ed event flags to unsubscribe.   *  @param events   LSCP event to unsubscribe.
704   *   *
705   *  @returns LSCP_OK on success, LSCP_FAILED otherwise.   *  @returns LSCP_OK on success, LSCP_FAILED otherwise.
706   */   */
707  lscp_status_t lscp_client_unsubscribe ( lscp_client_t *pClient, lscp_event_t events )  lscp_status_t lscp_client_unsubscribe ( lscp_client_t *pClient, lscp_event_t events )
708  {  {
709          lscp_status_t ret = LSCP_OK;          lscp_status_t ret = LSCP_OK;
710            lscp_event_t currentEvent;
711    
712          if (pClient == NULL)          if (pClient == NULL)
713                  return LSCP_FAILED;                  return LSCP_FAILED;
# Line 638  lscp_status_t lscp_client_unsubscribe ( Line 726  lscp_status_t lscp_client_unsubscribe (
726                  ret = _lscp_client_evt_request(pClient, 0, LSCP_EVENT_BUFFER_FILL);                  ret = _lscp_client_evt_request(pClient, 0, LSCP_EVENT_BUFFER_FILL);
727          if (ret == LSCP_OK && (events & LSCP_EVENT_CHANNEL_INFO))          if (ret == LSCP_OK && (events & LSCP_EVENT_CHANNEL_INFO))
728                  ret = _lscp_client_evt_request(pClient, 0, LSCP_EVENT_CHANNEL_INFO);                  ret = _lscp_client_evt_request(pClient, 0, LSCP_EVENT_CHANNEL_INFO);
729            if (ret == LSCP_OK && (events & LSCP_EVENT_TOTAL_VOICE_COUNT))
730                    ret = _lscp_client_evt_request(pClient, 0, LSCP_EVENT_TOTAL_VOICE_COUNT);
731            if (ret == LSCP_OK && (events & LSCP_EVENT_AUDIO_OUTPUT_DEVICE_COUNT))
732                    ret = _lscp_client_evt_request(pClient, 0, LSCP_EVENT_AUDIO_OUTPUT_DEVICE_COUNT);
733            if (ret == LSCP_OK && (events & LSCP_EVENT_AUDIO_OUTPUT_DEVICE_INFO))
734                    ret = _lscp_client_evt_request(pClient, 0, LSCP_EVENT_AUDIO_OUTPUT_DEVICE_INFO);
735            if (ret == LSCP_OK && (events & LSCP_EVENT_MIDI_INPUT_DEVICE_COUNT))
736                    ret = _lscp_client_evt_request(pClient, 0, LSCP_EVENT_MIDI_INPUT_DEVICE_COUNT);
737            if (ret == LSCP_OK && (events & LSCP_EVENT_MIDI_INPUT_DEVICE_INFO))
738                    ret = _lscp_client_evt_request(pClient, 0, LSCP_EVENT_MIDI_INPUT_DEVICE_INFO);
739            if (ret == LSCP_OK && (events & LSCP_EVENT_MIDI_INSTRUMENT_MAP_COUNT))
740                    ret = _lscp_client_evt_request(pClient, 0, LSCP_EVENT_MIDI_INSTRUMENT_MAP_COUNT);
741            if (ret == LSCP_OK && (events & LSCP_EVENT_MIDI_INSTRUMENT_MAP_INFO))
742                    ret = _lscp_client_evt_request(pClient, 0, LSCP_EVENT_MIDI_INSTRUMENT_MAP_INFO);
743            if (ret == LSCP_OK && (events & LSCP_EVENT_MIDI_INSTRUMENT_COUNT))
744                    ret = _lscp_client_evt_request(pClient, 0, LSCP_EVENT_MIDI_INSTRUMENT_COUNT);
745            if (ret == LSCP_OK && (events & LSCP_EVENT_MIDI_INSTRUMENT_INFO))
746                    ret = _lscp_client_evt_request(pClient, 0, LSCP_EVENT_MIDI_INSTRUMENT_INFO);
747          if (ret == LSCP_OK && (events & LSCP_EVENT_MISCELLANEOUS))          if (ret == LSCP_OK && (events & LSCP_EVENT_MISCELLANEOUS))
748                  ret = _lscp_client_evt_request(pClient, 0, LSCP_EVENT_MISCELLANEOUS);                  ret = _lscp_client_evt_request(pClient, 0, LSCP_EVENT_MISCELLANEOUS);
749            // Caution: for the upper 16 bits, we don't use bit flags anymore ...
750            currentEvent = events & 0xffff0000;
751            if (ret == LSCP_OK && currentEvent) {
752                    switch (currentEvent) {
753                            case LSCP_EVENT_CHANNEL_MIDI:
754                            case LSCP_EVENT_DEVICE_MIDI:
755                                    ret = _lscp_client_evt_request(pClient, 0, currentEvent);
756                                    break;
757                            default: // unknown "upper" event type
758                                    ret = LSCP_FAILED;
759                                    break;
760                    }
761            }
762    
763          // If necessary, close the alternate connection...          // If necessary, close the alternate connection...
764          if (pClient->events == LSCP_EVENT_NONE)          if (pClient->events == LSCP_EVENT_NONE)
# Line 752  int lscp_get_channels ( lscp_client_t *p Line 871  int lscp_get_channels ( lscp_client_t *p
871  {  {
872          int iChannels = -1;          int iChannels = -1;
873    
874            if (pClient == NULL)
875                    return -1;
876    
877          // Lock this section up.          // Lock this section up.
878          lscp_mutex_lock(pClient->mutex);          lscp_mutex_lock(pClient->mutex);
879    
# Line 812  int lscp_add_channel ( lscp_client_t *pC Line 934  int lscp_add_channel ( lscp_client_t *pC
934  {  {
935          int iSamplerChannel = -1;          int iSamplerChannel = -1;
936    
937            if (pClient == NULL)
938                    return -1;
939    
940          // Lock this section up.          // Lock this section up.
941          lscp_mutex_lock(pClient->mutex);          lscp_mutex_lock(pClient->mutex);
942    
# Line 859  int lscp_get_available_engines ( lscp_cl Line 984  int lscp_get_available_engines ( lscp_cl
984  {  {
985          int iAvailableEngines = -1;          int iAvailableEngines = -1;
986    
987            if (pClient == NULL)
988                    return -1;
989    
990          // Lock this section up.          // Lock this section up.
991          lscp_mutex_lock(pClient->mutex);          lscp_mutex_lock(pClient->mutex);
992    
# Line 885  const char **lscp_list_available_engines Line 1013  const char **lscp_list_available_engines
1013  {  {
1014          const char *pszSeps = ",";          const char *pszSeps = ",";
1015    
1016            if (pClient == NULL)
1017                    return NULL;
1018    
1019          // Lock this section up.          // Lock this section up.
1020          lscp_mutex_lock(pClient->mutex);          lscp_mutex_lock(pClient->mutex);
1021    
# Line 923  lscp_engine_info_t *lscp_get_engine_info Line 1054  lscp_engine_info_t *lscp_get_engine_info
1054          char *pszToken;          char *pszToken;
1055          char *pch;          char *pch;
1056    
1057            if (pClient == NULL)
1058                    return NULL;
1059          if (pszEngineName == NULL)          if (pszEngineName == NULL)
1060                  return NULL;                  return NULL;
1061    
# Line 979  lscp_channel_info_t *lscp_get_channel_in Line 1112  lscp_channel_info_t *lscp_get_channel_in
1112          char *pszToken;          char *pszToken;
1113          char *pch;          char *pch;
1114    
1115            if (pClient == NULL)
1116                    return NULL;
1117          if (iSamplerChannel < 0)          if (iSamplerChannel < 0)
1118                  return NULL;                  return NULL;
1119    
# Line 1012  lscp_channel_info_t *lscp_get_channel_in Line 1147  lscp_channel_info_t *lscp_get_channel_in
1147                                  pszToken = lscp_strtok(NULL, pszCrlf, &(pch));                                  pszToken = lscp_strtok(NULL, pszCrlf, &(pch));
1148                                  if (pszToken) {                                  if (pszToken) {
1149                                          if (pChannelInfo->audio_routing)                                          if (pChannelInfo->audio_routing)
1150                                                  lscp_szsplit_destroy(pChannelInfo->audio_routing);                                                  lscp_isplit_destroy(pChannelInfo->audio_routing);
1151                                          pChannelInfo->audio_routing = lscp_szsplit_create(pszToken, ",");                                          pChannelInfo->audio_routing = lscp_isplit_create(pszToken, ",");
1152                                  }                                  }
1153                          }                          }
1154                          else if (strcasecmp(pszToken, "INSTRUMENT_FILE") == 0) {                          else if (strcasecmp(pszToken, "INSTRUMENT_FILE") == 0) {
# Line 1056  lscp_channel_info_t *lscp_get_channel_in Line 1191  lscp_channel_info_t *lscp_get_channel_in
1191                                                  pChannelInfo->midi_channel = atoi(pszToken);                                                  pChannelInfo->midi_channel = atoi(pszToken);
1192                                  }                                  }
1193                          }                          }
1194                            else if (strcasecmp(pszToken, "MIDI_INSTRUMENT_MAP") == 0) {
1195                                    pszToken = lscp_strtok(NULL, pszCrlf, &(pch));
1196                                    if (pszToken) {
1197                                            pszToken = lscp_ltrim(pszToken);
1198                                            if (strcasecmp(pszToken, "NONE") == 0)
1199                                                    pChannelInfo->midi_map = LSCP_MIDI_MAP_NONE;
1200                                            else
1201                                            if (strcasecmp(pszToken, "DEFAULT") == 0)
1202                                                    pChannelInfo->midi_map = LSCP_MIDI_MAP_DEFAULT;
1203                                            else
1204                                                    pChannelInfo->midi_map = atoi(pszToken);
1205                                    }
1206                            }
1207                          else if (strcasecmp(pszToken, "VOLUME") == 0) {                          else if (strcasecmp(pszToken, "VOLUME") == 0) {
1208                                  pszToken = lscp_strtok(NULL, pszCrlf, &(pch));                                  pszToken = lscp_strtok(NULL, pszCrlf, &(pch));
1209                                  if (pszToken)                                  if (pszToken)
# Line 1097  int lscp_get_channel_voice_count ( lscp_ Line 1245  int lscp_get_channel_voice_count ( lscp_
1245          char szQuery[LSCP_BUFSIZ];          char szQuery[LSCP_BUFSIZ];
1246          int iVoiceCount = -1;          int iVoiceCount = -1;
1247    
1248            if (pClient == NULL)
1249                    return -1;
1250          if (iSamplerChannel < 0)          if (iSamplerChannel < 0)
1251                  return iVoiceCount;                  return -1;
1252    
1253          // Lock this section up.          // Lock this section up.
1254          lscp_mutex_lock(pClient->mutex);          lscp_mutex_lock(pClient->mutex);
# Line 1128  int lscp_get_channel_stream_count ( lscp Line 1278  int lscp_get_channel_stream_count ( lscp
1278          char szQuery[LSCP_BUFSIZ];          char szQuery[LSCP_BUFSIZ];
1279          int iStreamCount = -1;          int iStreamCount = -1;
1280    
1281            if (pClient == NULL)
1282                    return -1;
1283          if (iSamplerChannel < 0)          if (iSamplerChannel < 0)
1284                  return iStreamCount;                  return -1;
1285    
1286          // Lock this section up.          // Lock this section up.
1287          lscp_mutex_lock(pClient->mutex);          lscp_mutex_lock(pClient->mutex);
# Line 1165  int lscp_get_channel_stream_usage ( lscp Line 1317  int lscp_get_channel_stream_usage ( lscp
1317          int   iStream;          int   iStream;
1318          int   iPercent;          int   iPercent;
1319    
1320            if (pClient == NULL)
1321                    return -1;
1322          if (iSamplerChannel < 0)          if (iSamplerChannel < 0)
1323                  return iStreamUsage;                  return -1;
1324    
1325          // Lock this section up.          // Lock this section up.
1326          lscp_mutex_lock(pClient->mutex);          lscp_mutex_lock(pClient->mutex);
# Line 1227  lscp_buffer_fill_t *lscp_get_channel_buf Line 1381  lscp_buffer_fill_t *lscp_get_channel_buf
1381    
1382          // Retrieve a channel stream estimation.          // Retrieve a channel stream estimation.
1383          iStreamCount = lscp_get_channel_stream_count(pClient, iSamplerChannel);          iStreamCount = lscp_get_channel_stream_count(pClient, iSamplerChannel);
1384          if (pClient->iStreamCount < 0)          if (iStreamCount < 0)
1385                  return NULL;                  return NULL;
1386    
1387          // Lock this section up.          // Lock this section up.
# Line 1416  lscp_status_t lscp_set_channel_midi_port Line 1570  lscp_status_t lscp_set_channel_midi_port
1570   *  @param pClient          Pointer to client instance structure.   *  @param pClient          Pointer to client instance structure.
1571   *  @param iSamplerChannel  Sampler channel number.   *  @param iSamplerChannel  Sampler channel number.
1572   *  @param iMidiChannel     MIDI channel address number to listen (0-15) or   *  @param iMidiChannel     MIDI channel address number to listen (0-15) or
1573   *                          LSCP_MIDI_CHANNEL_ALL (16) to listen on all channels.   *                          @ref LSCP_MIDI_CHANNEL_ALL (16) to listen on all channels.
1574   *   *
1575   *  @returns LSCP_OK on success, LSCP_FAILED otherwise.   *  @returns LSCP_OK on success, LSCP_FAILED otherwise.
1576   */   */
# Line 1436  lscp_status_t lscp_set_channel_midi_chan Line 1590  lscp_status_t lscp_set_channel_midi_chan
1590    
1591    
1592  /**  /**
1593     *  Setting MIDI instrument map:
1594     *  SET CHANNEL MIDI_INSTRUMENT_MAP <sampler-channel> <midi-map>
1595     *
1596     *  @param pClient          Pointer to client instance structure.
1597     *  @param iSamplerChannel  Sampler channel number.
1598     *  @param iMidiMap         MIDI instrument map number, or either
1599     *                          @ref LSCP_MIDI_MAP_NONE or
1600     *                          @ref LSCP_MIDI_MAP_DEFAULT .
1601     *
1602     *  @returns LSCP_OK on success, LSCP_FAILED otherwise.
1603     */
1604    lscp_status_t lscp_set_channel_midi_map ( lscp_client_t *pClient, int iSamplerChannel, int iMidiMap )
1605    {
1606            char szQuery[LSCP_BUFSIZ];
1607    
1608            if (iSamplerChannel < 0)
1609                    return LSCP_FAILED;
1610    
1611            sprintf(szQuery, "SET CHANNEL MIDI_INSTRUMENT_MAP %d ", iSamplerChannel);
1612            if (iMidiMap == LSCP_MIDI_MAP_NONE)
1613                    strcat(szQuery , "NONE");
1614            else
1615            if (iMidiMap == LSCP_MIDI_MAP_DEFAULT)
1616                    strcat(szQuery , "DEFAULT");
1617            else
1618                    sprintf(szQuery + strlen(szQuery), "%d", iMidiMap);
1619    
1620            strcat(szQuery, "\r\n");
1621    
1622            return lscp_client_query(pClient, szQuery);
1623    }
1624    
1625    
1626    /**
1627   *  Setting channel volume:   *  Setting channel volume:
1628   *  SET CHANNEL VOLUME <sampler-channel> <volume>   *  SET CHANNEL VOLUME <sampler-channel> <volume>
1629   *   *
# Line 1451  lscp_status_t lscp_set_channel_volume ( Line 1639  lscp_status_t lscp_set_channel_volume (
1639  {  {
1640          char szQuery[LSCP_BUFSIZ];          char szQuery[LSCP_BUFSIZ];
1641    
1642          if (iSamplerChannel < 0 || fVolume < 0.0)          if (iSamplerChannel < 0 || fVolume < 0.0f)
1643                  return LSCP_FAILED;                  return LSCP_FAILED;
1644    
1645          sprintf(szQuery, "SET CHANNEL VOLUME %d %g\r\n", iSamplerChannel, fVolume);          sprintf(szQuery, "SET CHANNEL VOLUME %d %g\r\n", iSamplerChannel, fVolume);
# Line 1538  lscp_status_t lscp_reset_channel ( lscp_ Line 1726  lscp_status_t lscp_reset_channel ( lscp_
1726   */   */
1727  lscp_status_t lscp_reset_sampler ( lscp_client_t *pClient )  lscp_status_t lscp_reset_sampler ( lscp_client_t *pClient )
1728  {  {
1729            // Do actual whole sampler reset...
1730          return lscp_client_query(pClient, "RESET\r\n");          return lscp_client_query(pClient, "RESET\r\n");
1731  }  }
1732    
# Line 1560  lscp_server_info_t *lscp_get_server_info Line 1749  lscp_server_info_t *lscp_get_server_info
1749          char *pszToken;          char *pszToken;
1750          char *pch;          char *pch;
1751    
1752            if (pClient == NULL)
1753                    return NULL;
1754    
1755          // Lock this section up.          // Lock this section up.
1756          lscp_mutex_lock(pClient->mutex);          lscp_mutex_lock(pClient->mutex);
1757    
# Line 1580  lscp_server_info_t *lscp_get_server_info Line 1772  lscp_server_info_t *lscp_get_server_info
1772                                  if (pszToken)                                  if (pszToken)
1773                                          lscp_unquote_dup(&(pServerInfo->version), &pszToken);                                          lscp_unquote_dup(&(pServerInfo->version), &pszToken);
1774                          }                          }
1775                            else if (strcasecmp(pszToken, "PROTOCOL_VERSION") == 0) {
1776                                    pszToken = lscp_strtok(NULL, pszCrlf, &(pch));
1777                                    if (pszToken)
1778                                            lscp_unquote_dup(&(pServerInfo->protocol_version), &pszToken);
1779                            }
1780                          pszToken = lscp_strtok(NULL, pszSeps, &(pch));                          pszToken = lscp_strtok(NULL, pszSeps, &(pch));
1781                  }                  }
1782          }          }
# Line 1605  int lscp_get_total_voice_count ( lscp_cl Line 1802  int lscp_get_total_voice_count ( lscp_cl
1802  {  {
1803          int iVoiceCount = -1;          int iVoiceCount = -1;
1804    
1805            if (pClient == NULL)
1806                    return -1;
1807    
1808          // Lock this section up.          // Lock this section up.
1809          lscp_mutex_lock(pClient->mutex);          lscp_mutex_lock(pClient->mutex);
1810    
# Line 1631  int lscp_get_total_voice_count_max ( lsc Line 1831  int lscp_get_total_voice_count_max ( lsc
1831  {  {
1832          int iVoiceCount = -1;          int iVoiceCount = -1;
1833    
1834            if (pClient == NULL)
1835                    return -1;
1836    
1837          // Lock this section up.          // Lock this section up.
1838          lscp_mutex_lock(pClient->mutex);          lscp_mutex_lock(pClient->mutex);
1839    
# Line 1645  int lscp_get_total_voice_count_max ( lsc Line 1848  int lscp_get_total_voice_count_max ( lsc
1848    
1849    
1850  /**  /**
1851     *  Get global volume attenuation:
1852     *  GET VOLUME
1853     *
1854     *  @param pClient  Pointer to client instance structure.
1855     *
1856     *  @returns The global volume as positive floating point value usually in
1857     *  the range between 0.0 and 1.0; in case of failure 0.0 is returned.
1858     */
1859    float lscp_get_volume ( lscp_client_t *pClient )
1860    {
1861            float fVolume = 0.0f;
1862    
1863            if (pClient == NULL)
1864                    return 0.0f;
1865    
1866            // Lock this section up.
1867            lscp_mutex_lock(pClient->mutex);
1868    
1869            if (lscp_client_call(pClient, "GET VOLUME\r\n", 0) == LSCP_OK)
1870                    fVolume = (float) atof(lscp_client_get_result(pClient));
1871    
1872            // Unlock this section down.
1873            lscp_mutex_unlock(pClient->mutex);
1874    
1875            return fVolume;
1876    }
1877    
1878    
1879    /**
1880     *  Setting global volume attenuation:
1881     *  SET VOLUME <volume>
1882     *
1883     *  @param pClient  Pointer to client instance structure.
1884     *  @param fVolume  Global volume parameter as positive floating point
1885     *                  value usually be in the range between 0.0 and 1.0,
1886     *                  that is for attenuating the overall volume.
1887     *
1888     *  @returns LSCP_OK on success, LSCP_FAILED otherwise.
1889     */
1890    lscp_status_t lscp_set_volume ( lscp_client_t *pClient, float fVolume )
1891    {
1892            char szQuery[LSCP_BUFSIZ];
1893    
1894            if (fVolume < 0.0f)
1895                    return LSCP_FAILED;
1896    
1897            sprintf(szQuery, "SET VOLUME %g\r\n", fVolume);
1898            return lscp_client_query(pClient, szQuery);
1899    }
1900    
1901    
1902    /**
1903     *  Add an effect send to a sampler channel:
1904     *  CREATE FX_SEND <sampler-channel> <midi-ctrl> [<name>]
1905     *
1906     *  @param pClient          Pointer to client instance structure.
1907     *  @param iSamplerChannel  Sampler channel number.
1908     *  @param iMidiController  MIDI controller used to alter the effect,
1909     *                          usually a number between 0 and 127.
1910     *  @param pszName          Optional name for the effect send entity,
1911     *                          does not have to be unique.
1912     *
1913     *  @returns The new effect send number identifier, or -1 in case of failure.
1914     */
1915    int lscp_create_fxsend ( lscp_client_t *pClient, int iSamplerChannel, int iMidiController, const char *pszFxName )
1916    {
1917            int iFxSend = -1;
1918            char szQuery[LSCP_BUFSIZ];
1919    
1920            if (pClient == NULL)
1921                    return -1;
1922            if (iSamplerChannel < 0 || iMidiController < 0 || iMidiController > 127)
1923                    return -1;
1924    
1925            // Lock this section up.
1926            lscp_mutex_lock(pClient->mutex);
1927    
1928            sprintf(szQuery, "CREATE FX_SEND %d %d", iSamplerChannel, iMidiController);
1929            
1930            if (pszFxName)
1931                    sprintf(szQuery + strlen(szQuery), " '%s'", pszFxName);
1932    
1933            strcat(szQuery, "\r\n");
1934    
1935            if (lscp_client_call(pClient, szQuery, 0) == LSCP_OK)
1936                    iFxSend = atoi(lscp_client_get_result(pClient));
1937    
1938            // Unlock this section down.
1939            lscp_mutex_unlock(pClient->mutex);
1940    
1941            return iFxSend;
1942    }
1943    
1944    
1945    /**
1946     *  Remove an effect send from a sampler channel:
1947     *  DESTROY FX_SEND <sampler-channel> <fx-send-id>
1948     *
1949     *  @param pClient          Pointer to client instance structure.
1950     *  @param iSamplerChannel  Sampler channel number.
1951     *  @param iFxSend          Effect send number.
1952     *
1953     *  @returns LSCP_OK on success, LSCP_FAILED otherwise.
1954     */
1955    lscp_status_t lscp_destroy_fxsend ( lscp_client_t *pClient, int iSamplerChannel, int iFxSend )
1956    {
1957            char szQuery[LSCP_BUFSIZ];
1958    
1959            if (iSamplerChannel < 0 || iFxSend < 0)
1960                    return LSCP_FAILED;
1961    
1962            sprintf(szQuery, "DESTROY FX_SEND %d %d\r\n", iSamplerChannel, iFxSend);
1963    
1964            return lscp_client_query(pClient, szQuery);
1965    }
1966    
1967    
1968    /**
1969     *  Get amount of effect sends on a sampler channel:
1970     *  GET FX_SENDS <sampler-channel>
1971     *
1972     *  @param pClient          Pointer to client instance structure.
1973     *  @param iSamplerChannel  Sampler channel number.
1974     *
1975     *  @returns The current total number of effect sends of the sampler channel
1976     *  on success, -1 otherwise.
1977     */
1978    int lscp_get_fxsends ( lscp_client_t *pClient, int iSamplerChannel )
1979    {
1980            int iFxSends = -1;
1981            char szQuery[LSCP_BUFSIZ];
1982    
1983            if (pClient == NULL)
1984                    return -1;
1985            if (iSamplerChannel < 0)
1986                    return -1;
1987    
1988            // Lock this section up.
1989            lscp_mutex_lock(pClient->mutex);
1990    
1991            sprintf(szQuery, "GET FX_SENDS %d\r\n", iSamplerChannel);
1992    
1993            if (lscp_client_call(pClient, szQuery, 0) == LSCP_OK)
1994                    iFxSends = atoi(lscp_client_get_result(pClient));
1995    
1996            // Unlock this section doen.
1997            lscp_mutex_unlock(pClient->mutex);
1998    
1999            return iFxSends;
2000    }
2001    
2002    
2003    /**
2004     *  List all effect sends on a sampler channel:
2005     *  LIST FX_SENDS <sampler-channel>
2006     *
2007     *  @param pClient          Pointer to client instance structure.
2008     *  @param iSamplerChannel  Sampler channel number.
2009     *
2010     *  @returns An array of the effect sends identifiers as positive integers,
2011     *  terminated with -1 on success, NULL otherwise.
2012     */
2013    int *lscp_list_fxsends ( lscp_client_t *pClient, int iSamplerChannel )
2014    {
2015            const char *pszSeps = ",";
2016            char szQuery[LSCP_BUFSIZ];
2017    
2018            if (pClient == NULL)
2019                    return NULL;
2020    
2021            // Lock this section up.
2022            lscp_mutex_lock(pClient->mutex);
2023    
2024            if (pClient->fxsends) {
2025                    lscp_isplit_destroy(pClient->fxsends);
2026                    pClient->fxsends = NULL;
2027            }
2028    
2029            sprintf(szQuery, "LIST FX_SENDS %d\r\n", iSamplerChannel);
2030    
2031            if (lscp_client_call(pClient, szQuery, 0) == LSCP_OK)
2032                    pClient->fxsends = lscp_isplit_create(lscp_client_get_result(pClient), pszSeps);
2033    
2034            // Unlock this section down.
2035            lscp_mutex_unlock(pClient->mutex);
2036    
2037            return pClient->fxsends;
2038    }
2039    
2040    
2041    /**
2042     *  Getting effect send information
2043     *  GET FX_SEND INFO <sampler-channel> <fx-send-id>
2044     *
2045     *  @param pClient          Pointer to client instance structure.
2046     *  @param iSamplerChannel  Sampler channel number.
2047     *  @param iFxSend          Effect send number.
2048     *
2049     *  @returns A pointer to a @ref lscp_fxsend_info_t structure, with the
2050     *  information of the given FX send, or NULL in case of failure.
2051     */
2052    lscp_fxsend_info_t *lscp_get_fxsend_info ( lscp_client_t *pClient, int iSamplerChannel, int iFxSend )
2053    {
2054            lscp_fxsend_info_t *pFxSendInfo;
2055            char szQuery[LSCP_BUFSIZ];
2056            const char *pszResult;
2057            const char *pszSeps = ":";
2058            const char *pszCrlf = "\r\n";
2059            char *pszToken;
2060            char *pch;
2061    
2062            if (pClient == NULL)
2063                    return NULL;
2064            if (iSamplerChannel < 0 || iFxSend < 0)
2065                    return NULL;
2066    
2067            // Lock this section up.
2068            lscp_mutex_lock(pClient->mutex);
2069    
2070            pFxSendInfo = &(pClient->fxsend_info);
2071            lscp_fxsend_info_reset(pFxSendInfo);
2072    
2073            sprintf(szQuery, "GET FX_SEND INFO %d %d\r\n", iSamplerChannel, iFxSend);
2074            if (lscp_client_call(pClient, szQuery, 1) == LSCP_OK) {
2075                    pszResult = lscp_client_get_result(pClient);
2076                    pszToken = lscp_strtok((char *) pszResult, pszSeps, &(pch));
2077                    while (pszToken) {
2078                            if (strcasecmp(pszToken, "NAME") == 0) {
2079                                    pszToken = lscp_strtok(NULL, pszCrlf, &(pch));
2080                                    if (pszToken)
2081                                            lscp_unquote_dup(&(pFxSendInfo->name), &pszToken);
2082                            }
2083                            else if (strcasecmp(pszToken, "MIDI_CONTROLLER") == 0) {
2084                                    pszToken = lscp_strtok(NULL, pszCrlf, &(pch));
2085                                    if (pszToken)
2086                                            pFxSendInfo->midi_controller = atoi(lscp_ltrim(pszToken));
2087                            }
2088                            else if (strcasecmp(pszToken, "AUDIO_OUTPUT_ROUTING") == 0) {
2089                                    pszToken = lscp_strtok(NULL, pszCrlf, &(pch));
2090                                    if (pszToken) {
2091                                            if (pFxSendInfo->audio_routing)
2092                                                    lscp_isplit_destroy(pFxSendInfo->audio_routing);
2093                                            pFxSendInfo->audio_routing = lscp_isplit_create(pszToken, ",");
2094                                    }
2095                            }
2096                            else if (strcasecmp(pszToken, "LEVEL") == 0) {
2097                                    pszToken = lscp_strtok(NULL, pszCrlf, &(pch));
2098                                    if (pszToken)
2099                                            pFxSendInfo->level = (float) atof(lscp_ltrim(pszToken));
2100                            }
2101                            pszToken = lscp_strtok(NULL, pszSeps, &(pch));
2102                    }
2103            }
2104            else pFxSendInfo = NULL;
2105    
2106            // Unlock this section up.
2107            lscp_mutex_unlock(pClient->mutex);
2108    
2109            return pFxSendInfo;
2110    }
2111    
2112    /**
2113     *  Alter effect send's name:
2114     *  @code
2115     *  SET FX_SEND NAME <sampler-chan> <fx-send-id> <name>
2116     *  @endcode
2117     *
2118     *  @param pClient          Pointer to client instance structure.
2119     *  @param iSamplerChannel  Sampler channel number.
2120     *  @param iFxSend          Effect send number.
2121     *  @param pszFxName        Effect send's new name.
2122     *
2123     *  @returns LSCP_OK on success, LSCP_FAILED otherwise.
2124     */
2125    lscp_status_t lscp_set_fxsend_name ( lscp_client_t *pClient, int iSamplerChannel, int iFxSend, const char *pszFxName )
2126    {
2127            char szQuery[LSCP_BUFSIZ];
2128    
2129            if (!pClient || iSamplerChannel < 0 || iFxSend < 0 || !pszFxName)
2130                    return LSCP_FAILED;
2131    
2132            snprintf(szQuery, LSCP_BUFSIZ, "SET FX_SEND NAME %d %d '%s'\r\n", iSamplerChannel, iFxSend, pszFxName);
2133            return lscp_client_query(pClient, szQuery);
2134    }
2135    
2136    /**
2137     *  Alter effect send's audio routing:
2138     *  SET FX_SEND AUDIO_OUTPUT_CHANNEL <sampler-chan> <fx-send-id>
2139     *    <audio-src> <audio-dst>
2140     *
2141     *  @param pClient          Pointer to client instance structure.
2142     *  @param iSamplerChannel  Sampler channel number.
2143     *  @param iFxSend          Effect send number.
2144     *  @param iAudioSrc        Audio output device channel to be routed from.
2145     *  @param iAudioDst        Audio output device channel to be routed into.
2146     *
2147     *  @returns LSCP_OK on success, LSCP_FAILED otherwise.
2148     */
2149    lscp_status_t lscp_set_fxsend_audio_channel ( lscp_client_t *pClient, int iSamplerChannel, int iFxSend, int iAudioSrc, int iAudioDst )
2150    {
2151            char szQuery[LSCP_BUFSIZ];
2152    
2153            if (iSamplerChannel < 0 || iFxSend < 0 || iAudioSrc < 0 || iAudioDst < 0)
2154                    return LSCP_FAILED;
2155    
2156            sprintf(szQuery, "SET FX_SEND AUDIO_OUTPUT_CHANNEL %d %d %d %d\r\n", iSamplerChannel, iFxSend, iAudioSrc, iAudioDst);
2157            return lscp_client_query(pClient, szQuery);
2158    }
2159    
2160    
2161    /**
2162     *  Alter effect send's MIDI controller:
2163     *  SET FX_SEND MIDI_CONTROLLER <sampler-chan> <fx-send-id> <midi-ctrl>
2164     *
2165     *  @param pClient          Pointer to client instance structure.
2166     *  @param iSamplerChannel  Sampler channel number.
2167     *  @param iFxSend          Effect send number.
2168     *  @param iMidiController  MIDI controller used to alter the effect,
2169     *                          usually a number between 0 and 127.
2170     *
2171     *  @returns LSCP_OK on success, LSCP_FAILED otherwise.
2172     */
2173    lscp_status_t lscp_set_fxsend_midi_controller ( lscp_client_t *pClient, int iSamplerChannel, int iFxSend, int iMidiController )
2174    {
2175            char szQuery[LSCP_BUFSIZ];
2176    
2177            if (iSamplerChannel < 0 || iFxSend < 0 || iMidiController < 0 || iMidiController > 127)
2178                    return LSCP_FAILED;
2179    
2180            sprintf(szQuery, "SET FX_SEND MIDI_CONTROLLER %d %d %d\r\n", iSamplerChannel, iFxSend, iMidiController);
2181            return lscp_client_query(pClient, szQuery);
2182    }
2183    
2184    
2185    /**
2186     *  Alter effect send's audio level:
2187     *  SET FX_SEND LEVEL <sampler-chan> <fx-send-id> <level>
2188     *
2189     *  @param pClient          Pointer to client instance structure.
2190     *  @param iSamplerChannel  Sampler channel number.
2191     *  @param iFxSend          Effect send number.
2192     *  @param fLevel           Effect send volume level.
2193     *
2194     *  @returns LSCP_OK on success, LSCP_FAILED otherwise.
2195     */
2196    lscp_status_t lscp_set_fxsend_level ( lscp_client_t *pClient, int iSamplerChannel, int iFxSend, float fLevel )
2197    {
2198            char szQuery[LSCP_BUFSIZ];
2199    
2200            if (iSamplerChannel < 0 || iFxSend < 0 || fLevel < 0.0f)
2201                    return LSCP_FAILED;
2202    
2203            sprintf(szQuery, "SET FX_SEND LEVEL %d %d %f\r\n", iSamplerChannel, iFxSend, fLevel);
2204            return lscp_client_query(pClient, szQuery);
2205    }
2206    
2207    
2208    /**
2209     *  Create a new MIDI instrument map:
2210     *  ADD MIDI_INSTRUMENT_MAP [<name>]
2211     *
2212     *  @param pClient      Pointer to client instance structure.
2213     *  @param pszMapName   MIDI instrument map name (optional)
2214     *
2215     *  @returns The new MIDI instrument map number identifier,
2216     *  or -1 in case of failure.
2217     */
2218    int lscp_add_midi_instrument_map ( lscp_client_t *pClient, const char *pszMapName )
2219    {
2220            int iMidiMap = -1;
2221            char szQuery[LSCP_BUFSIZ];
2222    
2223            if (pClient == NULL)
2224                    return -1;
2225    
2226            // Lock this section up.
2227            lscp_mutex_lock(pClient->mutex);
2228    
2229            strcpy(szQuery, "ADD MIDI_INSTRUMENT_MAP");
2230            
2231            if (pszMapName)
2232                    sprintf(szQuery + strlen(szQuery), " '%s'", pszMapName);
2233    
2234            strcat(szQuery, "\r\n");
2235    
2236            if (lscp_client_call(pClient, szQuery, 0) == LSCP_OK)
2237                    iMidiMap = atoi(lscp_client_get_result(pClient));
2238    
2239            // Unlock this section down.
2240            lscp_mutex_unlock(pClient->mutex);
2241    
2242            return iMidiMap;
2243    }
2244    
2245    
2246    /**
2247     *  Delete one particular or all MIDI instrument maps:
2248     *  REMOVE MIDI_INSTRUMENT_MAP <midi-map>
2249     *
2250     *  @param pClient  Pointer to client instance structure.
2251     *  @param iMidiMap MIDI instrument map number.
2252     *
2253     *  @returns LSCP_OK on success, LSCP_FAILED otherwise.
2254     */
2255    lscp_status_t lscp_remove_midi_instrument_map ( lscp_client_t *pClient, int iMidiMap )
2256    {
2257            char szQuery[LSCP_BUFSIZ];
2258    
2259            if (iMidiMap < 0)
2260                    return LSCP_FAILED;
2261    
2262            sprintf(szQuery, "REMOVE MIDI_INSTRUMENT_MAP %d\r\n", iMidiMap);
2263    
2264            return lscp_client_query(pClient, szQuery);
2265    }
2266    
2267    
2268    /**
2269     *  Get amount of existing MIDI instrument maps:
2270     *  GET MIDI_INSTRUMENT_MAPS
2271     *
2272     *  @param pClient  Pointer to client instance structure.
2273     *
2274     *  @returns The current total number of MIDI instrument maps
2275     *  on success, -1 otherwise.
2276     */
2277    int lscp_get_midi_instrument_maps ( lscp_client_t *pClient )
2278    {
2279            int iMidiMaps = -1;
2280    
2281            if (pClient == NULL)
2282                    return -1;
2283    
2284            // Lock this section up.
2285            lscp_mutex_lock(pClient->mutex);
2286    
2287            if (lscp_client_call(pClient, "GET MIDI_INSTRUMENT_MAPS\r\n", 0) == LSCP_OK)
2288                    iMidiMaps = atoi(lscp_client_get_result(pClient));
2289    
2290            // Unlock this section doen.
2291            lscp_mutex_unlock(pClient->mutex);
2292    
2293            return iMidiMaps;
2294    }
2295    
2296    
2297    /**
2298     *  Getting all created MIDI instrument maps:
2299     *  LIST MIDI_INSTRUMENT_MAPS
2300     *
2301     *  @param pClient  Pointer to client instance structure.
2302     *
2303     *  @returns An array of the MIDI instrument map identifiers as positive
2304     *  integers, terminated with -1 on success, NULL otherwise.
2305     */
2306    int *lscp_list_midi_instrument_maps ( lscp_client_t *pClient )
2307    {
2308            const char *pszSeps = ",";
2309    
2310            if (pClient == NULL)
2311                    return NULL;
2312    
2313            // Lock this section up.
2314            lscp_mutex_lock(pClient->mutex);
2315    
2316            if (pClient->midi_maps) {
2317                    lscp_isplit_destroy(pClient->midi_maps);
2318                    pClient->midi_maps = NULL;
2319            }
2320    
2321            if (lscp_client_call(pClient, "LIST MIDI_INSTRUMENT_MAPS\r\n", 0) == LSCP_OK)
2322                    pClient->midi_maps = lscp_isplit_create(lscp_client_get_result(pClient), pszSeps);
2323    
2324            // Unlock this section down.
2325            lscp_mutex_unlock(pClient->mutex);
2326    
2327            return pClient->midi_maps;
2328    }
2329    
2330    
2331    /**
2332     *  Getting a MIDI instrument map name:
2333     *  GET MIDI_INSTRUMENT_MAP INFO <midi-map>
2334     *
2335     *  @param pClient  Pointer to client instance structure.
2336     *  @param iMidiMap MIDI instrument map number.
2337     *
2338     *  @returns The MIDI instrument map name on success, NULL on failure.
2339     */
2340    const char *lscp_get_midi_instrument_map_name ( lscp_client_t *pClient, int iMidiMap )
2341    {
2342            char szQuery[LSCP_BUFSIZ];
2343            const char *pszResult;
2344            const char *pszSeps = ":";
2345            const char *pszCrlf = "\r\n";
2346            char *pszToken;
2347            char *pch;
2348    
2349            if (pClient == NULL)
2350                    return NULL;
2351            if (iMidiMap < 0)
2352                    return NULL;
2353    
2354            // Lock this section up.
2355            lscp_mutex_lock(pClient->mutex);
2356            
2357            if (pClient->midi_map_name) {
2358                    free(pClient->midi_map_name);
2359                    pClient->midi_map_name = NULL;
2360            }
2361    
2362            sprintf(szQuery, "GET MIDI_INSTRUMENT_MAP INFO %d\r\n", iMidiMap);
2363            if (lscp_client_call(pClient, szQuery, 1) == LSCP_OK) {
2364                    pszResult = lscp_client_get_result(pClient);
2365                    pszToken = lscp_strtok((char *) pszResult, pszSeps, &(pch));
2366                    while (pszToken) {
2367                            if (strcasecmp(pszToken, "NAME") == 0) {
2368                                    pszToken = lscp_strtok(NULL, pszCrlf, &(pch));
2369                                    if (pszToken)
2370                                            lscp_unquote_dup(&(pClient->midi_map_name), &pszToken);
2371                            }
2372                            pszToken = lscp_strtok(NULL, pszSeps, &(pch));
2373                    }
2374            }
2375    
2376            // Unlock this section down.
2377            lscp_mutex_unlock(pClient->mutex);
2378    
2379            return pClient->midi_map_name;
2380    }
2381    
2382    
2383    /**
2384     *  Renaming a MIDI instrument map:
2385     *  SET MIDI_INSTRUMENT_MAP NAME <midi-map> <map-name>
2386     *
2387     *  @param pClient      Pointer to client instance structure.
2388     *  @param iMidiMap     MIDI instrument map number.
2389     *  @param pszMapName   MIDI instrument map name.
2390     *
2391     *  @returns LSCP_OK on success, LSCP_FAILED otherwise.
2392     */
2393    lscp_status_t lscp_set_midi_instrument_map_name ( lscp_client_t *pClient, int iMidiMap, const char *pszMapName )
2394    {
2395            char szQuery[LSCP_BUFSIZ];
2396    
2397            if (iMidiMap < 0)
2398                    return LSCP_FAILED;
2399            if (pszMapName == NULL)
2400                    return LSCP_FAILED;
2401    
2402            sprintf(szQuery, "SET MIDI_INSTRUMENT_MAP NAME %d '%s'\r\n",
2403                    iMidiMap, pszMapName);
2404    
2405            return lscp_client_query(pClient, szQuery);
2406    }
2407    
2408    
2409    /**
2410   *  Create or replace a MIDI instrumnet map entry:   *  Create or replace a MIDI instrumnet map entry:
2411   *  MAP MIDI_INSTRUMENT <midi-bank-msb> <midi-bank-lsb> <midi-prog>   *  MAP MIDI_INSTRUMENT <midi-map> <midi-bank> <midi-prog>
2412   *      <engine-name> <filename> <instr-index> <volume> <load-mode> [<name>]   *      <engine-name> <filename> <instr-index> <volume> [<load-mode> [<name>]}
2413   *   *
2414   *  @param pClient          Pointer to client instance structure.   *  @param pClient          Pointer to client instance structure.
2415   *  @param pMidiInstr       MIDI instrument bank and program parameter key.   *  @param pMidiInstr       MIDI instrument bank and program parameter key.
# Line 1663  int lscp_get_total_voice_count_max ( lsc Line 2425  int lscp_get_total_voice_count_max ( lsc
2425   *                          @ref LSCP_LOAD_ON_DEMAND, or   *                          @ref LSCP_LOAD_ON_DEMAND, or
2426   *                          @ref LSCP_LOAD_ON_DEMAND_HOLD, or   *                          @ref LSCP_LOAD_ON_DEMAND_HOLD, or
2427   *                          @ref LSCP_LOAD_PERSISTENT.   *                          @ref LSCP_LOAD_PERSISTENT.
2428   *  @param pszName          Instrument custom name for the map entry.   *  @param pszName         Instrument custom name for the map entry (optional).
2429   *   *
2430   *  @returns LSCP_OK on success, LSCP_FAILED otherwise.   *  @returns LSCP_OK on success, LSCP_FAILED otherwise.
2431   */   */
# Line 1671  lscp_status_t lscp_map_midi_instrument ( Line 2433  lscp_status_t lscp_map_midi_instrument (
2433  {  {
2434          char szQuery[LSCP_BUFSIZ];          char szQuery[LSCP_BUFSIZ];
2435    
2436          if (pMidiInstr->bank_msb < 0 || pMidiInstr->bank_msb > 127)          if (pMidiInstr->map < 0)
2437                  return LSCP_FAILED;                  return LSCP_FAILED;
2438          if (pMidiInstr->bank_lsb < 0 || pMidiInstr->bank_lsb > 127)          if (pMidiInstr->bank < 0 || pMidiInstr->bank > 16383)
2439                  return LSCP_FAILED;                  return LSCP_FAILED;
2440          if (pMidiInstr->program < 0 || pMidiInstr->program > 127)          if (pMidiInstr->prog < 0 || pMidiInstr->prog > 127)
2441                  return LSCP_FAILED;                  return LSCP_FAILED;
2442          if (pszEngineName == NULL || pszFileName == NULL)          if (pszEngineName == NULL || pszFileName == NULL)
2443                  return LSCP_FAILED;                  return LSCP_FAILED;
# Line 1684  lscp_status_t lscp_map_midi_instrument ( Line 2446  lscp_status_t lscp_map_midi_instrument (
2446                  fVolume = 1.0f;                  fVolume = 1.0f;
2447    
2448          sprintf(szQuery, "MAP MIDI_INSTRUMENT %d %d %d %s '%s' %d %g",          sprintf(szQuery, "MAP MIDI_INSTRUMENT %d %d %d %s '%s' %d %g",
2449                  pMidiInstr->bank_msb, pMidiInstr->bank_lsb, pMidiInstr->program,                  pMidiInstr->map, pMidiInstr->bank, pMidiInstr->prog,
2450                  pszEngineName, pszFileName, iInstrIndex, fVolume);                  pszEngineName, pszFileName, iInstrIndex, fVolume);
2451    
2452          switch (load_mode) {          switch (load_mode) {
# Line 1713  lscp_status_t lscp_map_midi_instrument ( Line 2475  lscp_status_t lscp_map_midi_instrument (
2475    
2476  /**  /**
2477   *  Remove an entry from the MIDI instrument map:   *  Remove an entry from the MIDI instrument map:
2478   *  UNMAP MIDI_INSTRUMENT <midi-bank-msb> <midi-bank-lsb> <midi-prog>   *  UNMAP MIDI_INSTRUMENT <midi-map> <midi-bank> <midi-prog>
2479   *   *
2480   *  @param pClient      Pointer to client instance structure.   *  @param pClient      Pointer to client instance structure.
2481   *  @param pMidiInstr   MIDI instrument bank and program parameter key.   *  @param pMidiInstr   MIDI instrument bank and program parameter key.
# Line 1724  lscp_status_t lscp_unmap_midi_instrument Line 2486  lscp_status_t lscp_unmap_midi_instrument
2486  {  {
2487          char szQuery[LSCP_BUFSIZ];          char szQuery[LSCP_BUFSIZ];
2488    
2489          if (pMidiInstr->bank_msb < 0 || pMidiInstr->bank_msb > 127)          if (pMidiInstr->map < 0)
2490                  return LSCP_FAILED;                  return LSCP_FAILED;
2491          if (pMidiInstr->bank_lsb < 0 || pMidiInstr->bank_lsb > 127)          if (pMidiInstr->bank < 0 || pMidiInstr->bank > 16383)
2492                  return LSCP_FAILED;                  return LSCP_FAILED;
2493          if (pMidiInstr->program < 0 || pMidiInstr->program > 127)          if (pMidiInstr->prog < 0 || pMidiInstr->prog > 127)
2494                  return LSCP_FAILED;                  return LSCP_FAILED;
2495    
2496          sprintf(szQuery, "UNMAP MIDI_INSTRUMENT %d %d %d\r\n",          sprintf(szQuery, "UNMAP MIDI_INSTRUMENT %d %d %d\r\n",
2497                  pMidiInstr->bank_msb, pMidiInstr->bank_lsb, pMidiInstr->program);                  pMidiInstr->map, pMidiInstr->bank, pMidiInstr->prog);
2498    
2499          return lscp_client_query(pClient, szQuery);          return lscp_client_query(pClient, szQuery);
2500  }  }
# Line 1740  lscp_status_t lscp_unmap_midi_instrument Line 2502  lscp_status_t lscp_unmap_midi_instrument
2502    
2503  /**  /**
2504   *  Get the total count of MIDI instrument map entries:   *  Get the total count of MIDI instrument map entries:
2505   *  GET MIDI_INSTRUMENTS   *  GET MIDI_INSTRUMENTS ALL|<midi-map>
2506   *   *
2507   *  @param pClient  Pointer to client instance structure.   *  @param pClient  Pointer to client instance structure.
2508     *  @param iMidiMap MIDI instrument map number, or @ref LSCP_MIDI_MAP_ALL .
2509   *   *
2510   *  @returns The current total number of MIDI instrument map entries   *  @returns The current total number of MIDI instrument map entries
2511   *  on success, -1 otherwise.   *  on success, -1 otherwise.
2512   */   */
2513  int lscp_get_midi_instruments ( lscp_client_t *pClient )  int lscp_get_midi_instruments ( lscp_client_t *pClient, int iMidiMap )
2514  {  {
2515          int iInstruments = -1;          int iInstruments = -1;
2516            char szQuery[LSCP_BUFSIZ];
2517    
2518            if (pClient == NULL)
2519                    return -1;
2520    
2521          // Lock this section up.          // Lock this section up.
2522          lscp_mutex_lock(pClient->mutex);          lscp_mutex_lock(pClient->mutex);
2523    
2524          if (lscp_client_call(pClient, "GET MIDI_INSTRUMENTS\r\n", 0) == LSCP_OK)          strcpy(szQuery, "GET MIDI_INSTRUMENTS ");
2525    
2526            if (iMidiMap < 0)
2527                    strcat(szQuery, "ALL");
2528            else
2529                    sprintf(szQuery + strlen(szQuery), "%d", iMidiMap);
2530    
2531            strcat(szQuery, "\r\n");
2532    
2533            if (lscp_client_call(pClient, szQuery, 0) == LSCP_OK)
2534                  iInstruments = atoi(lscp_client_get_result(pClient));                  iInstruments = atoi(lscp_client_get_result(pClient));
2535    
2536          // Unlock this section down.          // Unlock this section down.
# Line 1766  int lscp_get_midi_instruments ( lscp_cli Line 2542  int lscp_get_midi_instruments ( lscp_cli
2542    
2543  /**  /**
2544   *  Getting indeces of all MIDI instrument map entries:   *  Getting indeces of all MIDI instrument map entries:
2545   *  LIST MIDI_INSTRUMENTS   *  LIST MIDI_INSTRUMENTS ALL|<midi-map>
2546   *   *
2547   *  @param pClient  Pointer to client instance structure.   *  @param pClient  Pointer to client instance structure.
2548     *  @param iMidiMap MIDI instrument map number, or @ref LSCP_MIDI_MAP_ALL .
2549   *   *
2550   *  @returns An array of @ref lscp_midi_instrument_t, terminated with the   *  @returns An array of @ref lscp_midi_instrument_t, terminated with the
2551   *  {-1,-1,-1} triplet, NULL otherwise.   *  {-1,-1,-1} triplet, NULL otherwise.
2552   */   */
2553  lscp_midi_instrument_t *lscp_list_midi_instruments ( lscp_client_t *pClient )  lscp_midi_instrument_t *lscp_list_midi_instruments ( lscp_client_t *pClient, int iMidiMap )
2554  {  {
2555            char szQuery[LSCP_BUFSIZ];
2556    
2557          if (pClient == NULL)          if (pClient == NULL)
2558                  return NULL;                  return NULL;
2559    
# Line 1786  lscp_midi_instrument_t *lscp_list_midi_i Line 2565  lscp_midi_instrument_t *lscp_list_midi_i
2565                  pClient->midi_instruments = NULL;                  pClient->midi_instruments = NULL;
2566          }          }
2567    
2568          if (lscp_client_call(pClient, "LIST MIDI_INSTRUMENTS\r\n", 0) == LSCP_OK)          strcpy(szQuery, "LIST MIDI_INSTRUMENTS ");
2569    
2570            if (iMidiMap < 0)
2571                    strcat(szQuery, "ALL");
2572            else
2573                    sprintf(szQuery + strlen(szQuery), "%d", iMidiMap);
2574    
2575            strcat(szQuery, "\r\n");
2576    
2577            if (lscp_client_call(pClient, szQuery, 0) == LSCP_OK)
2578                  pClient->midi_instruments = lscp_midi_instruments_create(lscp_client_get_result(pClient));                  pClient->midi_instruments = lscp_midi_instruments_create(lscp_client_get_result(pClient));
2579    
2580          // Unlock this section down.          // Unlock this section down.
# Line 1798  lscp_midi_instrument_t *lscp_list_midi_i Line 2586  lscp_midi_instrument_t *lscp_list_midi_i
2586    
2587  /**  /**
2588   *  Getting information about a MIDI instrument map entry:   *  Getting information about a MIDI instrument map entry:
2589   *  GET MIDI_INSTRUMENT INFO <midi-bank-msb> <midi-bank-lsb> <midi-prog>   *  GET MIDI_INSTRUMENT INFO <midi-map> <midi-bank> <midi-prog>
2590   *   *
2591   *  @param pClient      Pointer to client instance structure.   *  @param pClient      Pointer to client instance structure.
2592   *  @param pMidiInstr   MIDI instrument bank and program parameter key.   *  @param pMidiInstr   MIDI instrument bank and program parameter key.
# Line 1817  lscp_midi_instrument_info_t *lscp_get_mi Line 2605  lscp_midi_instrument_info_t *lscp_get_mi
2605          char *pszToken;          char *pszToken;
2606          char *pch;          char *pch;
2607    
2608          if (pMidiInstr->bank_msb < 0 || pMidiInstr->bank_msb > 127)          if (pClient == NULL)
2609                    return NULL;
2610            if (pMidiInstr->map < 0)
2611                  return NULL;                  return NULL;
2612          if (pMidiInstr->bank_lsb < 0 || pMidiInstr->bank_lsb > 127)          if (pMidiInstr->bank < 0 || pMidiInstr->bank > 16383)
2613                  return NULL;                  return NULL;
2614          if (pMidiInstr->program < 0 || pMidiInstr->program > 127)          if (pMidiInstr->prog < 0 || pMidiInstr->prog > 127)
2615                  return NULL;                  return NULL;
2616    
2617          // Lock this section up.          // Lock this section up.
# Line 1831  lscp_midi_instrument_info_t *lscp_get_mi Line 2621  lscp_midi_instrument_info_t *lscp_get_mi
2621          lscp_midi_instrument_info_reset(pInstrInfo);          lscp_midi_instrument_info_reset(pInstrInfo);
2622    
2623          sprintf(szQuery, "GET MIDI_INSTRUMENT INFO %d %d %d\r\n",          sprintf(szQuery, "GET MIDI_INSTRUMENT INFO %d %d %d\r\n",
2624                  pMidiInstr->bank_msb, pMidiInstr->bank_lsb, pMidiInstr->program);                  pMidiInstr->map, pMidiInstr->bank, pMidiInstr->prog);
2625          if (lscp_client_call(pClient, szQuery, 1) == LSCP_OK) {          if (lscp_client_call(pClient, szQuery, 1) == LSCP_OK) {
2626                  pszResult = lscp_client_get_result(pClient);                  pszResult = lscp_client_get_result(pClient);
2627                  pszToken = lscp_strtok((char *) pszResult, pszSeps, &(pch));                  pszToken = lscp_strtok((char *) pszResult, pszSeps, &(pch));
# Line 1896  lscp_midi_instrument_info_t *lscp_get_mi Line 2686  lscp_midi_instrument_info_t *lscp_get_mi
2686    
2687  /**  /**
2688   *  Clear the MIDI instrumnet map:   *  Clear the MIDI instrumnet map:
2689   *  CLEAR MIDI_INSTRUMENTS   *  CLEAR MIDI_INSTRUMENTS ALL|<midi-map>
2690   *   *
2691   *  @param pClient         Pointer to client instance structure.   *  @param pClient  Pointer to client instance structure.
2692   *  @param iSamplerChannel  Sampler channel number.   *  @param iMidiMap MIDI instrument map number, or @ref LSCP_MIDI_MAP_ALL .
2693   *   *
2694   *  @returns LSCP_OK on success, LSCP_FAILED otherwise.   *  @returns LSCP_OK on success, LSCP_FAILED otherwise.
2695   */   */
2696  lscp_status_t lscp_clear_midi_instruments  ( lscp_client_t *pClient )  lscp_status_t lscp_clear_midi_instruments  ( lscp_client_t *pClient, int iMidiMap )
2697    {
2698            char szQuery[LSCP_BUFSIZ];
2699    
2700            strcpy(szQuery, "CLEAR MIDI_INSTRUMENTS ");
2701    
2702            if (iMidiMap < 0)
2703                    strcat(szQuery, "ALL");
2704            else
2705                    sprintf(szQuery + strlen(szQuery), "%d", iMidiMap);
2706    
2707            strcat(szQuery, "\r\n");
2708    
2709            return lscp_client_query(pClient, szQuery);
2710    }
2711    
2712    /**
2713     * Open an instrument editor application for the instrument
2714     * on the given sampler channel:
2715     * EDIT CHANNEL INSTRUMENT <sampler-channel>
2716     *
2717     * @param pClient         Pointer to client instance structure.
2718     * @param iSamplerChannel Sampler Channel.
2719     *
2720     * @returns LSCP_OK on success, LSCP_FAILED otherwise.
2721     */
2722    lscp_status_t lscp_edit_channel_instrument ( lscp_client_t *pClient, int iSamplerChannel )
2723  {  {
2724          return lscp_client_query(pClient, "CLEAR MIDI_INSTRUMENTS\r\n");          char szQuery[LSCP_BUFSIZ];
2725    
2726            if (iSamplerChannel < 0)
2727                    return LSCP_FAILED;
2728    
2729            sprintf(szQuery, "EDIT CHANNEL INSTRUMENT %d\r\n", iSamplerChannel);
2730    
2731            return lscp_client_query(pClient, szQuery);
2732  }  }
2733    
2734    

Legend:
Removed from v.963  
changed lines
  Added in v.1697

  ViewVC Help
Powered by ViewVC