207 |
sock.bind(null); |
sock.bind(null); |
208 |
sock.connect(sockAddr, soTimeout); |
sock.connect(sockAddr, soTimeout); |
209 |
sock.setSoTimeout(soTimeout); |
sock.setSoTimeout(soTimeout); |
210 |
|
sock.setTcpNoDelay(true); |
211 |
|
|
212 |
in = new LscpInputStream(sock.getInputStream()); |
in = new LscpInputStream(sock.getInputStream()); |
213 |
out = new LscpOutputStream(sock.getOutputStream()); |
out = new LscpOutputStream(sock.getOutputStream()); |
257 |
if(!llCI.isEmpty()) subscribe("CHANNEL_INFO"); |
if(!llCI.isEmpty()) subscribe("CHANNEL_INFO"); |
258 |
if(!llSC.isEmpty()) subscribe("STREAM_COUNT"); |
if(!llSC.isEmpty()) subscribe("STREAM_COUNT"); |
259 |
if(!llVC.isEmpty()) subscribe("VOICE_COUNT"); |
if(!llVC.isEmpty()) subscribe("VOICE_COUNT"); |
260 |
|
if(!llTVC.isEmpty()) subscribe("TOTAL_VOICE_COUNT"); |
261 |
} |
} |
262 |
|
|
263 |
/** |
/** |
372 |
private final Vector<MiscellaneousListener> llM = new Vector<MiscellaneousListener>(); |
private final Vector<MiscellaneousListener> llM = new Vector<MiscellaneousListener>(); |
373 |
private final Vector<StreamCountListener> llSC = new Vector<StreamCountListener>(); |
private final Vector<StreamCountListener> llSC = new Vector<StreamCountListener>(); |
374 |
private final Vector<VoiceCountListener> llVC = new Vector<VoiceCountListener>(); |
private final Vector<VoiceCountListener> llVC = new Vector<VoiceCountListener>(); |
375 |
|
private final Vector<TotalVoiceCountListener> llTVC = new Vector<TotalVoiceCountListener>(); |
376 |
|
|
377 |
/** |
/** |
378 |
* Determines whether there is at least one subscription for notification events. |
* Determines whether there is at least one subscription for notification events. |
379 |
* Do not forget to check for additional listeners if the LSCP specification |
* Do not forget to check for additional listeners if the LSCP specification |
380 |
* extends in the future. |
* is extended in the future. |
381 |
* @return <code>true</code> if there is at least one subscription for notification events, |
* @return <code>true</code> if there is at least one subscription for notification events, |
382 |
* <code>false</code> otherwise. |
* <code>false</code> otherwise. |
383 |
*/ |
*/ |
388 |
!llCI.isEmpty() || |
!llCI.isEmpty() || |
389 |
!llM.isEmpty() || |
!llM.isEmpty() || |
390 |
!llSC.isEmpty() || |
!llSC.isEmpty() || |
391 |
!llVC.isEmpty(); |
!llVC.isEmpty() || |
392 |
|
!llTVC.isEmpty(); |
393 |
} |
} |
394 |
|
|
395 |
private void |
private void |
458 |
} catch(NumberFormatException x) { |
} catch(NumberFormatException x) { |
459 |
getLogger().log(Level.WARNING, "Unknown STREAM_COUNT format", x); |
getLogger().log(Level.WARNING, "Unknown STREAM_COUNT format", x); |
460 |
} |
} |
461 |
|
} else if(s.startsWith("TOTAL_VOICE_COUNT:")) { |
462 |
|
try { |
463 |
|
s = s.substring("TOTAL_VOICE_COUNT:".length()); |
464 |
|
int i = Integer.parseInt(s); |
465 |
|
TotalVoiceCountEvent e = new TotalVoiceCountEvent(this, i); |
466 |
|
for(TotalVoiceCountListener l : llTVC) l.totalVoiceCountChanged(e); |
467 |
|
} catch(NumberFormatException x) { |
468 |
|
getLogger().log ( |
469 |
|
Level.WARNING, "Unknown TOTAL_VOICE_COUNT format", x |
470 |
|
); |
471 |
|
} |
472 |
} else if(s.startsWith("MISCELLANEOUS:")) { |
} else if(s.startsWith("MISCELLANEOUS:")) { |
473 |
s = s.substring("MISCELLANEOUS:".length()); |
s = s.substring("MISCELLANEOUS:".length()); |
474 |
MiscellaneousEvent e = new MiscellaneousEvent(this, s); |
MiscellaneousEvent e = new MiscellaneousEvent(this, s); |
643 |
} |
} |
644 |
|
|
645 |
/** |
/** |
646 |
|
* Registers the specified listener for receiving event messages. |
647 |
|
* Listeners can be registered regardless of the connection state. |
648 |
|
* @param l The <code>TotalVoiceCountListener</code> to register. |
649 |
|
*/ |
650 |
|
public synchronized void |
651 |
|
addTotalVoiceCountListener(TotalVoiceCountListener l) { |
652 |
|
if(llTVC.isEmpty()) subscribe("TOTAL_VOICE_COUNT"); |
653 |
|
llTVC.add(l); |
654 |
|
} |
655 |
|
|
656 |
|
/** |
657 |
|
* Removes the specified listener. |
658 |
|
* Listeners can be removed regardless of the connection state. |
659 |
|
* @param l The <code>TotalVoiceCountListener</code> to remove. |
660 |
|
*/ |
661 |
|
public synchronized void |
662 |
|
removeTotalVoiceCountListener(TotalVoiceCountListener l) { |
663 |
|
boolean b = llTVC.remove(l); |
664 |
|
if(b && llTVC.isEmpty()) unsubscribe("TOTAL_VOICE_COUNT"); |
665 |
|
} |
666 |
|
|
667 |
|
/** |
668 |
* Gets the number of all audio output drivers currently |
* Gets the number of all audio output drivers currently |
669 |
* available for the LinuxSampler instance. |
* available for the LinuxSampler instance. |
670 |
* @return The number of all audio output drivers currently |
* @return The number of all audio output drivers currently |
791 |
if(!multi) prm = new BoolParameter(lnS); |
if(!multi) prm = new BoolParameter(lnS); |
792 |
else prm = new BoolListParameter(lnS); |
else prm = new BoolListParameter(lnS); |
793 |
prm.setName(param); |
prm.setName(param); |
794 |
|
prm.setValue(prm.getDefault()); |
795 |
return prm; |
return prm; |
796 |
case INT: |
case INT: |
797 |
if(!multi) prm = new IntParameter(lnS); |
if(!multi) prm = new IntParameter(lnS); |
798 |
else prm = new IntListParameter(lnS); |
else prm = new IntListParameter(lnS); |
799 |
prm.setName(param); |
prm.setName(param); |
800 |
|
prm.setValue(prm.getDefault()); |
801 |
return prm; |
return prm; |
802 |
case FLOAT: |
case FLOAT: |
803 |
if(!multi) prm = new FloatParameter(lnS); |
if(!multi) prm = new FloatParameter(lnS); |
804 |
else prm = new FloatListParameter(lnS); |
else prm = new FloatListParameter(lnS); |
805 |
prm.setName(param); |
prm.setName(param); |
806 |
|
prm.setValue(prm.getDefault()); |
807 |
return prm; |
return prm; |
808 |
case STRING: |
case STRING: |
809 |
if(!multi) prm = new StringParameter(lnS); |
if(!multi) prm = new StringParameter(lnS); |
810 |
else prm = new StringListParameter(lnS); |
else prm = new StringListParameter(lnS); |
811 |
prm.setName(param); |
prm.setName(param); |
812 |
|
prm.setValue(prm.getDefault()); |
813 |
return prm; |
return prm; |
814 |
default: throw new LscpException(LscpI18n.getLogMsg("Client.unknownPrmType!")); |
default: throw new LscpException(LscpI18n.getLogMsg("Client.unknownPrmType!")); |
815 |
} |
} |
859 |
ResultSet rs = getEmptyResultSet(); |
ResultSet rs = getEmptyResultSet(); |
860 |
} |
} |
861 |
|
|
862 |
|
/** |
863 |
|
* Enables/disables the specified audio output device. |
864 |
|
* @param deviceID The ID of the audio output device to be enabled/disabled. |
865 |
|
* @param enable If <code>true</code> the audio output device is enabled, |
866 |
|
* else the device is disabled. |
867 |
|
* @throws IOException If some I/O error occurs. |
868 |
|
* @throws LSException If there is no audio output |
869 |
|
* device with numerical ID <code>deviceID</code>. |
870 |
|
* @throws LscpException If LSCP protocol corruption occurs. |
871 |
|
*/ |
872 |
|
public void |
873 |
|
enableAudioOutputDevice(int deviceID, boolean enable) |
874 |
|
throws IOException, LSException, LscpException { |
875 |
|
|
876 |
|
setAudioOutputDeviceParameter(deviceID, new BoolParameter("ACTIVE", enable)); |
877 |
|
} |
878 |
|
|
879 |
/** |
/** |
880 |
* Gets the current number of all created audio output devices. |
* Gets the current number of all created audio output devices. |
881 |
* @return The current number of all created audio output devices. |
* @return The current number of all created audio output devices. |
892 |
} |
} |
893 |
|
|
894 |
/** |
/** |
895 |
|
* Gets a list of all created audio output devices. |
896 |
|
* @return An <code>AudioOutputDevice</code> array |
897 |
|
* providing all created audio output devices. |
898 |
|
* @throws IOException If some I/O error occurs. |
899 |
|
* @throws LscpException If LSCP protocol corruption occurs. |
900 |
|
* @throws LSException If some other error occurs. |
901 |
|
*/ |
902 |
|
public synchronized AudioOutputDevice[] |
903 |
|
getAudioOutputDevices() throws IOException, LscpException, LSException { |
904 |
|
Integer[] idS = getAudioOutputDeviceIDs(); |
905 |
|
AudioOutputDevice[] devices = new AudioOutputDevice[idS.length]; |
906 |
|
|
907 |
|
for(int i = 0; i < devices.length; i++) |
908 |
|
devices[i] = getAudioOutputDeviceInfo(idS[i]); |
909 |
|
|
910 |
|
return devices; |
911 |
|
} |
912 |
|
|
913 |
|
/** |
914 |
* Gets a list of numerical IDs of all created audio output devices. |
* Gets a list of numerical IDs of all created audio output devices. |
915 |
* @return An <code>Integer</code> array with numerical IDs of |
* @return An <code>Integer</code> array providing the numerical IDs of |
916 |
* all created audio output devices. |
* all created audio output devices. |
917 |
* @throws IOException If some I/O error occurs. |
* @throws IOException If some I/O error occurs. |
918 |
* @throws LscpException If LSCP protocol corruption occurs. |
* @throws LscpException If LSCP protocol corruption occurs. |
919 |
* @throws LSException If some other error occurs. |
* @throws LSException If some other error occurs. |
920 |
*/ |
*/ |
921 |
public synchronized Integer[] |
public synchronized Integer[] |
922 |
getAudioOutputDevices() throws IOException, LscpException, LSException { |
getAudioOutputDeviceIDs() throws IOException, LscpException, LSException { |
923 |
verifyConnection(); |
verifyConnection(); |
924 |
out.writeLine("LIST AUDIO_OUTPUT_DEVICES"); |
out.writeLine("LIST AUDIO_OUTPUT_DEVICES"); |
925 |
return parseIntList(getSingleLineResultSet().getResult()); |
return parseIntList(getSingleLineResultSet().getResult()); |
950 |
String[] lnS = rs.getMultiLineResult(); |
String[] lnS = rs.getMultiLineResult(); |
951 |
|
|
952 |
AudioOutputDevice aod = new AudioOutputDevice(); |
AudioOutputDevice aod = new AudioOutputDevice(); |
953 |
|
aod.setDeviceID(deviceID); |
954 |
Parameter<Integer> channels; |
Parameter<Integer> channels; |
955 |
Parameter<Integer> samplerate; |
Parameter<Integer> samplerate; |
956 |
|
|
965 |
s = s.substring("CHANNELS: ".length(), s.length()); |
s = s.substring("CHANNELS: ".length(), s.length()); |
966 |
channels.parseValue(s); |
channels.parseValue(s); |
967 |
aod.setChannelsParameter(channels); |
aod.setChannelsParameter(channels); |
968 |
|
int count = channels.getValue() > 0 ? channels.getValue() : 0; |
969 |
|
AudioOutputChannel[] aoc = new AudioOutputChannel[count]; |
970 |
|
for(int i = 0; i < count; i++) { |
971 |
|
aoc[i] = this.getAudioOutputChannelInfo(deviceID, i); |
972 |
|
} |
973 |
|
aod.setAudioChannels(aoc); |
974 |
} else if(s.startsWith("SAMPLERATE: ")) { |
} else if(s.startsWith("SAMPLERATE: ")) { |
975 |
samplerate = (Parameter<Integer>) |
samplerate = (Parameter<Integer>) |
976 |
getAudioOutputDriverParameterInfo(drv, "SAMPLERATE"); |
getAudioOutputDriverParameterInfo(drv, "SAMPLERATE"); |
1034 |
} |
} |
1035 |
|
|
1036 |
/** |
/** |
1037 |
|
* Changes the channels number of the speicifed audio output device. |
1038 |
|
* @param deviceID The numerical ID of the audio output device. |
1039 |
|
* @param channels The new number of audio output channels. |
1040 |
|
* |
1041 |
|
* @throws IOException If an I/O error occurs. |
1042 |
|
* @throws LscpException If LSCP protocol corruption occurs. |
1043 |
|
* @throws LSException If there is no device with ID <code>deviceID</code> or |
1044 |
|
* if <code>channels</code> number is out of range. |
1045 |
|
* |
1046 |
|
* @see #getAudioOutputChannelInfo |
1047 |
|
*/ |
1048 |
|
public synchronized void |
1049 |
|
setAudioOutputChannelCount(int deviceID, int channels) |
1050 |
|
throws IOException, LscpException, LSException { |
1051 |
|
|
1052 |
|
setAudioOutputDeviceParameter(deviceID, new IntParameter("CHANNELS", channels)); |
1053 |
|
} |
1054 |
|
|
1055 |
|
/** |
1056 |
* Gets information about an audio channel. |
* Gets information about an audio channel. |
1057 |
* |
* |
1058 |
* @param deviceID The numerical ID of the audio output device. |
* @param deviceID The numerical ID of the audio output device. |
1086 |
String[] lnS = rs.getMultiLineResult(); |
String[] lnS = rs.getMultiLineResult(); |
1087 |
for(String s : lnS) { |
for(String s : lnS) { |
1088 |
if(s.startsWith("NAME: ")) { |
if(s.startsWith("NAME: ")) { |
1089 |
aoc.setName(s.substring("NAME: ".length())); |
s = s.substring("NAME: ".length()); |
1090 |
|
Parameter<String> prm = getAudioOutputChannelParameterInfo ( |
1091 |
|
deviceID, audioChn, "NAME" |
1092 |
|
); |
1093 |
|
prm.setValue(removeQuotation(s)); |
1094 |
|
aoc.setNameParameter(prm); |
1095 |
} else if(s.startsWith("IS_MIX_CHANNEL: ")) { |
} else if(s.startsWith("IS_MIX_CHANNEL: ")) { |
1096 |
s = s.substring("IS_MIX_CHANNEL: ".length()); |
s = s.substring("IS_MIX_CHANNEL: ".length()); |
1097 |
|
Parameter<Boolean> prm = getAudioOutputChannelParameterInfo ( |
1098 |
aoc.setMixChannel(Boolean.parseBoolean(s)); |
deviceID, audioChn, "IS_MIX_CHANNEL" |
1099 |
|
); |
1100 |
|
prm.setValue(Boolean.parseBoolean(s)); |
1101 |
|
aoc.setMixChannelParameter(prm); |
1102 |
} else if(s.startsWith("MIX_CHANNEL_DESTINATION: ")) { |
} else if(s.startsWith("MIX_CHANNEL_DESTINATION: ")) { |
1103 |
s = s.substring("MIX_CHANNEL_DESTINATION: ".length()); |
s = s.substring("MIX_CHANNEL_DESTINATION: ".length()); |
1104 |
aoc.setMixChannelDest(parseInt(s)); |
Parameter<Integer> prm = getAudioOutputChannelParameterInfo ( |
1105 |
|
deviceID, audioChn, "MIX_CHANNEL_DESTINATION" |
1106 |
|
); |
1107 |
|
prm.setValue(parseInt(s)); |
1108 |
|
aoc.setMixChannelDestParameter(prm); |
1109 |
} else { |
} else { |
1110 |
int i = s.indexOf(": "); |
int i = s.indexOf(": "); |
1111 |
if(i == -1) throw new LscpException ( |
if(i == -1) throw new LscpException ( |
1153 |
throws IOException, LscpException, LSException { |
throws IOException, LscpException, LSException { |
1154 |
|
|
1155 |
verifyConnection(); |
verifyConnection(); |
1156 |
String args = devID + ' ' + chan + ' ' + param; |
String args = devID + " " + chan + " " + param; |
1157 |
out.writeLine("GET AUDIO_OUTPUT_CHANNEL_PARAMETER INFO " + args); |
out.writeLine("GET AUDIO_OUTPUT_CHANNEL_PARAMETER INFO " + args); |
1158 |
|
|
1159 |
ResultSet rs = getMultiLineResultSet(); |
ResultSet rs = getMultiLineResultSet(); |
1215 |
throws IOException, LscpException, LSException { |
throws IOException, LscpException, LSException { |
1216 |
|
|
1217 |
verifyConnection(); |
verifyConnection(); |
1218 |
String args = devID + ' ' + chn + ' ' + prm.getName() + '=' + prm.getStringValue(); |
String args = devID + " " + chn + " " + prm.getName() + '=' + prm.getStringValue(); |
1219 |
out.writeLine("SET AUDIO_OUTPUT_CHANNEL_PARAMETER " + args); |
out.writeLine("SET AUDIO_OUTPUT_CHANNEL_PARAMETER " + args); |
1220 |
|
|
1221 |
ResultSet rs = getEmptyResultSet(); |
ResultSet rs = getEmptyResultSet(); |
1347 |
if(!multi) prm = new BoolParameter(lnS); |
if(!multi) prm = new BoolParameter(lnS); |
1348 |
else prm = new BoolListParameter(lnS); |
else prm = new BoolListParameter(lnS); |
1349 |
prm.setName(param); |
prm.setName(param); |
1350 |
|
prm.setValue(prm.getDefault()); |
1351 |
return prm; |
return prm; |
1352 |
case INT: |
case INT: |
1353 |
if(!multi) prm = new IntParameter(lnS); |
if(!multi) prm = new IntParameter(lnS); |
1354 |
else prm = new IntListParameter(lnS); |
else prm = new IntListParameter(lnS); |
1355 |
prm.setName(param); |
prm.setName(param); |
1356 |
|
prm.setValue(prm.getDefault()); |
1357 |
return prm; |
return prm; |
1358 |
case FLOAT: |
case FLOAT: |
1359 |
if(!multi) prm = new FloatParameter(lnS); |
if(!multi) prm = new FloatParameter(lnS); |
1360 |
else prm = new FloatListParameter(lnS); |
else prm = new FloatListParameter(lnS); |
1361 |
prm.setName(param); |
prm.setName(param); |
1362 |
|
prm.setValue(prm.getDefault()); |
1363 |
return prm; |
return prm; |
1364 |
case STRING: |
case STRING: |
1365 |
if(!multi) prm = new StringParameter(lnS); |
if(!multi) prm = new StringParameter(lnS); |
1366 |
else prm = new StringListParameter(lnS); |
else prm = new StringListParameter(lnS); |
1367 |
prm.setName(param); |
prm.setName(param); |
1368 |
|
prm.setValue(prm.getDefault()); |
1369 |
return prm; |
return prm; |
1370 |
default: throw new LscpException(LscpI18n.getLogMsg("Client.unknownPrmType!")); |
default: throw new LscpException(LscpI18n.getLogMsg("Client.unknownPrmType!")); |
1371 |
} |
} |
1417 |
ResultSet rs = getEmptyResultSet(); |
ResultSet rs = getEmptyResultSet(); |
1418 |
} |
} |
1419 |
|
|
1420 |
|
/** |
1421 |
|
* Enables/disables the specified MIDI input device. |
1422 |
|
* @param deviceID The ID of the MIDI input device to be enabled/disabled. |
1423 |
|
* @param enable If <code>true</code> the MIDI input device is enabled, |
1424 |
|
* else the device is disabled. |
1425 |
|
* @throws IOException If some I/O error occurs. |
1426 |
|
* @throws LSException If there is no MIDI input |
1427 |
|
* device with numerical ID <code>deviceID</code>. |
1428 |
|
* @throws LscpException If LSCP protocol corruption occurs. |
1429 |
|
*/ |
1430 |
|
public void |
1431 |
|
enableMidiInputDevice(int deviceID, boolean enable) |
1432 |
|
throws IOException, LSException, LscpException { |
1433 |
|
|
1434 |
|
setMidiInputDeviceParameter(deviceID, new BoolParameter("ACTIVE", enable)); |
1435 |
|
} |
1436 |
|
|
1437 |
/** |
/** |
1438 |
* Gets the current number of all created MIDI input devices. |
* Gets the current number of all created MIDI input devices. |
1439 |
* @return The current number of all created MIDI input devices. |
* @return The current number of all created MIDI input devices. |
1450 |
} |
} |
1451 |
|
|
1452 |
/** |
/** |
1453 |
|
* Gets a list of all created MIDI input devices. |
1454 |
|
* @return A <code>MidiInputDevice</code> array |
1455 |
|
* providing all created MIDI input devices. |
1456 |
|
* @throws IOException If some I/O error occurs. |
1457 |
|
* @throws LscpException If LSCP protocol corruption occurs. |
1458 |
|
* @throws LSException If some other error occurs. |
1459 |
|
* |
1460 |
|
* @see #createMidiInputDevice |
1461 |
|
* @see #destroyMidiInputDevice |
1462 |
|
*/ |
1463 |
|
public synchronized MidiInputDevice[] |
1464 |
|
getMidiInputDevices() throws IOException, LscpException, LSException { |
1465 |
|
Integer[] idS = getMidiInputDeviceIDs(); |
1466 |
|
MidiInputDevice[] devices = new MidiInputDevice[idS.length]; |
1467 |
|
|
1468 |
|
for(int i = 0; i < devices.length; i++) |
1469 |
|
devices[i] = getMidiInputDeviceInfo(idS[i]); |
1470 |
|
|
1471 |
|
return devices; |
1472 |
|
} |
1473 |
|
|
1474 |
|
/** |
1475 |
* Gets a list of numerical IDs of all created MIDI input devices. |
* Gets a list of numerical IDs of all created MIDI input devices. |
1476 |
* @return An <code>Integer</code> array with numerical IDs of |
* @return An <code>Integer</code> array providing the numerical IDs of |
1477 |
* all created MIDI input devices. |
* all created MIDI input devices. |
1478 |
* @throws IOException If some I/O error occurs. |
* @throws IOException If some I/O error occurs. |
1479 |
* @throws LscpException If LSCP protocol corruption occurs. |
* @throws LscpException If LSCP protocol corruption occurs. |
1483 |
* @see #destroyMidiInputDevice |
* @see #destroyMidiInputDevice |
1484 |
*/ |
*/ |
1485 |
public synchronized Integer[] |
public synchronized Integer[] |
1486 |
getMidiInputDevices() throws IOException, LscpException, LSException { |
getMidiInputDeviceIDs() throws IOException, LscpException, LSException { |
1487 |
verifyConnection(); |
verifyConnection(); |
1488 |
out.writeLine("LIST MIDI_INPUT_DEVICES"); |
out.writeLine("LIST MIDI_INPUT_DEVICES"); |
1489 |
return parseIntList(getSingleLineResultSet().getResult()); |
return parseIntList(getSingleLineResultSet().getResult()); |
1514 |
String[] lnS = rs.getMultiLineResult(); |
String[] lnS = rs.getMultiLineResult(); |
1515 |
|
|
1516 |
MidiInputDevice mid = new MidiInputDevice(); |
MidiInputDevice mid = new MidiInputDevice(); |
1517 |
|
mid.setDeviceID(deviceID); |
1518 |
|
|
1519 |
String drv = getCategoryInfo(lnS, "DRIVER"); |
String drv = getCategoryInfo(lnS, "DRIVER"); |
1520 |
mid.setDriverName(drv); |
mid.setDriverName(drv); |
1525 |
} else if(s.startsWith("ACTIVE: ")) { |
} else if(s.startsWith("ACTIVE: ")) { |
1526 |
s = s.substring("ACTIVE: ".length()); |
s = s.substring("ACTIVE: ".length()); |
1527 |
mid.setActive(Boolean.parseBoolean(s)); |
mid.setActive(Boolean.parseBoolean(s)); |
1528 |
|
} else if(s.startsWith("PORTS: ")) { |
1529 |
|
s = s.substring("PORTS: ".length()); |
1530 |
|
int ports = Parser.parseInt(s); |
1531 |
|
MidiPort[] midiPorts = new MidiPort[ports > 0 ? ports : 0]; |
1532 |
|
|
1533 |
|
for(int i = 0; i < midiPorts.length; i++) |
1534 |
|
midiPorts[i] = getMidiInputPortInfo(deviceID, i); |
1535 |
|
|
1536 |
|
mid.setMidiPorts(midiPorts); |
1537 |
} else { |
} else { |
1538 |
int i = s.indexOf(": "); |
int i = s.indexOf(": "); |
1539 |
if(i == -1) throw new LscpException ( |
if(i == -1) throw new LscpException ( |
1584 |
ResultSet rs = getEmptyResultSet(); |
ResultSet rs = getEmptyResultSet(); |
1585 |
} |
} |
1586 |
|
|
1587 |
|
|
1588 |
|
/** |
1589 |
|
* Changes the ports number of the speicifed MIDI input device. |
1590 |
|
* @param deviceID The numerical ID of the MIDI input device. |
1591 |
|
* @param ports The new number of MIDI input ports. |
1592 |
|
* |
1593 |
|
* @throws IOException If an I/O error occurs. |
1594 |
|
* @throws LscpException If LSCP protocol corruption occurs. |
1595 |
|
* @throws LSException If there is no device with ID <code>deviceID</code> or |
1596 |
|
* if <code>ports</code> number is out of range. |
1597 |
|
* |
1598 |
|
* @see #getMidiInputPortInfo |
1599 |
|
*/ |
1600 |
|
public synchronized void |
1601 |
|
setMidiInputPortCount(int deviceID, int ports) |
1602 |
|
throws IOException, LscpException, LSException { |
1603 |
|
|
1604 |
|
setMidiInputDeviceParameter(deviceID, new IntParameter("PORTS", ports)); |
1605 |
|
} |
1606 |
|
|
1607 |
/** |
/** |
1608 |
* Gets detailed information about a specific MIDI input port. |
* Gets detailed information about a specific MIDI input port. |
1609 |
* @param deviceID The numerical ID of the MIDI input device. |
* @param deviceID The numerical ID of the MIDI input device. |
1632 |
|
|
1633 |
for(String s : lnS) { |
for(String s : lnS) { |
1634 |
if(s.startsWith("NAME: ")) { |
if(s.startsWith("NAME: ")) { |
1635 |
mp.setName(s.substring("NAME: ".length())); |
s = s.substring("NAME: ".length()); |
1636 |
|
Parameter prm = getMidiInputPortParameterInfo ( |
1637 |
|
deviceID, midiPort, "NAME" |
1638 |
|
); |
1639 |
|
prm.setValue(removeQuotation(s)); |
1640 |
|
mp.setNameParameter(prm); |
1641 |
} else { |
} else { |
1642 |
int i = s.indexOf(": "); |
int i = s.indexOf(": "); |
1643 |
if(i == -1) throw new LscpException ( |
if(i == -1) throw new LscpException ( |
1747 |
throws IOException, LscpException, LSException { |
throws IOException, LscpException, LSException { |
1748 |
|
|
1749 |
verifyConnection(); |
verifyConnection(); |
1750 |
String args = deviceID + ' ' + port + ' ' + |
String args = deviceID + " " + port + " " + |
1751 |
prm.getName() + '=' + prm.getStringValue(); |
prm.getName() + '=' + prm.getStringValue(); |
1752 |
out.writeLine("SET MIDI_INPUT_PORT_PARAMETER " + args); |
out.writeLine("SET MIDI_INPUT_PORT_PARAMETER " + args); |
1753 |
|
|
1846 |
} |
} |
1847 |
|
|
1848 |
/** |
/** |
1849 |
|
* Gets a list of all created sampler channels. |
1850 |
|
* @return A <code>SamplerChannel</code> array providing all created sampler channels. |
1851 |
|
* @throws IOException If some I/O error occurs. |
1852 |
|
* @throws LscpException If LSCP protocol corruption occurs. |
1853 |
|
* @throws LSException If some other error occurs. |
1854 |
|
* @see #addSamplerChannel |
1855 |
|
* @see #removeSamplerChannel |
1856 |
|
*/ |
1857 |
|
public synchronized SamplerChannel[] |
1858 |
|
getSamplerChannels() throws IOException, LscpException, LSException { |
1859 |
|
Integer[] idS = getSamplerChannelIDs(); |
1860 |
|
SamplerChannel[] channels = new SamplerChannel[idS.length]; |
1861 |
|
|
1862 |
|
for(int i = 0; i < channels.length; i++) |
1863 |
|
channels[i] = getSamplerChannelInfo(idS[i]); |
1864 |
|
|
1865 |
|
return channels; |
1866 |
|
} |
1867 |
|
|
1868 |
|
/** |
1869 |
* Gets a list with numerical IDs of all created sampler channels. |
* Gets a list with numerical IDs of all created sampler channels. |
1870 |
* @return An <code>Integer</code> array with numerical IDs of all created sampler channels. |
* @return An <code>Integer</code> array providing |
1871 |
|
* the numerical IDs of all created sampler channels. |
1872 |
* @throws IOException If some I/O error occurs. |
* @throws IOException If some I/O error occurs. |
1873 |
* @throws LscpException If LSCP protocol corruption occurs. |
* @throws LscpException If LSCP protocol corruption occurs. |
1874 |
* @throws LSException If some other error occurs. |
* @throws LSException If some other error occurs. |
1876 |
* @see #removeSamplerChannel |
* @see #removeSamplerChannel |
1877 |
*/ |
*/ |
1878 |
public synchronized Integer[] |
public synchronized Integer[] |
1879 |
getSamplerChannels() throws IOException, LscpException, LSException { |
getSamplerChannelIDs() throws IOException, LscpException, LSException { |
1880 |
verifyConnection(); |
verifyConnection(); |
1881 |
out.writeLine("LIST CHANNELS"); |
out.writeLine("LIST CHANNELS"); |
1882 |
return parseIntList(getSingleLineResultSet().getResult()); |
return parseIntList(getSingleLineResultSet().getResult()); |
2009 |
ResultSet rs = getMultiLineResultSet(); |
ResultSet rs = getMultiLineResultSet(); |
2010 |
SamplerChannel sc = new SamplerChannel(rs.getMultiLineResult()); |
SamplerChannel sc = new SamplerChannel(rs.getMultiLineResult()); |
2011 |
sc.setChannelID(samplerChn); |
sc.setChannelID(samplerChn); |
2012 |
|
if(sc.getEngine() != null) sc.setEngine(getEngineInfo(sc.getEngine().getName())); |
2013 |
|
|
2014 |
return sc; |
return sc; |
2015 |
} |
} |
2298 |
} |
} |
2299 |
|
|
2300 |
/** |
/** |
2301 |
|
* Mute/unmute the specified sampler channel. |
2302 |
|
* |
2303 |
|
* @param samplerChn The sampler channel number. |
2304 |
|
* @param mute If <code>true</code> the specified channel is muted, else the channel |
2305 |
|
* is unmuted. |
2306 |
|
* |
2307 |
|
* @throws IOException If some I/O error occurs. |
2308 |
|
* @throws LscpException If LSCP protocol corruption occurs. |
2309 |
|
* @throws LSException If <code>samplerChn</code> is not a valid channel number or if |
2310 |
|
* there is no engine assigned yet to the specified sampler channel. |
2311 |
|
* @see #getSamplerChannels |
2312 |
|
*/ |
2313 |
|
public synchronized void |
2314 |
|
setChannelMute(int samplerChn, boolean mute) |
2315 |
|
throws IOException, LscpException, LSException { |
2316 |
|
|
2317 |
|
verifyConnection(); |
2318 |
|
out.writeLine("SET CHANNEL MUTE " + samplerChn + ' ' + (mute ? 1 : 0)); |
2319 |
|
|
2320 |
|
ResultSet rs = getEmptyResultSet(); |
2321 |
|
} |
2322 |
|
|
2323 |
|
/** |
2324 |
|
* Solo/unsolo the specified sampler channel. |
2325 |
|
* |
2326 |
|
* @param samplerChn The sampler channel number. |
2327 |
|
* @param solo <code>true</code> to solo the specified channel, <code>false</code> |
2328 |
|
* otherwise. |
2329 |
|
* |
2330 |
|
* @throws IOException If some I/O error occurs. |
2331 |
|
* @throws LscpException If LSCP protocol corruption occurs. |
2332 |
|
* @throws LSException If <code>samplerChn</code> is not a valid channel number or if |
2333 |
|
* there is no engine assigned yet to the specified sampler channel. |
2334 |
|
* @see #getSamplerChannels |
2335 |
|
*/ |
2336 |
|
public synchronized void |
2337 |
|
setChannelSolo(int samplerChn, boolean solo) |
2338 |
|
throws IOException, LscpException, LSException { |
2339 |
|
|
2340 |
|
verifyConnection(); |
2341 |
|
out.writeLine("SET CHANNEL SOLO " + samplerChn + ' ' + (solo ? 1 : 0)); |
2342 |
|
|
2343 |
|
ResultSet rs = getEmptyResultSet(); |
2344 |
|
} |
2345 |
|
|
2346 |
|
/** |
2347 |
* Resets the specified sampler channel. |
* Resets the specified sampler channel. |
2348 |
* |
* |
2349 |
* @param samplerChn The sampler channel number. |
* @param samplerChn The sampler channel number. |
2377 |
} |
} |
2378 |
|
|
2379 |
/** |
/** |
2380 |
|
* Gets the current number of all active voices. |
2381 |
|
* @return The current number of all active voices. |
2382 |
|
* @throws IOException If some I/O error occurs. |
2383 |
|
* @throws LscpException If LSCP protocol corruption occurs. |
2384 |
|
* @throws LSException If some other error occurs. |
2385 |
|
*/ |
2386 |
|
public synchronized int |
2387 |
|
getTotalVoiceCount() throws IOException, LscpException, LSException { |
2388 |
|
verifyConnection(); |
2389 |
|
out.writeLine("GET TOTAL_VOICE_COUNT"); |
2390 |
|
String s = getSingleLineResultSet().getResult(); |
2391 |
|
return parseInt(s); |
2392 |
|
} |
2393 |
|
|
2394 |
|
/** |
2395 |
|
* Gets the maximum number of active voices. |
2396 |
|
* @return The maximum number of active voices. |
2397 |
|
* @throws IOException If some I/O error occurs. |
2398 |
|
* @throws LscpException If LSCP protocol corruption occurs. |
2399 |
|
* @throws LSException If some other error occurs. |
2400 |
|
*/ |
2401 |
|
public synchronized int |
2402 |
|
getTotalVoiceCountMax() throws IOException, LscpException, LSException { |
2403 |
|
verifyConnection(); |
2404 |
|
out.writeLine("GET TOTAL_VOICE_COUNT_MAX"); |
2405 |
|
String s = getSingleLineResultSet().getResult(); |
2406 |
|
return parseInt(s); |
2407 |
|
} |
2408 |
|
|
2409 |
|
/** |
2410 |
* Gets information about the LinuxSampler instance. |
* Gets information about the LinuxSampler instance. |
2411 |
* |
* |
2412 |
* @return <code>ServerInfo</code> instance containing |
* @return <code>ServerInfo</code> instance containing |