/[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 977 by capela, Sun Dec 17 15:08:35 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 1580  lscp_server_info_t *lscp_get_server_info Line 1662  lscp_server_info_t *lscp_get_server_info
1662                                  if (pszToken)                                  if (pszToken)
1663                                          lscp_unquote_dup(&(pServerInfo->version), &pszToken);                                          lscp_unquote_dup(&(pServerInfo->version), &pszToken);
1664                          }                          }
1665                            else if (strcasecmp(pszToken, "PROTOCOL_VERSION") == 0) {
1666                                    pszToken = lscp_strtok(NULL, pszCrlf, &(pch));
1667                                    if (pszToken)
1668                                            lscp_unquote_dup(&(pServerInfo->protocol_version), &pszToken);
1669                            }
1670                          pszToken = lscp_strtok(NULL, pszSeps, &(pch));                          pszToken = lscp_strtok(NULL, pszSeps, &(pch));
1671                  }                  }
1672          }          }
# Line 1605  int lscp_get_total_voice_count ( lscp_cl Line 1692  int lscp_get_total_voice_count ( lscp_cl
1692  {  {
1693          int iVoiceCount = -1;          int iVoiceCount = -1;
1694    
1695            if (pClient == NULL)
1696                    return -1;
1697    
1698          // Lock this section up.          // Lock this section up.
1699          lscp_mutex_lock(pClient->mutex);          lscp_mutex_lock(pClient->mutex);
1700    
# Line 1631  int lscp_get_total_voice_count_max ( lsc Line 1721  int lscp_get_total_voice_count_max ( lsc
1721  {  {
1722          int iVoiceCount = -1;          int iVoiceCount = -1;
1723    
1724            if (pClient == NULL)
1725                    return -1;
1726    
1727          // Lock this section up.          // Lock this section up.
1728          lscp_mutex_lock(pClient->mutex);          lscp_mutex_lock(pClient->mutex);
1729    
# Line 1645  int lscp_get_total_voice_count_max ( lsc Line 1738  int lscp_get_total_voice_count_max ( lsc
1738    
1739    
1740  /**  /**
1741     *  Create a new MIDI instrument map:
1742     *  ADD MIDI_INSTRUMENT_MAP [<name>]
1743     *
1744     *  @param pClient      Pointer to client instance structure.
1745     *  @param pszMapName   MIDI instrument map name (optional)
1746     *
1747     *  @returns The new MIDI instrument map number identifier,
1748     *  or -1 in case of failure.
1749     */
1750    int lscp_add_midi_instrument_map ( lscp_client_t *pClient, const char *pszMapName )
1751    {
1752            int iMidiMap = -1;
1753            char szQuery[LSCP_BUFSIZ];
1754    
1755            if (pClient == NULL)
1756                    return -1;
1757    
1758            // Lock this section up.
1759            lscp_mutex_lock(pClient->mutex);
1760    
1761            strcpy(szQuery, "ADD MIDI_INSTRUMENT_MAP");
1762            
1763            if (pszMapName)
1764                    sprintf(szQuery + strlen(szQuery), " '%s'", pszMapName);
1765    
1766            strcat(szQuery, "\r\n");
1767    
1768            if (lscp_client_call(pClient, szQuery, 0) == LSCP_OK)
1769                    iMidiMap = atoi(lscp_client_get_result(pClient));
1770    
1771            // Unlock this section down.
1772            lscp_mutex_unlock(pClient->mutex);
1773    
1774            return iMidiMap;
1775    }
1776    
1777    
1778    /**
1779     *  Delete one particular or all MIDI instrument maps:
1780     *  REMOVE MIDI_INSTRUMENT_MAP <midi-map>
1781     *
1782     *  @param pClient  Pointer to client instance structure.
1783     *  @param iMidiMap MIDI instrument map number.
1784     *
1785     *  @returns LSCP_OK on success, LSCP_FAILED otherwise.
1786     */
1787    lscp_status_t lscp_remove_midi_instrument_map ( lscp_client_t *pClient, int iMidiMap )
1788    {
1789            char szQuery[LSCP_BUFSIZ];
1790    
1791            if (iMidiMap < 0)
1792                    return LSCP_FAILED;
1793    
1794            sprintf(szQuery, "REMOVE MIDI_INSTRUMENT_MAP %d\r\n", iMidiMap);
1795    
1796            return lscp_client_query(pClient, szQuery);
1797    }
1798    
1799    
1800    /**
1801     *  Get amount of existing MIDI instrument maps:
1802     *  GET MIDI_INSTRUMENT_MAPS
1803     *
1804     *  @param pClient  Pointer to client instance structure.
1805     *
1806     *  @returns The current total number of MIDI instrument maps
1807     *  on success, -1 otherwise.
1808     */
1809    int lscp_get_midi_instrument_maps ( lscp_client_t *pClient )
1810    {
1811            int iMidiMaps = -1;
1812    
1813            if (pClient == NULL)
1814                    return -1;
1815    
1816            // Lock this section up.
1817            lscp_mutex_lock(pClient->mutex);
1818    
1819            if (lscp_client_call(pClient, "GET MIDI_INSTRUMENT_MAPS\r\n", 0) == LSCP_OK)
1820                    iMidiMaps = atoi(lscp_client_get_result(pClient));
1821    
1822            // Unlock this section doen.
1823            lscp_mutex_unlock(pClient->mutex);
1824    
1825            return iMidiMaps;
1826    }
1827    
1828    
1829    /**
1830     *  Getting all created MIDI instrument maps:
1831     *  LIST MIDI_INSTRUMENT_MAPS
1832     *
1833     *  @param pClient  Pointer to client instance structure.
1834     *
1835     *  @returns An array of the MIDI instrument map identifiers as positive
1836     *  integers, terminated with -1 on success, NULL otherwise.
1837     */
1838    int *lscp_list_midi_instrument_maps ( lscp_client_t *pClient )
1839    {
1840            const char *pszSeps = ",";
1841    
1842            if (pClient == NULL)
1843                    return NULL;
1844    
1845            // Lock this section up.
1846            lscp_mutex_lock(pClient->mutex);
1847    
1848            if (pClient->midi_maps) {
1849                    lscp_isplit_destroy(pClient->midi_maps);
1850                    pClient->midi_maps = NULL;
1851            }
1852    
1853            if (lscp_client_call(pClient, "LIST MIDI_INSTRUMENT_MAPS\r\n", 0) == LSCP_OK)
1854                    pClient->midi_maps = lscp_isplit_create(lscp_client_get_result(pClient), pszSeps);
1855    
1856            // Unlock this section down.
1857            lscp_mutex_unlock(pClient->mutex);
1858    
1859            return pClient->midi_maps;
1860    }
1861    
1862    
1863    /**
1864     *  Getting a MIDI instrument map name:
1865     *  GET MIDI_INSTRUMENT_MAP INFO <midi-map>
1866     *
1867     *  @param pClient  Pointer to client instance structure.
1868     *  @param iMidiMap MIDI instrument map number.
1869     *
1870     *  @returns The MIDI instrument map name on success, NULL on failure.
1871     */
1872    const char *lscp_get_midi_instrument_map_name ( lscp_client_t *pClient, int iMidiMap )
1873    {
1874            char szQuery[LSCP_BUFSIZ];
1875            const char *pszResult;
1876            const char *pszSeps = ":";
1877            const char *pszCrlf = "\r\n";
1878            char *pszToken;
1879            char *pch;
1880    
1881            if (pClient == NULL)
1882                    return NULL;
1883            if (iMidiMap < 0)
1884                    return NULL;
1885    
1886            // Lock this section up.
1887            lscp_mutex_lock(pClient->mutex);
1888            
1889            if (pClient->midi_map_name) {
1890                    free(pClient->midi_map_name);
1891                    pClient->midi_map_name = NULL;
1892            }
1893    
1894            sprintf(szQuery, "GET MIDI_INSTRUMENT_MAP INFO %d\r\n", iMidiMap);
1895            if (lscp_client_call(pClient, szQuery, 1) == LSCP_OK) {
1896                    pszResult = lscp_client_get_result(pClient);
1897                    pszToken = lscp_strtok((char *) pszResult, pszSeps, &(pch));
1898                    while (pszToken) {
1899                            if (strcasecmp(pszToken, "NAME") == 0) {
1900                                    pszToken = lscp_strtok(NULL, pszCrlf, &(pch));
1901                                    if (pszToken)
1902                                            lscp_unquote_dup(&(pClient->midi_map_name), &pszToken);
1903                            }
1904                            pszToken = lscp_strtok(NULL, pszSeps, &(pch));
1905                    }
1906            }
1907    
1908            // Unlock this section down.
1909            lscp_mutex_unlock(pClient->mutex);
1910    
1911            return pClient->midi_map_name;
1912    }
1913    
1914    
1915    /**
1916     *  Renaming a MIDI instrument map:
1917     *  SET MIDI_INSTRUMENT_MAP NAME <midi-map> <map-name>
1918     *
1919     *  @param pClient      Pointer to client instance structure.
1920     *  @param iMidiMap     MIDI instrument map number.
1921     *  @param pszMapName   MIDI instrument map name.
1922     *
1923     *  @returns LSCP_OK on success, LSCP_FAILED otherwise.
1924     */
1925    lscp_status_t lscp_set_midi_instrument_map_name ( lscp_client_t *pClient, int iMidiMap, const char *pszMapName )
1926    {
1927            char szQuery[LSCP_BUFSIZ];
1928    
1929            if (iMidiMap < 0)
1930                    return LSCP_FAILED;
1931            if (pszMapName == NULL)
1932                    return LSCP_FAILED;
1933    
1934            sprintf(szQuery, "SET MIDI_INSTRUMENT_MAP NAME %d '%s'\r\n",
1935                    iMidiMap, pszMapName);
1936    
1937            return lscp_client_query(pClient, szQuery);
1938    }
1939    
1940    
1941    /**
1942   *  Create or replace a MIDI instrumnet map entry:   *  Create or replace a MIDI instrumnet map entry:
1943   *  MAP MIDI_INSTRUMENT <midi-bank-msb> <midi-bank-lsb> <midi-prog>   *  MAP MIDI_INSTRUMENT <midi-map> <midi-bank> <midi-prog>
1944   *      <engine-name> <filename> <instr-index> <volume> <load-mode> [<name>]   *      <engine-name> <filename> <instr-index> <volume> [<load-mode> [<name>]}
1945   *   *
1946   *  @param pClient          Pointer to client instance structure.   *  @param pClient          Pointer to client instance structure.
1947   *  @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 1957  int lscp_get_total_voice_count_max ( lsc
1957   *                          @ref LSCP_LOAD_ON_DEMAND, or   *                          @ref LSCP_LOAD_ON_DEMAND, or
1958   *                          @ref LSCP_LOAD_ON_DEMAND_HOLD, or   *                          @ref LSCP_LOAD_ON_DEMAND_HOLD, or
1959   *                          @ref LSCP_LOAD_PERSISTENT.   *                          @ref LSCP_LOAD_PERSISTENT.
1960   *  @param pszName          Instrument custom name for the map entry.   *  @param pszName         Instrument custom name for the map entry (optional).
1961   *   *
1962   *  @returns LSCP_OK on success, LSCP_FAILED otherwise.   *  @returns LSCP_OK on success, LSCP_FAILED otherwise.
1963   */   */
# Line 1671  lscp_status_t lscp_map_midi_instrument ( Line 1965  lscp_status_t lscp_map_midi_instrument (
1965  {  {
1966          char szQuery[LSCP_BUFSIZ];          char szQuery[LSCP_BUFSIZ];
1967    
1968          if (pMidiInstr->bank_msb < 0 || pMidiInstr->bank_msb > 127)          if (pMidiInstr->map < 0)
1969                  return LSCP_FAILED;                  return LSCP_FAILED;
1970          if (pMidiInstr->bank_lsb < 0 || pMidiInstr->bank_lsb > 127)          if (pMidiInstr->bank < 0 || pMidiInstr->bank > 16383)
1971                  return LSCP_FAILED;                  return LSCP_FAILED;
1972          if (pMidiInstr->program < 0 || pMidiInstr->program > 127)          if (pMidiInstr->prog < 0 || pMidiInstr->prog > 127)
1973                  return LSCP_FAILED;                  return LSCP_FAILED;
1974          if (pszEngineName == NULL || pszFileName == NULL)          if (pszEngineName == NULL || pszFileName == NULL)
1975                  return LSCP_FAILED;                  return LSCP_FAILED;
# Line 1684  lscp_status_t lscp_map_midi_instrument ( Line 1978  lscp_status_t lscp_map_midi_instrument (
1978                  fVolume = 1.0f;                  fVolume = 1.0f;
1979    
1980          sprintf(szQuery, "MAP MIDI_INSTRUMENT %d %d %d %s '%s' %d %g",          sprintf(szQuery, "MAP MIDI_INSTRUMENT %d %d %d %s '%s' %d %g",
1981                  pMidiInstr->bank_msb, pMidiInstr->bank_lsb, pMidiInstr->program,                  pMidiInstr->map, pMidiInstr->bank, pMidiInstr->prog,
1982                  pszEngineName, pszFileName, iInstrIndex, fVolume);                  pszEngineName, pszFileName, iInstrIndex, fVolume);
1983    
1984          switch (load_mode) {          switch (load_mode) {
# Line 1713  lscp_status_t lscp_map_midi_instrument ( Line 2007  lscp_status_t lscp_map_midi_instrument (
2007    
2008  /**  /**
2009   *  Remove an entry from the MIDI instrument map:   *  Remove an entry from the MIDI instrument map:
2010   *  UNMAP MIDI_INSTRUMENT <midi-bank-msb> <midi-bank-lsb> <midi-prog>   *  UNMAP MIDI_INSTRUMENT <midi-map> <midi-bank> <midi-prog>
2011   *   *
2012   *  @param pClient      Pointer to client instance structure.   *  @param pClient      Pointer to client instance structure.
2013   *  @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 2018  lscp_status_t lscp_unmap_midi_instrument
2018  {  {
2019          char szQuery[LSCP_BUFSIZ];          char szQuery[LSCP_BUFSIZ];
2020    
2021          if (pMidiInstr->bank_msb < 0 || pMidiInstr->bank_msb > 127)          if (pMidiInstr->map < 0)
2022                  return LSCP_FAILED;                  return LSCP_FAILED;
2023          if (pMidiInstr->bank_lsb < 0 || pMidiInstr->bank_lsb > 127)          if (pMidiInstr->bank < 0 || pMidiInstr->bank > 16383)
2024                  return LSCP_FAILED;                  return LSCP_FAILED;
2025          if (pMidiInstr->program < 0 || pMidiInstr->program > 127)          if (pMidiInstr->prog < 0 || pMidiInstr->prog > 127)
2026                  return LSCP_FAILED;                  return LSCP_FAILED;
2027    
2028          sprintf(szQuery, "UNMAP MIDI_INSTRUMENT %d %d %d\r\n",          sprintf(szQuery, "UNMAP MIDI_INSTRUMENT %d %d %d\r\n",
2029                  pMidiInstr->bank_msb, pMidiInstr->bank_lsb, pMidiInstr->program);                  pMidiInstr->map, pMidiInstr->bank, pMidiInstr->prog);
2030    
2031          return lscp_client_query(pClient, szQuery);          return lscp_client_query(pClient, szQuery);
2032  }  }
# Line 1740  lscp_status_t lscp_unmap_midi_instrument Line 2034  lscp_status_t lscp_unmap_midi_instrument
2034    
2035  /**  /**
2036   *  Get the total count of MIDI instrument map entries:   *  Get the total count of MIDI instrument map entries:
2037   *  GET MIDI_INSTRUMENTS   *  GET MIDI_INSTRUMENTS ALL|<midi-map>
2038   *   *
2039   *  @param pClient  Pointer to client instance structure.   *  @param pClient  Pointer to client instance structure.
2040     *  @param iMidiMap MIDI instrument map number, or @ref LSCP_MIDI_MAP_ALL .
2041   *   *
2042   *  @returns The current total number of MIDI instrument map entries   *  @returns The current total number of MIDI instrument map entries
2043   *  on success, -1 otherwise.   *  on success, -1 otherwise.
2044   */   */
2045  int lscp_get_midi_instruments ( lscp_client_t *pClient )  int lscp_get_midi_instruments ( lscp_client_t *pClient, int iMidiMap )
2046  {  {
2047          int iInstruments = -1;          int iInstruments = -1;
2048            char szQuery[LSCP_BUFSIZ];
2049    
2050            if (pClient == NULL)
2051                    return -1;
2052    
2053          // Lock this section up.          // Lock this section up.
2054          lscp_mutex_lock(pClient->mutex);          lscp_mutex_lock(pClient->mutex);
2055    
2056          if (lscp_client_call(pClient, "GET MIDI_INSTRUMENTS\r\n", 0) == LSCP_OK)          strcpy(szQuery, "GET MIDI_INSTRUMENTS ");
2057    
2058            if (iMidiMap < 0)
2059                    strcat(szQuery, "ALL");
2060            else
2061                    sprintf(szQuery + strlen(szQuery), "%d", iMidiMap);
2062    
2063            strcat(szQuery, "\r\n");
2064    
2065            if (lscp_client_call(pClient, szQuery, 0) == LSCP_OK)
2066                  iInstruments = atoi(lscp_client_get_result(pClient));                  iInstruments = atoi(lscp_client_get_result(pClient));
2067    
2068          // Unlock this section down.          // Unlock this section down.
# Line 1766  int lscp_get_midi_instruments ( lscp_cli Line 2074  int lscp_get_midi_instruments ( lscp_cli
2074    
2075  /**  /**
2076   *  Getting indeces of all MIDI instrument map entries:   *  Getting indeces of all MIDI instrument map entries:
2077   *  LIST MIDI_INSTRUMENTS   *  LIST MIDI_INSTRUMENTS ALL|<midi-map>
2078   *   *
2079   *  @param pClient  Pointer to client instance structure.   *  @param pClient  Pointer to client instance structure.
2080     *  @param iMidiMap MIDI instrument map number, or @ref LSCP_MIDI_MAP_ALL .
2081   *   *
2082   *  @returns An array of @ref lscp_midi_instrument_t, terminated with the   *  @returns An array of @ref lscp_midi_instrument_t, terminated with the
2083   *  {-1,-1,-1} triplet, NULL otherwise.   *  {-1,-1,-1} triplet, NULL otherwise.
2084   */   */
2085  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 )
2086  {  {
2087            char szQuery[LSCP_BUFSIZ];
2088    
2089          if (pClient == NULL)          if (pClient == NULL)
2090                  return NULL;                  return NULL;
2091    
# Line 1786  lscp_midi_instrument_t *lscp_list_midi_i Line 2097  lscp_midi_instrument_t *lscp_list_midi_i
2097                  pClient->midi_instruments = NULL;                  pClient->midi_instruments = NULL;
2098          }          }
2099    
2100          if (lscp_client_call(pClient, "LIST MIDI_INSTRUMENTS\r\n", 0) == LSCP_OK)          strcpy(szQuery, "LIST MIDI_INSTRUMENTS ");
2101    
2102            if (iMidiMap < 0)
2103                    strcat(szQuery, "ALL");
2104            else
2105                    sprintf(szQuery + strlen(szQuery), "%d", iMidiMap);
2106    
2107            strcat(szQuery, "\r\n");
2108    
2109            if (lscp_client_call(pClient, szQuery, 0) == LSCP_OK)
2110                  pClient->midi_instruments = lscp_midi_instruments_create(lscp_client_get_result(pClient));                  pClient->midi_instruments = lscp_midi_instruments_create(lscp_client_get_result(pClient));
2111    
2112          // Unlock this section down.          // Unlock this section down.
# Line 1798  lscp_midi_instrument_t *lscp_list_midi_i Line 2118  lscp_midi_instrument_t *lscp_list_midi_i
2118    
2119  /**  /**
2120   *  Getting information about a MIDI instrument map entry:   *  Getting information about a MIDI instrument map entry:
2121   *  GET MIDI_INSTRUMENT INFO <midi-bank-msb> <midi-bank-lsb> <midi-prog>   *  GET MIDI_INSTRUMENT INFO <midi-map> <midi-bank> <midi-prog>
2122   *   *
2123   *  @param pClient      Pointer to client instance structure.   *  @param pClient      Pointer to client instance structure.
2124   *  @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 2137  lscp_midi_instrument_info_t *lscp_get_mi
2137          char *pszToken;          char *pszToken;
2138          char *pch;          char *pch;
2139    
2140          if (pMidiInstr->bank_msb < 0 || pMidiInstr->bank_msb > 127)          if (pClient == NULL)
2141                  return NULL;                  return NULL;
2142          if (pMidiInstr->bank_lsb < 0 || pMidiInstr->bank_lsb > 127)          if (pMidiInstr->map < 0)
2143                  return NULL;                  return NULL;
2144          if (pMidiInstr->program < 0 || pMidiInstr->program > 127)          if (pMidiInstr->bank < 0 || pMidiInstr->bank > 16383)
2145                    return NULL;
2146            if (pMidiInstr->prog < 0 || pMidiInstr->prog > 127)
2147                  return NULL;                  return NULL;
2148    
2149          // Lock this section up.          // Lock this section up.
# Line 1831  lscp_midi_instrument_info_t *lscp_get_mi Line 2153  lscp_midi_instrument_info_t *lscp_get_mi
2153          lscp_midi_instrument_info_reset(pInstrInfo);          lscp_midi_instrument_info_reset(pInstrInfo);
2154    
2155          sprintf(szQuery, "GET MIDI_INSTRUMENT INFO %d %d %d\r\n",          sprintf(szQuery, "GET MIDI_INSTRUMENT INFO %d %d %d\r\n",
2156                  pMidiInstr->bank_msb, pMidiInstr->bank_lsb, pMidiInstr->program);                  pMidiInstr->map, pMidiInstr->bank, pMidiInstr->prog);
2157          if (lscp_client_call(pClient, szQuery, 1) == LSCP_OK) {          if (lscp_client_call(pClient, szQuery, 1) == LSCP_OK) {
2158                  pszResult = lscp_client_get_result(pClient);                  pszResult = lscp_client_get_result(pClient);
2159                  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 2218  lscp_midi_instrument_info_t *lscp_get_mi
2218    
2219  /**  /**
2220   *  Clear the MIDI instrumnet map:   *  Clear the MIDI instrumnet map:
2221   *  CLEAR MIDI_INSTRUMENTS   *  CLEAR MIDI_INSTRUMENTS ALL|<midi-map>
2222   *   *
2223   *  @param pClient         Pointer to client instance structure.   *  @param pClient  Pointer to client instance structure.
2224   *  @param iSamplerChannel  Sampler channel number.   *  @param iMidiMap MIDI instrument map number, or @ref LSCP_MIDI_MAP_ALL .
2225   *   *
2226   *  @returns LSCP_OK on success, LSCP_FAILED otherwise.   *  @returns LSCP_OK on success, LSCP_FAILED otherwise.
2227   */   */
2228  lscp_status_t lscp_clear_midi_instruments  ( lscp_client_t *pClient )  lscp_status_t lscp_clear_midi_instruments  ( lscp_client_t *pClient, int iMidiMap )
2229  {  {
2230          return lscp_client_query(pClient, "CLEAR MIDI_INSTRUMENTS\r\n");          char szQuery[LSCP_BUFSIZ];
2231    
2232            strcpy(szQuery, "CLEAR MIDI_INSTRUMENTS ");
2233    
2234            if (iMidiMap < 0)
2235                    strcat(szQuery, "ALL");
2236            else
2237                    sprintf(szQuery + strlen(szQuery), "%d", iMidiMap);
2238    
2239            strcat(szQuery, "\r\n");
2240    
2241            return lscp_client_query(pClient, szQuery);
2242  }  }
2243    
2244    

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

  ViewVC Help
Powered by ViewVC