344 |
if(!llFSI.isEmpty()) subscribe("FX_SEND_INFO"); |
if(!llFSI.isEmpty()) subscribe("FX_SEND_INFO"); |
345 |
if(!llSC.isEmpty()) subscribe("STREAM_COUNT"); |
if(!llSC.isEmpty()) subscribe("STREAM_COUNT"); |
346 |
if(!llVC.isEmpty()) subscribe("VOICE_COUNT"); |
if(!llVC.isEmpty()) subscribe("VOICE_COUNT"); |
347 |
|
if(!llTSC.isEmpty()) subscribe("TOTAL_STREAM_COUNT"); |
348 |
if(!llTVC.isEmpty()) subscribe("TOTAL_VOICE_COUNT"); |
if(!llTVC.isEmpty()) subscribe("TOTAL_VOICE_COUNT"); |
349 |
if(!llMIMC.isEmpty()) subscribe("MIDI_INSTRUMENT_MAP_COUNT"); |
if(!llMIMC.isEmpty()) subscribe("MIDI_INSTRUMENT_MAP_COUNT"); |
350 |
if(!llMIMI.isEmpty()) subscribe("MIDI_INSTRUMENT_MAP_INFO"); |
if(!llMIMI.isEmpty()) subscribe("MIDI_INSTRUMENT_MAP_INFO"); |
486 |
private final Vector<ItemInfoListener> llMIDI = new Vector<ItemInfoListener>(); |
private final Vector<ItemInfoListener> llMIDI = new Vector<ItemInfoListener>(); |
487 |
private final Vector<StreamCountListener> llSC = new Vector<StreamCountListener>(); |
private final Vector<StreamCountListener> llSC = new Vector<StreamCountListener>(); |
488 |
private final Vector<VoiceCountListener> llVC = new Vector<VoiceCountListener>(); |
private final Vector<VoiceCountListener> llVC = new Vector<VoiceCountListener>(); |
489 |
|
private final Vector<TotalStreamCountListener> llTSC = new Vector<TotalStreamCountListener>(); |
490 |
private final Vector<TotalVoiceCountListener> llTVC = new Vector<TotalVoiceCountListener>(); |
private final Vector<TotalVoiceCountListener> llTVC = new Vector<TotalVoiceCountListener>(); |
491 |
|
|
492 |
/** MIDI instrument map count listeners */ |
/** MIDI instrument map count listeners */ |
524 |
!llMIDI.isEmpty() || |
!llMIDI.isEmpty() || |
525 |
!llSC.isEmpty() || |
!llSC.isEmpty() || |
526 |
!llVC.isEmpty() || |
!llVC.isEmpty() || |
527 |
|
!llTSC.isEmpty() || |
528 |
!llTVC.isEmpty() || |
!llTVC.isEmpty() || |
529 |
!llMIMC.isEmpty() || |
!llMIMC.isEmpty() || |
530 |
!llMIMI.isEmpty() || |
!llMIMI.isEmpty() || |
665 |
} catch(NumberFormatException x) { |
} catch(NumberFormatException x) { |
666 |
getLogger().log(Level.WARNING, "Unknown CHANNEL_INFO format", x); |
getLogger().log(Level.WARNING, "Unknown CHANNEL_INFO format", x); |
667 |
} |
} |
668 |
|
} else if(s.startsWith("TOTAL_STREAM_COUNT:")) { |
669 |
|
try { |
670 |
|
s = s.substring("TOTAL_STREAM_COUNT:".length()); |
671 |
|
int i = Integer.parseInt(s); |
672 |
|
TotalStreamCountEvent e = new TotalStreamCountEvent(this, i); |
673 |
|
for(TotalStreamCountListener l : llTSC) l.totalStreamCountChanged(e); |
674 |
|
} catch(NumberFormatException x) { |
675 |
|
getLogger().log ( |
676 |
|
Level.WARNING, "Unknown TOTAL_STREAM_COUNT format", x |
677 |
|
); |
678 |
|
} |
679 |
} else if(s.startsWith("TOTAL_VOICE_COUNT:")) { |
} else if(s.startsWith("TOTAL_VOICE_COUNT:")) { |
680 |
try { |
try { |
681 |
s = s.substring("TOTAL_VOICE_COUNT:".length()); |
s = s.substring("TOTAL_VOICE_COUNT:".length()); |
1148 |
/** |
/** |
1149 |
* Registers the specified listener for receiving event messages. |
* Registers the specified listener for receiving event messages. |
1150 |
* Listeners can be registered regardless of the connection state. |
* Listeners can be registered regardless of the connection state. |
1151 |
|
* @param l The <code>TotalStreamCountListener</code> to register. |
1152 |
|
*/ |
1153 |
|
public synchronized void |
1154 |
|
addTotalStreamCountListener(TotalStreamCountListener l) { |
1155 |
|
if(llTSC.isEmpty()) subscribe("TOTAL_STREAM_COUNT"); |
1156 |
|
llTSC.add(l); |
1157 |
|
} |
1158 |
|
|
1159 |
|
/** |
1160 |
|
* Removes the specified listener. |
1161 |
|
* Listeners can be removed regardless of the connection state. |
1162 |
|
* @param l The <code>TotalStreamCountListener</code> to remove. |
1163 |
|
*/ |
1164 |
|
public synchronized void |
1165 |
|
removeTotalStreamCountListener(TotalStreamCountListener l) { |
1166 |
|
boolean b = llTSC.remove(l); |
1167 |
|
if(b && llTSC.isEmpty()) unsubscribe("TOTAL_STREAM_COUNT"); |
1168 |
|
} |
1169 |
|
|
1170 |
|
/** |
1171 |
|
* Registers the specified listener for receiving event messages. |
1172 |
|
* Listeners can be registered regardless of the connection state. |
1173 |
* @param l The <code>TotalVoiceCountListener</code> to register. |
* @param l The <code>TotalVoiceCountListener</code> to register. |
1174 |
*/ |
*/ |
1175 |
public synchronized void |
public synchronized void |
2252 |
mid.setActive(Boolean.parseBoolean(s)); |
mid.setActive(Boolean.parseBoolean(s)); |
2253 |
} else if(s.startsWith("PORTS: ")) { |
} else if(s.startsWith("PORTS: ")) { |
2254 |
s = s.substring("PORTS: ".length()); |
s = s.substring("PORTS: ".length()); |
2255 |
int ports = Parser.parseInt(s); |
|
2256 |
MidiPort[] midiPorts = new MidiPort[ports > 0 ? ports : 0]; |
Parameter<Integer> ports = (Parameter<Integer>) |
2257 |
|
getMidiInputDriverParameterInfo(drv, "PORTS"); |
2258 |
|
|
2259 |
|
ports.parseValue(s); |
2260 |
|
mid.setPortsParameter(ports); |
2261 |
|
|
2262 |
|
int j = ports.getValue(); |
2263 |
|
MidiPort[] midiPorts = new MidiPort[j > 0 ? j : 0]; |
2264 |
|
|
2265 |
for(int i = 0; i < midiPorts.length; i++) |
for(int i = 0; i < midiPorts.length; i++) |
2266 |
midiPorts[i] = getMidiInputPortInfo(deviceId, i); |
midiPorts[i] = getMidiInputPortInfo(deviceId, i); |
4907 |
} |
} |
4908 |
|
|
4909 |
/** |
/** |
4910 |
|
* Gets the current number of all active streams. |
4911 |
|
* @return The current number of all active streams. |
4912 |
|
* @throws IOException If some I/O error occurs. |
4913 |
|
* @throws LscpException If LSCP protocol corruption occurs. |
4914 |
|
* @throws LSException If some other error occurs. |
4915 |
|
*/ |
4916 |
|
public synchronized int |
4917 |
|
getTotalStreamCount() throws IOException, LscpException, LSException { |
4918 |
|
verifyConnection(); |
4919 |
|
out.writeLine("GET TOTAL_STREAM_COUNT"); |
4920 |
|
if(getPrintOnlyMode()) return -1; |
4921 |
|
|
4922 |
|
String s = getSingleLineResultSet().getResult(); |
4923 |
|
return parseInt(s); |
4924 |
|
} |
4925 |
|
|
4926 |
|
/** |
4927 |
* Gets the current number of all active voices. |
* Gets the current number of all active voices. |
4928 |
* @return The current number of all active voices. |
* @return The current number of all active voices. |
4929 |
* @throws IOException If some I/O error occurs. |
* @throws IOException If some I/O error occurs. |
5012 |
ResultSet rs = getEmptyResultSet(); |
ResultSet rs = getEmptyResultSet(); |
5013 |
} |
} |
5014 |
|
|
5015 |
|
/** |
5016 |
|
* Gets the number of instruments in the specified instrument file. |
5017 |
|
* @param filename The absolute path name of the instrument file. |
5018 |
|
* @return The number of instruments in the specified instrument file. |
5019 |
|
* @throws IOException If some I/O error occurs. |
5020 |
|
* @throws LscpException If LSCP protocol corruption occurs. |
5021 |
|
* @throws LSException If the file is not found, or other error occur. |
5022 |
|
*/ |
5023 |
|
public synchronized int |
5024 |
|
getFileInstrumentCount(String filename) throws IOException, LscpException, LSException { |
5025 |
|
verifyConnection(); |
5026 |
|
out.writeLine("GET FILE INSTRUMENTS '" + filename +"'"); |
5027 |
|
if(getPrintOnlyMode()) return -1; |
5028 |
|
|
5029 |
|
String s = getSingleLineResultSet().getResult(); |
5030 |
|
return parseInt(s); |
5031 |
|
} |
5032 |
|
|
5033 |
|
/** |
5034 |
|
* Gets information about the instrument with index |
5035 |
|
* <code>instrIdx</code> in the specified instrument file. |
5036 |
|
* @param filename The absolute path name of the instrument file. |
5037 |
|
* @param instrIdx The index of the instrument in the specified instrument file. |
5038 |
|
* @throws IOException If some I/O error occurs. |
5039 |
|
* @throws LscpException If LSCP protocol corruption occurs. |
5040 |
|
* @throws LSException If failed to retrieve information. |
5041 |
|
*/ |
5042 |
|
public synchronized Instrument |
5043 |
|
getFileInstrumentInfo(String filename, int instrIdx) |
5044 |
|
throws IOException, LscpException, LSException { |
5045 |
|
|
5046 |
|
verifyConnection(); |
5047 |
|
out.writeLine("GET FILE INSTRUMENT INFO '" + filename + "' " + String.valueOf(instrIdx)); |
5048 |
|
if(getPrintOnlyMode()) return null; |
5049 |
|
|
5050 |
|
ResultSet rs = getMultiLineResultSet(); |
5051 |
|
Instrument instr = new FileInstrument(rs.getMultiLineResult()) { }; |
5052 |
|
|
5053 |
|
return instr; |
5054 |
|
} |
5055 |
|
|
5056 |
|
/** |
5057 |
|
* Gets the list of instruments in the specified instrument file. |
5058 |
|
* @param filename The absolute path name of the instrument file. |
5059 |
|
* @return An <code>Instrument</code> array providing |
5060 |
|
* information about all instruments in the specified instrument file. |
5061 |
|
* @throws IOException If some I/O error occurs. |
5062 |
|
* @throws LscpException If LSCP protocol corruption occurs. |
5063 |
|
* @throws LSException If the specified file name is invalid. |
5064 |
|
*/ |
5065 |
|
public synchronized Instrument[] |
5066 |
|
getFileInstruments(String filename) throws IOException, LscpException, LSException { |
5067 |
|
int l = getFileInstrumentCount(filename); |
5068 |
|
if(l < 0) return null; |
5069 |
|
Instrument[] instrS = new FileInstrument[l]; |
5070 |
|
|
5071 |
|
for(int i = 0; i < instrS.length; i++) { |
5072 |
|
instrS[i] = getFileInstrumentInfo(filename, i); |
5073 |
|
} |
5074 |
|
return instrS; |
5075 |
|
} |
5076 |
|
|
5077 |
|
private static class FileInstrument extends AbstractInstrument { |
5078 |
|
FileInstrument(String[] resultSet) throws LscpException { |
5079 |
|
super(resultSet); |
5080 |
|
} |
5081 |
|
|
5082 |
|
public String |
5083 |
|
getEngine() { |
5084 |
|
// TODO: engine lookup? |
5085 |
|
return getFormatFamily(); |
5086 |
|
} |
5087 |
|
|
5088 |
|
public boolean |
5089 |
|
parse(String s) throws LscpException { |
5090 |
|
if(s.startsWith("PRODUCT: ") || s.startsWith("ARTISTS: ")) return true; |
5091 |
|
return super.parse(s); |
5092 |
|
} |
5093 |
|
} |
5094 |
|
|
5095 |
private void |
private void |
5096 |
getEmptyResultSets(int count, String err) throws LSException { |
getEmptyResultSets(int count, String err) throws LSException { |
5097 |
StringBuffer sb = new StringBuffer(); |
StringBuffer sb = new StringBuffer(); |