3 |
* LinuxSampler - modular, streaming capable sampler * |
* LinuxSampler - modular, streaming capable sampler * |
4 |
* * |
* * |
5 |
* Copyright (C) 2003, 2004 by Benno Senoner and Christian Schoenebeck * |
* Copyright (C) 2003, 2004 by Benno Senoner and Christian Schoenebeck * |
6 |
* Copyright (C) 2005, 2006 Christian Schoenebeck * |
* Copyright (C) 2005 - 2007 Christian Schoenebeck * |
7 |
* * |
* * |
8 |
* This library is free software; you can redistribute it and/or modify * |
* This library is free software; you can redistribute it and/or modify * |
9 |
* it under the terms of the GNU General Public License as published by * |
* it under the terms of the GNU General Public License as published by * |
24 |
#include "lscpserver.h" |
#include "lscpserver.h" |
25 |
#include "lscpresultset.h" |
#include "lscpresultset.h" |
26 |
#include "lscpevent.h" |
#include "lscpevent.h" |
27 |
//#include "../common/global.h" |
#include "../common/global.h" |
28 |
|
|
29 |
#include <fcntl.h> |
#include <fcntl.h> |
30 |
|
|
66 |
SocketAddress.sin_addr.s_addr = addr; |
SocketAddress.sin_addr.s_addr = addr; |
67 |
SocketAddress.sin_port = port; |
SocketAddress.sin_port = port; |
68 |
this->pSampler = pSampler; |
this->pSampler = pSampler; |
69 |
|
LSCPEvent::RegisterEvent(LSCPEvent::event_audio_device_count, "AUDIO_OUTPUT_DEVICE_COUNT"); |
70 |
|
LSCPEvent::RegisterEvent(LSCPEvent::event_audio_device_info, "AUDIO_OUTPUT_DEVICE_INFO"); |
71 |
|
LSCPEvent::RegisterEvent(LSCPEvent::event_midi_device_count, "MIDI_INPUT_DEVICE_COUNT"); |
72 |
|
LSCPEvent::RegisterEvent(LSCPEvent::event_midi_device_info, "MIDI_INPUT_DEVICE_INFO"); |
73 |
LSCPEvent::RegisterEvent(LSCPEvent::event_channel_count, "CHANNEL_COUNT"); |
LSCPEvent::RegisterEvent(LSCPEvent::event_channel_count, "CHANNEL_COUNT"); |
74 |
LSCPEvent::RegisterEvent(LSCPEvent::event_voice_count, "VOICE_COUNT"); |
LSCPEvent::RegisterEvent(LSCPEvent::event_voice_count, "VOICE_COUNT"); |
75 |
LSCPEvent::RegisterEvent(LSCPEvent::event_stream_count, "STREAM_COUNT"); |
LSCPEvent::RegisterEvent(LSCPEvent::event_stream_count, "STREAM_COUNT"); |
76 |
LSCPEvent::RegisterEvent(LSCPEvent::event_buffer_fill, "BUFFER_FILL"); |
LSCPEvent::RegisterEvent(LSCPEvent::event_buffer_fill, "BUFFER_FILL"); |
77 |
LSCPEvent::RegisterEvent(LSCPEvent::event_channel_info, "CHANNEL_INFO"); |
LSCPEvent::RegisterEvent(LSCPEvent::event_channel_info, "CHANNEL_INFO"); |
78 |
|
LSCPEvent::RegisterEvent(LSCPEvent::event_midi_instr_map_count, "MIDI_INSTRUMENT_MAP_COUNT"); |
79 |
|
LSCPEvent::RegisterEvent(LSCPEvent::event_midi_instr_map_info, "MIDI_INSTRUMENT_MAP_INFO"); |
80 |
|
LSCPEvent::RegisterEvent(LSCPEvent::event_midi_instr_count, "MIDI_INSTRUMENT_COUNT"); |
81 |
|
LSCPEvent::RegisterEvent(LSCPEvent::event_midi_instr_info, "MIDI_INSTRUMENT_INFO"); |
82 |
LSCPEvent::RegisterEvent(LSCPEvent::event_misc, "MISCELLANEOUS"); |
LSCPEvent::RegisterEvent(LSCPEvent::event_misc, "MISCELLANEOUS"); |
83 |
LSCPEvent::RegisterEvent(LSCPEvent::event_total_voice_count, "TOTAL_VOICE_COUNT"); |
LSCPEvent::RegisterEvent(LSCPEvent::event_total_voice_count, "TOTAL_VOICE_COUNT"); |
84 |
hSocket = -1; |
hSocket = -1; |
670 |
String AudioRouting; |
String AudioRouting; |
671 |
int Mute = 0; |
int Mute = 0; |
672 |
bool Solo = false; |
bool Solo = false; |
673 |
|
String MidiInstrumentMap; |
674 |
|
|
675 |
if (pEngineChannel) { |
if (pEngineChannel) { |
676 |
EngineName = pEngineChannel->EngineName(); |
EngineName = pEngineChannel->EngineName(); |
688 |
} |
} |
689 |
Mute = pEngineChannel->GetMute(); |
Mute = pEngineChannel->GetMute(); |
690 |
Solo = pEngineChannel->GetSolo(); |
Solo = pEngineChannel->GetSolo(); |
691 |
|
if (pEngineChannel->UsesNoMidiInstrumentMap()) |
692 |
|
MidiInstrumentMap = "NONE"; |
693 |
|
else if (pEngineChannel->UsesDefaultMidiInstrumentMap()) |
694 |
|
MidiInstrumentMap = "DEFAULT"; |
695 |
|
else |
696 |
|
MidiInstrumentMap = ToString(pEngineChannel->GetMidiInstrumentMap()); |
697 |
} |
} |
698 |
|
|
699 |
result.Add("ENGINE_NAME", EngineName); |
result.Add("ENGINE_NAME", EngineName); |
715 |
result.Add("INSTRUMENT_STATUS", InstrumentStatus); |
result.Add("INSTRUMENT_STATUS", InstrumentStatus); |
716 |
result.Add("MUTE", Mute == -1 ? "MUTED_BY_SOLO" : (Mute ? "true" : "false")); |
result.Add("MUTE", Mute == -1 ? "MUTED_BY_SOLO" : (Mute ? "true" : "false")); |
717 |
result.Add("SOLO", Solo); |
result.Add("SOLO", Solo); |
718 |
|
result.Add("MIDI_INSTRUMENT_MAP", MidiInstrumentMap); |
719 |
} |
} |
720 |
catch (Exception e) { |
catch (Exception e) { |
721 |
result.Error(e); |
result.Error(e); |
1193 |
|
|
1194 |
// set new channel parameter value |
// set new channel parameter value |
1195 |
pParameter->SetValue(ParamVal); |
pParameter->SetValue(ParamVal); |
1196 |
|
LSCPServer::SendLSCPNotify(LSCPEvent(LSCPEvent::event_audio_device_info, DeviceId)); |
1197 |
} |
} |
1198 |
catch (Exception e) { |
catch (Exception e) { |
1199 |
result.Error(e); |
result.Error(e); |
1211 |
std::map<String,DeviceCreationParameter*> parameters = pDevice->DeviceParameters(); |
std::map<String,DeviceCreationParameter*> parameters = pDevice->DeviceParameters(); |
1212 |
if (!parameters.count(ParamKey)) throw Exception("Audio output device " + ToString(DeviceIndex) + " does not have a device parameter '" + ParamKey + "'"); |
if (!parameters.count(ParamKey)) throw Exception("Audio output device " + ToString(DeviceIndex) + " does not have a device parameter '" + ParamKey + "'"); |
1213 |
parameters[ParamKey]->SetValue(ParamVal); |
parameters[ParamKey]->SetValue(ParamVal); |
1214 |
|
LSCPServer::SendLSCPNotify(LSCPEvent(LSCPEvent::event_audio_device_info, DeviceIndex)); |
1215 |
} |
} |
1216 |
catch (Exception e) { |
catch (Exception e) { |
1217 |
result.Error(e); |
result.Error(e); |
1229 |
std::map<String,DeviceCreationParameter*> parameters = pDevice->DeviceParameters(); |
std::map<String,DeviceCreationParameter*> parameters = pDevice->DeviceParameters(); |
1230 |
if (!parameters.count(ParamKey)) throw Exception("MIDI input device " + ToString(DeviceIndex) + " does not have a device parameter '" + ParamKey + "'"); |
if (!parameters.count(ParamKey)) throw Exception("MIDI input device " + ToString(DeviceIndex) + " does not have a device parameter '" + ParamKey + "'"); |
1231 |
parameters[ParamKey]->SetValue(ParamVal); |
parameters[ParamKey]->SetValue(ParamVal); |
1232 |
|
LSCPServer::SendLSCPNotify(LSCPEvent(LSCPEvent::event_midi_device_info, DeviceIndex)); |
1233 |
} |
} |
1234 |
catch (Exception e) { |
catch (Exception e) { |
1235 |
result.Error(e); |
result.Error(e); |
1254 |
std::map<String,DeviceRuntimeParameter*> parameters = pMidiInputPort->PortParameters(); |
std::map<String,DeviceRuntimeParameter*> parameters = pMidiInputPort->PortParameters(); |
1255 |
if (!parameters.count(ParamKey)) throw Exception("MIDI input device " + ToString(PortIndex) + " does not have a parameter '" + ParamKey + "'"); |
if (!parameters.count(ParamKey)) throw Exception("MIDI input device " + ToString(PortIndex) + " does not have a parameter '" + ParamKey + "'"); |
1256 |
parameters[ParamKey]->SetValue(ParamVal); |
parameters[ParamKey]->SetValue(ParamVal); |
1257 |
|
LSCPServer::SendLSCPNotify(LSCPEvent(LSCPEvent::event_midi_device_info, DeviceIndex)); |
1258 |
} |
} |
1259 |
catch (Exception e) { |
catch (Exception e) { |
1260 |
result.Error(e); |
result.Error(e); |
1502 |
|
|
1503 |
bool oldSolo = pEngineChannel->GetSolo(); |
bool oldSolo = pEngineChannel->GetSolo(); |
1504 |
bool hadSoloChannel = HasSoloChannel(); |
bool hadSoloChannel = HasSoloChannel(); |
1505 |
|
|
1506 |
pEngineChannel->SetSolo(bSolo); |
pEngineChannel->SetSolo(bSolo); |
1507 |
|
|
1508 |
if(!oldSolo && bSolo) { |
if(!oldSolo && bSolo) { |
1509 |
if(pEngineChannel->GetMute() == -1) pEngineChannel->SetMute(0); |
if(pEngineChannel->GetMute() == -1) pEngineChannel->SetMute(0); |
1510 |
if(!hadSoloChannel) MuteNonSoloChannels(); |
if(!hadSoloChannel) MuteNonSoloChannels(); |
1511 |
} |
} |
1512 |
|
|
1513 |
if(oldSolo && !bSolo) { |
if(oldSolo && !bSolo) { |
1514 |
if(!HasSoloChannel()) UnmuteChannels(); |
if(!HasSoloChannel()) UnmuteChannels(); |
1515 |
else if(!pEngineChannel->GetMute()) pEngineChannel->SetMute(-1); |
else if(!pEngineChannel->GetMute()) pEngineChannel->SetMute(-1); |
1567 |
} |
} |
1568 |
} |
} |
1569 |
|
|
1570 |
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) { |
1571 |
dmsg(2,("LSCPServer: AddOrReplaceMIDIInstrumentMapping()\n")); |
dmsg(2,("LSCPServer: AddOrReplaceMIDIInstrumentMapping()\n")); |
1572 |
|
|
1573 |
midi_prog_index_t idx; |
midi_prog_index_t idx; |
1574 |
idx.midi_bank_msb = MidiBankMSB; |
idx.midi_bank_msb = (MidiBank >> 7) & 0x7f; |
1575 |
idx.midi_bank_lsb = MidiBankLSB; |
idx.midi_bank_lsb = MidiBank & 0x7f; |
1576 |
idx.midi_prog = MidiProg; |
idx.midi_prog = MidiProg; |
1577 |
|
|
1578 |
MidiInstrumentMapper::entry_t entry; |
MidiInstrumentMapper::entry_t entry; |
1588 |
// PERSISTENT mapping commands might bloock for a long time, so in |
// PERSISTENT mapping commands might bloock for a long time, so in |
1589 |
// that case we add/replace the mapping in another thread |
// that case we add/replace the mapping in another thread |
1590 |
bool bInBackground = (entry.LoadMode == MidiInstrumentMapper::PERSISTENT); |
bool bInBackground = (entry.LoadMode == MidiInstrumentMapper::PERSISTENT); |
1591 |
MidiInstrumentMapper::AddOrReplaceMapping(idx, entry, bInBackground); |
MidiInstrumentMapper::AddOrReplaceEntry(MidiMapID, idx, entry, bInBackground); |
1592 |
} catch (Exception e) { |
} catch (Exception e) { |
1593 |
result.Error(e); |
result.Error(e); |
1594 |
} |
} |
1595 |
return result.Produce(); |
return result.Produce(); |
1596 |
} |
} |
1597 |
|
|
1598 |
String LSCPServer::RemoveMIDIInstrumentMapping(uint MidiBankMSB, uint MidiBankLSB, uint MidiProg) { |
String LSCPServer::RemoveMIDIInstrumentMapping(uint MidiMapID, uint MidiBank, uint MidiProg) { |
1599 |
dmsg(2,("LSCPServer: RemoveMIDIInstrumentMapping()\n")); |
dmsg(2,("LSCPServer: RemoveMIDIInstrumentMapping()\n")); |
1600 |
|
|
1601 |
midi_prog_index_t idx; |
midi_prog_index_t idx; |
1602 |
idx.midi_bank_msb = MidiBankMSB; |
idx.midi_bank_msb = (MidiBank >> 7) & 0x7f; |
1603 |
idx.midi_bank_lsb = MidiBankLSB; |
idx.midi_bank_lsb = MidiBank & 0x7f; |
1604 |
idx.midi_prog = MidiProg; |
idx.midi_prog = MidiProg; |
1605 |
|
|
1606 |
LSCPResultSet result; |
LSCPResultSet result; |
1607 |
try { |
try { |
1608 |
MidiInstrumentMapper::RemoveMapping(idx); |
MidiInstrumentMapper::RemoveEntry(MidiMapID, idx); |
1609 |
|
} catch (Exception e) { |
1610 |
|
result.Error(e); |
1611 |
|
} |
1612 |
|
return result.Produce(); |
1613 |
|
} |
1614 |
|
|
1615 |
|
String LSCPServer::GetMidiInstrumentMappings(uint MidiMapID) { |
1616 |
|
dmsg(2,("LSCPServer: GetMidiInstrumentMappings()\n")); |
1617 |
|
LSCPResultSet result; |
1618 |
|
try { |
1619 |
|
result.Add(MidiInstrumentMapper::Entries(MidiMapID).size()); |
1620 |
} catch (Exception e) { |
} catch (Exception e) { |
1621 |
result.Error(e); |
result.Error(e); |
1622 |
} |
} |
1623 |
return result.Produce(); |
return result.Produce(); |
1624 |
} |
} |
1625 |
|
|
1626 |
String LSCPServer::GetMidiIstrumentMappings() { |
|
1627 |
dmsg(2,("LSCPServer: GetMidiIstrumentMappings()\n")); |
String LSCPServer::GetAllMidiInstrumentMappings() { |
1628 |
|
dmsg(2,("LSCPServer: GetAllMidiInstrumentMappings()\n")); |
1629 |
LSCPResultSet result; |
LSCPResultSet result; |
1630 |
result.Add(MidiInstrumentMapper::Mappings().size()); |
std::vector<int> maps = MidiInstrumentMapper::Maps(); |
1631 |
|
int totalMappings = 0; |
1632 |
|
for (int i = 0; i < maps.size(); i++) { |
1633 |
|
try { |
1634 |
|
totalMappings += MidiInstrumentMapper::Entries(maps[i]).size(); |
1635 |
|
} catch (Exception e) { /*NOOP*/ } |
1636 |
|
} |
1637 |
|
result.Add(totalMappings); |
1638 |
return result.Produce(); |
return result.Produce(); |
1639 |
} |
} |
1640 |
|
|
1641 |
String LSCPServer::GetMidiInstrumentMapping(uint MidiBankMSB, uint MidiBankLSB, uint MidiProg) { |
String LSCPServer::GetMidiInstrumentMapping(uint MidiMapID, uint MidiBank, uint MidiProg) { |
1642 |
dmsg(2,("LSCPServer: GetMidiIstrumentMapping()\n")); |
dmsg(2,("LSCPServer: GetMidiIstrumentMapping()\n")); |
1643 |
LSCPResultSet result; |
LSCPResultSet result; |
1644 |
try { |
try { |
1645 |
midi_prog_index_t idx; |
midi_prog_index_t idx; |
1646 |
idx.midi_bank_msb = MidiBankMSB; |
idx.midi_bank_msb = (MidiBank >> 7) & 0x7f; |
1647 |
idx.midi_bank_lsb = MidiBankLSB; |
idx.midi_bank_lsb = MidiBank & 0x7f; |
1648 |
idx.midi_prog = MidiProg; |
idx.midi_prog = MidiProg; |
1649 |
|
|
1650 |
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); |
1651 |
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); |
1652 |
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"); |
1653 |
else { // found |
else { // found |
1688 |
return result.Produce(); |
return result.Produce(); |
1689 |
} |
} |
1690 |
|
|
1691 |
String LSCPServer::ListMidiInstrumentMappings() { |
String LSCPServer::ListMidiInstrumentMappings(uint MidiMapID) { |
1692 |
dmsg(2,("LSCPServer: ListMidiIstrumentMappings()\n")); |
dmsg(2,("LSCPServer: ListMidiInstrumentMappings()\n")); |
1693 |
LSCPResultSet result; |
LSCPResultSet result; |
1694 |
try { |
try { |
1695 |
String s; |
String s; |
1696 |
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); |
1697 |
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(); |
1698 |
for (; iter != mappings.end(); iter++) { |
for (; iter != mappings.end(); iter++) { |
1699 |
if (s.size()) s += ","; |
if (s.size()) s += ","; |
1700 |
s += "{" + ToString(iter->first.midi_bank_msb) + "," |
s += "{" + ToString(MidiMapID) + "," |
1701 |
+ ToString(iter->first.midi_bank_lsb) + "," |
+ ToString((int(iter->first.midi_bank_msb) << 7) | int(iter->first.midi_bank_lsb)) + "," |
1702 |
+ ToString(iter->first.midi_prog) + "}"; |
+ ToString(int(iter->first.midi_prog)) + "}"; |
1703 |
} |
} |
1704 |
result.Add(s); |
result.Add(s); |
1705 |
} catch (Exception e) { |
} catch (Exception e) { |
1708 |
return result.Produce(); |
return result.Produce(); |
1709 |
} |
} |
1710 |
|
|
1711 |
String LSCPServer::ClearMidiInstrumentMappings() { |
String LSCPServer::ListAllMidiInstrumentMappings() { |
1712 |
|
dmsg(2,("LSCPServer: ListAllMidiInstrumentMappings()\n")); |
1713 |
|
LSCPResultSet result; |
1714 |
|
try { |
1715 |
|
std::vector<int> maps = MidiInstrumentMapper::Maps(); |
1716 |
|
String s; |
1717 |
|
for (int i = 0; i < maps.size(); i++) { |
1718 |
|
std::map<midi_prog_index_t,MidiInstrumentMapper::entry_t> mappings = MidiInstrumentMapper::Entries(maps[i]); |
1719 |
|
std::map<midi_prog_index_t,MidiInstrumentMapper::entry_t>::iterator iter = mappings.begin(); |
1720 |
|
for (; iter != mappings.end(); iter++) { |
1721 |
|
if (s.size()) s += ","; |
1722 |
|
s += "{" + ToString(maps[i]) + "," |
1723 |
|
+ ToString((int(iter->first.midi_bank_msb) << 7) | int(iter->first.midi_bank_lsb)) + "," |
1724 |
|
+ ToString(int(iter->first.midi_prog)) + "}"; |
1725 |
|
} |
1726 |
|
} |
1727 |
|
result.Add(s); |
1728 |
|
} catch (Exception e) { |
1729 |
|
result.Error(e); |
1730 |
|
} |
1731 |
|
return result.Produce(); |
1732 |
|
} |
1733 |
|
|
1734 |
|
String LSCPServer::ClearMidiInstrumentMappings(uint MidiMapID) { |
1735 |
dmsg(2,("LSCPServer: ClearMidiInstrumentMappings()\n")); |
dmsg(2,("LSCPServer: ClearMidiInstrumentMappings()\n")); |
1736 |
LSCPResultSet result; |
LSCPResultSet result; |
1737 |
try { |
try { |
1738 |
MidiInstrumentMapper::RemoveAllMappings(); |
MidiInstrumentMapper::RemoveAllEntries(MidiMapID); |
1739 |
|
} catch (Exception e) { |
1740 |
|
result.Error(e); |
1741 |
|
} |
1742 |
|
return result.Produce(); |
1743 |
|
} |
1744 |
|
|
1745 |
|
String LSCPServer::ClearAllMidiInstrumentMappings() { |
1746 |
|
dmsg(2,("LSCPServer: ClearAllMidiInstrumentMappings()\n")); |
1747 |
|
LSCPResultSet result; |
1748 |
|
try { |
1749 |
|
std::vector<int> maps = MidiInstrumentMapper::Maps(); |
1750 |
|
for (int i = 0; i < maps.size(); i++) |
1751 |
|
MidiInstrumentMapper::RemoveAllEntries(maps[i]); |
1752 |
|
} catch (Exception e) { |
1753 |
|
result.Error(e); |
1754 |
|
} |
1755 |
|
return result.Produce(); |
1756 |
|
} |
1757 |
|
|
1758 |
|
String LSCPServer::AddMidiInstrumentMap(String MapName) { |
1759 |
|
dmsg(2,("LSCPServer: AddMidiInstrumentMap()\n")); |
1760 |
|
LSCPResultSet result; |
1761 |
|
try { |
1762 |
|
int MapID = MidiInstrumentMapper::AddMap(MapName); |
1763 |
|
result = LSCPResultSet(MapID); |
1764 |
|
} catch (Exception e) { |
1765 |
|
result.Error(e); |
1766 |
|
} |
1767 |
|
return result.Produce(); |
1768 |
|
} |
1769 |
|
|
1770 |
|
String LSCPServer::RemoveMidiInstrumentMap(uint MidiMapID) { |
1771 |
|
dmsg(2,("LSCPServer: RemoveMidiInstrumentMap()\n")); |
1772 |
|
LSCPResultSet result; |
1773 |
|
try { |
1774 |
|
MidiInstrumentMapper::RemoveMap(MidiMapID); |
1775 |
|
} catch (Exception e) { |
1776 |
|
result.Error(e); |
1777 |
|
} |
1778 |
|
return result.Produce(); |
1779 |
|
} |
1780 |
|
|
1781 |
|
String LSCPServer::RemoveAllMidiInstrumentMaps() { |
1782 |
|
dmsg(2,("LSCPServer: RemoveAllMidiInstrumentMaps()\n")); |
1783 |
|
LSCPResultSet result; |
1784 |
|
try { |
1785 |
|
MidiInstrumentMapper::RemoveAllMaps(); |
1786 |
|
} catch (Exception e) { |
1787 |
|
result.Error(e); |
1788 |
|
} |
1789 |
|
return result.Produce(); |
1790 |
|
} |
1791 |
|
|
1792 |
|
String LSCPServer::GetMidiInstrumentMaps() { |
1793 |
|
dmsg(2,("LSCPServer: GetMidiInstrumentMaps()\n")); |
1794 |
|
LSCPResultSet result; |
1795 |
|
try { |
1796 |
|
result.Add(MidiInstrumentMapper::Maps().size()); |
1797 |
|
} catch (Exception e) { |
1798 |
|
result.Error(e); |
1799 |
|
} |
1800 |
|
return result.Produce(); |
1801 |
|
} |
1802 |
|
|
1803 |
|
String LSCPServer::ListMidiInstrumentMaps() { |
1804 |
|
dmsg(2,("LSCPServer: ListMidiInstrumentMaps()\n")); |
1805 |
|
LSCPResultSet result; |
1806 |
|
try { |
1807 |
|
std::vector<int> maps = MidiInstrumentMapper::Maps(); |
1808 |
|
String sList; |
1809 |
|
for (int i = 0; i < maps.size(); i++) { |
1810 |
|
if (sList != "") sList += ","; |
1811 |
|
sList += ToString(maps[i]); |
1812 |
|
} |
1813 |
|
result.Add(sList); |
1814 |
|
} catch (Exception e) { |
1815 |
|
result.Error(e); |
1816 |
|
} |
1817 |
|
return result.Produce(); |
1818 |
|
} |
1819 |
|
|
1820 |
|
String LSCPServer::GetMidiInstrumentMap(uint MidiMapID) { |
1821 |
|
dmsg(2,("LSCPServer: GetMidiInstrumentMap()\n")); |
1822 |
|
LSCPResultSet result; |
1823 |
|
try { |
1824 |
|
result.Add("NAME", MidiInstrumentMapper::MapName(MidiMapID)); |
1825 |
|
} catch (Exception e) { |
1826 |
|
result.Error(e); |
1827 |
|
} |
1828 |
|
return result.Produce(); |
1829 |
|
} |
1830 |
|
|
1831 |
|
String LSCPServer::SetMidiInstrumentMapName(uint MidiMapID, String NewName) { |
1832 |
|
dmsg(2,("LSCPServer: SetMidiInstrumentMapName()\n")); |
1833 |
|
LSCPResultSet result; |
1834 |
|
try { |
1835 |
|
MidiInstrumentMapper::RenameMap(MidiMapID, NewName); |
1836 |
|
} catch (Exception e) { |
1837 |
|
result.Error(e); |
1838 |
|
} |
1839 |
|
return result.Produce(); |
1840 |
|
} |
1841 |
|
|
1842 |
|
/** |
1843 |
|
* Set the MIDI instrument map the given sampler channel shall use for |
1844 |
|
* handling MIDI program change messages. There are the following two |
1845 |
|
* special (negative) values: |
1846 |
|
* |
1847 |
|
* - (-1) : set to NONE (ignore program changes) |
1848 |
|
* - (-2) : set to DEFAULT map |
1849 |
|
*/ |
1850 |
|
String LSCPServer::SetChannelMap(uint uiSamplerChannel, int MidiMapID) { |
1851 |
|
dmsg(2,("LSCPServer: SetChannelMap()\n")); |
1852 |
|
LSCPResultSet result; |
1853 |
|
try { |
1854 |
|
SamplerChannel* pSamplerChannel = pSampler->GetSamplerChannel(uiSamplerChannel); |
1855 |
|
if (!pSamplerChannel) throw Exception("Invalid sampler channel number " + ToString(uiSamplerChannel)); |
1856 |
|
|
1857 |
|
EngineChannel* pEngineChannel = pSamplerChannel->GetEngineChannel(); |
1858 |
|
if (!pEngineChannel) throw Exception("There is no engine deployed on this sampler channel yet"); |
1859 |
|
|
1860 |
|
if (MidiMapID == -1) pEngineChannel->SetMidiInstrumentMapToNone(); |
1861 |
|
else if (MidiMapID == -2) pEngineChannel->SetMidiInstrumentMapToDefault(); |
1862 |
|
else pEngineChannel->SetMidiInstrumentMap(MidiMapID); |
1863 |
|
} catch (Exception e) { |
1864 |
|
result.Error(e); |
1865 |
|
} |
1866 |
|
return result.Produce(); |
1867 |
|
} |
1868 |
|
|
1869 |
|
String LSCPServer::CreateFxSend(uint uiSamplerChannel, uint MidiCtrl, String Name) { |
1870 |
|
dmsg(2,("LSCPServer: CreateFxSend()\n")); |
1871 |
|
LSCPResultSet result; |
1872 |
|
try { |
1873 |
|
SamplerChannel* pSamplerChannel = pSampler->GetSamplerChannel(uiSamplerChannel); |
1874 |
|
if (!pSamplerChannel) throw Exception("Invalid sampler channel number " + ToString(uiSamplerChannel)); |
1875 |
|
|
1876 |
|
EngineChannel* pEngineChannel = pSamplerChannel->GetEngineChannel(); |
1877 |
|
if (!pEngineChannel) throw Exception("There is no engine deployed on this sampler channel yet"); |
1878 |
|
|
1879 |
|
FxSend* pFxSend = pEngineChannel->AddFxSend(MidiCtrl, Name); |
1880 |
|
if (!pFxSend) throw Exception("Could not add FxSend, don't ask, I don't know why (probably a bug)"); |
1881 |
|
|
1882 |
|
result = LSCPResultSet(pFxSend->Id()); // success |
1883 |
|
} catch (Exception e) { |
1884 |
|
result.Error(e); |
1885 |
|
} |
1886 |
|
return result.Produce(); |
1887 |
|
} |
1888 |
|
|
1889 |
|
String LSCPServer::DestroyFxSend(uint uiSamplerChannel, uint FxSendID) { |
1890 |
|
dmsg(2,("LSCPServer: DestroyFxSend()\n")); |
1891 |
|
LSCPResultSet result; |
1892 |
|
try { |
1893 |
|
SamplerChannel* pSamplerChannel = pSampler->GetSamplerChannel(uiSamplerChannel); |
1894 |
|
if (!pSamplerChannel) throw Exception("Invalid sampler channel number " + ToString(uiSamplerChannel)); |
1895 |
|
|
1896 |
|
EngineChannel* pEngineChannel = pSamplerChannel->GetEngineChannel(); |
1897 |
|
if (!pEngineChannel) throw Exception("There is no engine deployed on this sampler channel yet"); |
1898 |
|
|
1899 |
|
FxSend* pFxSend = NULL; |
1900 |
|
for (int i = 0; i < pEngineChannel->GetFxSendCount(); i++) { |
1901 |
|
if (pEngineChannel->GetFxSend(i)->Id() == FxSendID) { |
1902 |
|
pFxSend = pEngineChannel->GetFxSend(i); |
1903 |
|
break; |
1904 |
|
} |
1905 |
|
} |
1906 |
|
if (!pFxSend) throw Exception("There is no FxSend with that ID on the given sampler channel"); |
1907 |
|
pEngineChannel->RemoveFxSend(pFxSend); |
1908 |
|
} catch (Exception e) { |
1909 |
|
result.Error(e); |
1910 |
|
} |
1911 |
|
return result.Produce(); |
1912 |
|
} |
1913 |
|
|
1914 |
|
String LSCPServer::GetFxSends(uint uiSamplerChannel) { |
1915 |
|
dmsg(2,("LSCPServer: GetFxSends()\n")); |
1916 |
|
LSCPResultSet result; |
1917 |
|
try { |
1918 |
|
SamplerChannel* pSamplerChannel = pSampler->GetSamplerChannel(uiSamplerChannel); |
1919 |
|
if (!pSamplerChannel) throw Exception("Invalid sampler channel number " + ToString(uiSamplerChannel)); |
1920 |
|
|
1921 |
|
EngineChannel* pEngineChannel = pSamplerChannel->GetEngineChannel(); |
1922 |
|
if (!pEngineChannel) throw Exception("There is no engine deployed on this sampler channel yet"); |
1923 |
|
|
1924 |
|
result.Add(pEngineChannel->GetFxSendCount()); |
1925 |
|
} catch (Exception e) { |
1926 |
|
result.Error(e); |
1927 |
|
} |
1928 |
|
return result.Produce(); |
1929 |
|
} |
1930 |
|
|
1931 |
|
String LSCPServer::ListFxSends(uint uiSamplerChannel) { |
1932 |
|
dmsg(2,("LSCPServer: ListFxSends()\n")); |
1933 |
|
LSCPResultSet result; |
1934 |
|
String list; |
1935 |
|
try { |
1936 |
|
SamplerChannel* pSamplerChannel = pSampler->GetSamplerChannel(uiSamplerChannel); |
1937 |
|
if (!pSamplerChannel) throw Exception("Invalid sampler channel number " + ToString(uiSamplerChannel)); |
1938 |
|
|
1939 |
|
EngineChannel* pEngineChannel = pSamplerChannel->GetEngineChannel(); |
1940 |
|
if (!pEngineChannel) throw Exception("There is no engine deployed on this sampler channel yet"); |
1941 |
|
|
1942 |
|
for (int i = 0; i < pEngineChannel->GetFxSendCount(); i++) { |
1943 |
|
FxSend* pFxSend = pEngineChannel->GetFxSend(i); |
1944 |
|
if (list != "") list += ","; |
1945 |
|
list += ToString(pFxSend->Id()); |
1946 |
|
} |
1947 |
|
result.Add(list); |
1948 |
|
} catch (Exception e) { |
1949 |
|
result.Error(e); |
1950 |
|
} |
1951 |
|
return result.Produce(); |
1952 |
|
} |
1953 |
|
|
1954 |
|
String LSCPServer::GetFxSendInfo(uint uiSamplerChannel, uint FxSendID) { |
1955 |
|
dmsg(2,("LSCPServer: GetFxSendInfo()\n")); |
1956 |
|
LSCPResultSet result; |
1957 |
|
try { |
1958 |
|
SamplerChannel* pSamplerChannel = pSampler->GetSamplerChannel(uiSamplerChannel); |
1959 |
|
if (!pSamplerChannel) throw Exception("Invalid sampler channel number " + ToString(uiSamplerChannel)); |
1960 |
|
|
1961 |
|
EngineChannel* pEngineChannel = pSamplerChannel->GetEngineChannel(); |
1962 |
|
if (!pEngineChannel) throw Exception("There is no engine deployed on this sampler channel yet"); |
1963 |
|
|
1964 |
|
FxSend* pFxSend = NULL; |
1965 |
|
for (int i = 0; i < pEngineChannel->GetFxSendCount(); i++) { |
1966 |
|
if (pEngineChannel->GetFxSend(i)->Id() == FxSendID) { |
1967 |
|
pFxSend = pEngineChannel->GetFxSend(i); |
1968 |
|
break; |
1969 |
|
} |
1970 |
|
} |
1971 |
|
if (!pFxSend) throw Exception("There is no FxSend with that ID on the given sampler channel"); |
1972 |
|
|
1973 |
|
// gather audio routing informations |
1974 |
|
String AudioRouting; |
1975 |
|
for (int chan = 0; chan < pEngineChannel->Channels(); chan++) { |
1976 |
|
if (AudioRouting != "") AudioRouting += ","; |
1977 |
|
AudioRouting += ToString(pFxSend->DestinationChannel(chan)); |
1978 |
|
} |
1979 |
|
|
1980 |
|
// success |
1981 |
|
result.Add("NAME", pFxSend->Name()); |
1982 |
|
result.Add("AUDIO_OUTPUT_ROUTING", AudioRouting); |
1983 |
|
} catch (Exception e) { |
1984 |
|
result.Error(e); |
1985 |
|
} |
1986 |
|
return result.Produce(); |
1987 |
|
} |
1988 |
|
|
1989 |
|
String LSCPServer::SetFxSendAudioOutputChannel(uint uiSamplerChannel, uint FxSendID, uint FxSendChannel, uint DeviceChannel) { |
1990 |
|
dmsg(2,("LSCPServer: SetFxSendAudioOutputChannel()\n")); |
1991 |
|
LSCPResultSet result; |
1992 |
|
try { |
1993 |
|
SamplerChannel* pSamplerChannel = pSampler->GetSamplerChannel(uiSamplerChannel); |
1994 |
|
if (!pSamplerChannel) throw Exception("Invalid sampler channel number " + ToString(uiSamplerChannel)); |
1995 |
|
|
1996 |
|
EngineChannel* pEngineChannel = pSamplerChannel->GetEngineChannel(); |
1997 |
|
if (!pEngineChannel) throw Exception("There is no engine deployed on this sampler channel yet"); |
1998 |
|
|
1999 |
|
FxSend* pFxSend = NULL; |
2000 |
|
for (int i = 0; i < pEngineChannel->GetFxSendCount(); i++) { |
2001 |
|
if (pEngineChannel->GetFxSend(i)->Id() == FxSendID) { |
2002 |
|
pFxSend = pEngineChannel->GetFxSend(i); |
2003 |
|
break; |
2004 |
|
} |
2005 |
|
} |
2006 |
|
if (!pFxSend) throw Exception("There is no FxSend with that ID on the given sampler channel"); |
2007 |
|
|
2008 |
|
pFxSend->SetDestinationChannel(FxSendChannel, DeviceChannel); |
2009 |
} catch (Exception e) { |
} catch (Exception e) { |
2010 |
result.Error(e); |
result.Error(e); |
2011 |
} |
} |
2074 |
return result.Produce(); |
return result.Produce(); |
2075 |
} |
} |
2076 |
|
|
2077 |
|
String LSCPServer::GetGlobalVolume() { |
2078 |
|
LSCPResultSet result; |
2079 |
|
result.Add(ToString(GLOBAL_VOLUME)); // see common/global.cpp |
2080 |
|
return result.Produce(); |
2081 |
|
} |
2082 |
|
|
2083 |
|
String LSCPServer::SetGlobalVolume(double dVolume) { |
2084 |
|
LSCPResultSet result; |
2085 |
|
try { |
2086 |
|
if (dVolume < 0) throw Exception("Volume may not be negative"); |
2087 |
|
GLOBAL_VOLUME = dVolume; // see common/global.cpp |
2088 |
|
} catch (Exception e) { |
2089 |
|
result.Error(e); |
2090 |
|
} |
2091 |
|
return result.Produce(); |
2092 |
|
} |
2093 |
|
|
2094 |
/** |
/** |
2095 |
* Will be called by the parser to subscribe a client (frontend) on the |
* Will be called by the parser to subscribe a client (frontend) on the |
2096 |
* server for receiving event messages. |
* server for receiving event messages. |