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->midi_instruments = NULL; |
331 |
lscp_driver_info_init(&(pClient->audio_driver_info)); |
lscp_driver_info_init(&(pClient->audio_driver_info)); |
332 |
lscp_driver_info_init(&(pClient->midi_driver_info)); |
lscp_driver_info_init(&(pClient->midi_driver_info)); |
333 |
lscp_device_info_init(&(pClient->audio_device_info)); |
lscp_device_info_init(&(pClient->audio_device_info)); |
423 |
lscp_isplit_destroy(pClient->midi_devices); |
lscp_isplit_destroy(pClient->midi_devices); |
424 |
lscp_szsplit_destroy(pClient->engines); |
lscp_szsplit_destroy(pClient->engines); |
425 |
lscp_isplit_destroy(pClient->channels); |
lscp_isplit_destroy(pClient->channels); |
426 |
|
lscp_midi_instruments_destroy(pClient->midi_instruments); |
427 |
// Make them null. |
// Make them null. |
428 |
pClient->audio_drivers = NULL; |
pClient->audio_drivers = NULL; |
429 |
pClient->midi_drivers = NULL; |
pClient->midi_drivers = NULL; |
430 |
|
pClient->audio_devices = NULL; |
431 |
|
pClient->midi_devices = NULL; |
432 |
pClient->engines = NULL; |
pClient->engines = NULL; |
433 |
|
pClient->channels = NULL; |
434 |
|
pClient->midi_instruments = NULL; |
435 |
// Free result error stuff. |
// Free result error stuff. |
436 |
lscp_client_set_result(pClient, NULL, 0); |
lscp_client_set_result(pClient, NULL, 0); |
437 |
// Free stream usage stuff. |
// Free stream usage stuff. |
516 |
lscp_mutex_lock(pClient->mutex); |
lscp_mutex_lock(pClient->mutex); |
517 |
|
|
518 |
// Just make the now guarded call. |
// Just make the now guarded call. |
519 |
ret = lscp_client_call(pClient, pszQuery); |
ret = lscp_client_call(pClient, pszQuery, 0); |
520 |
|
|
521 |
// Unlock this section down. |
// Unlock this section down. |
522 |
lscp_mutex_unlock(pClient->mutex); |
lscp_mutex_unlock(pClient->mutex); |
755 |
// Lock this section up. |
// Lock this section up. |
756 |
lscp_mutex_lock(pClient->mutex); |
lscp_mutex_lock(pClient->mutex); |
757 |
|
|
758 |
if (lscp_client_call(pClient, "GET CHANNELS\r\n") == LSCP_OK) |
if (lscp_client_call(pClient, "GET CHANNELS\r\n", 0) == LSCP_OK) |
759 |
iChannels = atoi(lscp_client_get_result(pClient)); |
iChannels = atoi(lscp_client_get_result(pClient)); |
760 |
|
|
761 |
// Unlock this section doen. |
// Unlock this section doen. |
789 |
pClient->channels = NULL; |
pClient->channels = NULL; |
790 |
} |
} |
791 |
|
|
792 |
if (lscp_client_call(pClient, "LIST CHANNELS\r\n") == LSCP_OK) |
if (lscp_client_call(pClient, "LIST CHANNELS\r\n", 0) == LSCP_OK) |
793 |
pClient->channels = lscp_isplit_create(lscp_client_get_result(pClient), pszSeps); |
pClient->channels = lscp_isplit_create(lscp_client_get_result(pClient), pszSeps); |
794 |
|
|
795 |
// Unlock this section down. |
// Unlock this section down. |
815 |
// Lock this section up. |
// Lock this section up. |
816 |
lscp_mutex_lock(pClient->mutex); |
lscp_mutex_lock(pClient->mutex); |
817 |
|
|
818 |
if (lscp_client_call(pClient, "ADD CHANNEL\r\n") == LSCP_OK) |
if (lscp_client_call(pClient, "ADD CHANNEL\r\n", 0) == LSCP_OK) |
819 |
iSamplerChannel = atoi(lscp_client_get_result(pClient)); |
iSamplerChannel = atoi(lscp_client_get_result(pClient)); |
820 |
|
|
821 |
// Unlock this section down. |
// Unlock this section down. |
862 |
// Lock this section up. |
// Lock this section up. |
863 |
lscp_mutex_lock(pClient->mutex); |
lscp_mutex_lock(pClient->mutex); |
864 |
|
|
865 |
if (lscp_client_call(pClient, "GET AVAILABLE_ENGINES\r\n") == LSCP_OK) |
if (lscp_client_call(pClient, "GET AVAILABLE_ENGINES\r\n", 0) == LSCP_OK) |
866 |
iAvailableEngines = atoi(lscp_client_get_result(pClient)); |
iAvailableEngines = atoi(lscp_client_get_result(pClient)); |
867 |
|
|
868 |
// Unlock this section down. |
// Unlock this section down. |
893 |
pClient->engines = NULL; |
pClient->engines = NULL; |
894 |
} |
} |
895 |
|
|
896 |
if (lscp_client_call(pClient, "LIST AVAILABLE_ENGINES\r\n") == LSCP_OK) |
if (lscp_client_call(pClient, "LIST AVAILABLE_ENGINES\r\n", 0) == LSCP_OK) |
897 |
pClient->engines = lscp_szsplit_create(lscp_client_get_result(pClient), pszSeps); |
pClient->engines = lscp_szsplit_create(lscp_client_get_result(pClient), pszSeps); |
898 |
|
|
899 |
// Unlock this section down. |
// Unlock this section down. |
933 |
lscp_engine_info_reset(pEngineInfo); |
lscp_engine_info_reset(pEngineInfo); |
934 |
|
|
935 |
sprintf(szQuery, "GET ENGINE INFO %s\r\n", pszEngineName); |
sprintf(szQuery, "GET ENGINE INFO %s\r\n", pszEngineName); |
936 |
if (lscp_client_call(pClient, szQuery) == LSCP_OK) { |
if (lscp_client_call(pClient, szQuery, 1) == LSCP_OK) { |
937 |
pszResult = lscp_client_get_result(pClient); |
pszResult = lscp_client_get_result(pClient); |
938 |
pszToken = lscp_strtok((char *) pszResult, pszSeps, &(pch)); |
pszToken = lscp_strtok((char *) pszResult, pszSeps, &(pch)); |
939 |
while (pszToken) { |
while (pszToken) { |
989 |
lscp_channel_info_reset(pChannelInfo); |
lscp_channel_info_reset(pChannelInfo); |
990 |
|
|
991 |
sprintf(szQuery, "GET CHANNEL INFO %d\r\n", iSamplerChannel); |
sprintf(szQuery, "GET CHANNEL INFO %d\r\n", iSamplerChannel); |
992 |
if (lscp_client_call(pClient, szQuery) == LSCP_OK) { |
if (lscp_client_call(pClient, szQuery, 1) == LSCP_OK) { |
993 |
pszResult = lscp_client_get_result(pClient); |
pszResult = lscp_client_get_result(pClient); |
994 |
pszToken = lscp_strtok((char *) pszResult, pszSeps, &(pch)); |
pszToken = lscp_strtok((char *) pszResult, pszSeps, &(pch)); |
995 |
while (pszToken) { |
while (pszToken) { |
1104 |
lscp_mutex_lock(pClient->mutex); |
lscp_mutex_lock(pClient->mutex); |
1105 |
|
|
1106 |
sprintf(szQuery, "GET CHANNEL VOICE_COUNT %d\r\n", iSamplerChannel); |
sprintf(szQuery, "GET CHANNEL VOICE_COUNT %d\r\n", iSamplerChannel); |
1107 |
if (lscp_client_call(pClient, szQuery) == LSCP_OK) |
if (lscp_client_call(pClient, szQuery, 0) == LSCP_OK) |
1108 |
iVoiceCount = atoi(lscp_client_get_result(pClient)); |
iVoiceCount = atoi(lscp_client_get_result(pClient)); |
1109 |
|
|
1110 |
// Unlock this section down. |
// Unlock this section down. |
1135 |
lscp_mutex_lock(pClient->mutex); |
lscp_mutex_lock(pClient->mutex); |
1136 |
|
|
1137 |
sprintf(szQuery, "GET CHANNEL STREAM_COUNT %d\r\n", iSamplerChannel); |
sprintf(szQuery, "GET CHANNEL STREAM_COUNT %d\r\n", iSamplerChannel); |
1138 |
if (lscp_client_call(pClient, szQuery) == LSCP_OK) |
if (lscp_client_call(pClient, szQuery, 0) == LSCP_OK) |
1139 |
iStreamCount = atoi(lscp_client_get_result(pClient)); |
iStreamCount = atoi(lscp_client_get_result(pClient)); |
1140 |
|
|
1141 |
// Unlock this section down. |
// Unlock this section down. |
1173 |
|
|
1174 |
iStream = 0; |
iStream = 0; |
1175 |
sprintf(szQuery, "GET CHANNEL BUFFER_FILL PERCENTAGE %d\r\n", iSamplerChannel); |
sprintf(szQuery, "GET CHANNEL BUFFER_FILL PERCENTAGE %d\r\n", iSamplerChannel); |
1176 |
if (lscp_client_call(pClient, szQuery) == LSCP_OK) { |
if (lscp_client_call(pClient, szQuery, 0) == LSCP_OK) { |
1177 |
pszResult = lscp_client_get_result(pClient); |
pszResult = lscp_client_get_result(pClient); |
1178 |
pszToken = lscp_strtok((char *) pszResult, pszSeps, &(pch)); |
pszToken = lscp_strtok((char *) pszResult, pszSeps, &(pch)); |
1179 |
while (pszToken) { |
while (pszToken) { |
1250 |
iStream = 0; |
iStream = 0; |
1251 |
pBufferFill = pClient->buffer_fill; |
pBufferFill = pClient->buffer_fill; |
1252 |
sprintf(szQuery, "GET CHANNEL BUFFER_FILL %s %d\r\n", pszUsageType, iSamplerChannel); |
sprintf(szQuery, "GET CHANNEL BUFFER_FILL %s %d\r\n", pszUsageType, iSamplerChannel); |
1253 |
if (lscp_client_call(pClient, szQuery) == LSCP_OK) { |
if (lscp_client_call(pClient, szQuery, 0) == LSCP_OK) { |
1254 |
pszResult = lscp_client_get_result(pClient); |
pszResult = lscp_client_get_result(pClient); |
1255 |
pszToken = lscp_strtok((char *) pszResult, pszSeps, &(pch)); |
pszToken = lscp_strtok((char *) pszResult, pszSeps, &(pch)); |
1256 |
while (pszToken && iStream < pClient->iStreamCount) { |
while (pszToken && iStream < pClient->iStreamCount) { |
1566 |
pServerInfo = &(pClient->server_info); |
pServerInfo = &(pClient->server_info); |
1567 |
lscp_server_info_reset(pServerInfo); |
lscp_server_info_reset(pServerInfo); |
1568 |
|
|
1569 |
if (lscp_client_call(pClient, "GET SERVER INFO\r\n") == LSCP_OK) { |
if (lscp_client_call(pClient, "GET SERVER INFO\r\n", 1) == LSCP_OK) { |
1570 |
pszResult = lscp_client_get_result(pClient); |
pszResult = lscp_client_get_result(pClient); |
1571 |
pszToken = lscp_strtok((char *) pszResult, pszSeps, &(pch)); |
pszToken = lscp_strtok((char *) pszResult, pszSeps, &(pch)); |
1572 |
while (pszToken) { |
while (pszToken) { |
1608 |
// Lock this section up. |
// Lock this section up. |
1609 |
lscp_mutex_lock(pClient->mutex); |
lscp_mutex_lock(pClient->mutex); |
1610 |
|
|
1611 |
if (lscp_client_call(pClient, "GET TOTAL_VOICE_COUNT\r\n") == LSCP_OK) |
if (lscp_client_call(pClient, "GET TOTAL_VOICE_COUNT\r\n", 0) == LSCP_OK) |
1612 |
iVoiceCount = atoi(lscp_client_get_result(pClient)); |
iVoiceCount = atoi(lscp_client_get_result(pClient)); |
1613 |
|
|
1614 |
// Unlock this section down. |
// Unlock this section down. |
1634 |
// Lock this section up. |
// Lock this section up. |
1635 |
lscp_mutex_lock(pClient->mutex); |
lscp_mutex_lock(pClient->mutex); |
1636 |
|
|
1637 |
if (lscp_client_call(pClient, "GET TOTAL_VOICE_COUNT_MAX\r\n") == LSCP_OK) |
if (lscp_client_call(pClient, "GET TOTAL_VOICE_COUNT_MAX\r\n", 0) == LSCP_OK) |
1638 |
iVoiceCount = atoi(lscp_client_get_result(pClient)); |
iVoiceCount = atoi(lscp_client_get_result(pClient)); |
1639 |
|
|
1640 |
// Unlock this section down. |
// Unlock this section down. |
1670 |
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 ) |
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 ) |
1671 |
{ |
{ |
1672 |
char szQuery[LSCP_BUFSIZ]; |
char szQuery[LSCP_BUFSIZ]; |
1673 |
|
|
1674 |
if (pMidiInstr->bank_msb < 0 || pMidiInstr->bank_msb > 127) |
if (pMidiInstr->bank_msb < 0 || pMidiInstr->bank_msb > 127) |
1675 |
return LSCP_FAILED; |
return LSCP_FAILED; |
1676 |
if (pMidiInstr->bank_lsb < 0 || pMidiInstr->bank_lsb > 127) |
if (pMidiInstr->bank_lsb < 0 || pMidiInstr->bank_lsb > 127) |
1679 |
return LSCP_FAILED; |
return LSCP_FAILED; |
1680 |
if (pszEngineName == NULL || pszFileName == NULL) |
if (pszEngineName == NULL || pszFileName == NULL) |
1681 |
return LSCP_FAILED; |
return LSCP_FAILED; |
1682 |
|
|
1683 |
if (fVolume < 0.0f) |
if (fVolume < 0.0f) |
1684 |
fVolume = 1.0f; |
fVolume = 1.0f; |
1685 |
|
|
1686 |
sprintf(szQuery, "MAP MIDI_INSTRUMENT %d %d %d %s '%s' %d %g", |
sprintf(szQuery, "MAP MIDI_INSTRUMENT %d %d %d %s '%s' %d %g", |
1687 |
pMidiInstr->bank_msb, pMidiInstr->bank_lsb, pMidiInstr->program, |
pMidiInstr->bank_msb, pMidiInstr->bank_lsb, pMidiInstr->program, |
1688 |
pszEngineName, pszFileName, iInstrIndex, fVolume); |
pszEngineName, pszFileName, iInstrIndex, fVolume); |
1689 |
|
|
1690 |
switch (load_mode) { |
switch (load_mode) { |
1691 |
case LSCP_LOAD_PERSISTENT: |
case LSCP_LOAD_PERSISTENT: |
1692 |
strcat(szQuery, " PERSISTENT"); |
strcat(szQuery, " PERSISTENT"); |
1693 |
break; |
break; |
1694 |
case LSCP_LOAD_ON_DEMAND_HOLD: |
case LSCP_LOAD_ON_DEMAND_HOLD: |
1695 |
strcat(szQuery, " ON_DEMAND_HOLD"); |
strcat(szQuery, " ON_DEMAND_HOLD"); |
1696 |
break; |
break; |
1697 |
case LSCP_LOAD_ON_DEMAND: |
case LSCP_LOAD_ON_DEMAND: |
1698 |
strcat(szQuery, " ON_DEMAND_HOLD"); |
strcat(szQuery, " ON_DEMAND_HOLD"); |
1699 |
break; |
break; |
1700 |
case LSCP_LOAD_DEFAULT: |
case LSCP_LOAD_DEFAULT: |
1701 |
default: |
default: |
1702 |
break; |
break; |
1703 |
} |
} |
1704 |
|
|
1705 |
if (pszName) |
if (pszName) |
1706 |
sprintf(szQuery + strlen(szQuery), " '%s'", pszName); |
sprintf(szQuery + strlen(szQuery), " '%s'", pszName); |
1707 |
|
|
1708 |
strcat(szQuery, "\r\n"); |
strcat(szQuery, "\r\n"); |
1709 |
|
|
1710 |
return lscp_client_query(pClient, szQuery); |
return lscp_client_query(pClient, szQuery); |
1711 |
} |
} |
1712 |
|
|
1754 |
// Lock this section up. |
// Lock this section up. |
1755 |
lscp_mutex_lock(pClient->mutex); |
lscp_mutex_lock(pClient->mutex); |
1756 |
|
|
1757 |
if (lscp_client_call(pClient, "GET MIDI_INSTRUMENTS\r\n") == LSCP_OK) |
if (lscp_client_call(pClient, "GET MIDI_INSTRUMENTS\r\n", 0) == LSCP_OK) |
1758 |
iInstruments = atoi(lscp_client_get_result(pClient)); |
iInstruments = atoi(lscp_client_get_result(pClient)); |
1759 |
|
|
1760 |
// Unlock this section down. |
// Unlock this section down. |
1765 |
|
|
1766 |
|
|
1767 |
/** |
/** |
1768 |
|
* Getting indeces of all MIDI instrument map entries: |
1769 |
|
* LIST MIDI_INSTRUMENTS |
1770 |
|
* |
1771 |
|
* @param pClient Pointer to client instance structure. |
1772 |
|
* |
1773 |
|
* @returns An array of @ref lscp_midi_instrument_t, terminated with the |
1774 |
|
* {-1,-1,-1} triplet, NULL otherwise. |
1775 |
|
*/ |
1776 |
|
lscp_midi_instrument_t *lscp_list_midi_instruments ( lscp_client_t *pClient ) |
1777 |
|
{ |
1778 |
|
if (pClient == NULL) |
1779 |
|
return NULL; |
1780 |
|
|
1781 |
|
// Lock this section up. |
1782 |
|
lscp_mutex_lock(pClient->mutex); |
1783 |
|
|
1784 |
|
if (pClient->midi_instruments) { |
1785 |
|
lscp_midi_instruments_destroy(pClient->midi_instruments); |
1786 |
|
pClient->midi_instruments = NULL; |
1787 |
|
} |
1788 |
|
|
1789 |
|
if (lscp_client_call(pClient, "LIST MIDI_INSTRUMENTS\r\n", 0) == LSCP_OK) |
1790 |
|
pClient->midi_instruments = lscp_midi_instruments_create(lscp_client_get_result(pClient)); |
1791 |
|
|
1792 |
|
// Unlock this section down. |
1793 |
|
lscp_mutex_unlock(pClient->mutex); |
1794 |
|
|
1795 |
|
return pClient->midi_instruments; |
1796 |
|
} |
1797 |
|
|
1798 |
|
|
1799 |
|
/** |
1800 |
* Getting information about a MIDI instrument map entry: |
* Getting information about a MIDI instrument map entry: |
1801 |
* GET MIDI_INSTRUMENT INFO <midi-bank-msb> <midi-bank-lsb> <midi-prog> |
* GET MIDI_INSTRUMENT INFO <midi-bank-msb> <midi-bank-lsb> <midi-prog> |
1802 |
* |
* |
1816 |
const char *pszCrlf = "\r\n"; |
const char *pszCrlf = "\r\n"; |
1817 |
char *pszToken; |
char *pszToken; |
1818 |
char *pch; |
char *pch; |
1819 |
|
|
1820 |
if (pMidiInstr->bank_msb < 0 || pMidiInstr->bank_msb > 127) |
if (pMidiInstr->bank_msb < 0 || pMidiInstr->bank_msb > 127) |
1821 |
return NULL; |
return NULL; |
1822 |
if (pMidiInstr->bank_lsb < 0 || pMidiInstr->bank_lsb > 127) |
if (pMidiInstr->bank_lsb < 0 || pMidiInstr->bank_lsb > 127) |
1823 |
return NULL; |
return NULL; |
1824 |
if (pMidiInstr->program < 0 || pMidiInstr->program > 127) |
if (pMidiInstr->program < 0 || pMidiInstr->program > 127) |
1825 |
return NULL; |
return NULL; |
1826 |
|
|
1827 |
// Lock this section up. |
// Lock this section up. |
1828 |
lscp_mutex_lock(pClient->mutex); |
lscp_mutex_lock(pClient->mutex); |
1829 |
|
|
1830 |
pInstrInfo = &(pClient->midi_instrument_info); |
pInstrInfo = &(pClient->midi_instrument_info); |
1831 |
lscp_midi_instrument_info_reset(pInstrInfo); |
lscp_midi_instrument_info_reset(pInstrInfo); |
1832 |
|
|
1833 |
sprintf(szQuery, "GET MIDI_INSTRUMENT INFO %d %d %d\r\n", |
sprintf(szQuery, "GET MIDI_INSTRUMENT INFO %d %d %d\r\n", |
1834 |
pMidiInstr->bank_msb, pMidiInstr->bank_lsb, pMidiInstr->program); |
pMidiInstr->bank_msb, pMidiInstr->bank_lsb, pMidiInstr->program); |
1835 |
if (lscp_client_call(pClient, szQuery) == LSCP_OK) { |
if (lscp_client_call(pClient, szQuery, 1) == LSCP_OK) { |
1836 |
pszResult = lscp_client_get_result(pClient); |
pszResult = lscp_client_get_result(pClient); |
1837 |
pszToken = lscp_strtok((char *) pszResult, pszSeps, &(pch)); |
pszToken = lscp_strtok((char *) pszResult, pszSeps, &(pch)); |
1838 |
while (pszToken) { |
while (pszToken) { |
1883 |
pInstrInfo->volume = (float) atof(lscp_ltrim(pszToken)); |
pInstrInfo->volume = (float) atof(lscp_ltrim(pszToken)); |
1884 |
} |
} |
1885 |
pszToken = lscp_strtok(NULL, pszSeps, &(pch)); |
pszToken = lscp_strtok(NULL, pszSeps, &(pch)); |
1886 |
} |
} |
1887 |
} |
} |
1888 |
else pInstrInfo = NULL; |
else pInstrInfo = NULL; |
1889 |
|
|
1890 |
// Unlock this section down. |
// Unlock this section down. |
1891 |
lscp_mutex_unlock(pClient->mutex); |
lscp_mutex_unlock(pClient->mutex); |
1892 |
|
|
1893 |
return pInstrInfo; |
return pInstrInfo; |
1894 |
} |
} |
1895 |
|
|