/[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 975 by capela, Sun Dec 17 00:59:40 2006 UTC revision 1665 by schoenebeck, Mon Feb 4 13:02:30 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 327  lscp_client_t* lscp_client_create ( cons Line 327  lscp_client_t* lscp_client_create ( cons
327          pClient->midi_devices = NULL;          pClient->midi_devices = NULL;
328          pClient->engines = NULL;          pClient->engines = NULL;
329          pClient->channels = NULL;          pClient->channels = NULL;
330            pClient->fxsends = NULL;
331          pClient->midi_instruments = NULL;          pClient->midi_instruments = NULL;
332          pClient->midi_maps = NULL;          pClient->midi_maps = NULL;
333          pClient->midi_map_name = NULL;          pClient->midi_map_name = NULL;
# Line 343  lscp_client_t* lscp_client_create ( cons Line 344  lscp_client_t* lscp_client_create ( cons
344          lscp_server_info_init(&(pClient->server_info));          lscp_server_info_init(&(pClient->server_info));
345          lscp_engine_info_init(&(pClient->engine_info));          lscp_engine_info_init(&(pClient->engine_info));
346          lscp_channel_info_init(&(pClient->channel_info));          lscp_channel_info_init(&(pClient->channel_info));
347            lscp_fxsend_info_init(&(pClient->fxsend_info));
348          lscp_midi_instrument_info_init(&(pClient->midi_instrument_info));          lscp_midi_instrument_info_init(&(pClient->midi_instrument_info));
349          // Initialize error stuff.          // Initialize error stuff.
350          pClient->pszResult = NULL;          pClient->pszResult = NULL;
# Line 405  lscp_status_t lscp_client_destroy ( lscp Line 407  lscp_status_t lscp_client_destroy ( lscp
407    
408          // Free up all cached members.          // Free up all cached members.
409          lscp_midi_instrument_info_free(&(pClient->midi_instrument_info));          lscp_midi_instrument_info_free(&(pClient->midi_instrument_info));
410            lscp_fxsend_info_free(&(pClient->fxsend_info));
411          lscp_channel_info_free(&(pClient->channel_info));          lscp_channel_info_free(&(pClient->channel_info));
412          lscp_engine_info_free(&(pClient->engine_info));          lscp_engine_info_free(&(pClient->engine_info));
413          lscp_server_info_free(&(pClient->server_info));          lscp_server_info_free(&(pClient->server_info));
# Line 425  lscp_status_t lscp_client_destroy ( lscp Line 428  lscp_status_t lscp_client_destroy ( lscp
428          lscp_isplit_destroy(pClient->midi_devices);          lscp_isplit_destroy(pClient->midi_devices);
429          lscp_szsplit_destroy(pClient->engines);          lscp_szsplit_destroy(pClient->engines);
430          lscp_isplit_destroy(pClient->channels);          lscp_isplit_destroy(pClient->channels);
431            lscp_isplit_destroy(pClient->fxsends);
432          lscp_midi_instruments_destroy(pClient->midi_instruments);          lscp_midi_instruments_destroy(pClient->midi_instruments);
433          lscp_isplit_destroy(pClient->midi_maps);          lscp_isplit_destroy(pClient->midi_maps);
434          if (pClient->midi_map_name)          if (pClient->midi_map_name)
# Line 436  lscp_status_t lscp_client_destroy ( lscp Line 440  lscp_status_t lscp_client_destroy ( lscp
440          pClient->midi_devices = NULL;          pClient->midi_devices = NULL;
441          pClient->engines = NULL;          pClient->engines = NULL;
442          pClient->channels = NULL;          pClient->channels = NULL;
443            pClient->fxsends = NULL;
444          pClient->midi_instruments = NULL;          pClient->midi_instruments = NULL;
445          pClient->midi_maps = NULL;          pClient->midi_maps = NULL;
446          pClient->midi_map_name = NULL;          pClient->midi_map_name = NULL;
# Line 574  int lscp_client_get_errno ( lscp_client_ Line 579  int lscp_client_get_errno ( lscp_client_
579    
580  /**  /**
581   *  Register frontend for receiving event messages:   *  Register frontend for receiving event messages:
582   *  SUBSCRIBE CHANNEL_COUNT | VOICE_COUNT | STREAM_COUNT | BUFFER_FILL   *  SUBSCRIBE CHANNEL_COUNT | VOICE_COUNT | STREAM_COUNT
583   *      | CHANNEL_INFO | MISCELLANEOUS   *      | BUFFER_FILL | CHANNEL_INFO | TOTAL_VOICE_COUNT
584     *      | AUDIO_OUTPUT_DEVICE_COUNT | AUDIO_OUTPUT_DEVICE_INFO
585     *      | MIDI_INPUT_DEVICE_COUNT | MIDI_INPUT_DEVICE_INFO
586     *      | MIDI_INSTRUMENT_MAP_COUNT | MIDI_INSTRUMENT_MAP_INFO
587     *      | MIDI_INSTRUMENT_COUNT | MIDI_INSTRUMENT_INFO
588     *      | MISCELLANEOUS
589   *   *
590   *  @param pClient  Pointer to client instance structure.   *  @param pClient  Pointer to client instance structure.
591   *  @param events   Bit-wise OR'ed event flags to subscribe.   *  @param events   Bit-wise OR'ed event flags to subscribe.
# Line 607  lscp_status_t lscp_client_subscribe ( ls Line 617  lscp_status_t lscp_client_subscribe ( ls
617                  ret = _lscp_client_evt_request(pClient, 1, LSCP_EVENT_BUFFER_FILL);                  ret = _lscp_client_evt_request(pClient, 1, LSCP_EVENT_BUFFER_FILL);
618          if (ret == LSCP_OK && (events & LSCP_EVENT_CHANNEL_INFO))          if (ret == LSCP_OK && (events & LSCP_EVENT_CHANNEL_INFO))
619                  ret = _lscp_client_evt_request(pClient, 1, LSCP_EVENT_CHANNEL_INFO);                  ret = _lscp_client_evt_request(pClient, 1, LSCP_EVENT_CHANNEL_INFO);
620            if (ret == LSCP_OK && (events & LSCP_EVENT_TOTAL_VOICE_COUNT))
621                    ret = _lscp_client_evt_request(pClient, 1, LSCP_EVENT_TOTAL_VOICE_COUNT);
622            if (ret == LSCP_OK && (events & LSCP_EVENT_AUDIO_OUTPUT_DEVICE_COUNT))
623                    ret = _lscp_client_evt_request(pClient, 1, LSCP_EVENT_AUDIO_OUTPUT_DEVICE_COUNT);
624            if (ret == LSCP_OK && (events & LSCP_EVENT_AUDIO_OUTPUT_DEVICE_INFO))
625                    ret = _lscp_client_evt_request(pClient, 1, LSCP_EVENT_AUDIO_OUTPUT_DEVICE_INFO);
626            if (ret == LSCP_OK && (events & LSCP_EVENT_MIDI_INPUT_DEVICE_COUNT))
627                    ret = _lscp_client_evt_request(pClient, 1, LSCP_EVENT_MIDI_INPUT_DEVICE_COUNT);
628            if (ret == LSCP_OK && (events & LSCP_EVENT_MIDI_INPUT_DEVICE_INFO))
629                    ret = _lscp_client_evt_request(pClient, 1, LSCP_EVENT_MIDI_INPUT_DEVICE_INFO);
630            if (ret == LSCP_OK && (events & LSCP_EVENT_MIDI_INSTRUMENT_MAP_COUNT))
631                    ret = _lscp_client_evt_request(pClient, 1, LSCP_EVENT_MIDI_INSTRUMENT_MAP_COUNT);
632            if (ret == LSCP_OK && (events & LSCP_EVENT_MIDI_INSTRUMENT_MAP_INFO))
633                    ret = _lscp_client_evt_request(pClient, 1, LSCP_EVENT_MIDI_INSTRUMENT_MAP_INFO);
634            if (ret == LSCP_OK && (events & LSCP_EVENT_MIDI_INSTRUMENT_COUNT))
635                    ret = _lscp_client_evt_request(pClient, 1, LSCP_EVENT_MIDI_INSTRUMENT_COUNT);
636            if (ret == LSCP_OK && (events & LSCP_EVENT_MIDI_INSTRUMENT_INFO))
637                    ret = _lscp_client_evt_request(pClient, 1, LSCP_EVENT_MIDI_INSTRUMENT_INFO);
638          if (ret == LSCP_OK && (events & LSCP_EVENT_MISCELLANEOUS))          if (ret == LSCP_OK && (events & LSCP_EVENT_MISCELLANEOUS))
639                  ret = _lscp_client_evt_request(pClient, 1, LSCP_EVENT_MISCELLANEOUS);                  ret = _lscp_client_evt_request(pClient, 1, LSCP_EVENT_MISCELLANEOUS);
640    
# Line 619  lscp_status_t lscp_client_subscribe ( ls Line 647  lscp_status_t lscp_client_subscribe ( ls
647    
648  /**  /**
649   *  Deregister frontend from receiving UDP event messages anymore:   *  Deregister frontend from receiving UDP event messages anymore:
650   *  SUBSCRIBE CHANNEL_COUNT | VOICE_COUNT | STREAM_COUNT | BUFFER_FILL   *  UNSUBSCRIBE CHANNEL_COUNT | VOICE_COUNT | STREAM_COUNT
651   *      | CHANNEL_INFO | MISCELLANEOUS   *      | BUFFER_FILL | CHANNEL_INFO | TOTAL_VOICE_COUNT
652     *      | AUDIO_OUTPUT_DEVICE_COUNT | AUDIO_OUTPUT_DEVICE_INFO
653     *      | MIDI_INPUT_DEVICE_COUNT | MIDI_INPUT_DEVICE_INFO
654     *      | MIDI_INSTRUMENT_MAP_COUNT | MIDI_INSTRUMENT_MAP_INFO
655     *      | MIDI_INSTRUMENT_COUNT | MIDI_INSTRUMENT_INFO
656     *      | MISCELLANEOUS
657   *   *
658   *  @param pClient  Pointer to client instance structure.   *  @param pClient  Pointer to client instance structure.
659   *  @param events   Bit-wise OR'ed event flags to unsubscribe.   *  @param events   Bit-wise OR'ed event flags to unsubscribe.
# Line 648  lscp_status_t lscp_client_unsubscribe ( Line 681  lscp_status_t lscp_client_unsubscribe (
681                  ret = _lscp_client_evt_request(pClient, 0, LSCP_EVENT_BUFFER_FILL);                  ret = _lscp_client_evt_request(pClient, 0, LSCP_EVENT_BUFFER_FILL);
682          if (ret == LSCP_OK && (events & LSCP_EVENT_CHANNEL_INFO))          if (ret == LSCP_OK && (events & LSCP_EVENT_CHANNEL_INFO))
683                  ret = _lscp_client_evt_request(pClient, 0, LSCP_EVENT_CHANNEL_INFO);                  ret = _lscp_client_evt_request(pClient, 0, LSCP_EVENT_CHANNEL_INFO);
684            if (ret == LSCP_OK && (events & LSCP_EVENT_TOTAL_VOICE_COUNT))
685                    ret = _lscp_client_evt_request(pClient, 0, LSCP_EVENT_TOTAL_VOICE_COUNT);
686            if (ret == LSCP_OK && (events & LSCP_EVENT_AUDIO_OUTPUT_DEVICE_COUNT))
687                    ret = _lscp_client_evt_request(pClient, 0, LSCP_EVENT_AUDIO_OUTPUT_DEVICE_COUNT);
688            if (ret == LSCP_OK && (events & LSCP_EVENT_AUDIO_OUTPUT_DEVICE_INFO))
689                    ret = _lscp_client_evt_request(pClient, 0, LSCP_EVENT_AUDIO_OUTPUT_DEVICE_INFO);
690            if (ret == LSCP_OK && (events & LSCP_EVENT_MIDI_INPUT_DEVICE_COUNT))
691                    ret = _lscp_client_evt_request(pClient, 0, LSCP_EVENT_MIDI_INPUT_DEVICE_COUNT);
692            if (ret == LSCP_OK && (events & LSCP_EVENT_MIDI_INPUT_DEVICE_INFO))
693                    ret = _lscp_client_evt_request(pClient, 0, LSCP_EVENT_MIDI_INPUT_DEVICE_INFO);
694            if (ret == LSCP_OK && (events & LSCP_EVENT_MIDI_INSTRUMENT_MAP_COUNT))
695                    ret = _lscp_client_evt_request(pClient, 0, LSCP_EVENT_MIDI_INSTRUMENT_MAP_COUNT);
696            if (ret == LSCP_OK && (events & LSCP_EVENT_MIDI_INSTRUMENT_MAP_INFO))
697                    ret = _lscp_client_evt_request(pClient, 0, LSCP_EVENT_MIDI_INSTRUMENT_MAP_INFO);
698            if (ret == LSCP_OK && (events & LSCP_EVENT_MIDI_INSTRUMENT_COUNT))
699                    ret = _lscp_client_evt_request(pClient, 0, LSCP_EVENT_MIDI_INSTRUMENT_COUNT);
700            if (ret == LSCP_OK && (events & LSCP_EVENT_MIDI_INSTRUMENT_INFO))
701                    ret = _lscp_client_evt_request(pClient, 0, LSCP_EVENT_MIDI_INSTRUMENT_INFO);
702          if (ret == LSCP_OK && (events & LSCP_EVENT_MISCELLANEOUS))          if (ret == LSCP_OK && (events & LSCP_EVENT_MISCELLANEOUS))
703                  ret = _lscp_client_evt_request(pClient, 0, LSCP_EVENT_MISCELLANEOUS);                  ret = _lscp_client_evt_request(pClient, 0, LSCP_EVENT_MISCELLANEOUS);
704    
# Line 1038  lscp_channel_info_t *lscp_get_channel_in Line 1089  lscp_channel_info_t *lscp_get_channel_in
1089                                  pszToken = lscp_strtok(NULL, pszCrlf, &(pch));                                  pszToken = lscp_strtok(NULL, pszCrlf, &(pch));
1090                                  if (pszToken) {                                  if (pszToken) {
1091                                          if (pChannelInfo->audio_routing)                                          if (pChannelInfo->audio_routing)
1092                                                  lscp_szsplit_destroy(pChannelInfo->audio_routing);                                                  lscp_isplit_destroy(pChannelInfo->audio_routing);
1093                                          pChannelInfo->audio_routing = lscp_szsplit_create(pszToken, ",");                                          pChannelInfo->audio_routing = lscp_isplit_create(pszToken, ",");
1094                                  }                                  }
1095                          }                          }
1096                          else if (strcasecmp(pszToken, "INSTRUMENT_FILE") == 0) {                          else if (strcasecmp(pszToken, "INSTRUMENT_FILE") == 0) {
# Line 1530  lscp_status_t lscp_set_channel_volume ( Line 1581  lscp_status_t lscp_set_channel_volume (
1581  {  {
1582          char szQuery[LSCP_BUFSIZ];          char szQuery[LSCP_BUFSIZ];
1583    
1584          if (iSamplerChannel < 0 || fVolume < 0.0)          if (iSamplerChannel < 0 || fVolume < 0.0f)
1585                  return LSCP_FAILED;                  return LSCP_FAILED;
1586    
1587          sprintf(szQuery, "SET CHANNEL VOLUME %d %g\r\n", iSamplerChannel, fVolume);          sprintf(szQuery, "SET CHANNEL VOLUME %d %g\r\n", iSamplerChannel, fVolume);
# Line 1617  lscp_status_t lscp_reset_channel ( lscp_ Line 1668  lscp_status_t lscp_reset_channel ( lscp_
1668   */   */
1669  lscp_status_t lscp_reset_sampler ( lscp_client_t *pClient )  lscp_status_t lscp_reset_sampler ( lscp_client_t *pClient )
1670  {  {
1671            // Do actual whole sampler reset...
1672          return lscp_client_query(pClient, "RESET\r\n");          return lscp_client_query(pClient, "RESET\r\n");
1673  }  }
1674    
# Line 1662  lscp_server_info_t *lscp_get_server_info Line 1714  lscp_server_info_t *lscp_get_server_info
1714                                  if (pszToken)                                  if (pszToken)
1715                                          lscp_unquote_dup(&(pServerInfo->version), &pszToken);                                          lscp_unquote_dup(&(pServerInfo->version), &pszToken);
1716                          }                          }
1717                            else if (strcasecmp(pszToken, "PROTOCOL_VERSION") == 0) {
1718                                    pszToken = lscp_strtok(NULL, pszCrlf, &(pch));
1719                                    if (pszToken)
1720                                            lscp_unquote_dup(&(pServerInfo->protocol_version), &pszToken);
1721                            }
1722                          pszToken = lscp_strtok(NULL, pszSeps, &(pch));                          pszToken = lscp_strtok(NULL, pszSeps, &(pch));
1723                  }                  }
1724          }          }
# Line 1733  int lscp_get_total_voice_count_max ( lsc Line 1790  int lscp_get_total_voice_count_max ( lsc
1790    
1791    
1792  /**  /**
1793     *  Get global volume attenuation:
1794     *  GET VOLUME
1795     *
1796     *  @param pClient  Pointer to client instance structure.
1797     *
1798     *  @returns The global volume as positive floating point value usually in
1799     *  the range between 0.0 and 1.0; in case of failure 0.0 is returned.
1800     */
1801    float lscp_get_volume ( lscp_client_t *pClient )
1802    {
1803            float fVolume = 0.0f;
1804    
1805            if (pClient == NULL)
1806                    return 0.0f;
1807    
1808            // Lock this section up.
1809            lscp_mutex_lock(pClient->mutex);
1810    
1811            if (lscp_client_call(pClient, "GET VOLUME\r\n", 0) == LSCP_OK)
1812                    fVolume = (float) atof(lscp_client_get_result(pClient));
1813    
1814            // Unlock this section down.
1815            lscp_mutex_unlock(pClient->mutex);
1816    
1817            return fVolume;
1818    }
1819    
1820    
1821    /**
1822     *  Setting global volume attenuation:
1823     *  SET VOLUME <volume>
1824     *
1825     *  @param pClient  Pointer to client instance structure.
1826     *  @param fVolume  Global volume parameter as positive floating point
1827     *                  value usually be in the range between 0.0 and 1.0,
1828     *                  that is for attenuating the overall volume.
1829     *
1830     *  @returns LSCP_OK on success, LSCP_FAILED otherwise.
1831     */
1832    lscp_status_t lscp_set_volume ( lscp_client_t *pClient, float fVolume )
1833    {
1834            char szQuery[LSCP_BUFSIZ];
1835    
1836            if (fVolume < 0.0f)
1837                    return LSCP_FAILED;
1838    
1839            sprintf(szQuery, "SET VOLUME %g\r\n", fVolume);
1840            return lscp_client_query(pClient, szQuery);
1841    }
1842    
1843    
1844    /**
1845     *  Add an effect send to a sampler channel:
1846     *  CREATE FX_SEND <sampler-channel> <midi-ctrl> [<name>]
1847     *
1848     *  @param pClient          Pointer to client instance structure.
1849     *  @param iSamplerChannel  Sampler channel number.
1850     *  @param iMidiController  MIDI controller used to alter the effect,
1851     *                          usually a number between 0 and 127.
1852     *  @param pszName          Optional name for the effect send entity,
1853     *                          does not have to be unique.
1854     *
1855     *  @returns The new effect send number identifier, or -1 in case of failure.
1856     */
1857    int lscp_create_fxsend ( lscp_client_t *pClient, int iSamplerChannel, int iMidiController, const char *pszFxName )
1858    {
1859            int iFxSend = -1;
1860            char szQuery[LSCP_BUFSIZ];
1861    
1862            if (pClient == NULL)
1863                    return -1;
1864            if (iSamplerChannel < 0 || iMidiController < 0 || iMidiController > 127)
1865                    return -1;
1866    
1867            // Lock this section up.
1868            lscp_mutex_lock(pClient->mutex);
1869    
1870            sprintf(szQuery, "CREATE FX_SEND %d %d", iSamplerChannel, iMidiController);
1871            
1872            if (pszFxName)
1873                    sprintf(szQuery + strlen(szQuery), " '%s'", pszFxName);
1874    
1875            strcat(szQuery, "\r\n");
1876    
1877            if (lscp_client_call(pClient, szQuery, 0) == LSCP_OK)
1878                    iFxSend = atoi(lscp_client_get_result(pClient));
1879    
1880            // Unlock this section down.
1881            lscp_mutex_unlock(pClient->mutex);
1882    
1883            return iFxSend;
1884    }
1885    
1886    
1887    /**
1888     *  Remove an effect send from a sampler channel:
1889     *  DESTROY FX_SEND <sampler-channel> <fx-send-id>
1890     *
1891     *  @param pClient          Pointer to client instance structure.
1892     *  @param iSamplerChannel  Sampler channel number.
1893     *  @param iFxSend          Effect send number.
1894     *
1895     *  @returns LSCP_OK on success, LSCP_FAILED otherwise.
1896     */
1897    lscp_status_t lscp_destroy_fxsend ( lscp_client_t *pClient, int iSamplerChannel, int iFxSend )
1898    {
1899            char szQuery[LSCP_BUFSIZ];
1900    
1901            if (iSamplerChannel < 0 || iFxSend < 0)
1902                    return LSCP_FAILED;
1903    
1904            sprintf(szQuery, "DESTROY FX_SEND %d %d\r\n", iSamplerChannel, iFxSend);
1905    
1906            return lscp_client_query(pClient, szQuery);
1907    }
1908    
1909    
1910    /**
1911     *  Get amount of effect sends on a sampler channel:
1912     *  GET FX_SENDS <sampler-channel>
1913     *
1914     *  @param pClient          Pointer to client instance structure.
1915     *  @param iSamplerChannel  Sampler channel number.
1916     *
1917     *  @returns The current total number of effect sends of the sampler channel
1918     *  on success, -1 otherwise.
1919     */
1920    int lscp_get_fxsends ( lscp_client_t *pClient, int iSamplerChannel )
1921    {
1922            int iFxSends = -1;
1923            char szQuery[LSCP_BUFSIZ];
1924    
1925            if (pClient == NULL)
1926                    return -1;
1927            if (iSamplerChannel < 0)
1928                    return -1;
1929    
1930            // Lock this section up.
1931            lscp_mutex_lock(pClient->mutex);
1932    
1933            sprintf(szQuery, "GET FX_SENDS %d\r\n", iSamplerChannel);
1934    
1935            if (lscp_client_call(pClient, szQuery, 0) == LSCP_OK)
1936                    iFxSends = atoi(lscp_client_get_result(pClient));
1937    
1938            // Unlock this section doen.
1939            lscp_mutex_unlock(pClient->mutex);
1940    
1941            return iFxSends;
1942    }
1943    
1944    
1945    /**
1946     *  List all effect sends on a sampler channel:
1947     *  LIST FX_SENDS <sampler-channel>
1948     *
1949     *  @param pClient          Pointer to client instance structure.
1950     *  @param iSamplerChannel  Sampler channel number.
1951     *
1952     *  @returns An array of the effect sends identifiers as positive integers,
1953     *  terminated with -1 on success, NULL otherwise.
1954     */
1955    int *lscp_list_fxsends ( lscp_client_t *pClient, int iSamplerChannel )
1956    {
1957            const char *pszSeps = ",";
1958            char szQuery[LSCP_BUFSIZ];
1959    
1960            if (pClient == NULL)
1961                    return NULL;
1962    
1963            // Lock this section up.
1964            lscp_mutex_lock(pClient->mutex);
1965    
1966            if (pClient->fxsends) {
1967                    lscp_isplit_destroy(pClient->fxsends);
1968                    pClient->fxsends = NULL;
1969            }
1970    
1971            sprintf(szQuery, "LIST FX_SENDS %d\r\n", iSamplerChannel);
1972    
1973            if (lscp_client_call(pClient, szQuery, 0) == LSCP_OK)
1974                    pClient->fxsends = lscp_isplit_create(lscp_client_get_result(pClient), pszSeps);
1975    
1976            // Unlock this section down.
1977            lscp_mutex_unlock(pClient->mutex);
1978    
1979            return pClient->fxsends;
1980    }
1981    
1982    
1983    /**
1984     *  Getting effect send information
1985     *  GET FX_SEND INFO <sampler-channel> <fx-send-id>
1986     *
1987     *  @param pClient          Pointer to client instance structure.
1988     *  @param iSamplerChannel  Sampler channel number.
1989     *  @param iFxSend          Effect send number.
1990     *
1991     *  @returns A pointer to a @ref lscp_fxsend_info_t structure, with the
1992     *  information of the given FX send, or NULL in case of failure.
1993     */
1994    lscp_fxsend_info_t *lscp_get_fxsend_info ( lscp_client_t *pClient, int iSamplerChannel, int iFxSend )
1995    {
1996            lscp_fxsend_info_t *pFxSendInfo;
1997            char szQuery[LSCP_BUFSIZ];
1998            const char *pszResult;
1999            const char *pszSeps = ":";
2000            const char *pszCrlf = "\r\n";
2001            char *pszToken;
2002            char *pch;
2003    
2004            if (pClient == NULL)
2005                    return NULL;
2006            if (iSamplerChannel < 0 || iFxSend < 0)
2007                    return NULL;
2008    
2009            // Lock this section up.
2010            lscp_mutex_lock(pClient->mutex);
2011    
2012            pFxSendInfo = &(pClient->fxsend_info);
2013            lscp_fxsend_info_reset(pFxSendInfo);
2014    
2015            sprintf(szQuery, "GET FX_SEND INFO %d %d\r\n", iSamplerChannel, iFxSend);
2016            if (lscp_client_call(pClient, szQuery, 1) == LSCP_OK) {
2017                    pszResult = lscp_client_get_result(pClient);
2018                    pszToken = lscp_strtok((char *) pszResult, pszSeps, &(pch));
2019                    while (pszToken) {
2020                            if (strcasecmp(pszToken, "NAME") == 0) {
2021                                    pszToken = lscp_strtok(NULL, pszCrlf, &(pch));
2022                                    if (pszToken)
2023                                            lscp_unquote_dup(&(pFxSendInfo->name), &pszToken);
2024                            }
2025                            else if (strcasecmp(pszToken, "MIDI_CONTROLLER") == 0) {
2026                                    pszToken = lscp_strtok(NULL, pszCrlf, &(pch));
2027                                    if (pszToken)
2028                                            pFxSendInfo->midi_controller = atoi(lscp_ltrim(pszToken));
2029                            }
2030                            else if (strcasecmp(pszToken, "AUDIO_OUTPUT_ROUTING") == 0) {
2031                                    pszToken = lscp_strtok(NULL, pszCrlf, &(pch));
2032                                    if (pszToken) {
2033                                            if (pFxSendInfo->audio_routing)
2034                                                    lscp_isplit_destroy(pFxSendInfo->audio_routing);
2035                                            pFxSendInfo->audio_routing = lscp_isplit_create(pszToken, ",");
2036                                    }
2037                            }
2038                            else if (strcasecmp(pszToken, "LEVEL") == 0) {
2039                                    pszToken = lscp_strtok(NULL, pszCrlf, &(pch));
2040                                    if (pszToken)
2041                                            pFxSendInfo->level = (float) atof(lscp_ltrim(pszToken));
2042                            }
2043                            pszToken = lscp_strtok(NULL, pszSeps, &(pch));
2044                    }
2045            }
2046            else pFxSendInfo = NULL;
2047    
2048            // Unlock this section up.
2049            lscp_mutex_unlock(pClient->mutex);
2050    
2051            return pFxSendInfo;
2052    }
2053    
2054    /**
2055     *  Alter effect send's name:
2056     *  @code
2057     *  SET FX_SEND NAME <sampler-chan> <fx-send-id> <name>
2058     *  @endcode
2059     *
2060     *  @param pClient          Pointer to client instance structure.
2061     *  @param iSamplerChannel  Sampler channel number.
2062     *  @param iFxSend          Effect send number.
2063     *  @param pszFxName        Effect send's new name.
2064     *
2065     *  @returns LSCP_OK on success, LSCP_FAILED otherwise.
2066     */
2067    lscp_status_t lscp_set_fxsend_name ( lscp_client_t *pClient, int iSamplerChannel, int iFxSend, const char *pszFxName )
2068    {
2069            char szQuery[LSCP_BUFSIZ];
2070    
2071            if (!pClient || iSamplerChannel < 0 || iFxSend < 0 || !pszFxName)
2072                    return LSCP_FAILED;
2073    
2074            snprintf(szQuery, LSCP_BUFSIZ, "SET FX_SEND NAME %d %d %s\r\n", iSamplerChannel, iFxSend, pszFxName);
2075            return lscp_client_query(pClient, szQuery);
2076    }
2077    
2078    /**
2079     *  Alter effect send's audio routing:
2080     *  SET FX_SEND AUDIO_OUTPUT_CHANNEL <sampler-chan> <fx-send-id>
2081     *    <audio-src> <audio-dst>
2082     *
2083     *  @param pClient          Pointer to client instance structure.
2084     *  @param iSamplerChannel  Sampler channel number.
2085     *  @param iFxSend          Effect send number.
2086     *  @param iAudioSrc        Audio output device channel to be routed from.
2087     *  @param iAudioDst        Audio output device channel to be routed into.
2088     *
2089     *  @returns LSCP_OK on success, LSCP_FAILED otherwise.
2090     */
2091    lscp_status_t lscp_set_fxsend_audio_channel ( lscp_client_t *pClient, int iSamplerChannel, int iFxSend, int iAudioSrc, int iAudioDst )
2092    {
2093            char szQuery[LSCP_BUFSIZ];
2094    
2095            if (iSamplerChannel < 0 || iFxSend < 0 || iAudioSrc < 0 || iAudioDst < 0)
2096                    return LSCP_FAILED;
2097    
2098            sprintf(szQuery, "SET FX_SEND AUDIO_OUTPUT_CHANNEL %d %d %d %d\r\n", iSamplerChannel, iFxSend, iAudioSrc, iAudioDst);
2099            return lscp_client_query(pClient, szQuery);
2100    }
2101    
2102    
2103    /**
2104     *  Alter effect send's MIDI controller:
2105     *  SET FX_SEND MIDI_CONTROLLER <sampler-chan> <fx-send-id> <midi-ctrl>
2106     *
2107     *  @param pClient          Pointer to client instance structure.
2108     *  @param iSamplerChannel  Sampler channel number.
2109     *  @param iFxSend          Effect send number.
2110     *  @param iMidiController  MIDI controller used to alter the effect,
2111     *                          usually a number between 0 and 127.
2112     *
2113     *  @returns LSCP_OK on success, LSCP_FAILED otherwise.
2114     */
2115    lscp_status_t lscp_set_fxsend_midi_controller ( lscp_client_t *pClient, int iSamplerChannel, int iFxSend, int iMidiController )
2116    {
2117            char szQuery[LSCP_BUFSIZ];
2118    
2119            if (iSamplerChannel < 0 || iFxSend < 0 || iMidiController < 0 || iMidiController > 127)
2120                    return LSCP_FAILED;
2121    
2122            sprintf(szQuery, "SET FX_SEND MIDI_CONTROLLER %d %d %d\r\n", iSamplerChannel, iFxSend, iMidiController);
2123            return lscp_client_query(pClient, szQuery);
2124    }
2125    
2126    
2127    /**
2128     *  Alter effect send's audio level:
2129     *  SET FX_SEND LEVEL <sampler-chan> <fx-send-id> <level>
2130     *
2131     *  @param pClient          Pointer to client instance structure.
2132     *  @param iSamplerChannel  Sampler channel number.
2133     *  @param iFxSend          Effect send number.
2134     *  @param fLevel           Effect send volume level.
2135     *
2136     *  @returns LSCP_OK on success, LSCP_FAILED otherwise.
2137     */
2138    lscp_status_t lscp_set_fxsend_level ( lscp_client_t *pClient, int iSamplerChannel, int iFxSend, float fLevel )
2139    {
2140            char szQuery[LSCP_BUFSIZ];
2141    
2142            if (iSamplerChannel < 0 || iFxSend < 0 || fLevel < 0.0f)
2143                    return LSCP_FAILED;
2144    
2145            sprintf(szQuery, "SET FX_SEND LEVEL %d %d %f\r\n", iSamplerChannel, iFxSend, fLevel);
2146            return lscp_client_query(pClient, szQuery);
2147    }
2148    
2149    
2150    /**
2151   *  Create a new MIDI instrument map:   *  Create a new MIDI instrument map:
2152   *  ADD MIDI_INSTRUMENT_MAP [<name>]   *  ADD MIDI_INSTRUMENT_MAP [<name>]
2153   *   *
# Line 2235  lscp_status_t lscp_clear_midi_instrument Line 2650  lscp_status_t lscp_clear_midi_instrument
2650    
2651          return lscp_client_query(pClient, szQuery);          return lscp_client_query(pClient, szQuery);
2652  }  }
2653    
2654    /**
2655     * Open an instrument editor application for the instrument
2656     * on the given sampler channel:
2657     * EDIT CHANNEL INSTRUMENT <sampler-channel>
2658     *
2659     * @param pClient         Pointer to client instance structure.
2660     * @param iSamplerChannel Sampler Channel.
2661     *
2662     * @returns LSCP_OK on success, LSCP_FAILED otherwise.
2663     */
2664    lscp_status_t lscp_edit_channel_instrument ( lscp_client_t *pClient, int iSamplerChannel )
2665    {
2666            char szQuery[LSCP_BUFSIZ];
2667    
2668            if (iSamplerChannel < 0)
2669                    return LSCP_FAILED;
2670    
2671            sprintf(szQuery, "EDIT CHANNEL INSTRUMENT %d\r\n", iSamplerChannel);
2672    
2673            return lscp_client_query(pClient, szQuery);
2674    }
2675    
2676    
2677  // end of client.c  // end of client.c

Legend:
Removed from v.975  
changed lines
  Added in v.1665

  ViewVC Help
Powered by ViewVC