/[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 974 by capela, Sun Dec 3 18:30:04 2006 UTC revision 975 by capela, Sun Dec 17 00:59:40 2006 UTC
# Line 328  lscp_client_t* lscp_client_create ( cons Line 328  lscp_client_t* lscp_client_create ( cons
328          pClient->engines = NULL;          pClient->engines = NULL;
329          pClient->channels = NULL;          pClient->channels = NULL;
330          pClient->midi_instruments = NULL;          pClient->midi_instruments = NULL;
331            pClient->midi_maps = NULL;
332            pClient->midi_map_name = NULL;
333          lscp_driver_info_init(&(pClient->audio_driver_info));          lscp_driver_info_init(&(pClient->audio_driver_info));
334          lscp_driver_info_init(&(pClient->midi_driver_info));          lscp_driver_info_init(&(pClient->midi_driver_info));
335          lscp_device_info_init(&(pClient->audio_device_info));          lscp_device_info_init(&(pClient->audio_device_info));
# Line 424  lscp_status_t lscp_client_destroy ( lscp Line 426  lscp_status_t lscp_client_destroy ( lscp
426          lscp_szsplit_destroy(pClient->engines);          lscp_szsplit_destroy(pClient->engines);
427          lscp_isplit_destroy(pClient->channels);          lscp_isplit_destroy(pClient->channels);
428          lscp_midi_instruments_destroy(pClient->midi_instruments);          lscp_midi_instruments_destroy(pClient->midi_instruments);
429            lscp_isplit_destroy(pClient->midi_maps);
430            if (pClient->midi_map_name)
431                    free(pClient->midi_map_name);
432          // Make them null.          // Make them null.
433          pClient->audio_drivers = NULL;          pClient->audio_drivers = NULL;
434          pClient->midi_drivers = NULL;          pClient->midi_drivers = NULL;
# Line 432  lscp_status_t lscp_client_destroy ( lscp Line 437  lscp_status_t lscp_client_destroy ( lscp
437          pClient->engines = NULL;          pClient->engines = NULL;
438          pClient->channels = NULL;          pClient->channels = NULL;
439          pClient->midi_instruments = NULL;          pClient->midi_instruments = NULL;
440            pClient->midi_maps = NULL;
441            pClient->midi_map_name = NULL;
442          // Free result error stuff.          // Free result error stuff.
443          lscp_client_set_result(pClient, NULL, 0);          lscp_client_set_result(pClient, NULL, 0);
444          // Free stream usage stuff.          // Free stream usage stuff.
# Line 512  lscp_status_t lscp_client_query ( lscp_c Line 519  lscp_status_t lscp_client_query ( lscp_c
519  {  {
520          lscp_status_t ret;          lscp_status_t ret;
521    
522            if (pClient == NULL)
523                    return LSCP_FAILED;
524    
525          // Lock this section up.          // Lock this section up.
526          lscp_mutex_lock(pClient->mutex);          lscp_mutex_lock(pClient->mutex);
527    
# Line 752  int lscp_get_channels ( lscp_client_t *p Line 762  int lscp_get_channels ( lscp_client_t *p
762  {  {
763          int iChannels = -1;          int iChannels = -1;
764    
765            if (pClient == NULL)
766                    return -1;
767    
768          // Lock this section up.          // Lock this section up.
769          lscp_mutex_lock(pClient->mutex);          lscp_mutex_lock(pClient->mutex);
770    
# Line 812  int lscp_add_channel ( lscp_client_t *pC Line 825  int lscp_add_channel ( lscp_client_t *pC
825  {  {
826          int iSamplerChannel = -1;          int iSamplerChannel = -1;
827    
828            if (pClient == NULL)
829                    return -1;
830    
831          // Lock this section up.          // Lock this section up.
832          lscp_mutex_lock(pClient->mutex);          lscp_mutex_lock(pClient->mutex);
833    
# Line 859  int lscp_get_available_engines ( lscp_cl Line 875  int lscp_get_available_engines ( lscp_cl
875  {  {
876          int iAvailableEngines = -1;          int iAvailableEngines = -1;
877    
878            if (pClient == NULL)
879                    return -1;
880    
881          // Lock this section up.          // Lock this section up.
882          lscp_mutex_lock(pClient->mutex);          lscp_mutex_lock(pClient->mutex);
883    
# Line 885  const char **lscp_list_available_engines Line 904  const char **lscp_list_available_engines
904  {  {
905          const char *pszSeps = ",";          const char *pszSeps = ",";
906    
907            if (pClient == NULL)
908                    return NULL;
909    
910          // Lock this section up.          // Lock this section up.
911          lscp_mutex_lock(pClient->mutex);          lscp_mutex_lock(pClient->mutex);
912    
# Line 923  lscp_engine_info_t *lscp_get_engine_info Line 945  lscp_engine_info_t *lscp_get_engine_info
945          char *pszToken;          char *pszToken;
946          char *pch;          char *pch;
947    
948            if (pClient == NULL)
949                    return NULL;
950          if (pszEngineName == NULL)          if (pszEngineName == NULL)
951                  return NULL;                  return NULL;
952    
# Line 979  lscp_channel_info_t *lscp_get_channel_in Line 1003  lscp_channel_info_t *lscp_get_channel_in
1003          char *pszToken;          char *pszToken;
1004          char *pch;          char *pch;
1005    
1006            if (pClient == NULL)
1007                    return NULL;
1008          if (iSamplerChannel < 0)          if (iSamplerChannel < 0)
1009                  return NULL;                  return NULL;
1010    
# Line 1056  lscp_channel_info_t *lscp_get_channel_in Line 1082  lscp_channel_info_t *lscp_get_channel_in
1082                                                  pChannelInfo->midi_channel = atoi(pszToken);                                                  pChannelInfo->midi_channel = atoi(pszToken);
1083                                  }                                  }
1084                          }                          }
1085                            else if (strcasecmp(pszToken, "MIDI_INSTRUMENT_MAP") == 0) {
1086                                    pszToken = lscp_strtok(NULL, pszCrlf, &(pch));
1087                                    if (pszToken) {
1088                                            pszToken = lscp_ltrim(pszToken);
1089                                            if (strcasecmp(pszToken, "NONE") == 0)
1090                                                    pChannelInfo->midi_map = LSCP_MIDI_MAP_NONE;
1091                                            else
1092                                            if (strcasecmp(pszToken, "DEFAULT") == 0)
1093                                                    pChannelInfo->midi_map = LSCP_MIDI_MAP_DEFAULT;
1094                                            else
1095                                                    pChannelInfo->midi_map = atoi(pszToken);
1096                                    }
1097                            }
1098                          else if (strcasecmp(pszToken, "VOLUME") == 0) {                          else if (strcasecmp(pszToken, "VOLUME") == 0) {
1099                                  pszToken = lscp_strtok(NULL, pszCrlf, &(pch));                                  pszToken = lscp_strtok(NULL, pszCrlf, &(pch));
1100                                  if (pszToken)                                  if (pszToken)
# Line 1097  int lscp_get_channel_voice_count ( lscp_ Line 1136  int lscp_get_channel_voice_count ( lscp_
1136          char szQuery[LSCP_BUFSIZ];          char szQuery[LSCP_BUFSIZ];
1137          int iVoiceCount = -1;          int iVoiceCount = -1;
1138    
1139            if (pClient == NULL)
1140                    return -1;
1141          if (iSamplerChannel < 0)          if (iSamplerChannel < 0)
1142                  return iVoiceCount;                  return -1;
1143    
1144          // Lock this section up.          // Lock this section up.
1145          lscp_mutex_lock(pClient->mutex);          lscp_mutex_lock(pClient->mutex);
# Line 1128  int lscp_get_channel_stream_count ( lscp Line 1169  int lscp_get_channel_stream_count ( lscp
1169          char szQuery[LSCP_BUFSIZ];          char szQuery[LSCP_BUFSIZ];
1170          int iStreamCount = -1;          int iStreamCount = -1;
1171    
1172            if (pClient == NULL)
1173                    return -1;
1174          if (iSamplerChannel < 0)          if (iSamplerChannel < 0)
1175                  return iStreamCount;                  return -1;
1176    
1177          // Lock this section up.          // Lock this section up.
1178          lscp_mutex_lock(pClient->mutex);          lscp_mutex_lock(pClient->mutex);
# Line 1165  int lscp_get_channel_stream_usage ( lscp Line 1208  int lscp_get_channel_stream_usage ( lscp
1208          int   iStream;          int   iStream;
1209          int   iPercent;          int   iPercent;
1210    
1211            if (pClient == NULL)
1212                    return -1;
1213          if (iSamplerChannel < 0)          if (iSamplerChannel < 0)
1214                  return iStreamUsage;                  return -1;
1215    
1216          // Lock this section up.          // Lock this section up.
1217          lscp_mutex_lock(pClient->mutex);          lscp_mutex_lock(pClient->mutex);
# Line 1227  lscp_buffer_fill_t *lscp_get_channel_buf Line 1272  lscp_buffer_fill_t *lscp_get_channel_buf
1272    
1273          // Retrieve a channel stream estimation.          // Retrieve a channel stream estimation.
1274          iStreamCount = lscp_get_channel_stream_count(pClient, iSamplerChannel);          iStreamCount = lscp_get_channel_stream_count(pClient, iSamplerChannel);
1275          if (pClient->iStreamCount < 0)          if (iStreamCount < 0)
1276                  return NULL;                  return NULL;
1277    
1278          // Lock this section up.          // Lock this section up.
# Line 1416  lscp_status_t lscp_set_channel_midi_port Line 1461  lscp_status_t lscp_set_channel_midi_port
1461   *  @param pClient          Pointer to client instance structure.   *  @param pClient          Pointer to client instance structure.
1462   *  @param iSamplerChannel  Sampler channel number.   *  @param iSamplerChannel  Sampler channel number.
1463   *  @param iMidiChannel     MIDI channel address number to listen (0-15) or   *  @param iMidiChannel     MIDI channel address number to listen (0-15) or
1464   *                          LSCP_MIDI_CHANNEL_ALL (16) to listen on all channels.   *                          @ref LSCP_MIDI_CHANNEL_ALL (16) to listen on all channels.
1465   *   *
1466   *  @returns LSCP_OK on success, LSCP_FAILED otherwise.   *  @returns LSCP_OK on success, LSCP_FAILED otherwise.
1467   */   */
# Line 1436  lscp_status_t lscp_set_channel_midi_chan Line 1481  lscp_status_t lscp_set_channel_midi_chan
1481    
1482    
1483  /**  /**
1484     *  Setting MIDI instrument map:
1485     *  SET CHANNEL MIDI_INSTRUMENT_MAP <sampler-channel> <midi-map>
1486     *
1487     *  @param pClient          Pointer to client instance structure.
1488     *  @param iSamplerChannel  Sampler channel number.
1489     *  @param iMidiMap         MIDI instrument map number, or either
1490     *                          @ref LSCP_MIDI_MAP_NONE or
1491     *                          @ref LSCP_MIDI_MAP_DEFAULT .
1492     *
1493     *  @returns LSCP_OK on success, LSCP_FAILED otherwise.
1494     */
1495    lscp_status_t lscp_set_channel_midi_map ( lscp_client_t *pClient, int iSamplerChannel, int iMidiMap )
1496    {
1497            char szQuery[LSCP_BUFSIZ];
1498    
1499            if (iSamplerChannel < 0)
1500                    return LSCP_FAILED;
1501    
1502            sprintf(szQuery, "SET CHANNEL MIDI_INSTRUMENT_MAP %d ", iSamplerChannel);
1503            if (iMidiMap == LSCP_MIDI_MAP_NONE)
1504                    strcat(szQuery , "NONE");
1505            else
1506            if (iMidiMap == LSCP_MIDI_MAP_DEFAULT)
1507                    strcat(szQuery , "DEFAULT");
1508            else
1509                    sprintf(szQuery + strlen(szQuery), "%d", iMidiMap);
1510    
1511            strcat(szQuery, "\r\n");
1512    
1513            return lscp_client_query(pClient, szQuery);
1514    }
1515    
1516    
1517    /**
1518   *  Setting channel volume:   *  Setting channel volume:
1519   *  SET CHANNEL VOLUME <sampler-channel> <volume>   *  SET CHANNEL VOLUME <sampler-channel> <volume>
1520   *   *
# Line 1560  lscp_server_info_t *lscp_get_server_info Line 1639  lscp_server_info_t *lscp_get_server_info
1639          char *pszToken;          char *pszToken;
1640          char *pch;          char *pch;
1641    
1642            if (pClient == NULL)
1643                    return NULL;
1644    
1645          // Lock this section up.          // Lock this section up.
1646          lscp_mutex_lock(pClient->mutex);          lscp_mutex_lock(pClient->mutex);
1647    
# Line 1605  int lscp_get_total_voice_count ( lscp_cl Line 1687  int lscp_get_total_voice_count ( lscp_cl
1687  {  {
1688          int iVoiceCount = -1;          int iVoiceCount = -1;
1689    
1690            if (pClient == NULL)
1691                    return -1;
1692    
1693          // Lock this section up.          // Lock this section up.
1694          lscp_mutex_lock(pClient->mutex);          lscp_mutex_lock(pClient->mutex);
1695    
# Line 1631  int lscp_get_total_voice_count_max ( lsc Line 1716  int lscp_get_total_voice_count_max ( lsc
1716  {  {
1717          int iVoiceCount = -1;          int iVoiceCount = -1;
1718    
1719            if (pClient == NULL)
1720                    return -1;
1721    
1722          // Lock this section up.          // Lock this section up.
1723          lscp_mutex_lock(pClient->mutex);          lscp_mutex_lock(pClient->mutex);
1724    
# Line 1645  int lscp_get_total_voice_count_max ( lsc Line 1733  int lscp_get_total_voice_count_max ( lsc
1733    
1734    
1735  /**  /**
1736     *  Create a new MIDI instrument map:
1737     *  ADD MIDI_INSTRUMENT_MAP [<name>]
1738     *
1739     *  @param pClient      Pointer to client instance structure.
1740     *  @param pszMapName   MIDI instrument map name (optional)
1741     *
1742     *  @returns The new MIDI instrument map number identifier,
1743     *  or -1 in case of failure.
1744     */
1745    int lscp_add_midi_instrument_map ( lscp_client_t *pClient, const char *pszMapName )
1746    {
1747            int iMidiMap = -1;
1748            char szQuery[LSCP_BUFSIZ];
1749    
1750            if (pClient == NULL)
1751                    return -1;
1752    
1753            // Lock this section up.
1754            lscp_mutex_lock(pClient->mutex);
1755    
1756            strcpy(szQuery, "ADD MIDI_INSTRUMENT_MAP");
1757            
1758            if (pszMapName)
1759                    sprintf(szQuery + strlen(szQuery), " '%s'", pszMapName);
1760    
1761            strcat(szQuery, "\r\n");
1762    
1763            if (lscp_client_call(pClient, szQuery, 0) == LSCP_OK)
1764                    iMidiMap = atoi(lscp_client_get_result(pClient));
1765    
1766            // Unlock this section down.
1767            lscp_mutex_unlock(pClient->mutex);
1768    
1769            return iMidiMap;
1770    }
1771    
1772    
1773    /**
1774     *  Delete one particular or all MIDI instrument maps:
1775     *  REMOVE MIDI_INSTRUMENT_MAP <midi-map>
1776     *
1777     *  @param pClient  Pointer to client instance structure.
1778     *  @param iMidiMap MIDI instrument map number.
1779     *
1780     *  @returns LSCP_OK on success, LSCP_FAILED otherwise.
1781     */
1782    lscp_status_t lscp_remove_midi_instrument_map ( lscp_client_t *pClient, int iMidiMap )
1783    {
1784            char szQuery[LSCP_BUFSIZ];
1785    
1786            if (iMidiMap < 0)
1787                    return LSCP_FAILED;
1788    
1789            sprintf(szQuery, "REMOVE MIDI_INSTRUMENT_MAP %d\r\n", iMidiMap);
1790    
1791            return lscp_client_query(pClient, szQuery);
1792    }
1793    
1794    
1795    /**
1796     *  Get amount of existing MIDI instrument maps:
1797     *  GET MIDI_INSTRUMENT_MAPS
1798     *
1799     *  @param pClient  Pointer to client instance structure.
1800     *
1801     *  @returns The current total number of MIDI instrument maps
1802     *  on success, -1 otherwise.
1803     */
1804    int lscp_get_midi_instrument_maps ( lscp_client_t *pClient )
1805    {
1806            int iMidiMaps = -1;
1807    
1808            if (pClient == NULL)
1809                    return -1;
1810    
1811            // Lock this section up.
1812            lscp_mutex_lock(pClient->mutex);
1813    
1814            if (lscp_client_call(pClient, "GET MIDI_INSTRUMENT_MAPS\r\n", 0) == LSCP_OK)
1815                    iMidiMaps = atoi(lscp_client_get_result(pClient));
1816    
1817            // Unlock this section doen.
1818            lscp_mutex_unlock(pClient->mutex);
1819    
1820            return iMidiMaps;
1821    }
1822    
1823    
1824    /**
1825     *  Getting all created MIDI instrument maps:
1826     *  LIST MIDI_INSTRUMENT_MAPS
1827     *
1828     *  @param pClient  Pointer to client instance structure.
1829     *
1830     *  @returns An array of the MIDI instrument map identifiers as positive
1831     *  integers, terminated with -1 on success, NULL otherwise.
1832     */
1833    int *lscp_list_midi_instrument_maps ( lscp_client_t *pClient )
1834    {
1835            const char *pszSeps = ",";
1836    
1837            if (pClient == NULL)
1838                    return NULL;
1839    
1840            // Lock this section up.
1841            lscp_mutex_lock(pClient->mutex);
1842    
1843            if (pClient->midi_maps) {
1844                    lscp_isplit_destroy(pClient->midi_maps);
1845                    pClient->midi_maps = NULL;
1846            }
1847    
1848            if (lscp_client_call(pClient, "LIST MIDI_INSTRUMENT_MAPS\r\n", 0) == LSCP_OK)
1849                    pClient->midi_maps = lscp_isplit_create(lscp_client_get_result(pClient), pszSeps);
1850    
1851            // Unlock this section down.
1852            lscp_mutex_unlock(pClient->mutex);
1853    
1854            return pClient->midi_maps;
1855    }
1856    
1857    
1858    /**
1859     *  Getting a MIDI instrument map name:
1860     *  GET MIDI_INSTRUMENT_MAP INFO <midi-map>
1861     *
1862     *  @param pClient  Pointer to client instance structure.
1863     *  @param iMidiMap MIDI instrument map number.
1864     *
1865     *  @returns The MIDI instrument map name on success, NULL on failure.
1866     */
1867    const char *lscp_get_midi_instrument_map_name ( lscp_client_t *pClient, int iMidiMap )
1868    {
1869            char szQuery[LSCP_BUFSIZ];
1870            const char *pszResult;
1871            const char *pszSeps = ":";
1872            const char *pszCrlf = "\r\n";
1873            char *pszToken;
1874            char *pch;
1875    
1876            if (pClient == NULL)
1877                    return NULL;
1878            if (iMidiMap < 0)
1879                    return NULL;
1880    
1881            // Lock this section up.
1882            lscp_mutex_lock(pClient->mutex);
1883            
1884            if (pClient->midi_map_name) {
1885                    free(pClient->midi_map_name);
1886                    pClient->midi_map_name = NULL;
1887            }
1888    
1889            sprintf(szQuery, "GET MIDI_INSTRUMENT_MAP INFO %d\r\n", iMidiMap);
1890            if (lscp_client_call(pClient, szQuery, 1) == LSCP_OK) {
1891                    pszResult = lscp_client_get_result(pClient);
1892                    pszToken = lscp_strtok((char *) pszResult, pszSeps, &(pch));
1893                    while (pszToken) {
1894                            if (strcasecmp(pszToken, "NAME") == 0) {
1895                                    pszToken = lscp_strtok(NULL, pszCrlf, &(pch));
1896                                    if (pszToken)
1897                                            lscp_unquote_dup(&(pClient->midi_map_name), &pszToken);
1898                            }
1899                            pszToken = lscp_strtok(NULL, pszSeps, &(pch));
1900                    }
1901            }
1902    
1903            // Unlock this section down.
1904            lscp_mutex_unlock(pClient->mutex);
1905    
1906            return pClient->midi_map_name;
1907    }
1908    
1909    
1910    /**
1911     *  Renaming a MIDI instrument map:
1912     *  SET MIDI_INSTRUMENT_MAP NAME <midi-map> <map-name>
1913     *
1914     *  @param pClient      Pointer to client instance structure.
1915     *  @param iMidiMap     MIDI instrument map number.
1916     *  @param pszMapName   MIDI instrument map name.
1917     *
1918     *  @returns LSCP_OK on success, LSCP_FAILED otherwise.
1919     */
1920    lscp_status_t lscp_set_midi_instrument_map_name ( lscp_client_t *pClient, int iMidiMap, const char *pszMapName )
1921    {
1922            char szQuery[LSCP_BUFSIZ];
1923    
1924            if (iMidiMap < 0)
1925                    return LSCP_FAILED;
1926            if (pszMapName == NULL)
1927                    return LSCP_FAILED;
1928    
1929            sprintf(szQuery, "SET MIDI_INSTRUMENT_MAP NAME %d '%s'\r\n",
1930                    iMidiMap, pszMapName);
1931    
1932            return lscp_client_query(pClient, szQuery);
1933    }
1934    
1935    
1936    /**
1937   *  Create or replace a MIDI instrumnet map entry:   *  Create or replace a MIDI instrumnet map entry:
1938   *  MAP MIDI_INSTRUMENT <midi-bank-msb> <midi-bank-lsb> <midi-prog>   *  MAP MIDI_INSTRUMENT <midi-map> <midi-bank> <midi-prog>
1939   *      <engine-name> <filename> <instr-index> <volume> <load-mode> [<name>]   *      <engine-name> <filename> <instr-index> <volume> [<load-mode> [<name>]}
1940   *   *
1941   *  @param pClient          Pointer to client instance structure.   *  @param pClient          Pointer to client instance structure.
1942   *  @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 1952  int lscp_get_total_voice_count_max ( lsc
1952   *                          @ref LSCP_LOAD_ON_DEMAND, or   *                          @ref LSCP_LOAD_ON_DEMAND, or
1953   *                          @ref LSCP_LOAD_ON_DEMAND_HOLD, or   *                          @ref LSCP_LOAD_ON_DEMAND_HOLD, or
1954   *                          @ref LSCP_LOAD_PERSISTENT.   *                          @ref LSCP_LOAD_PERSISTENT.
1955   *  @param pszName          Instrument custom name for the map entry.   *  @param pszName         Instrument custom name for the map entry (optional).
1956   *   *
1957   *  @returns LSCP_OK on success, LSCP_FAILED otherwise.   *  @returns LSCP_OK on success, LSCP_FAILED otherwise.
1958   */   */
# Line 1671  lscp_status_t lscp_map_midi_instrument ( Line 1960  lscp_status_t lscp_map_midi_instrument (
1960  {  {
1961          char szQuery[LSCP_BUFSIZ];          char szQuery[LSCP_BUFSIZ];
1962    
1963          if (pMidiInstr->bank_msb < 0 || pMidiInstr->bank_msb > 127)          if (pMidiInstr->map < 0)
1964                  return LSCP_FAILED;                  return LSCP_FAILED;
1965          if (pMidiInstr->bank_lsb < 0 || pMidiInstr->bank_lsb > 127)          if (pMidiInstr->bank < 0 || pMidiInstr->bank > 16383)
1966                  return LSCP_FAILED;                  return LSCP_FAILED;
1967          if (pMidiInstr->program < 0 || pMidiInstr->program > 127)          if (pMidiInstr->prog < 0 || pMidiInstr->prog > 127)
1968                  return LSCP_FAILED;                  return LSCP_FAILED;
1969          if (pszEngineName == NULL || pszFileName == NULL)          if (pszEngineName == NULL || pszFileName == NULL)
1970                  return LSCP_FAILED;                  return LSCP_FAILED;
# Line 1684  lscp_status_t lscp_map_midi_instrument ( Line 1973  lscp_status_t lscp_map_midi_instrument (
1973                  fVolume = 1.0f;                  fVolume = 1.0f;
1974    
1975          sprintf(szQuery, "MAP MIDI_INSTRUMENT %d %d %d %s '%s' %d %g",          sprintf(szQuery, "MAP MIDI_INSTRUMENT %d %d %d %s '%s' %d %g",
1976                  pMidiInstr->bank_msb, pMidiInstr->bank_lsb, pMidiInstr->program,                  pMidiInstr->map, pMidiInstr->bank, pMidiInstr->prog,
1977                  pszEngineName, pszFileName, iInstrIndex, fVolume);                  pszEngineName, pszFileName, iInstrIndex, fVolume);
1978    
1979          switch (load_mode) {          switch (load_mode) {
# Line 1713  lscp_status_t lscp_map_midi_instrument ( Line 2002  lscp_status_t lscp_map_midi_instrument (
2002    
2003  /**  /**
2004   *  Remove an entry from the MIDI instrument map:   *  Remove an entry from the MIDI instrument map:
2005   *  UNMAP MIDI_INSTRUMENT <midi-bank-msb> <midi-bank-lsb> <midi-prog>   *  UNMAP MIDI_INSTRUMENT <midi-map> <midi-bank> <midi-prog>
2006   *   *
2007   *  @param pClient      Pointer to client instance structure.   *  @param pClient      Pointer to client instance structure.
2008   *  @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 2013  lscp_status_t lscp_unmap_midi_instrument
2013  {  {
2014          char szQuery[LSCP_BUFSIZ];          char szQuery[LSCP_BUFSIZ];
2015    
2016          if (pMidiInstr->bank_msb < 0 || pMidiInstr->bank_msb > 127)          if (pMidiInstr->map < 0)
2017                  return LSCP_FAILED;                  return LSCP_FAILED;
2018          if (pMidiInstr->bank_lsb < 0 || pMidiInstr->bank_lsb > 127)          if (pMidiInstr->bank < 0 || pMidiInstr->bank > 16383)
2019                  return LSCP_FAILED;                  return LSCP_FAILED;
2020          if (pMidiInstr->program < 0 || pMidiInstr->program > 127)          if (pMidiInstr->prog < 0 || pMidiInstr->prog > 127)
2021                  return LSCP_FAILED;                  return LSCP_FAILED;
2022    
2023          sprintf(szQuery, "UNMAP MIDI_INSTRUMENT %d %d %d\r\n",          sprintf(szQuery, "UNMAP MIDI_INSTRUMENT %d %d %d\r\n",
2024                  pMidiInstr->bank_msb, pMidiInstr->bank_lsb, pMidiInstr->program);                  pMidiInstr->map, pMidiInstr->bank, pMidiInstr->prog);
2025    
2026          return lscp_client_query(pClient, szQuery);          return lscp_client_query(pClient, szQuery);
2027  }  }
# Line 1740  lscp_status_t lscp_unmap_midi_instrument Line 2029  lscp_status_t lscp_unmap_midi_instrument
2029    
2030  /**  /**
2031   *  Get the total count of MIDI instrument map entries:   *  Get the total count of MIDI instrument map entries:
2032   *  GET MIDI_INSTRUMENTS   *  GET MIDI_INSTRUMENTS ALL|<midi-map>
2033   *   *
2034   *  @param pClient  Pointer to client instance structure.   *  @param pClient  Pointer to client instance structure.
2035     *  @param iMidiMap MIDI instrument map number, or @ref LSCP_MIDI_MAP_ALL .
2036   *   *
2037   *  @returns The current total number of MIDI instrument map entries   *  @returns The current total number of MIDI instrument map entries
2038   *  on success, -1 otherwise.   *  on success, -1 otherwise.
2039   */   */
2040  int lscp_get_midi_instruments ( lscp_client_t *pClient )  int lscp_get_midi_instruments ( lscp_client_t *pClient, int iMidiMap )
2041  {  {
2042          int iInstruments = -1;          int iInstruments = -1;
2043            char szQuery[LSCP_BUFSIZ];
2044    
2045            if (pClient == NULL)
2046                    return -1;
2047    
2048          // Lock this section up.          // Lock this section up.
2049          lscp_mutex_lock(pClient->mutex);          lscp_mutex_lock(pClient->mutex);
2050    
2051          if (lscp_client_call(pClient, "GET MIDI_INSTRUMENTS\r\n", 0) == LSCP_OK)          strcpy(szQuery, "GET MIDI_INSTRUMENTS ");
2052    
2053            if (iMidiMap < 0)
2054                    strcat(szQuery, "ALL");
2055            else
2056                    sprintf(szQuery + strlen(szQuery), "%d", iMidiMap);
2057    
2058            strcat(szQuery, "\r\n");
2059    
2060            if (lscp_client_call(pClient, szQuery, 0) == LSCP_OK)
2061                  iInstruments = atoi(lscp_client_get_result(pClient));                  iInstruments = atoi(lscp_client_get_result(pClient));
2062    
2063          // Unlock this section down.          // Unlock this section down.
# Line 1766  int lscp_get_midi_instruments ( lscp_cli Line 2069  int lscp_get_midi_instruments ( lscp_cli
2069    
2070  /**  /**
2071   *  Getting indeces of all MIDI instrument map entries:   *  Getting indeces of all MIDI instrument map entries:
2072   *  LIST MIDI_INSTRUMENTS   *  LIST MIDI_INSTRUMENTS ALL|<midi-map>
2073   *   *
2074   *  @param pClient  Pointer to client instance structure.   *  @param pClient  Pointer to client instance structure.
2075     *  @param iMidiMap MIDI instrument map number, or @ref LSCP_MIDI_MAP_ALL .
2076   *   *
2077   *  @returns An array of @ref lscp_midi_instrument_t, terminated with the   *  @returns An array of @ref lscp_midi_instrument_t, terminated with the
2078   *  {-1,-1,-1} triplet, NULL otherwise.   *  {-1,-1,-1} triplet, NULL otherwise.
2079   */   */
2080  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 )
2081  {  {
2082            char szQuery[LSCP_BUFSIZ];
2083    
2084          if (pClient == NULL)          if (pClient == NULL)
2085                  return NULL;                  return NULL;
2086    
# Line 1786  lscp_midi_instrument_t *lscp_list_midi_i Line 2092  lscp_midi_instrument_t *lscp_list_midi_i
2092                  pClient->midi_instruments = NULL;                  pClient->midi_instruments = NULL;
2093          }          }
2094    
2095          if (lscp_client_call(pClient, "LIST MIDI_INSTRUMENTS\r\n", 0) == LSCP_OK)          strcpy(szQuery, "LIST MIDI_INSTRUMENTS ");
2096    
2097            if (iMidiMap < 0)
2098                    strcat(szQuery, "ALL");
2099            else
2100                    sprintf(szQuery + strlen(szQuery), "%d", iMidiMap);
2101    
2102            strcat(szQuery, "\r\n");
2103    
2104            if (lscp_client_call(pClient, szQuery, 0) == LSCP_OK)
2105                  pClient->midi_instruments = lscp_midi_instruments_create(lscp_client_get_result(pClient));                  pClient->midi_instruments = lscp_midi_instruments_create(lscp_client_get_result(pClient));
2106    
2107          // Unlock this section down.          // Unlock this section down.
# Line 1798  lscp_midi_instrument_t *lscp_list_midi_i Line 2113  lscp_midi_instrument_t *lscp_list_midi_i
2113    
2114  /**  /**
2115   *  Getting information about a MIDI instrument map entry:   *  Getting information about a MIDI instrument map entry:
2116   *  GET MIDI_INSTRUMENT INFO <midi-bank-msb> <midi-bank-lsb> <midi-prog>   *  GET MIDI_INSTRUMENT INFO <midi-map> <midi-bank> <midi-prog>
2117   *   *
2118   *  @param pClient      Pointer to client instance structure.   *  @param pClient      Pointer to client instance structure.
2119   *  @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 2132  lscp_midi_instrument_info_t *lscp_get_mi
2132          char *pszToken;          char *pszToken;
2133          char *pch;          char *pch;
2134    
2135          if (pMidiInstr->bank_msb < 0 || pMidiInstr->bank_msb > 127)          if (pClient == NULL)
2136                  return NULL;                  return NULL;
2137          if (pMidiInstr->bank_lsb < 0 || pMidiInstr->bank_lsb > 127)          if (pMidiInstr->map < 0)
2138                  return NULL;                  return NULL;
2139          if (pMidiInstr->program < 0 || pMidiInstr->program > 127)          if (pMidiInstr->bank < 0 || pMidiInstr->bank > 16383)
2140                    return NULL;
2141            if (pMidiInstr->prog < 0 || pMidiInstr->prog > 127)
2142                  return NULL;                  return NULL;
2143    
2144          // Lock this section up.          // Lock this section up.
# Line 1831  lscp_midi_instrument_info_t *lscp_get_mi Line 2148  lscp_midi_instrument_info_t *lscp_get_mi
2148          lscp_midi_instrument_info_reset(pInstrInfo);          lscp_midi_instrument_info_reset(pInstrInfo);
2149    
2150          sprintf(szQuery, "GET MIDI_INSTRUMENT INFO %d %d %d\r\n",          sprintf(szQuery, "GET MIDI_INSTRUMENT INFO %d %d %d\r\n",
2151                  pMidiInstr->bank_msb, pMidiInstr->bank_lsb, pMidiInstr->program);                  pMidiInstr->map, pMidiInstr->bank, pMidiInstr->prog);
2152          if (lscp_client_call(pClient, szQuery, 1) == LSCP_OK) {          if (lscp_client_call(pClient, szQuery, 1) == LSCP_OK) {
2153                  pszResult = lscp_client_get_result(pClient);                  pszResult = lscp_client_get_result(pClient);
2154                  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 2213  lscp_midi_instrument_info_t *lscp_get_mi
2213    
2214  /**  /**
2215   *  Clear the MIDI instrumnet map:   *  Clear the MIDI instrumnet map:
2216   *  CLEAR MIDI_INSTRUMENTS   *  CLEAR MIDI_INSTRUMENTS ALL|<midi-map>
2217   *   *
2218   *  @param pClient         Pointer to client instance structure.   *  @param pClient  Pointer to client instance structure.
2219   *  @param iSamplerChannel  Sampler channel number.   *  @param iMidiMap MIDI instrument map number, or @ref LSCP_MIDI_MAP_ALL .
2220   *   *
2221   *  @returns LSCP_OK on success, LSCP_FAILED otherwise.   *  @returns LSCP_OK on success, LSCP_FAILED otherwise.
2222   */   */
2223  lscp_status_t lscp_clear_midi_instruments  ( lscp_client_t *pClient )  lscp_status_t lscp_clear_midi_instruments  ( lscp_client_t *pClient, int iMidiMap )
2224  {  {
2225          return lscp_client_query(pClient, "CLEAR MIDI_INSTRUMENTS\r\n");          char szQuery[LSCP_BUFSIZ];
2226    
2227            strcpy(szQuery, "CLEAR MIDI_INSTRUMENTS ");
2228    
2229            if (iMidiMap < 0)
2230                    strcat(szQuery, "ALL");
2231            else
2232                    sprintf(szQuery + strlen(szQuery), "%d", iMidiMap);
2233    
2234            strcat(szQuery, "\r\n");
2235    
2236            return lscp_client_query(pClient, szQuery);
2237  }  }
2238    
2239    

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

  ViewVC Help
Powered by ViewVC