662 |
String AudioRouting; |
String AudioRouting; |
663 |
int Mute = 0; |
int Mute = 0; |
664 |
bool Solo = false; |
bool Solo = false; |
665 |
|
String MidiInstrumentMap; |
666 |
|
|
667 |
if (pEngineChannel) { |
if (pEngineChannel) { |
668 |
EngineName = pEngineChannel->EngineName(); |
EngineName = pEngineChannel->EngineName(); |
680 |
} |
} |
681 |
Mute = pEngineChannel->GetMute(); |
Mute = pEngineChannel->GetMute(); |
682 |
Solo = pEngineChannel->GetSolo(); |
Solo = pEngineChannel->GetSolo(); |
683 |
|
if (pEngineChannel->UsesNoMidiInstrumentMap()) |
684 |
|
MidiInstrumentMap = "NONE"; |
685 |
|
else if (pEngineChannel->UsesDefaultMidiInstrumentMap()) |
686 |
|
MidiInstrumentMap = "DEFAULT"; |
687 |
|
else |
688 |
|
MidiInstrumentMap = ToString(pEngineChannel->GetMidiInstrumentMap()); |
689 |
} |
} |
690 |
|
|
691 |
result.Add("ENGINE_NAME", EngineName); |
result.Add("ENGINE_NAME", EngineName); |
707 |
result.Add("INSTRUMENT_STATUS", InstrumentStatus); |
result.Add("INSTRUMENT_STATUS", InstrumentStatus); |
708 |
result.Add("MUTE", Mute == -1 ? "MUTED_BY_SOLO" : (Mute ? "true" : "false")); |
result.Add("MUTE", Mute == -1 ? "MUTED_BY_SOLO" : (Mute ? "true" : "false")); |
709 |
result.Add("SOLO", Solo); |
result.Add("SOLO", Solo); |
710 |
|
result.Add("MIDI_INSTRUMENT_MAP", MidiInstrumentMap); |
711 |
} |
} |
712 |
catch (Exception e) { |
catch (Exception e) { |
713 |
result.Error(e); |
result.Error(e); |
1555 |
} |
} |
1556 |
} |
} |
1557 |
|
|
1558 |
String LSCPServer::AddOrReplaceMIDIInstrumentMapping(uint MidiBankMSB, uint MidiBankLSB, uint MidiProg, String EngineType, String InstrumentFile, uint InstrumentIndex, float Volume, MidiInstrumentMapper::mode_t LoadMode, String Name) { |
String LSCPServer::AddOrReplaceMIDIInstrumentMapping(uint MidiMapID, uint MidiBank, uint MidiProg, String EngineType, String InstrumentFile, uint InstrumentIndex, float Volume, MidiInstrumentMapper::mode_t LoadMode, String Name) { |
1559 |
dmsg(2,("LSCPServer: AddOrReplaceMIDIInstrumentMapping()\n")); |
dmsg(2,("LSCPServer: AddOrReplaceMIDIInstrumentMapping()\n")); |
1560 |
|
|
1561 |
midi_prog_index_t idx; |
midi_prog_index_t idx; |
1562 |
idx.midi_bank_msb = MidiBankMSB; |
idx.midi_bank_msb = (MidiBank >> 7) & 0x7f; |
1563 |
idx.midi_bank_lsb = MidiBankLSB; |
idx.midi_bank_lsb = MidiBank & 0x7f; |
1564 |
idx.midi_prog = MidiProg; |
idx.midi_prog = MidiProg; |
1565 |
|
|
1566 |
MidiInstrumentMapper::entry_t entry; |
MidiInstrumentMapper::entry_t entry; |
1576 |
// PERSISTENT mapping commands might bloock for a long time, so in |
// PERSISTENT mapping commands might bloock for a long time, so in |
1577 |
// that case we add/replace the mapping in another thread |
// that case we add/replace the mapping in another thread |
1578 |
bool bInBackground = (entry.LoadMode == MidiInstrumentMapper::PERSISTENT); |
bool bInBackground = (entry.LoadMode == MidiInstrumentMapper::PERSISTENT); |
1579 |
MidiInstrumentMapper::AddOrReplaceMapping(idx, entry, bInBackground); |
MidiInstrumentMapper::AddOrReplaceEntry(MidiMapID, idx, entry, bInBackground); |
1580 |
} catch (Exception e) { |
} catch (Exception e) { |
1581 |
result.Error(e); |
result.Error(e); |
1582 |
} |
} |
1583 |
return result.Produce(); |
return result.Produce(); |
1584 |
} |
} |
1585 |
|
|
1586 |
String LSCPServer::RemoveMIDIInstrumentMapping(uint MidiBankMSB, uint MidiBankLSB, uint MidiProg) { |
String LSCPServer::RemoveMIDIInstrumentMapping(uint MidiMapID, uint MidiBank, uint MidiProg) { |
1587 |
dmsg(2,("LSCPServer: RemoveMIDIInstrumentMapping()\n")); |
dmsg(2,("LSCPServer: RemoveMIDIInstrumentMapping()\n")); |
1588 |
|
|
1589 |
midi_prog_index_t idx; |
midi_prog_index_t idx; |
1590 |
idx.midi_bank_msb = MidiBankMSB; |
idx.midi_bank_msb = (MidiBank >> 7) & 0x7f; |
1591 |
idx.midi_bank_lsb = MidiBankLSB; |
idx.midi_bank_lsb = MidiBank & 0x7f; |
1592 |
idx.midi_prog = MidiProg; |
idx.midi_prog = MidiProg; |
1593 |
|
|
1594 |
LSCPResultSet result; |
LSCPResultSet result; |
1595 |
try { |
try { |
1596 |
MidiInstrumentMapper::RemoveMapping(idx); |
MidiInstrumentMapper::RemoveEntry(MidiMapID, idx); |
1597 |
} catch (Exception e) { |
} catch (Exception e) { |
1598 |
result.Error(e); |
result.Error(e); |
1599 |
} |
} |
1600 |
return result.Produce(); |
return result.Produce(); |
1601 |
} |
} |
1602 |
|
|
1603 |
String LSCPServer::GetMidiIstrumentMappings() { |
String LSCPServer::GetMidiInstrumentMappings(uint MidiMapID) { |
1604 |
dmsg(2,("LSCPServer: GetMidiIstrumentMappings()\n")); |
dmsg(2,("LSCPServer: GetMidiInstrumentMappings()\n")); |
1605 |
LSCPResultSet result; |
LSCPResultSet result; |
1606 |
result.Add(MidiInstrumentMapper::Mappings().size()); |
try { |
1607 |
|
result.Add(MidiInstrumentMapper::Entries(MidiMapID).size()); |
1608 |
|
} catch (Exception e) { |
1609 |
|
result.Error(e); |
1610 |
|
} |
1611 |
return result.Produce(); |
return result.Produce(); |
1612 |
} |
} |
1613 |
|
|
1614 |
String LSCPServer::GetMidiInstrumentMapping(uint MidiBankMSB, uint MidiBankLSB, uint MidiProg) { |
|
1615 |
|
String LSCPServer::GetAllMidiInstrumentMappings() { |
1616 |
|
dmsg(2,("LSCPServer: GetAllMidiInstrumentMappings()\n")); |
1617 |
|
LSCPResultSet result; |
1618 |
|
std::vector<int> maps = MidiInstrumentMapper::Maps(); |
1619 |
|
int totalMappings = 0; |
1620 |
|
for (int i = 0; i < maps.size(); i++) { |
1621 |
|
try { |
1622 |
|
totalMappings += MidiInstrumentMapper::Entries(maps[i]).size(); |
1623 |
|
} catch (Exception e) { /*NOOP*/ } |
1624 |
|
} |
1625 |
|
result.Add(totalMappings); |
1626 |
|
return result.Produce(); |
1627 |
|
} |
1628 |
|
|
1629 |
|
String LSCPServer::GetMidiInstrumentMapping(uint MidiMapID, uint MidiBank, uint MidiProg) { |
1630 |
dmsg(2,("LSCPServer: GetMidiIstrumentMapping()\n")); |
dmsg(2,("LSCPServer: GetMidiIstrumentMapping()\n")); |
1631 |
LSCPResultSet result; |
LSCPResultSet result; |
1632 |
try { |
try { |
1633 |
midi_prog_index_t idx; |
midi_prog_index_t idx; |
1634 |
idx.midi_bank_msb = MidiBankMSB; |
idx.midi_bank_msb = (MidiBank >> 7) & 0x7f; |
1635 |
idx.midi_bank_lsb = MidiBankLSB; |
idx.midi_bank_lsb = MidiBank & 0x7f; |
1636 |
idx.midi_prog = MidiProg; |
idx.midi_prog = MidiProg; |
1637 |
|
|
1638 |
std::map<midi_prog_index_t,MidiInstrumentMapper::entry_t> mappings = MidiInstrumentMapper::Mappings(); |
std::map<midi_prog_index_t,MidiInstrumentMapper::entry_t> mappings = MidiInstrumentMapper::Entries(MidiMapID); |
1639 |
std::map<midi_prog_index_t,MidiInstrumentMapper::entry_t>::iterator iter = mappings.find(idx); |
std::map<midi_prog_index_t,MidiInstrumentMapper::entry_t>::iterator iter = mappings.find(idx); |
1640 |
if (iter == mappings.end()) result.Error("there is no map entry with that index"); |
if (iter == mappings.end()) result.Error("there is no map entry with that index"); |
1641 |
else { // found |
else { // found |
1676 |
return result.Produce(); |
return result.Produce(); |
1677 |
} |
} |
1678 |
|
|
1679 |
String LSCPServer::ListMidiInstrumentMappings() { |
String LSCPServer::ListMidiInstrumentMappings(uint MidiMapID) { |
1680 |
dmsg(2,("LSCPServer: ListMidiIstrumentMappings()\n")); |
dmsg(2,("LSCPServer: ListMidiInstrumentMappings()\n")); |
1681 |
LSCPResultSet result; |
LSCPResultSet result; |
1682 |
try { |
try { |
1683 |
String s; |
String s; |
1684 |
std::map<midi_prog_index_t,MidiInstrumentMapper::entry_t> mappings = MidiInstrumentMapper::Mappings(); |
std::map<midi_prog_index_t,MidiInstrumentMapper::entry_t> mappings = MidiInstrumentMapper::Entries(MidiMapID); |
1685 |
std::map<midi_prog_index_t,MidiInstrumentMapper::entry_t>::iterator iter = mappings.begin(); |
std::map<midi_prog_index_t,MidiInstrumentMapper::entry_t>::iterator iter = mappings.begin(); |
1686 |
for (; iter != mappings.end(); iter++) { |
for (; iter != mappings.end(); iter++) { |
1687 |
if (s.size()) s += ","; |
if (s.size()) s += ","; |
1688 |
s += "{" + ToString(int(iter->first.midi_bank_msb)) + "," |
s += "{" + ToString(MidiMapID) + "," |
1689 |
+ ToString(int(iter->first.midi_bank_lsb)) + "," |
+ ToString((int(iter->first.midi_bank_msb) << 7) & int(iter->first.midi_bank_lsb)) + "," |
1690 |
+ ToString(int(iter->first.midi_prog)) + "}"; |
+ ToString(int(iter->first.midi_prog)) + "}"; |
1691 |
|
} |
1692 |
|
result.Add(s); |
1693 |
|
} catch (Exception e) { |
1694 |
|
result.Error(e); |
1695 |
|
} |
1696 |
|
return result.Produce(); |
1697 |
|
} |
1698 |
|
|
1699 |
|
String LSCPServer::ListAllMidiInstrumentMappings() { |
1700 |
|
dmsg(2,("LSCPServer: ListAllMidiInstrumentMappings()\n")); |
1701 |
|
LSCPResultSet result; |
1702 |
|
try { |
1703 |
|
std::vector<int> maps = MidiInstrumentMapper::Maps(); |
1704 |
|
String s; |
1705 |
|
for (int i = 0; i < maps.size(); i++) { |
1706 |
|
std::map<midi_prog_index_t,MidiInstrumentMapper::entry_t> mappings = MidiInstrumentMapper::Entries(maps[i]); |
1707 |
|
std::map<midi_prog_index_t,MidiInstrumentMapper::entry_t>::iterator iter = mappings.begin(); |
1708 |
|
for (; iter != mappings.end(); iter++) { |
1709 |
|
if (s.size()) s += ","; |
1710 |
|
s += "{" + ToString(maps[i]) + "," |
1711 |
|
+ ToString((int(iter->first.midi_bank_msb) << 7) & int(iter->first.midi_bank_lsb)) + "," |
1712 |
|
+ ToString(int(iter->first.midi_prog)) + "}"; |
1713 |
|
} |
1714 |
} |
} |
1715 |
result.Add(s); |
result.Add(s); |
1716 |
} catch (Exception e) { |
} catch (Exception e) { |
1719 |
return result.Produce(); |
return result.Produce(); |
1720 |
} |
} |
1721 |
|
|
1722 |
String LSCPServer::ClearMidiInstrumentMappings() { |
String LSCPServer::ClearMidiInstrumentMappings(uint MidiMapID) { |
1723 |
dmsg(2,("LSCPServer: ClearMidiInstrumentMappings()\n")); |
dmsg(2,("LSCPServer: ClearMidiInstrumentMappings()\n")); |
1724 |
LSCPResultSet result; |
LSCPResultSet result; |
1725 |
try { |
try { |
1726 |
MidiInstrumentMapper::RemoveAllMappings(); |
MidiInstrumentMapper::RemoveAllEntries(MidiMapID); |
1727 |
|
} catch (Exception e) { |
1728 |
|
result.Error(e); |
1729 |
|
} |
1730 |
|
return result.Produce(); |
1731 |
|
} |
1732 |
|
|
1733 |
|
String LSCPServer::ClearAllMidiInstrumentMappings() { |
1734 |
|
dmsg(2,("LSCPServer: ClearAllMidiInstrumentMappings()\n")); |
1735 |
|
LSCPResultSet result; |
1736 |
|
try { |
1737 |
|
std::vector<int> maps = MidiInstrumentMapper::Maps(); |
1738 |
|
for (int i = 0; i < maps.size(); i++) |
1739 |
|
MidiInstrumentMapper::RemoveAllEntries(maps[i]); |
1740 |
|
} catch (Exception e) { |
1741 |
|
result.Error(e); |
1742 |
|
} |
1743 |
|
return result.Produce(); |
1744 |
|
} |
1745 |
|
|
1746 |
|
String LSCPServer::AddMidiInstrumentMap(String MapName) { |
1747 |
|
dmsg(2,("LSCPServer: AddMidiInstrumentMap()\n")); |
1748 |
|
LSCPResultSet result; |
1749 |
|
try { |
1750 |
|
int MapID = MidiInstrumentMapper::AddMap(MapName); |
1751 |
|
result = LSCPResultSet(MapID); |
1752 |
|
} catch (Exception e) { |
1753 |
|
result.Error(e); |
1754 |
|
} |
1755 |
|
return result.Produce(); |
1756 |
|
} |
1757 |
|
|
1758 |
|
String LSCPServer::RemoveMidiInstrumentMap(uint MidiMapID) { |
1759 |
|
dmsg(2,("LSCPServer: RemoveMidiInstrumentMap()\n")); |
1760 |
|
LSCPResultSet result; |
1761 |
|
try { |
1762 |
|
MidiInstrumentMapper::RemoveMap(MidiMapID); |
1763 |
|
} catch (Exception e) { |
1764 |
|
result.Error(e); |
1765 |
|
} |
1766 |
|
return result.Produce(); |
1767 |
|
} |
1768 |
|
|
1769 |
|
String LSCPServer::RemoveAllMidiInstrumentMaps() { |
1770 |
|
dmsg(2,("LSCPServer: RemoveAllMidiInstrumentMaps()\n")); |
1771 |
|
LSCPResultSet result; |
1772 |
|
try { |
1773 |
|
MidiInstrumentMapper::RemoveAllMaps(); |
1774 |
|
} catch (Exception e) { |
1775 |
|
result.Error(e); |
1776 |
|
} |
1777 |
|
return result.Produce(); |
1778 |
|
} |
1779 |
|
|
1780 |
|
String LSCPServer::GetMidiInstrumentMaps() { |
1781 |
|
dmsg(2,("LSCPServer: GetMidiInstrumentMaps()\n")); |
1782 |
|
LSCPResultSet result; |
1783 |
|
try { |
1784 |
|
result.Add(MidiInstrumentMapper::Maps().size()); |
1785 |
|
} catch (Exception e) { |
1786 |
|
result.Error(e); |
1787 |
|
} |
1788 |
|
return result.Produce(); |
1789 |
|
} |
1790 |
|
|
1791 |
|
String LSCPServer::ListMidiInstrumentMaps() { |
1792 |
|
dmsg(2,("LSCPServer: ListMidiInstrumentMaps()\n")); |
1793 |
|
LSCPResultSet result; |
1794 |
|
try { |
1795 |
|
std::vector<int> maps = MidiInstrumentMapper::Maps(); |
1796 |
|
String sList; |
1797 |
|
for (int i = 0; i < maps.size(); i++) { |
1798 |
|
if (sList != "") sList += ","; |
1799 |
|
sList += ToString(maps[i]); |
1800 |
|
} |
1801 |
|
result.Add(sList); |
1802 |
|
} catch (Exception e) { |
1803 |
|
result.Error(e); |
1804 |
|
} |
1805 |
|
return result.Produce(); |
1806 |
|
} |
1807 |
|
|
1808 |
|
String LSCPServer::GetMidiInstrumentMap(uint MidiMapID) { |
1809 |
|
dmsg(2,("LSCPServer: GetMidiInstrumentMap()\n")); |
1810 |
|
LSCPResultSet result; |
1811 |
|
try { |
1812 |
|
result.Add("NAME", MidiInstrumentMapper::MapName(MidiMapID)); |
1813 |
|
} catch (Exception e) { |
1814 |
|
result.Error(e); |
1815 |
|
} |
1816 |
|
return result.Produce(); |
1817 |
|
} |
1818 |
|
|
1819 |
|
String LSCPServer::SetMidiInstrumentMapName(uint MidiMapID, String NewName) { |
1820 |
|
dmsg(2,("LSCPServer: SetMidiInstrumentMapName()\n")); |
1821 |
|
LSCPResultSet result; |
1822 |
|
try { |
1823 |
|
MidiInstrumentMapper::RenameMap(MidiMapID, NewName); |
1824 |
|
} catch (Exception e) { |
1825 |
|
result.Error(e); |
1826 |
|
} |
1827 |
|
return result.Produce(); |
1828 |
|
} |
1829 |
|
|
1830 |
|
/** |
1831 |
|
* Set the MIDI instrument map the given sampler channel shall use for |
1832 |
|
* handling MIDI program change messages. There are the following two |
1833 |
|
* special (negative) values: |
1834 |
|
* |
1835 |
|
* - (-1) : set to NONE (ignore program changes) |
1836 |
|
* - (-2) : set to DEFAULT map |
1837 |
|
*/ |
1838 |
|
String LSCPServer::SetChannelMap(uint uiSamplerChannel, int MidiMapID) { |
1839 |
|
dmsg(2,("LSCPServer: SetChannelMap()\n")); |
1840 |
|
LSCPResultSet result; |
1841 |
|
try { |
1842 |
|
SamplerChannel* pSamplerChannel = pSampler->GetSamplerChannel(uiSamplerChannel); |
1843 |
|
if (!pSamplerChannel) throw Exception("Invalid sampler channel number " + ToString(uiSamplerChannel)); |
1844 |
|
|
1845 |
|
EngineChannel* pEngineChannel = pSamplerChannel->GetEngineChannel(); |
1846 |
|
if (!pEngineChannel) throw Exception("There is no engine deployed on this sampler channel yet"); |
1847 |
|
|
1848 |
|
if (MidiMapID == -1) pEngineChannel->SetMidiInstrumentMapToNone(); |
1849 |
|
else if (MidiMapID == -2) pEngineChannel->SetMidiInstrumentMapToDefault(); |
1850 |
|
else pEngineChannel->SetMidiInstrumentMap(MidiMapID); |
1851 |
} catch (Exception e) { |
} catch (Exception e) { |
1852 |
result.Error(e); |
result.Error(e); |
1853 |
} |
} |