340 |
lscp_server_info_init(&(pClient->server_info)); |
lscp_server_info_init(&(pClient->server_info)); |
341 |
lscp_engine_info_init(&(pClient->engine_info)); |
lscp_engine_info_init(&(pClient->engine_info)); |
342 |
lscp_channel_info_init(&(pClient->channel_info)); |
lscp_channel_info_init(&(pClient->channel_info)); |
343 |
|
lscp_midi_instrument_info_init(&(pClient->midi_instrument_info)); |
344 |
// Initialize error stuff. |
// Initialize error stuff. |
345 |
pClient->pszResult = NULL; |
pClient->pszResult = NULL; |
346 |
pClient->iErrno = -1; |
pClient->iErrno = -1; |
401 |
lscp_mutex_lock(pClient->mutex); |
lscp_mutex_lock(pClient->mutex); |
402 |
|
|
403 |
// Free up all cached members. |
// Free up all cached members. |
404 |
|
lscp_midi_instrument_info_free(&(pClient->midi_instrument_info)); |
405 |
lscp_channel_info_free(&(pClient->channel_info)); |
lscp_channel_info_free(&(pClient->channel_info)); |
406 |
lscp_engine_info_free(&(pClient->engine_info)); |
lscp_engine_info_free(&(pClient->engine_info)); |
407 |
lscp_server_info_free(&(pClient->server_info)); |
lscp_server_info_free(&(pClient->server_info)); |
1277 |
* @param pClient Pointer to client instance structure. |
* @param pClient Pointer to client instance structure. |
1278 |
* @param iSamplerChannel Sampler channel number. |
* @param iSamplerChannel Sampler channel number. |
1279 |
* @param pszAudioDriver Audio output driver type (e.g. "ALSA" or "JACK"). |
* @param pszAudioDriver Audio output driver type (e.g. "ALSA" or "JACK"). |
1280 |
|
* |
1281 |
|
* @returns LSCP_OK on success, LSCP_FAILED otherwise. |
1282 |
*/ |
*/ |
1283 |
lscp_status_t lscp_set_channel_audio_type ( lscp_client_t *pClient, int iSamplerChannel, const char *pszAudioDriver ) |
lscp_status_t lscp_set_channel_audio_type ( lscp_client_t *pClient, int iSamplerChannel, const char *pszAudioDriver ) |
1284 |
{ |
{ |
1299 |
* @param pClient Pointer to client instance structure. |
* @param pClient Pointer to client instance structure. |
1300 |
* @param iSamplerChannel Sampler channel number. |
* @param iSamplerChannel Sampler channel number. |
1301 |
* @param iAudioDevice Audio output device number identifier. |
* @param iAudioDevice Audio output device number identifier. |
1302 |
|
* |
1303 |
|
* @returns LSCP_OK on success, LSCP_FAILED otherwise. |
1304 |
*/ |
*/ |
1305 |
lscp_status_t lscp_set_channel_audio_device ( lscp_client_t *pClient, int iSamplerChannel, int iAudioDevice ) |
lscp_status_t lscp_set_channel_audio_device ( lscp_client_t *pClient, int iSamplerChannel, int iAudioDevice ) |
1306 |
{ |
{ |
1366 |
* @param pClient Pointer to client instance structure. |
* @param pClient Pointer to client instance structure. |
1367 |
* @param iSamplerChannel Sampler channel number. |
* @param iSamplerChannel Sampler channel number. |
1368 |
* @param iMidiDevice MIDI input device number identifier. |
* @param iMidiDevice MIDI input device number identifier. |
1369 |
|
* |
1370 |
|
* @returns LSCP_OK on success, LSCP_FAILED otherwise. |
1371 |
*/ |
*/ |
1372 |
lscp_status_t lscp_set_channel_midi_device ( lscp_client_t *pClient, int iSamplerChannel, int iMidiDevice ) |
lscp_status_t lscp_set_channel_midi_device ( lscp_client_t *pClient, int iSamplerChannel, int iMidiDevice ) |
1373 |
{ |
{ |
1586 |
} |
} |
1587 |
|
|
1588 |
|
|
1589 |
|
/** |
1590 |
|
* Current total number of active voices: |
1591 |
|
* GET TOTAL_VOICE_COUNT |
1592 |
|
* |
1593 |
|
* @param pClient Pointer to client instance structure. |
1594 |
|
* |
1595 |
|
* @returns The total number of voices currently active, |
1596 |
|
* -1 in case of failure. |
1597 |
|
*/ |
1598 |
|
int lscp_get_total_voice_count ( lscp_client_t *pClient ) |
1599 |
|
{ |
1600 |
|
int iVoiceCount = -1; |
1601 |
|
|
1602 |
|
// Lock this section up. |
1603 |
|
lscp_mutex_lock(pClient->mutex); |
1604 |
|
|
1605 |
|
if (lscp_client_call(pClient, "GET TOTAL_VOICE_COUNT\r\n") == LSCP_OK) |
1606 |
|
iVoiceCount = atoi(lscp_client_get_result(pClient)); |
1607 |
|
|
1608 |
|
// Unlock this section down. |
1609 |
|
lscp_mutex_unlock(pClient->mutex); |
1610 |
|
|
1611 |
|
return iVoiceCount; |
1612 |
|
} |
1613 |
|
|
1614 |
|
|
1615 |
|
/** |
1616 |
|
* Maximum amount of active voices: |
1617 |
|
* GET TOTAL_VOICE_COUNT_MAX |
1618 |
|
* |
1619 |
|
* @param pClient Pointer to client instance structure. |
1620 |
|
* |
1621 |
|
* @returns The maximum amount of voices currently active, |
1622 |
|
* -1 in case of failure. |
1623 |
|
*/ |
1624 |
|
int lscp_get_total_voice_count_max ( lscp_client_t *pClient ) |
1625 |
|
{ |
1626 |
|
int iVoiceCount = -1; |
1627 |
|
|
1628 |
|
// Lock this section up. |
1629 |
|
lscp_mutex_lock(pClient->mutex); |
1630 |
|
|
1631 |
|
if (lscp_client_call(pClient, "GET TOTAL_VOICE_COUNT_MAX\r\n") == LSCP_OK) |
1632 |
|
iVoiceCount = atoi(lscp_client_get_result(pClient)); |
1633 |
|
|
1634 |
|
// Unlock this section down. |
1635 |
|
lscp_mutex_unlock(pClient->mutex); |
1636 |
|
|
1637 |
|
return iVoiceCount; |
1638 |
|
} |
1639 |
|
|
1640 |
|
|
1641 |
|
/** |
1642 |
|
* Create or replace a MIDI instrumnet map entry: |
1643 |
|
* MAP MIDI_INSTRUMENT <midi-bank-msb> <midi-bank-lsb> <midi-prog> |
1644 |
|
* <engine-name> <filename> <instr-index> <volume> <load-mode> [<name>] |
1645 |
|
* |
1646 |
|
* @param pClient Pointer to client instance structure. |
1647 |
|
* @param pMidiInstr MIDI instrument bank and program parameter key. |
1648 |
|
* @param pszEngineName Engine name. |
1649 |
|
* @param pszFileName Instrument file name. |
1650 |
|
* @param iInstrIndex Instrument index number. |
1651 |
|
* @param fVolume Reflects the master volume of the instrument as |
1652 |
|
* a positive floating point number, where a value |
1653 |
|
* less than 1.0 for attenuation, and greater than |
1654 |
|
* 1.0 for amplification. |
1655 |
|
* @param load_mode Instrument load life-time strategy, either |
1656 |
|
* @ref LSCP_LOAD_DEFAULT, or |
1657 |
|
* @ref LSCP_LOAD_ON_DEMAND, or |
1658 |
|
* @ref LSCP_LOAD_ON_DEMAND_HOLD, or |
1659 |
|
* @ref LSCP_LOAD_PERSISTENT. |
1660 |
|
* @param pszName Instrument custom name for the map entry. |
1661 |
|
* |
1662 |
|
* @returns LSCP_OK on success, LSCP_FAILED otherwise. |
1663 |
|
*/ |
1664 |
|
lscp_status_t lscp_map_midi_instrument ( lscp_client_t *pClient, lscp_midi_instrument_t *pMidiInstr, const char *pszEngineName, const char *pszFileName, int iInstrIndex, float fVolume, lscp_load_mode_t load_mode, const char *pszName ) |
1665 |
|
{ |
1666 |
|
char szQuery[LSCP_BUFSIZ]; |
1667 |
|
|
1668 |
|
if (pMidiInstr->bank_msb < 0 || pMidiInstr->bank_msb > 127) |
1669 |
|
return LSCP_FAILED; |
1670 |
|
if (pMidiInstr->bank_lsb < 0 || pMidiInstr->bank_lsb > 127) |
1671 |
|
return LSCP_FAILED; |
1672 |
|
if (pMidiInstr->program < 0 || pMidiInstr->program > 127) |
1673 |
|
return LSCP_FAILED; |
1674 |
|
if (pszEngineName == NULL || pszFileName == NULL) |
1675 |
|
return LSCP_FAILED; |
1676 |
|
|
1677 |
|
if (fVolume < 0.0f) |
1678 |
|
fVolume = 1.0f; |
1679 |
|
|
1680 |
|
sprintf(szQuery, "MAP MIDI_INSTRUMENT %d %d %d %s '%s' %d %g", |
1681 |
|
pMidiInstr->bank_msb, pMidiInstr->bank_lsb, pMidiInstr->program, |
1682 |
|
pszEngineName, pszFileName, iInstrIndex, fVolume); |
1683 |
|
|
1684 |
|
switch (load_mode) { |
1685 |
|
case LSCP_LOAD_PERSISTENT: |
1686 |
|
strcat(szQuery, " PERSISTENT"); |
1687 |
|
break; |
1688 |
|
case LSCP_LOAD_ON_DEMAND_HOLD: |
1689 |
|
strcat(szQuery, " ON_DEMAND_HOLD"); |
1690 |
|
break; |
1691 |
|
case LSCP_LOAD_ON_DEMAND: |
1692 |
|
strcat(szQuery, " ON_DEMAND_HOLD"); |
1693 |
|
break; |
1694 |
|
case LSCP_LOAD_DEFAULT: |
1695 |
|
default: |
1696 |
|
break; |
1697 |
|
} |
1698 |
|
|
1699 |
|
if (pszName) |
1700 |
|
sprintf(szQuery + strlen(szQuery), " '%s'", pszName); |
1701 |
|
|
1702 |
|
strcat(szQuery, "\r\n"); |
1703 |
|
|
1704 |
|
return lscp_client_query(pClient, szQuery); |
1705 |
|
} |
1706 |
|
|
1707 |
|
|
1708 |
|
/** |
1709 |
|
* Remove an entry from the MIDI instrument map: |
1710 |
|
* UNMAP MIDI_INSTRUMENT <midi-bank-msb> <midi-bank-lsb> <midi-prog> |
1711 |
|
* |
1712 |
|
* @param pClient Pointer to client instance structure. |
1713 |
|
* @param pMidiInstr MIDI instrument bank and program parameter key. |
1714 |
|
* |
1715 |
|
* @returns LSCP_OK on success, LSCP_FAILED otherwise. |
1716 |
|
*/ |
1717 |
|
lscp_status_t lscp_unmap_midi_instrument ( lscp_client_t *pClient, lscp_midi_instrument_t *pMidiInstr ) |
1718 |
|
{ |
1719 |
|
char szQuery[LSCP_BUFSIZ]; |
1720 |
|
|
1721 |
|
if (pMidiInstr->bank_msb < 0 || pMidiInstr->bank_msb > 127) |
1722 |
|
return LSCP_FAILED; |
1723 |
|
if (pMidiInstr->bank_lsb < 0 || pMidiInstr->bank_lsb > 127) |
1724 |
|
return LSCP_FAILED; |
1725 |
|
if (pMidiInstr->program < 0 || pMidiInstr->program > 127) |
1726 |
|
return LSCP_FAILED; |
1727 |
|
|
1728 |
|
sprintf(szQuery, "UNMAP MIDI_INSTRUMENT %d %d %d\r\n", |
1729 |
|
pMidiInstr->bank_msb, pMidiInstr->bank_lsb, pMidiInstr->program); |
1730 |
|
|
1731 |
|
return lscp_client_query(pClient, szQuery); |
1732 |
|
} |
1733 |
|
|
1734 |
|
|
1735 |
|
/** |
1736 |
|
* Get the total count of MIDI instrument map entries: |
1737 |
|
* GET MIDI_INSTRUMENTS |
1738 |
|
* |
1739 |
|
* @param pClient Pointer to client instance structure. |
1740 |
|
* |
1741 |
|
* @returns The current total number of MIDI instrument map entries |
1742 |
|
* on success, -1 otherwise. |
1743 |
|
*/ |
1744 |
|
int lscp_get_midi_instruments ( lscp_client_t *pClient ) |
1745 |
|
{ |
1746 |
|
int iInstruments = -1; |
1747 |
|
|
1748 |
|
// Lock this section up. |
1749 |
|
lscp_mutex_lock(pClient->mutex); |
1750 |
|
|
1751 |
|
if (lscp_client_call(pClient, "GET MIDI_INSTRUMENTS\r\n") == LSCP_OK) |
1752 |
|
iInstruments = atoi(lscp_client_get_result(pClient)); |
1753 |
|
|
1754 |
|
// Unlock this section down. |
1755 |
|
lscp_mutex_unlock(pClient->mutex); |
1756 |
|
|
1757 |
|
return iInstruments; |
1758 |
|
} |
1759 |
|
|
1760 |
|
|
1761 |
|
/** |
1762 |
|
* Getting information about a MIDI instrument map entry: |
1763 |
|
* GET MIDI_INSTRUMENT INFO <midi-bank-msb> <midi-bank-lsb> <midi-prog> |
1764 |
|
* |
1765 |
|
* @param pClient Pointer to client instance structure. |
1766 |
|
* @param pMidiInstr MIDI instrument bank and program parameter key. |
1767 |
|
* |
1768 |
|
* @returns A pointer to a @ref lscp_midi_instrument_info_t structure, |
1769 |
|
* with all the information of the given MIDI instrument map entry, |
1770 |
|
* or NULL in case of failure. |
1771 |
|
*/ |
1772 |
|
lscp_midi_instrument_info_t *lscp_get_midi_instrument_info ( lscp_client_t *pClient, lscp_midi_instrument_t *pMidiInstr ) |
1773 |
|
{ |
1774 |
|
lscp_midi_instrument_info_t *pInstrInfo; |
1775 |
|
char szQuery[LSCP_BUFSIZ]; |
1776 |
|
const char *pszResult; |
1777 |
|
const char *pszSeps = ":"; |
1778 |
|
const char *pszCrlf = "\r\n"; |
1779 |
|
char *pszToken; |
1780 |
|
char *pch; |
1781 |
|
|
1782 |
|
if (pMidiInstr->bank_msb < 0 || pMidiInstr->bank_msb > 127) |
1783 |
|
return NULL; |
1784 |
|
if (pMidiInstr->bank_lsb < 0 || pMidiInstr->bank_lsb > 127) |
1785 |
|
return NULL; |
1786 |
|
if (pMidiInstr->program < 0 || pMidiInstr->program > 127) |
1787 |
|
return NULL; |
1788 |
|
|
1789 |
|
// Lock this section up. |
1790 |
|
lscp_mutex_lock(pClient->mutex); |
1791 |
|
|
1792 |
|
pInstrInfo = &(pClient->midi_instrument_info); |
1793 |
|
lscp_midi_instrument_info_reset(pInstrInfo); |
1794 |
|
|
1795 |
|
sprintf(szQuery, "GET MIDI_INSTRUMENT INFO %d %d %d\r\n", |
1796 |
|
pMidiInstr->bank_msb, pMidiInstr->bank_lsb, pMidiInstr->program); |
1797 |
|
if (lscp_client_call(pClient, szQuery) == LSCP_OK) { |
1798 |
|
pszResult = lscp_client_get_result(pClient); |
1799 |
|
pszToken = lscp_strtok((char *) pszResult, pszSeps, &(pch)); |
1800 |
|
while (pszToken) { |
1801 |
|
if (strcasecmp(pszToken, "NAME") == 0) { |
1802 |
|
pszToken = lscp_strtok(NULL, pszCrlf, &(pch)); |
1803 |
|
if (pszToken) |
1804 |
|
lscp_unquote_dup(&(pInstrInfo->name), &pszToken); |
1805 |
|
} |
1806 |
|
else if (strcasecmp(pszToken, "ENGINE_NAME") == 0) { |
1807 |
|
pszToken = lscp_strtok(NULL, pszCrlf, &(pch)); |
1808 |
|
if (pszToken) |
1809 |
|
lscp_unquote_dup(&(pInstrInfo->engine_name), &pszToken); |
1810 |
|
} |
1811 |
|
else if (strcasecmp(pszToken, "INSTRUMENT_FILE") == 0) { |
1812 |
|
pszToken = lscp_strtok(NULL, pszCrlf, &(pch)); |
1813 |
|
if (pszToken) |
1814 |
|
lscp_unquote_dup(&(pInstrInfo->instrument_file), &pszToken); |
1815 |
|
} |
1816 |
|
else if (strcasecmp(pszToken, "INSTRUMENT_NR") == 0) { |
1817 |
|
pszToken = lscp_strtok(NULL, pszCrlf, &(pch)); |
1818 |
|
if (pszToken) |
1819 |
|
pInstrInfo->instrument_nr = atoi(lscp_ltrim(pszToken)); |
1820 |
|
} |
1821 |
|
else if (strcasecmp(pszToken, "INSTRUMENT_NAME") == 0) { |
1822 |
|
pszToken = lscp_strtok(NULL, pszCrlf, &(pch)); |
1823 |
|
if (pszToken) |
1824 |
|
lscp_unquote_dup(&(pInstrInfo->instrument_name), &pszToken); |
1825 |
|
} |
1826 |
|
else if (strcasecmp(pszToken, "LOAD_MODE") == 0) { |
1827 |
|
pszToken = lscp_strtok(NULL, pszCrlf, &(pch)); |
1828 |
|
if (pszToken) { |
1829 |
|
pszToken = lscp_ltrim(pszToken); |
1830 |
|
if (strcasecmp(pszToken, "ON_DEMAND") == 0) |
1831 |
|
pInstrInfo->load_mode = LSCP_LOAD_ON_DEMAND; |
1832 |
|
else |
1833 |
|
if (strcasecmp(pszToken, "ON_DEMAND_HOLD") == 0) |
1834 |
|
pInstrInfo->load_mode = LSCP_LOAD_ON_DEMAND_HOLD; |
1835 |
|
else |
1836 |
|
if (strcasecmp(pszToken, "PERSISTENT") == 0) |
1837 |
|
pInstrInfo->load_mode = LSCP_LOAD_PERSISTENT; |
1838 |
|
else |
1839 |
|
pInstrInfo->load_mode = LSCP_LOAD_DEFAULT; |
1840 |
|
} |
1841 |
|
} |
1842 |
|
else if (strcasecmp(pszToken, "VOLUME") == 0) { |
1843 |
|
pszToken = lscp_strtok(NULL, pszCrlf, &(pch)); |
1844 |
|
if (pszToken) |
1845 |
|
pInstrInfo->volume = (float) atof(lscp_ltrim(pszToken)); |
1846 |
|
} |
1847 |
|
pszToken = lscp_strtok(NULL, pszSeps, &(pch)); |
1848 |
|
} |
1849 |
|
} |
1850 |
|
else pInstrInfo = NULL; |
1851 |
|
|
1852 |
|
// Unlock this section down. |
1853 |
|
lscp_mutex_unlock(pClient->mutex); |
1854 |
|
|
1855 |
|
return pInstrInfo; |
1856 |
|
} |
1857 |
|
|
1858 |
|
|
1859 |
|
/** |
1860 |
|
* Clear the MIDI instrumnet map: |
1861 |
|
* CLEAR MIDI_INSTRUMENTS |
1862 |
|
* |
1863 |
|
* @param pClient Pointer to client instance structure. |
1864 |
|
* @param iSamplerChannel Sampler channel number. |
1865 |
|
* |
1866 |
|
* @returns LSCP_OK on success, LSCP_FAILED otherwise. |
1867 |
|
*/ |
1868 |
|
lscp_status_t lscp_clear_midi_instruments ( lscp_client_t *pClient ) |
1869 |
|
{ |
1870 |
|
return lscp_client_query(pClient, "CLEAR MIDI_INSTRUMENTS\r\n"); |
1871 |
|
} |
1872 |
|
|
1873 |
|
|
1874 |
// end of client.c |
// end of client.c |