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 - 2013 Christian Schoenebeck * |
* Copyright (C) 2005 - 2014 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 * |
1777 |
} |
} |
1778 |
return result.Produce(); |
return result.Produce(); |
1779 |
} |
} |
1780 |
|
|
1781 |
|
String LSCPServer::AddChannelMidiInput(uint uiSamplerChannel, uint MIDIDeviceId, uint MIDIPort) { |
1782 |
|
dmsg(2,("LSCPServer: AddChannelMidiInput(uiSamplerChannel=%d, MIDIDeviceId=%d, MIDIPort=%d)\n",uiSamplerChannel,MIDIDeviceId,MIDIPort)); |
1783 |
|
LSCPResultSet result; |
1784 |
|
try { |
1785 |
|
SamplerChannel* pSamplerChannel = pSampler->GetSamplerChannel(uiSamplerChannel); |
1786 |
|
if (!pSamplerChannel) throw Exception("Invalid sampler channel number " + ToString(uiSamplerChannel)); |
1787 |
|
|
1788 |
|
std::map<uint, MidiInputDevice*> devices = pSampler->GetMidiInputDevices(); |
1789 |
|
if (!devices.count(MIDIDeviceId)) throw Exception("There is no MIDI input device with index " + ToString(MIDIDeviceId)); |
1790 |
|
MidiInputDevice* pDevice = devices[MIDIDeviceId]; |
1791 |
|
|
1792 |
|
MidiInputPort* pPort = pDevice->GetPort(MIDIPort); |
1793 |
|
if (!pPort) throw Exception("There is no MIDI input port with index " + ToString(MIDIPort) + " on MIDI input device with index " + ToString(MIDIDeviceId)); |
1794 |
|
|
1795 |
|
pSamplerChannel->Connect(pPort); |
1796 |
|
} catch (Exception e) { |
1797 |
|
result.Error(e); |
1798 |
|
} |
1799 |
|
return result.Produce(); |
1800 |
|
} |
1801 |
|
|
1802 |
|
String LSCPServer::RemoveChannelMidiInput(uint uiSamplerChannel) { |
1803 |
|
dmsg(2,("LSCPServer: RemoveChannelMidiInput(uiSamplerChannel=%d)\n",uiSamplerChannel)); |
1804 |
|
LSCPResultSet result; |
1805 |
|
try { |
1806 |
|
SamplerChannel* pSamplerChannel = pSampler->GetSamplerChannel(uiSamplerChannel); |
1807 |
|
if (!pSamplerChannel) throw Exception("Invalid sampler channel number " + ToString(uiSamplerChannel)); |
1808 |
|
pSamplerChannel->DisconnectAllMidiInputPorts(); |
1809 |
|
} catch (Exception e) { |
1810 |
|
result.Error(e); |
1811 |
|
} |
1812 |
|
return result.Produce(); |
1813 |
|
} |
1814 |
|
|
1815 |
|
String LSCPServer::RemoveChannelMidiInput(uint uiSamplerChannel, uint MIDIDeviceId) { |
1816 |
|
dmsg(2,("LSCPServer: RemoveChannelMidiInput(uiSamplerChannel=%d, MIDIDeviceId=%d)\n",uiSamplerChannel,MIDIDeviceId)); |
1817 |
|
LSCPResultSet result; |
1818 |
|
try { |
1819 |
|
SamplerChannel* pSamplerChannel = pSampler->GetSamplerChannel(uiSamplerChannel); |
1820 |
|
if (!pSamplerChannel) throw Exception("Invalid sampler channel number " + ToString(uiSamplerChannel)); |
1821 |
|
|
1822 |
|
std::map<uint, MidiInputDevice*> devices = pSampler->GetMidiInputDevices(); |
1823 |
|
if (!devices.count(MIDIDeviceId)) throw Exception("There is no MIDI input device with index " + ToString(MIDIDeviceId)); |
1824 |
|
MidiInputDevice* pDevice = devices[MIDIDeviceId]; |
1825 |
|
|
1826 |
|
std::vector<MidiInputPort*> vPorts = pSamplerChannel->GetMidiInputPorts(); |
1827 |
|
for (int i = 0; i < vPorts.size(); ++i) |
1828 |
|
if (vPorts[i]->GetDevice() == pDevice) |
1829 |
|
pSamplerChannel->Disconnect(vPorts[i]); |
1830 |
|
|
1831 |
|
} catch (Exception e) { |
1832 |
|
result.Error(e); |
1833 |
|
} |
1834 |
|
return result.Produce(); |
1835 |
|
} |
1836 |
|
|
1837 |
|
String LSCPServer::RemoveChannelMidiInput(uint uiSamplerChannel, uint MIDIDeviceId, uint MIDIPort) { |
1838 |
|
dmsg(2,("LSCPServer: RemoveChannelMidiInput(uiSamplerChannel=%d, MIDIDeviceId=%d, MIDIPort=%d)\n",uiSamplerChannel,MIDIDeviceId,MIDIPort)); |
1839 |
|
LSCPResultSet result; |
1840 |
|
try { |
1841 |
|
SamplerChannel* pSamplerChannel = pSampler->GetSamplerChannel(uiSamplerChannel); |
1842 |
|
if (!pSamplerChannel) throw Exception("Invalid sampler channel number " + ToString(uiSamplerChannel)); |
1843 |
|
|
1844 |
|
std::map<uint, MidiInputDevice*> devices = pSampler->GetMidiInputDevices(); |
1845 |
|
if (!devices.count(MIDIDeviceId)) throw Exception("There is no MIDI input device with index " + ToString(MIDIDeviceId)); |
1846 |
|
MidiInputDevice* pDevice = devices[MIDIDeviceId]; |
1847 |
|
|
1848 |
|
MidiInputPort* pPort = pDevice->GetPort(MIDIPort); |
1849 |
|
if (!pPort) throw Exception("There is no MIDI input port with index " + ToString(MIDIPort) + " on MIDI input device with index " + ToString(MIDIDeviceId)); |
1850 |
|
|
1851 |
|
pSamplerChannel->Disconnect(pPort); |
1852 |
|
} catch (Exception e) { |
1853 |
|
result.Error(e); |
1854 |
|
} |
1855 |
|
return result.Produce(); |
1856 |
|
} |
1857 |
|
|
1858 |
|
String LSCPServer::ListChannelMidiInputs(uint uiSamplerChannel) { |
1859 |
|
dmsg(2,("LSCPServer: ListChannelMidiInputs(uiSamplerChannel=%d)\n",uiSamplerChannel)); |
1860 |
|
LSCPResultSet result; |
1861 |
|
try { |
1862 |
|
SamplerChannel* pSamplerChannel = pSampler->GetSamplerChannel(uiSamplerChannel); |
1863 |
|
if (!pSamplerChannel) throw Exception("Invalid sampler channel number " + ToString(uiSamplerChannel)); |
1864 |
|
std::vector<MidiInputPort*> vPorts = pSamplerChannel->GetMidiInputPorts(); |
1865 |
|
|
1866 |
|
String s; |
1867 |
|
for (int i = 0; i < vPorts.size(); ++i) { |
1868 |
|
const int iDeviceID = vPorts[i]->GetDevice()->MidiInputDeviceID(); |
1869 |
|
const int iPortNr = vPorts[i]->GetPortNumber(); |
1870 |
|
if (s.size()) s += ","; |
1871 |
|
s += "{" + ToString(iDeviceID) + "," |
1872 |
|
+ ToString(iPortNr) + "}"; |
1873 |
|
} |
1874 |
|
result.Add(s); |
1875 |
|
} catch (Exception e) { |
1876 |
|
result.Error(e); |
1877 |
|
} |
1878 |
|
return result.Produce(); |
1879 |
|
} |
1880 |
|
|
1881 |
String LSCPServer::SetMIDIInputPort(uint MIDIPort, uint uiSamplerChannel) { |
String LSCPServer::SetMIDIInputPort(uint MIDIPort, uint uiSamplerChannel) { |
1882 |
dmsg(2,("LSCPServer: SetMIDIInputPort(MIDIPort=%d, SamplerChannel=%d)\n",MIDIPort,uiSamplerChannel)); |
dmsg(2,("LSCPServer: SetMIDIInputPort(MIDIPort=%d, SamplerChannel=%d)\n",MIDIPort,uiSamplerChannel)); |