1 |
/* |
/* |
2 |
* jlscp - a java LinuxSampler control protocol API |
* jlscp - a java LinuxSampler control protocol API |
3 |
* |
* |
4 |
* Copyright (C) 2005 Grigor Kirilov Iliev |
* Copyright (C) 2005-2007 Grigor Iliev <grigor@grigoriliev.com> |
5 |
* |
* |
6 |
* This file is part of jlscp. |
* This file is part of jlscp. |
7 |
* |
* |
23 |
package org.linuxsampler.lscp; |
package org.linuxsampler.lscp; |
24 |
|
|
25 |
import java.io.IOException; |
import java.io.IOException; |
26 |
|
import java.io.OutputStream; |
27 |
|
|
28 |
import java.net.InetSocketAddress; |
import java.net.InetSocketAddress; |
29 |
import java.net.Socket; |
import java.net.Socket; |
40 |
|
|
41 |
/** |
/** |
42 |
* This class is the abstraction representing a client endpoint for communication with LinuxSampler |
* This class is the abstraction representing a client endpoint for communication with LinuxSampler |
43 |
* instance. Since it implements all commands specified in the LSCP protocol v1.0, for more |
* instance. Since it implements all commands specified in the LSCP protocol v1.1, for more |
44 |
* information look at the |
* information look at the |
45 |
* <a href=http://www.linuxsampler.org/api/lscp-1.0.html>LSCP</a> specification. |
* <a href=http://www.linuxsampler.org/api/lscp-1.1.html>LSCP</a> specification. |
46 |
* |
* |
47 |
* <p> The following code establishes connection to LinuxSampler instance and gets the |
* <p> The following code establishes connection to LinuxSampler instance and gets the |
48 |
* LinuxSampler version: |
* LinuxSampler version: |
76 |
|
|
77 |
private EventThread eventThread; |
private EventThread eventThread; |
78 |
|
|
79 |
|
private boolean printOnlyMode = false; |
80 |
|
|
81 |
class EventThread extends Thread { |
class EventThread extends Thread { |
82 |
private boolean terminate = false; |
private boolean terminate = false; |
83 |
|
|
136 |
} |
} |
137 |
|
|
138 |
/** |
/** |
139 |
|
* Creates a new instance of Client. |
140 |
|
* @param printOnlyMode Determines whether the client will be in print-only mode. |
141 |
|
*/ |
142 |
|
public |
143 |
|
Client(boolean printOnlyMode) { |
144 |
|
if(printOnlyMode) setPrintOnlyMode(true); |
145 |
|
} |
146 |
|
|
147 |
|
/** |
148 |
|
* Determines whether the client is in print-only mode. |
149 |
|
* Print-only mode means that the client will just print all |
150 |
|
* LSCP commands to the specified output stream or to the standard output stream |
151 |
|
* (<code>java.lang.System.out</code>) if no output stream is specified, |
152 |
|
* without taking any further actions. Thus, in print-only mode all returned |
153 |
|
* values by <code>Client</code>'s methods are meaningless and should be discarded. |
154 |
|
* @return <code>true</code> if the client is in |
155 |
|
* print-only mode, <code>false</code> otherwise. |
156 |
|
* @see #setPrintOnlyModeOutputStream |
157 |
|
*/ |
158 |
|
public synchronized boolean |
159 |
|
getPrintOnlyMode() { return printOnlyMode; } |
160 |
|
|
161 |
|
/** |
162 |
|
* Sets the print-only mode. Note that in print-only mode all returned |
163 |
|
* values by <code>Client</code>'s methods are meaningless and should be discarded. |
164 |
|
* The default output stream in print-only mode is <code>java.lang.System.out</code>. |
165 |
|
* @param b If <code>true</code> all LSCP commands will be sent |
166 |
|
* to the specified output stream or to the standard output stream |
167 |
|
* (<code>java.lang.System.out</code>) if no output stream is specified, |
168 |
|
* and no further actions will be taken. |
169 |
|
* @throws IllegalStateException If the client is connected. |
170 |
|
* @see #setPrintOnlyModeOutputStream |
171 |
|
*/ |
172 |
|
public synchronized void |
173 |
|
setPrintOnlyMode(boolean b) { |
174 |
|
if(printOnlyMode == b) return; |
175 |
|
if(isConnected()) throw new IllegalStateException(); |
176 |
|
|
177 |
|
printOnlyMode = b; |
178 |
|
if(b) out = new LscpOutputStream(System.out); |
179 |
|
} |
180 |
|
|
181 |
|
/** |
182 |
|
* Sets the output stream to be used in print-only mode. |
183 |
|
* @param out The output stream to be used in print-only mode. |
184 |
|
* @throws IllegalStateException If the client is not in print-only mode. |
185 |
|
* @throws IllegalArgumentException if <code>out</code> is <code>null</code>. |
186 |
|
* @see #setPrintOnlyMode |
187 |
|
*/ |
188 |
|
public synchronized void |
189 |
|
setPrintOnlyModeOutputStream(OutputStream out) { |
190 |
|
if(!getPrintOnlyMode()) throw new IllegalStateException("Not in print-only mode"); |
191 |
|
if(out == null) throw new IllegalArgumentException("out must be non-null"); |
192 |
|
this.out = new LscpOutputStream(out); |
193 |
|
} |
194 |
|
|
195 |
|
/** |
196 |
* Specifies the jlscp version. |
* Specifies the jlscp version. |
197 |
* @return The jlscp version. |
* @return The jlscp version. |
198 |
*/ |
*/ |
240 |
public synchronized void |
public synchronized void |
241 |
connect() throws LscpException { |
connect() throws LscpException { |
242 |
if(sock != null) disconnect(); |
if(sock != null) disconnect(); |
243 |
|
if(getPrintOnlyMode()) return; |
244 |
|
|
245 |
// Initializing LSCP event thread |
// Initializing LSCP event thread |
246 |
if(eventThread.isAlive()) { |
if(eventThread.isAlive()) { |
313 |
if(hasSubscriptions()) eventThread.start(); |
if(hasSubscriptions()) eventThread.start(); |
314 |
|
|
315 |
if(!llM.isEmpty()) subscribe("MISCELLANEOUS"); |
if(!llM.isEmpty()) subscribe("MISCELLANEOUS"); |
316 |
|
if(!llAODC.isEmpty()) subscribe("AUDIO_OUTPUT_DEVICE_COUNT"); |
317 |
|
if(!llAODI.isEmpty()) subscribe("AUDIO_OUTPUT_DEVICE_INFO"); |
318 |
|
if(!llMIDC.isEmpty()) subscribe("MIDI_INPUT_DEVICE_COUNT"); |
319 |
|
if(!llMIDI.isEmpty()) subscribe("MIDI_INPUT_DEVICE_INFO"); |
320 |
if(!llBF.isEmpty()) subscribe("BUFFER_FILL"); |
if(!llBF.isEmpty()) subscribe("BUFFER_FILL"); |
321 |
if(!llCC.isEmpty()) subscribe("CHANNEL_COUNT"); |
if(!llCC.isEmpty()) subscribe("CHANNEL_COUNT"); |
322 |
if(!llCI.isEmpty()) subscribe("CHANNEL_INFO"); |
if(!llCI.isEmpty()) subscribe("CHANNEL_INFO"); |
323 |
|
if(!llFSC.isEmpty()) subscribe("FX_SEND_COUNT"); |
324 |
|
if(!llFSI.isEmpty()) subscribe("FX_SEND_INFO"); |
325 |
if(!llSC.isEmpty()) subscribe("STREAM_COUNT"); |
if(!llSC.isEmpty()) subscribe("STREAM_COUNT"); |
326 |
if(!llVC.isEmpty()) subscribe("VOICE_COUNT"); |
if(!llVC.isEmpty()) subscribe("VOICE_COUNT"); |
327 |
if(!llTVC.isEmpty()) subscribe("TOTAL_VOICE_COUNT"); |
if(!llTVC.isEmpty()) subscribe("TOTAL_VOICE_COUNT"); |
328 |
|
if(!llMIMC.isEmpty()) subscribe("MIDI_INSTRUMENT_MAP_COUNT"); |
329 |
|
if(!llMIMI.isEmpty()) subscribe("MIDI_INSTRUMENT_MAP_INFO"); |
330 |
|
if(!llMIC.isEmpty()) subscribe("MIDI_INSTRUMENT_COUNT"); |
331 |
|
if(!llMII.isEmpty()) subscribe("MIDI_INSTRUMENT_INFO"); |
332 |
|
if(!llGI.isEmpty()) subscribe("GLOBAL_INFO"); |
333 |
} |
} |
334 |
|
|
335 |
/** |
/** |
337 |
*/ |
*/ |
338 |
public synchronized void |
public synchronized void |
339 |
disconnect() { |
disconnect() { |
340 |
|
if(getPrintOnlyMode()) return; |
341 |
try { if(sock != null) sock.close(); } |
try { if(sock != null) sock.close(); } |
342 |
catch(Exception x) { getLogger().log(Level.FINE, x.getMessage(), x); } |
catch(Exception x) { getLogger().log(Level.FINE, x.getMessage(), x); } |
343 |
sock = null; |
sock = null; |
365 |
*/ |
*/ |
366 |
private void |
private void |
367 |
verifyConnection() throws IOException { |
verifyConnection() throws IOException { |
368 |
|
if(getPrintOnlyMode()) return; |
369 |
|
|
370 |
if(!isConnected()) |
if(!isConnected()) |
371 |
throw new IOException(LscpI18n.getLogMsg("Client.notConnected!")); |
throw new IOException(LscpI18n.getLogMsg("Client.notConnected!")); |
372 |
} |
} |
382 |
return s; |
return s; |
383 |
} |
} |
384 |
|
|
385 |
/** Processes the notifications send by LinuxSampler */ |
/** Processes the notifications sent by LinuxSampler */ |
386 |
private synchronized void |
private synchronized void |
387 |
processNotifications() throws IOException, LscpException { |
processNotifications() throws IOException, LscpException { |
388 |
while(in.available() > 0) { |
while(in.available() > 0) { |
441 |
return rs; |
return rs; |
442 |
} |
} |
443 |
|
|
444 |
|
/** Audio output device count listeners */ |
445 |
|
private final Vector<ItemCountListener> llAODC = new Vector<ItemCountListener>(); |
446 |
|
/** Audio output device info listeners */ |
447 |
|
private final Vector<ItemInfoListener> llAODI = new Vector<ItemInfoListener>(); |
448 |
private final Vector<BufferFillListener> llBF = new Vector<BufferFillListener>(); |
private final Vector<BufferFillListener> llBF = new Vector<BufferFillListener>(); |
449 |
private final Vector<ChannelCountListener> llCC = new Vector<ChannelCountListener>(); |
private final Vector<ChannelCountListener> llCC = new Vector<ChannelCountListener>(); |
450 |
private final Vector<ChannelInfoListener> llCI = new Vector<ChannelInfoListener>(); |
private final Vector<ChannelInfoListener> llCI = new Vector<ChannelInfoListener>(); |
451 |
|
private final Vector<FxSendCountListener> llFSC = new Vector<FxSendCountListener>(); |
452 |
|
private final Vector<FxSendInfoListener> llFSI = new Vector<FxSendInfoListener>(); |
453 |
private final Vector<MiscellaneousListener> llM = new Vector<MiscellaneousListener>(); |
private final Vector<MiscellaneousListener> llM = new Vector<MiscellaneousListener>(); |
454 |
|
/** MIDI input device count listeners */ |
455 |
|
private final Vector<ItemCountListener> llMIDC = new Vector<ItemCountListener>(); |
456 |
|
/** MIDI input device info listeners */ |
457 |
|
private final Vector<ItemInfoListener> llMIDI = new Vector<ItemInfoListener>(); |
458 |
private final Vector<StreamCountListener> llSC = new Vector<StreamCountListener>(); |
private final Vector<StreamCountListener> llSC = new Vector<StreamCountListener>(); |
459 |
private final Vector<VoiceCountListener> llVC = new Vector<VoiceCountListener>(); |
private final Vector<VoiceCountListener> llVC = new Vector<VoiceCountListener>(); |
460 |
private final Vector<TotalVoiceCountListener> llTVC = new Vector<TotalVoiceCountListener>(); |
private final Vector<TotalVoiceCountListener> llTVC = new Vector<TotalVoiceCountListener>(); |
461 |
|
|
462 |
|
/** MIDI instrument map count listeners */ |
463 |
|
private final Vector<ItemCountListener> llMIMC = new Vector<ItemCountListener>(); |
464 |
|
/** MIDI instrument map info listeners */ |
465 |
|
private final Vector<ItemInfoListener> llMIMI = new Vector<ItemInfoListener>(); |
466 |
|
/** MIDI instrument count listeners */ |
467 |
|
private final Vector<MidiInstrumentCountListener> llMIC = |
468 |
|
new Vector<MidiInstrumentCountListener>(); |
469 |
|
/** MIDI instrument info listeners */ |
470 |
|
private final Vector<MidiInstrumentInfoListener> llMII = |
471 |
|
new Vector<MidiInstrumentInfoListener>(); |
472 |
|
private final Vector<GlobalInfoListener> llGI = new Vector<GlobalInfoListener>(); |
473 |
|
|
474 |
|
|
475 |
/** |
/** |
476 |
* Determines whether there is at least one subscription for notification events. |
* Determines whether there is at least one subscription for notification events. |
477 |
* Do not forget to check for additional listeners if the LSCP specification |
* Do not forget to check for additional listeners if the LSCP specification |
481 |
*/ |
*/ |
482 |
private boolean |
private boolean |
483 |
hasSubscriptions() { |
hasSubscriptions() { |
484 |
return !llBF.isEmpty() || |
return !llAODC.isEmpty() || |
485 |
!llCC.isEmpty() || |
!llAODI.isEmpty() || |
486 |
!llCI.isEmpty() || |
!llBF.isEmpty() || |
487 |
!llM.isEmpty() || |
!llCC.isEmpty() || |
488 |
!llSC.isEmpty() || |
!llCI.isEmpty() || |
489 |
!llVC.isEmpty() || |
!llFSC.isEmpty() || |
490 |
!llTVC.isEmpty(); |
!llFSI.isEmpty() || |
491 |
|
!llM.isEmpty() || |
492 |
|
!llMIDC.isEmpty() || |
493 |
|
!llMIDI.isEmpty() || |
494 |
|
!llSC.isEmpty() || |
495 |
|
!llVC.isEmpty() || |
496 |
|
!llTVC.isEmpty() || |
497 |
|
!llMIMC.isEmpty() || |
498 |
|
!llMIMI.isEmpty() || |
499 |
|
!llMIC.isEmpty() || |
500 |
|
!llMII.isEmpty() || |
501 |
|
!llGI.isEmpty(); |
502 |
} |
} |
503 |
|
|
504 |
private void |
private void |
516 |
} else if(s.startsWith("VOICE_COUNT:")) { |
} else if(s.startsWith("VOICE_COUNT:")) { |
517 |
try { |
try { |
518 |
s = s.substring("VOICE_COUNT:".length()); |
s = s.substring("VOICE_COUNT:".length()); |
519 |
int i = s.indexOf(' '); |
Integer[] i = parseIntList(s, ' '); |
520 |
if(i == -1) { |
if(i.length != 2) { |
521 |
getLogger().warning("Unknown VOICE_COUNT format"); |
getLogger().warning("Unknown VOICE_COUNT format"); |
522 |
return; |
return; |
523 |
} |
} |
524 |
int j = Integer.parseInt(s.substring(0, i)); |
VoiceCountEvent e = new VoiceCountEvent(this, i[0], i[1]); |
|
i = Integer.parseInt(s.substring(i + 1)); |
|
|
VoiceCountEvent e = new VoiceCountEvent(this, j, i); |
|
525 |
for(VoiceCountListener l : llVC) l.voiceCountChanged(e); |
for(VoiceCountListener l : llVC) l.voiceCountChanged(e); |
526 |
} catch(NumberFormatException x) { |
} catch(Exception x) { |
527 |
getLogger().log(Level.WARNING, "Unknown VOICE_COUNT format", x); |
getLogger().log(Level.WARNING, "Unknown VOICE_COUNT format", x); |
528 |
} |
} |
529 |
} else if(s.startsWith("STREAM_COUNT:")) { |
} else if(s.startsWith("STREAM_COUNT:")) { |
530 |
try { |
try { |
531 |
s = s.substring("STREAM_COUNT:".length()); |
s = s.substring("STREAM_COUNT:".length()); |
532 |
int i = s.indexOf(' '); |
Integer[] i = parseIntList(s, ' '); |
533 |
if(i == -1) { |
if(i.length != 2) { |
534 |
getLogger().warning("Unknown STREAM_COUNT format"); |
getLogger().warning("Unknown STREAM_COUNT format"); |
535 |
return; |
return; |
536 |
} |
} |
537 |
int j = Integer.parseInt(s.substring(0, i)); |
StreamCountEvent e = new StreamCountEvent(this, i[0], i[1]); |
|
i = Integer.parseInt(s.substring(i + 1)); |
|
|
StreamCountEvent e = new StreamCountEvent(this, j, i); |
|
538 |
for(StreamCountListener l : llSC) l.streamCountChanged(e); |
for(StreamCountListener l : llSC) l.streamCountChanged(e); |
539 |
} catch(NumberFormatException x) { |
} catch(Exception x) { |
540 |
getLogger().log(Level.WARNING, "Unknown STREAM_COUNT format", x); |
getLogger().log(Level.WARNING, "Unknown STREAM_COUNT format", x); |
541 |
} |
} |
542 |
} else if(s.startsWith("BUFFER_FILL:")) { |
} else if(s.startsWith("BUFFER_FILL:")) { |
544 |
s = s.substring("BUFFER_FILL:".length()); |
s = s.substring("BUFFER_FILL:".length()); |
545 |
int i = s.indexOf(' '); |
int i = s.indexOf(' '); |
546 |
if(i == -1) { |
if(i == -1) { |
547 |
getLogger().warning("Unknown STREAM_COUNT format"); |
getLogger().warning("Unknown BUFFER_FILL format"); |
548 |
return; |
return; |
549 |
} |
} |
550 |
int j = Integer.parseInt(s.substring(0, i)); |
int j = Integer.parseInt(s.substring(0, i)); |
553 |
BufferFillEvent e = new BufferFillEvent(this, j, v); |
BufferFillEvent e = new BufferFillEvent(this, j, v); |
554 |
for(BufferFillListener l : llBF) l.bufferFillChanged(e); |
for(BufferFillListener l : llBF) l.bufferFillChanged(e); |
555 |
} catch(Exception x) { |
} catch(Exception x) { |
556 |
getLogger().log(Level.WARNING, "Unknown STREAM_COUNT format", x); |
getLogger().log(Level.WARNING, "Unknown BUFFER_FILL format", x); |
557 |
} |
} |
558 |
} else if(s.startsWith("CHANNEL_INFO:")) { |
} else if(s.startsWith("CHANNEL_INFO:")) { |
559 |
try { |
try { |
561 |
ChannelInfoEvent e = new ChannelInfoEvent(this, i); |
ChannelInfoEvent e = new ChannelInfoEvent(this, i); |
562 |
for(ChannelInfoListener l : llCI) l.channelInfoChanged(e); |
for(ChannelInfoListener l : llCI) l.channelInfoChanged(e); |
563 |
} catch(NumberFormatException x) { |
} catch(NumberFormatException x) { |
564 |
getLogger().log(Level.WARNING, "Unknown STREAM_COUNT format", x); |
getLogger().log(Level.WARNING, "Unknown CHANNEL_INFO format", x); |
565 |
} |
} |
566 |
} else if(s.startsWith("TOTAL_VOICE_COUNT:")) { |
} else if(s.startsWith("TOTAL_VOICE_COUNT:")) { |
567 |
try { |
try { |
574 |
Level.WARNING, "Unknown TOTAL_VOICE_COUNT format", x |
Level.WARNING, "Unknown TOTAL_VOICE_COUNT format", x |
575 |
); |
); |
576 |
} |
} |
577 |
|
} else if(s.startsWith("AUDIO_OUTPUT_DEVICE_COUNT:")) { |
578 |
|
try { |
579 |
|
s = s.substring("AUDIO_OUTPUT_DEVICE_COUNT:".length()); |
580 |
|
int i = Integer.parseInt(s); |
581 |
|
ItemCountEvent e = new ItemCountEvent(this, i); |
582 |
|
for(ItemCountListener l : llAODC) l.itemCountChanged(e); |
583 |
|
} catch(NumberFormatException x) { |
584 |
|
getLogger().log ( |
585 |
|
Level.WARNING, "Unknown AUDIO_OUTPUT_DEVICE_COUNT format", x |
586 |
|
); |
587 |
|
} |
588 |
|
} else if(s.startsWith("AUDIO_OUTPUT_DEVICE_INFO:")) { |
589 |
|
try { |
590 |
|
s = s.substring("AUDIO_OUTPUT_DEVICE_INFO:".length()); |
591 |
|
int i = Integer.parseInt(s); |
592 |
|
ItemInfoEvent e = new ItemInfoEvent(this, i); |
593 |
|
for(ItemInfoListener l : llAODI) l.itemInfoChanged(e); |
594 |
|
} catch(NumberFormatException x) { |
595 |
|
getLogger().log ( |
596 |
|
Level.WARNING, "Unknown AUDIO_OUTPUT_DEVICE_INFO format", x |
597 |
|
); |
598 |
|
} |
599 |
|
} else if(s.startsWith("MIDI_INPUT_DEVICE_COUNT:")) { |
600 |
|
try { |
601 |
|
s = s.substring("MIDI_INPUT_DEVICE_COUNT:".length()); |
602 |
|
int i = Integer.parseInt(s); |
603 |
|
ItemCountEvent e = new ItemCountEvent(this, i); |
604 |
|
for(ItemCountListener l : llMIDC) l.itemCountChanged(e); |
605 |
|
} catch(NumberFormatException x) { |
606 |
|
getLogger().log ( |
607 |
|
Level.WARNING, "Unknown MIDI_INPUT_DEVICE_COUNT format", x |
608 |
|
); |
609 |
|
} |
610 |
|
} else if(s.startsWith("MIDI_INPUT_DEVICE_INFO:")) { |
611 |
|
try { |
612 |
|
s = s.substring("MIDI_INPUT_DEVICE_INFO:".length()); |
613 |
|
int i = Integer.parseInt(s); |
614 |
|
ItemInfoEvent e = new ItemInfoEvent(this, i); |
615 |
|
for(ItemInfoListener l : llMIDI) l.itemInfoChanged(e); |
616 |
|
} catch(NumberFormatException x) { |
617 |
|
getLogger().log ( |
618 |
|
Level.WARNING, "Unknown MIDI_INPUT_DEVICE_INFO format", x |
619 |
|
); |
620 |
|
} |
621 |
|
} else if(s.startsWith("MIDI_INSTRUMENT_MAP_COUNT:")) { |
622 |
|
try { |
623 |
|
s = s.substring("MIDI_INSTRUMENT_MAP_COUNT:".length()); |
624 |
|
int i = Integer.parseInt(s); |
625 |
|
ItemCountEvent e = new ItemCountEvent(this, i); |
626 |
|
for(ItemCountListener l : llMIMC) l.itemCountChanged(e); |
627 |
|
} catch(NumberFormatException x) { |
628 |
|
getLogger().log ( |
629 |
|
Level.WARNING, "Unknown MIDI_INSTRUMENT_MAP_COUNT format", x |
630 |
|
); |
631 |
|
} |
632 |
|
} else if(s.startsWith("MIDI_INSTRUMENT_MAP_INFO:")) { |
633 |
|
try { |
634 |
|
s = s.substring("MIDI_INSTRUMENT_MAP_INFO:".length()); |
635 |
|
int i = Integer.parseInt(s); |
636 |
|
ItemInfoEvent e = new ItemInfoEvent(this, i); |
637 |
|
for(ItemInfoListener l : llMIMI) l.itemInfoChanged(e); |
638 |
|
} catch(NumberFormatException x) { |
639 |
|
getLogger().log ( |
640 |
|
Level.WARNING, "Unknown MIDI_INSTRUMENT_MAP_INFO format", x |
641 |
|
); |
642 |
|
} |
643 |
|
} else if(s.startsWith("MIDI_INSTRUMENT_COUNT:")) { |
644 |
|
try { |
645 |
|
s = s.substring("MIDI_INSTRUMENT_COUNT:".length()); |
646 |
|
Integer[] i = parseIntList(s, ' '); |
647 |
|
if(i.length != 2) { |
648 |
|
getLogger().warning("Unknown MIDI_INSTRUMENT_COUNT format"); |
649 |
|
return; |
650 |
|
} |
651 |
|
|
652 |
|
MidiInstrumentCountEvent e = |
653 |
|
new MidiInstrumentCountEvent(this, i[0], i[1]); |
654 |
|
|
655 |
|
for(MidiInstrumentCountListener l : llMIC) { |
656 |
|
l.instrumentCountChanged(e); |
657 |
|
} |
658 |
|
} catch(Exception x) { |
659 |
|
getLogger().log ( |
660 |
|
Level.WARNING, "Unknown MIDI_INSTRUMENT_COUNT format", x |
661 |
|
); |
662 |
|
} |
663 |
|
} else if(s.startsWith("MIDI_INSTRUMENT_INFO:")) { |
664 |
|
try { |
665 |
|
s = s.substring("MIDI_INSTRUMENT_INFO:".length()); |
666 |
|
Integer[] i = parseIntList(s, ' '); |
667 |
|
if(i.length != 3) { |
668 |
|
getLogger().warning("Unknown MIDI_INSTRUMENT_INFO format"); |
669 |
|
return; |
670 |
|
} |
671 |
|
|
672 |
|
MidiInstrumentInfoEvent e = |
673 |
|
new MidiInstrumentInfoEvent(this, i[0], i[1], i[2]); |
674 |
|
for(MidiInstrumentInfoListener l : llMII) { |
675 |
|
l.instrumentInfoChanged(e); |
676 |
|
} |
677 |
|
} catch(Exception x) { |
678 |
|
getLogger().log ( |
679 |
|
Level.WARNING, "Unknown MIDI_INSTRUMENT_INFO format", x |
680 |
|
); |
681 |
|
} |
682 |
|
} else if(s.startsWith("FX_SEND_COUNT:")) { |
683 |
|
try { |
684 |
|
s = s.substring("FX_SEND_COUNT:".length()); |
685 |
|
Integer[] i = parseIntList(s, ' '); |
686 |
|
if(i.length != 2) { |
687 |
|
getLogger().warning("Unknown FX_SEND_COUNT format"); |
688 |
|
return; |
689 |
|
} |
690 |
|
|
691 |
|
FxSendCountEvent e = new FxSendCountEvent(this, i[0], i[1]); |
692 |
|
|
693 |
|
for(FxSendCountListener l : llFSC) l.fxSendCountChanged(e); |
694 |
|
} catch(Exception x) { |
695 |
|
getLogger().log(Level.WARNING, "Unknown FX_SEND_COUNT format", x); |
696 |
|
} |
697 |
|
} else if(s.startsWith("FX_SEND_INFO:")) { |
698 |
|
try { |
699 |
|
s = s.substring("FX_SEND_INFO:".length()); |
700 |
|
Integer[] i = parseIntList(s, ' '); |
701 |
|
if(i.length != 2) { |
702 |
|
getLogger().warning("Unknown FX_SEND_INFO format"); |
703 |
|
return; |
704 |
|
} |
705 |
|
|
706 |
|
FxSendInfoEvent e = new FxSendInfoEvent(this, i[0], i[1]); |
707 |
|
for(FxSendInfoListener l : llFSI) { |
708 |
|
l.fxSendInfoChanged(e); |
709 |
|
} |
710 |
|
} catch(Exception x) { |
711 |
|
getLogger().log(Level.WARNING, "Unknown FX_SEND_INFO format", x); |
712 |
|
} |
713 |
|
} else if(s.startsWith("GLOBAL_INFO:")) { |
714 |
|
handleGlobalInfoEvent(s.substring("GLOBAL_INFO:".length())); |
715 |
} else if(s.startsWith("MISCELLANEOUS:")) { |
} else if(s.startsWith("MISCELLANEOUS:")) { |
716 |
s = s.substring("MISCELLANEOUS:".length()); |
s = s.substring("MISCELLANEOUS:".length()); |
717 |
MiscellaneousEvent e = new MiscellaneousEvent(this, s); |
MiscellaneousEvent e = new MiscellaneousEvent(this, s); |
720 |
} |
} |
721 |
|
|
722 |
private void |
private void |
723 |
|
handleGlobalInfoEvent(String s) { |
724 |
|
try { |
725 |
|
if(s.startsWith("VOLUME ")) { |
726 |
|
float f = Float.parseFloat(s.substring("VOLUME ".length())); |
727 |
|
GlobalInfoEvent e = new GlobalInfoEvent(this, f); |
728 |
|
for(GlobalInfoListener l : llGI) l.volumeChanged(e); |
729 |
|
} |
730 |
|
} catch(NumberFormatException x) { |
731 |
|
getLogger().log(Level.WARNING, "Unknown GLOBAL_INFO format", x); |
732 |
|
} |
733 |
|
} |
734 |
|
|
735 |
|
private void |
736 |
subscribe(String event) { |
subscribe(String event) { |
737 |
if(!isConnected()) return; |
if(!getPrintOnlyMode()) { |
738 |
|
if(!isConnected()) return; |
739 |
|
|
740 |
if(!eventThread.isAlive()) eventThread.start(); |
if(!eventThread.isAlive()) eventThread.start(); |
741 |
|
} |
742 |
|
|
743 |
try { |
try { |
744 |
out.writeLine("SUBSCRIBE " + event); |
out.writeLine("SUBSCRIBE " + event); |
745 |
ResultSet rs = getEmptyResultSet(); |
if(!getPrintOnlyMode()) getEmptyResultSet(); |
746 |
} catch(Exception x) { |
} catch(Exception x) { |
747 |
getLogger().log ( |
getLogger().log ( |
748 |
Level.WARNING, |
Level.WARNING, |
754 |
|
|
755 |
private void |
private void |
756 |
unsubscribe(String event) { |
unsubscribe(String event) { |
757 |
if(!isConnected()) return; |
if(!getPrintOnlyMode() && !isConnected()) return; |
758 |
|
|
759 |
try { |
try { |
760 |
out.writeLine("UNSUBSCRIBE " + event); |
out.writeLine("UNSUBSCRIBE " + event); |
761 |
ResultSet rs = getEmptyResultSet(); |
if(!getPrintOnlyMode()) getEmptyResultSet(); |
762 |
} catch(Exception x) { |
} catch(Exception x) { |
763 |
getLogger().log ( |
getLogger().log ( |
764 |
Level.WARNING, |
Level.WARNING, |
770 |
|
|
771 |
/** |
/** |
772 |
* Registers the specified listener for receiving event messages. |
* Registers the specified listener for receiving event messages. |
773 |
|
* Listeners can be registered regardless of the connection state. |
774 |
|
* @param l The <code>ItemCountListener</code> to register. |
775 |
|
*/ |
776 |
|
public synchronized void |
777 |
|
addAudioDeviceCountListener(ItemCountListener l) { |
778 |
|
if(llAODC.isEmpty()) subscribe("AUDIO_OUTPUT_DEVICE_COUNT"); |
779 |
|
llAODC.add(l); |
780 |
|
} |
781 |
|
|
782 |
|
/** |
783 |
|
* Removes the specified listener. |
784 |
|
* Listeners can be removed regardless of the connection state. |
785 |
|
* @param l The <code>ItemCountListener</code> to remove. |
786 |
|
*/ |
787 |
|
public synchronized void |
788 |
|
removeAudioDeviceCountListener(ItemCountListener l) { |
789 |
|
boolean b = llAODC.remove(l); |
790 |
|
if(b && llAODC.isEmpty()) unsubscribe("AUDIO_OUTPUT_DEVICE_COUNT"); |
791 |
|
} |
792 |
|
|
793 |
|
/** |
794 |
|
* Registers the specified listener for receiving event messages. |
795 |
|
* Listeners can be registered regardless of the connection state. |
796 |
|
* @param l The <code>ItemInfoListener</code> to register. |
797 |
|
*/ |
798 |
|
public synchronized void |
799 |
|
addAudioDeviceInfoListener(ItemInfoListener l) { |
800 |
|
if(llAODI.isEmpty()) subscribe("AUDIO_OUTPUT_DEVICE_INFO"); |
801 |
|
llAODI.add(l); |
802 |
|
} |
803 |
|
|
804 |
|
/** |
805 |
|
* Removes the specified listener. |
806 |
|
* Listeners can be removed regardless of the connection state. |
807 |
|
* @param l The <code>ItemInfoListener</code> to remove. |
808 |
|
*/ |
809 |
|
public synchronized void |
810 |
|
removeAudioDeviceInfoListener(ItemInfoListener l) { |
811 |
|
boolean b = llAODI.remove(l); |
812 |
|
if(b && llAODI.isEmpty()) unsubscribe("AUDIO_OUTPUT_DEVICE_INFO"); |
813 |
|
} |
814 |
|
|
815 |
|
/** |
816 |
|
* Registers the specified listener for receiving event messages. |
817 |
* Listeners can be removed regardless of the connection state. |
* Listeners can be removed regardless of the connection state. |
818 |
* @param l The <code>BufferFillListener</code> to register. |
* @param l The <code>BufferFillListener</code> to register. |
819 |
*/ |
*/ |
881 |
/** |
/** |
882 |
* Registers the specified listener for receiving event messages. |
* Registers the specified listener for receiving event messages. |
883 |
* Listeners can be registered regardless of the connection state. |
* Listeners can be registered regardless of the connection state. |
884 |
|
* @param l The <code>FxSendCountListener</code> to register. |
885 |
|
*/ |
886 |
|
public synchronized void |
887 |
|
addFxSendCountListener(FxSendCountListener l) { |
888 |
|
if(llFSC.isEmpty()) subscribe("FX_SEND_COUNT"); |
889 |
|
llFSC.add(l); |
890 |
|
} |
891 |
|
|
892 |
|
/** |
893 |
|
* Removes the specified listener. |
894 |
|
* Listeners can be removed regardless of the connection state. |
895 |
|
* @param l The <code>FxSendCountListener</code> to remove. |
896 |
|
*/ |
897 |
|
public synchronized void |
898 |
|
removeFxSendCountListener(FxSendCountListener l) { |
899 |
|
boolean b = llFSC.remove(l); |
900 |
|
if(b && llFSC.isEmpty()) unsubscribe("FX_SEND_COUNT"); |
901 |
|
} |
902 |
|
|
903 |
|
/** |
904 |
|
* Registers the specified listener for receiving event messages. |
905 |
|
* Listeners can be registered regardless of the connection state. |
906 |
|
* @param l The <code>FxSendInfoListener</code> to register. |
907 |
|
*/ |
908 |
|
public synchronized void |
909 |
|
addFxSendInfoListener(FxSendInfoListener l) { |
910 |
|
if(llFSI.isEmpty()) subscribe("FX_SEND_INFO"); |
911 |
|
llFSI.add(l); |
912 |
|
} |
913 |
|
|
914 |
|
/** |
915 |
|
* Removes the specified listener. |
916 |
|
* Listeners can be removed regardless of the connection state. |
917 |
|
* @param l The <code>FxSendInfoListener</code> to remove. |
918 |
|
*/ |
919 |
|
public synchronized void |
920 |
|
removeFxSendInfoListener(FxSendInfoListener l) { |
921 |
|
boolean b = llFSI.remove(l); |
922 |
|
if(b && llFSI.isEmpty()) unsubscribe("FX_SEND_INFO"); |
923 |
|
} |
924 |
|
|
925 |
|
/** |
926 |
|
* Registers the specified listener for receiving event messages. |
927 |
|
* Listeners can be registered regardless of the connection state. |
928 |
|
* @param l The <code>ItemCountListener</code> to register. |
929 |
|
*/ |
930 |
|
public synchronized void |
931 |
|
addMidiDeviceCountListener(ItemCountListener l) { |
932 |
|
if(llMIDC.isEmpty()) subscribe("MIDI_INPUT_DEVICE_COUNT"); |
933 |
|
llMIDC.add(l); |
934 |
|
} |
935 |
|
|
936 |
|
/** |
937 |
|
* Removes the specified listener. |
938 |
|
* Listeners can be removed regardless of the connection state. |
939 |
|
* @param l The <code>ItemCountListener</code> to remove. |
940 |
|
*/ |
941 |
|
public synchronized void |
942 |
|
removeMidiDeviceCountListener(ItemCountListener l) { |
943 |
|
boolean b = llMIDC.remove(l); |
944 |
|
if(b && llMIDC.isEmpty()) unsubscribe("MIDI_INPUT_DEVICE_COUNT"); |
945 |
|
} |
946 |
|
|
947 |
|
/** |
948 |
|
* Registers the specified listener for receiving event messages. |
949 |
|
* Listeners can be registered regardless of the connection state. |
950 |
|
* @param l The <code>ItemInfoListener</code> to register. |
951 |
|
*/ |
952 |
|
public synchronized void |
953 |
|
addMidiDeviceInfoListener(ItemInfoListener l) { |
954 |
|
if(llMIDI.isEmpty()) subscribe("MIDI_INPUT_DEVICE_INFO"); |
955 |
|
llMIDI.add(l); |
956 |
|
} |
957 |
|
|
958 |
|
/** |
959 |
|
* Removes the specified listener. |
960 |
|
* Listeners can be removed regardless of the connection state. |
961 |
|
* @param l The <code>ItemInfoListener</code> to remove. |
962 |
|
*/ |
963 |
|
public synchronized void |
964 |
|
removeMidiDeviceInfoListener(ItemInfoListener l) { |
965 |
|
boolean b = llMIDI.remove(l); |
966 |
|
if(b && llMIDI.isEmpty()) unsubscribe("MIDI_INPUT_DEVICE_INFO"); |
967 |
|
} |
968 |
|
|
969 |
|
/** |
970 |
|
* Registers the specified listener for receiving event messages. |
971 |
|
* Listeners can be registered regardless of the connection state. |
972 |
* @param l The <code>MiscellaneousListener</code> to register. |
* @param l The <code>MiscellaneousListener</code> to register. |
973 |
*/ |
*/ |
974 |
public synchronized void |
public synchronized void |
1055 |
} |
} |
1056 |
|
|
1057 |
/** |
/** |
1058 |
|
* Registers the specified listener for receiving event messages. |
1059 |
|
* Listeners can be registered regardless of the connection state. |
1060 |
|
* @param l The <code>ItemCountListener</code> to register. |
1061 |
|
*/ |
1062 |
|
public synchronized void |
1063 |
|
addMidiInstrumentMapCountListener(ItemCountListener l) { |
1064 |
|
if(llMIMC.isEmpty()) subscribe("MIDI_INSTRUMENT_MAP_COUNT"); |
1065 |
|
llMIMC.add(l); |
1066 |
|
} |
1067 |
|
|
1068 |
|
/** |
1069 |
|
* Removes the specified listener. |
1070 |
|
* Listeners can be removed regardless of the connection state. |
1071 |
|
* @param l The <code>ItemCountListener</code> to remove. |
1072 |
|
*/ |
1073 |
|
public synchronized void |
1074 |
|
removeMidiInstrumentMapCountListener(ItemCountListener l) { |
1075 |
|
boolean b = llMIMC.remove(l); |
1076 |
|
if(b && llMIMC.isEmpty()) unsubscribe("MIDI_INSTRUMENT_MAP_COUNT"); |
1077 |
|
} |
1078 |
|
|
1079 |
|
/** |
1080 |
|
* Registers the specified listener for receiving event messages. |
1081 |
|
* Listeners can be registered regardless of the connection state. |
1082 |
|
* @param l The <code>ItemInfoListener</code> to register. |
1083 |
|
*/ |
1084 |
|
public synchronized void |
1085 |
|
addMidiInstrumentMapInfoListener(ItemInfoListener l) { |
1086 |
|
if(llMIMI.isEmpty()) subscribe("MIDI_INSTRUMENT_MAP_INFO"); |
1087 |
|
llMIMI.add(l); |
1088 |
|
} |
1089 |
|
|
1090 |
|
/** |
1091 |
|
* Removes the specified listener. |
1092 |
|
* Listeners can be removed regardless of the connection state. |
1093 |
|
* @param l The <code>ItemInfoListener</code> to remove. |
1094 |
|
*/ |
1095 |
|
public synchronized void |
1096 |
|
removeMidiInstrumentMapInfoListener(ItemInfoListener l) { |
1097 |
|
boolean b = llMIMI.remove(l); |
1098 |
|
if(b && llMIMI.isEmpty()) unsubscribe("MIDI_INSTRUMENT_MAP_INFO"); |
1099 |
|
} |
1100 |
|
|
1101 |
|
/** |
1102 |
|
* Registers the specified listener for receiving event messages. |
1103 |
|
* Listeners can be registered regardless of the connection state. |
1104 |
|
* @param l The <code>MidiInstrumentCountListener</code> to register. |
1105 |
|
*/ |
1106 |
|
public synchronized void |
1107 |
|
addMidiInstrumentCountListener(MidiInstrumentCountListener l) { |
1108 |
|
if(llMIC.isEmpty()) subscribe("MIDI_INSTRUMENT_COUNT"); |
1109 |
|
llMIC.add(l); |
1110 |
|
} |
1111 |
|
|
1112 |
|
/** |
1113 |
|
* Removes the specified listener. |
1114 |
|
* Listeners can be removed regardless of the connection state. |
1115 |
|
* @param l The <code>MidiInstrumentCountListener</code> to remove. |
1116 |
|
*/ |
1117 |
|
public synchronized void |
1118 |
|
removeMidiInstrumentCountListener(MidiInstrumentCountListener l) { |
1119 |
|
boolean b = llMIC.remove(l); |
1120 |
|
if(b && llMIC.isEmpty()) unsubscribe("MIDI_INSTRUMENT_COUNT"); |
1121 |
|
} |
1122 |
|
|
1123 |
|
/** |
1124 |
|
* Registers the specified listener for receiving event messages. |
1125 |
|
* Listeners can be registered regardless of the connection state. |
1126 |
|
* @param l The <code>MidiInstrumentInfoListener</code> to register. |
1127 |
|
*/ |
1128 |
|
public synchronized void |
1129 |
|
addMidiInstrumentInfoListener(MidiInstrumentInfoListener l) { |
1130 |
|
if(llMII.isEmpty()) subscribe("MIDI_INSTRUMENT_INFO"); |
1131 |
|
llMII.add(l); |
1132 |
|
} |
1133 |
|
|
1134 |
|
/** |
1135 |
|
* Removes the specified listener. |
1136 |
|
* Listeners can be removed regardless of the connection state. |
1137 |
|
* @param l The <code>MidiInstrumentInfoListener</code> to remove. |
1138 |
|
*/ |
1139 |
|
public synchronized void |
1140 |
|
removeMidiInstrumentInfoListener(MidiInstrumentInfoListener l) { |
1141 |
|
boolean b = llMII.remove(l); |
1142 |
|
if(b && llMII.isEmpty()) unsubscribe("MIDI_INSTRUMENT_INFO"); |
1143 |
|
} |
1144 |
|
|
1145 |
|
/** |
1146 |
|
* Registers the specified listener for receiving event messages. |
1147 |
|
* Listeners can be registered regardless of the connection state. |
1148 |
|
* @param l The <code>GlobalInfoListener</code> to register. |
1149 |
|
*/ |
1150 |
|
public synchronized void |
1151 |
|
addGlobalInfoListener(GlobalInfoListener l) { |
1152 |
|
if(llGI.isEmpty()) subscribe("GLOBAL_INFO"); |
1153 |
|
llGI.add(l); |
1154 |
|
} |
1155 |
|
|
1156 |
|
/** |
1157 |
|
* Removes the specified listener. |
1158 |
|
* Listeners can be removed regardless of the connection state. |
1159 |
|
* @param l The <code>GlobalInfoListener</code> to remove. |
1160 |
|
*/ |
1161 |
|
public synchronized void |
1162 |
|
removeGlobalInfoListener(GlobalInfoListener l) { |
1163 |
|
boolean b = llGI.remove(l); |
1164 |
|
if(b && llGI.isEmpty()) unsubscribe("GLOBAL_INFO"); |
1165 |
|
} |
1166 |
|
|
1167 |
|
/** |
1168 |
* Gets the number of all audio output drivers currently |
* Gets the number of all audio output drivers currently |
1169 |
* available for the LinuxSampler instance. |
* available for the LinuxSampler instance. |
1170 |
* @return The number of all audio output drivers currently |
* @return The number of all audio output drivers currently |
1177 |
getAudioOutputDriverCount() throws IOException, LscpException, LSException { |
getAudioOutputDriverCount() throws IOException, LscpException, LSException { |
1178 |
verifyConnection(); |
verifyConnection(); |
1179 |
out.writeLine("GET AVAILABLE_AUDIO_OUTPUT_DRIVERS"); |
out.writeLine("GET AVAILABLE_AUDIO_OUTPUT_DRIVERS"); |
1180 |
|
|
1181 |
|
if(getPrintOnlyMode()) return -1; |
1182 |
|
|
1183 |
String s = getSingleLineResultSet().getResult(); |
String s = getSingleLineResultSet().getResult(); |
1184 |
return parseInt(s); |
return parseInt(s); |
1185 |
} |
} |
1197 |
public synchronized AudioOutputDriver[] |
public synchronized AudioOutputDriver[] |
1198 |
getAudioOutputDrivers() throws IOException, LscpException, LSException { |
getAudioOutputDrivers() throws IOException, LscpException, LSException { |
1199 |
String[] drivers = getAudioOutputDriverNames(); |
String[] drivers = getAudioOutputDriverNames(); |
1200 |
|
if(getPrintOnlyMode()) return null; |
1201 |
|
|
1202 |
AudioOutputDriver[] aod = new AudioOutputDriver[drivers.length]; |
AudioOutputDriver[] aod = new AudioOutputDriver[drivers.length]; |
1203 |
|
|
1204 |
for(int i = 0; i < aod.length; i++) aod[i] = getAudioOutputDriverInfo(drivers[i]); |
for(int i = 0; i < aod.length; i++) aod[i] = getAudioOutputDriverInfo(drivers[i]); |
1220 |
getAudioOutputDriverNames() throws IOException, LscpException, LSException { |
getAudioOutputDriverNames() throws IOException, LscpException, LSException { |
1221 |
verifyConnection(); |
verifyConnection(); |
1222 |
out.writeLine("LIST AVAILABLE_AUDIO_OUTPUT_DRIVERS"); |
out.writeLine("LIST AVAILABLE_AUDIO_OUTPUT_DRIVERS"); |
1223 |
|
if(getPrintOnlyMode()) return null; |
1224 |
return parseList(getSingleLineResultSet().getResult()); |
return parseList(getSingleLineResultSet().getResult()); |
1225 |
} |
} |
1226 |
|
|
1241 |
getAudioOutputDriverInfo(String driverName) throws IOException, LscpException, LSException { |
getAudioOutputDriverInfo(String driverName) throws IOException, LscpException, LSException { |
1242 |
verifyConnection(); |
verifyConnection(); |
1243 |
out.writeLine("GET AUDIO_OUTPUT_DRIVER INFO " + driverName); |
out.writeLine("GET AUDIO_OUTPUT_DRIVER INFO " + driverName); |
1244 |
|
if(getPrintOnlyMode()) return null; |
1245 |
|
|
1246 |
ResultSet rs = getMultiLineResultSet(); |
ResultSet rs = getMultiLineResultSet(); |
1247 |
AudioOutputDriver aod = new AudioOutputDriver(rs.getMultiLineResult()); |
AudioOutputDriver aod = new AudioOutputDriver(rs.getMultiLineResult()); |
1248 |
aod.setName(driverName); |
aod.setName(driverName); |
1286 |
args.append(' ').append(p.getName()).append('=').append(p.getStringValue()); |
args.append(' ').append(p.getName()).append('=').append(p.getStringValue()); |
1287 |
|
|
1288 |
out.writeLine("GET AUDIO_OUTPUT_DRIVER_PARAMETER INFO " + args.toString()); |
out.writeLine("GET AUDIO_OUTPUT_DRIVER_PARAMETER INFO " + args.toString()); |
1289 |
|
if(getPrintOnlyMode()) return null; |
1290 |
|
|
1291 |
ResultSet rs = getMultiLineResultSet(); |
ResultSet rs = getMultiLineResultSet(); |
1292 |
|
|
1348 |
args.append(' ').append(p.getName()).append('=').append(p.getStringValue()); |
args.append(' ').append(p.getName()).append('=').append(p.getStringValue()); |
1349 |
|
|
1350 |
out.writeLine("CREATE AUDIO_OUTPUT_DEVICE " + args.toString()); |
out.writeLine("CREATE AUDIO_OUTPUT_DEVICE " + args.toString()); |
1351 |
|
if(getPrintOnlyMode()) return -1; |
1352 |
|
|
1353 |
ResultSet rs = getEmptyResultSet(); |
ResultSet rs = getEmptyResultSet(); |
1354 |
|
|
1355 |
return rs.getIndex(); |
return rs.getIndex(); |
1357 |
|
|
1358 |
/** |
/** |
1359 |
* Destroys already created audio output device. |
* Destroys already created audio output device. |
1360 |
* @param deviceID The ID of the audio output device to be destroyed. |
* @param deviceId The ID of the audio output device to be destroyed. |
1361 |
* @throws IOException If some I/O error occurs. |
* @throws IOException If some I/O error occurs. |
1362 |
* @throws LSException If the destroying of the audio output device failed. |
* @throws LSException If the destroying of the audio output device failed. |
1363 |
* @throws LscpException If LSCP protocol corruption occurs. |
* @throws LscpException If LSCP protocol corruption occurs. |
1364 |
* @see #getAudioOutputDevices |
* @see #getAudioOutputDevices |
1365 |
*/ |
*/ |
1366 |
public synchronized void |
public synchronized void |
1367 |
destroyAudioOutputDevice(int deviceID) throws IOException, LSException, LscpException { |
destroyAudioOutputDevice(int deviceId) throws IOException, LSException, LscpException { |
1368 |
verifyConnection(); |
verifyConnection(); |
1369 |
out.writeLine("DESTROY AUDIO_OUTPUT_DEVICE " + deviceID); |
out.writeLine("DESTROY AUDIO_OUTPUT_DEVICE " + deviceId); |
1370 |
|
if(getPrintOnlyMode()) return; |
1371 |
|
|
1372 |
ResultSet rs = getEmptyResultSet(); |
ResultSet rs = getEmptyResultSet(); |
1373 |
} |
} |
1374 |
|
|
1375 |
/** |
/** |
1376 |
* Enables/disables the specified audio output device. |
* Enables/disables the specified audio output device. |
1377 |
* @param deviceID The ID of the audio output device to be enabled/disabled. |
* @param deviceId The ID of the audio output device to be enabled/disabled. |
1378 |
* @param enable If <code>true</code> the audio output device is enabled, |
* @param enable If <code>true</code> the audio output device is enabled, |
1379 |
* else the device is disabled. |
* else the device is disabled. |
1380 |
* @throws IOException If some I/O error occurs. |
* @throws IOException If some I/O error occurs. |
1381 |
* @throws LSException If there is no audio output |
* @throws LSException If there is no audio output |
1382 |
* device with numerical ID <code>deviceID</code>. |
* device with numerical ID <code>deviceId</code>. |
1383 |
* @throws LscpException If LSCP protocol corruption occurs. |
* @throws LscpException If LSCP protocol corruption occurs. |
1384 |
*/ |
*/ |
1385 |
public void |
public void |
1386 |
enableAudioOutputDevice(int deviceID, boolean enable) |
enableAudioOutputDevice(int deviceId, boolean enable) |
1387 |
throws IOException, LSException, LscpException { |
throws IOException, LSException, LscpException { |
1388 |
|
|
1389 |
setAudioOutputDeviceParameter(deviceID, new BoolParameter("ACTIVE", enable)); |
setAudioOutputDeviceParameter(deviceId, new BoolParameter("ACTIVE", enable)); |
1390 |
} |
} |
1391 |
|
|
1392 |
/** |
/** |
1400 |
getAudioOutputDeviceCount() throws IOException, LscpException, LSException { |
getAudioOutputDeviceCount() throws IOException, LscpException, LSException { |
1401 |
verifyConnection(); |
verifyConnection(); |
1402 |
out.writeLine("GET AUDIO_OUTPUT_DEVICES"); |
out.writeLine("GET AUDIO_OUTPUT_DEVICES"); |
1403 |
|
if(getPrintOnlyMode()) return -1; |
1404 |
|
|
1405 |
String s = getSingleLineResultSet().getResult(); |
String s = getSingleLineResultSet().getResult(); |
1406 |
return parseInt(s); |
return parseInt(s); |
1407 |
} |
} |
1417 |
public synchronized AudioOutputDevice[] |
public synchronized AudioOutputDevice[] |
1418 |
getAudioOutputDevices() throws IOException, LscpException, LSException { |
getAudioOutputDevices() throws IOException, LscpException, LSException { |
1419 |
Integer[] idS = getAudioOutputDeviceIDs(); |
Integer[] idS = getAudioOutputDeviceIDs(); |
1420 |
|
if(getPrintOnlyMode()) return null; |
1421 |
|
|
1422 |
AudioOutputDevice[] devices = new AudioOutputDevice[idS.length]; |
AudioOutputDevice[] devices = new AudioOutputDevice[idS.length]; |
1423 |
|
|
1424 |
for(int i = 0; i < devices.length; i++) |
for(int i = 0; i < devices.length; i++) |
1439 |
getAudioOutputDeviceIDs() throws IOException, LscpException, LSException { |
getAudioOutputDeviceIDs() throws IOException, LscpException, LSException { |
1440 |
verifyConnection(); |
verifyConnection(); |
1441 |
out.writeLine("LIST AUDIO_OUTPUT_DEVICES"); |
out.writeLine("LIST AUDIO_OUTPUT_DEVICES"); |
1442 |
|
if(getPrintOnlyMode()) return null; |
1443 |
|
|
1444 |
return parseIntList(getSingleLineResultSet().getResult()); |
return parseIntList(getSingleLineResultSet().getResult()); |
1445 |
} |
} |
1446 |
|
|
1447 |
/** |
/** |
1448 |
* Gets the current settings of a specific, already created audio output device. |
* Gets the current settings of a specific, already created audio output device. |
1449 |
* |
* |
1450 |
* @param deviceID Specifies the numerical ID of the audio output device. |
* @param deviceId Specifies the numerical ID of the audio output device. |
1451 |
* |
* |
1452 |
* @return An <code>AudioOutputDevice</code> instance containing information |
* @return An <code>AudioOutputDevice</code> instance containing information |
1453 |
* about the specified device. |
* about the specified device. |
1455 |
* @throws IOException If some I/O error occurs. |
* @throws IOException If some I/O error occurs. |
1456 |
* @throws LscpException If LSCP protocol corruption occurs. |
* @throws LscpException If LSCP protocol corruption occurs. |
1457 |
* @throws LSException If there is no audio output device |
* @throws LSException If there is no audio output device |
1458 |
* with device id <code>deviceID</code>. |
* with device id <code>deviceId</code>. |
1459 |
* |
* |
1460 |
* @see #getAudioOutputDevices |
* @see #getAudioOutputDevices |
1461 |
*/ |
*/ |
1462 |
public synchronized AudioOutputDevice |
public synchronized AudioOutputDevice |
1463 |
getAudioOutputDeviceInfo(int deviceID) throws IOException, LscpException, LSException { |
getAudioOutputDeviceInfo(int deviceId) throws IOException, LscpException, LSException { |
1464 |
verifyConnection(); |
verifyConnection(); |
1465 |
out.writeLine("GET AUDIO_OUTPUT_DEVICE INFO " + deviceID); |
out.writeLine("GET AUDIO_OUTPUT_DEVICE INFO " + deviceId); |
1466 |
|
if(getPrintOnlyMode()) return null; |
1467 |
|
|
1468 |
ResultSet rs = getMultiLineResultSet(); |
ResultSet rs = getMultiLineResultSet(); |
1469 |
|
|
1470 |
String[] lnS = rs.getMultiLineResult(); |
String[] lnS = rs.getMultiLineResult(); |
1471 |
|
|
1472 |
AudioOutputDevice aod = new AudioOutputDevice(); |
AudioOutputDevice aod = new AudioOutputDevice(); |
1473 |
aod.setDeviceID(deviceID); |
aod.setDeviceId(deviceId); |
1474 |
Parameter<Integer> channels; |
Parameter<Integer> channels; |
1475 |
Parameter<Integer> samplerate; |
Parameter<Integer> samplerate; |
1476 |
|
|
1488 |
int count = channels.getValue() > 0 ? channels.getValue() : 0; |
int count = channels.getValue() > 0 ? channels.getValue() : 0; |
1489 |
AudioOutputChannel[] aoc = new AudioOutputChannel[count]; |
AudioOutputChannel[] aoc = new AudioOutputChannel[count]; |
1490 |
for(int i = 0; i < count; i++) { |
for(int i = 0; i < count; i++) { |
1491 |
aoc[i] = this.getAudioOutputChannelInfo(deviceID, i); |
aoc[i] = getAudioOutputChannelInfo(deviceId, i); |
1492 |
} |
} |
1493 |
aod.setAudioChannels(aoc); |
aod.setAudioChannels(aoc); |
1494 |
} else if(s.startsWith("SAMPLERATE: ")) { |
} else if(s.startsWith("SAMPLERATE: ")) { |
1525 |
/** |
/** |
1526 |
* Alters a specific setting of a created audio output device. |
* Alters a specific setting of a created audio output device. |
1527 |
* |
* |
1528 |
* @param deviceID The numerical ID of the audio output device. |
* @param deviceId The numerical ID of the audio output device. |
1529 |
* @param prm A <code>Parameter</code> instance containing the name of the parameter |
* @param prm A <code>Parameter</code> instance containing the name of the parameter |
1530 |
* and the new value for this parameter. |
* and the new value for this parameter. |
1531 |
* |
* |
1533 |
* @throws LscpException If LSCP protocol corruption occurs. |
* @throws LscpException If LSCP protocol corruption occurs. |
1534 |
* @throws LSException If |
* @throws LSException If |
1535 |
* <ul> |
* <ul> |
1536 |
* <li>There is no audio output device with numerical ID <code>deviceID</code>; |
* <li>There is no audio output device with numerical ID <code>deviceId</code>; |
1537 |
* <li>There is no device parameter with the specified name; |
* <li>There is no device parameter with the specified name; |
1538 |
* <li>The device parameter is readonly; |
* <li>The device parameter is readonly; |
1539 |
* <li>The device parameter is from different type. |
* <li>The device parameter is from different type. |
1543 |
* @see #getAudioOutputDeviceInfo |
* @see #getAudioOutputDeviceInfo |
1544 |
*/ |
*/ |
1545 |
public synchronized void |
public synchronized void |
1546 |
setAudioOutputDeviceParameter(int deviceID, Parameter prm) |
setAudioOutputDeviceParameter(int deviceId, Parameter prm) |
1547 |
throws IOException, LscpException, LSException { |
throws IOException, LscpException, LSException { |
1548 |
|
|
1549 |
verifyConnection(); |
verifyConnection(); |
1550 |
String kv = prm.getName() + '=' + prm.getStringValue(); |
String kv = prm.getName() + '=' + prm.getStringValue(); |
1551 |
out.writeLine("SET AUDIO_OUTPUT_DEVICE_PARAMETER " + deviceID + ' ' + kv); |
out.writeLine("SET AUDIO_OUTPUT_DEVICE_PARAMETER " + deviceId + ' ' + kv); |
1552 |
|
if(getPrintOnlyMode()) return; |
1553 |
|
|
1554 |
ResultSet rs = getEmptyResultSet(); |
ResultSet rs = getEmptyResultSet(); |
1555 |
} |
} |
1556 |
|
|
1557 |
/** |
/** |
1558 |
* Changes the channels number of the speicifed audio output device. |
* Changes the channel number of the speicifed audio output device. |
1559 |
* @param deviceID The numerical ID of the audio output device. |
* @param deviceId The numerical ID of the audio output device. |
1560 |
* @param channels The new number of audio output channels. |
* @param channels The new number of audio output channels. |
1561 |
* |
* |
1562 |
* @throws IOException If an I/O error occurs. |
* @throws IOException If an I/O error occurs. |
1563 |
* @throws LscpException If LSCP protocol corruption occurs. |
* @throws LscpException If LSCP protocol corruption occurs. |
1564 |
* @throws LSException If there is no device with ID <code>deviceID</code> or |
* @throws LSException If there is no device with ID <code>deviceId</code> or |
1565 |
* if <code>channels</code> number is out of range. |
* if <code>channels</code> number is out of range. |
1566 |
* |
* |
1567 |
* @see #getAudioOutputChannelInfo |
* @see #getAudioOutputChannelInfo |
1568 |
*/ |
*/ |
1569 |
public synchronized void |
public synchronized void |
1570 |
setAudioOutputChannelCount(int deviceID, int channels) |
setAudioOutputChannelCount(int deviceId, int channels) |
1571 |
throws IOException, LscpException, LSException { |
throws IOException, LscpException, LSException { |
1572 |
|
|
1573 |
setAudioOutputDeviceParameter(deviceID, new IntParameter("CHANNELS", channels)); |
setAudioOutputDeviceParameter(deviceId, new IntParameter("CHANNELS", channels)); |
1574 |
} |
} |
1575 |
|
|
1576 |
/** |
/** |
1577 |
* Gets information about an audio channel. |
* Gets information about an audio channel. |
1578 |
* |
* |
1579 |
* @param deviceID The numerical ID of the audio output device. |
* @param deviceId The numerical ID of the audio output device. |
1580 |
* @param audioChn The audio channel number. |
* @param audioChn The audio channel number. |
1581 |
* |
* |
1582 |
* @return An <code>AudioOutputChannel</code> instance containing the |
* @return An <code>AudioOutputChannel</code> instance containing the |
1586 |
* @throws LscpException If LSCP protocol corruption occurs. |
* @throws LscpException If LSCP protocol corruption occurs. |
1587 |
* @throws LSException If |
* @throws LSException If |
1588 |
* <ul> |
* <ul> |
1589 |
* <li>There is no audio output device with numerical ID <code>deviceID</code>; |
* <li>There is no audio output device with numerical ID <code>deviceId</code>; |
1590 |
* <li><code>audioChn</code> is not a valid channel number; |
* <li><code>audioChn</code> is not a valid channel number; |
1591 |
* </ul> |
* </ul> |
1592 |
* |
* |
1594 |
* @see #getAudioOutputDeviceInfo |
* @see #getAudioOutputDeviceInfo |
1595 |
*/ |
*/ |
1596 |
public synchronized AudioOutputChannel |
public synchronized AudioOutputChannel |
1597 |
getAudioOutputChannelInfo(int deviceID, int audioChn) |
getAudioOutputChannelInfo(int deviceId, int audioChn) |
1598 |
throws IOException, LscpException, LSException { |
throws IOException, LscpException, LSException { |
1599 |
|
|
1600 |
verifyConnection(); |
verifyConnection(); |
1601 |
out.writeLine("GET AUDIO_OUTPUT_CHANNEL INFO " + deviceID + ' ' + audioChn); |
out.writeLine("GET AUDIO_OUTPUT_CHANNEL INFO " + deviceId + ' ' + audioChn); |
1602 |
|
if(getPrintOnlyMode()) return null; |
1603 |
|
|
1604 |
ResultSet rs = getMultiLineResultSet(); |
ResultSet rs = getMultiLineResultSet(); |
1605 |
|
|
1610 |
if(s.startsWith("NAME: ")) { |
if(s.startsWith("NAME: ")) { |
1611 |
s = s.substring("NAME: ".length()); |
s = s.substring("NAME: ".length()); |
1612 |
Parameter<String> prm = getAudioOutputChannelParameterInfo ( |
Parameter<String> prm = getAudioOutputChannelParameterInfo ( |
1613 |
deviceID, audioChn, "NAME" |
deviceId, audioChn, "NAME" |
1614 |
); |
); |
1615 |
prm.setValue(removeQuotation(s)); |
prm.setValue(removeQuotation(s)); |
1616 |
aoc.setNameParameter(prm); |
aoc.setNameParameter(prm); |
1617 |
} else if(s.startsWith("IS_MIX_CHANNEL: ")) { |
} else if(s.startsWith("IS_MIX_CHANNEL: ")) { |
1618 |
s = s.substring("IS_MIX_CHANNEL: ".length()); |
s = s.substring("IS_MIX_CHANNEL: ".length()); |
1619 |
Parameter<Boolean> prm = getAudioOutputChannelParameterInfo ( |
Parameter<Boolean> prm = getAudioOutputChannelParameterInfo ( |
1620 |
deviceID, audioChn, "IS_MIX_CHANNEL" |
deviceId, audioChn, "IS_MIX_CHANNEL" |
1621 |
); |
); |
1622 |
prm.setValue(Boolean.parseBoolean(s)); |
prm.setValue(Boolean.parseBoolean(s)); |
1623 |
aoc.setMixChannelParameter(prm); |
aoc.setMixChannelParameter(prm); |
1624 |
} else if(s.startsWith("MIX_CHANNEL_DESTINATION: ")) { |
} else if(s.startsWith("MIX_CHANNEL_DESTINATION: ")) { |
1625 |
s = s.substring("MIX_CHANNEL_DESTINATION: ".length()); |
s = s.substring("MIX_CHANNEL_DESTINATION: ".length()); |
1626 |
Parameter<Integer> prm = getAudioOutputChannelParameterInfo ( |
Parameter<Integer> prm = getAudioOutputChannelParameterInfo ( |
1627 |
deviceID, audioChn, "MIX_CHANNEL_DESTINATION" |
deviceId, audioChn, "MIX_CHANNEL_DESTINATION" |
1628 |
); |
); |
1629 |
prm.setValue(parseInt(s)); |
prm.setValue(parseInt(s)); |
1630 |
aoc.setMixChannelDestParameter(prm); |
aoc.setMixChannelDestParameter(prm); |
1635 |
); |
); |
1636 |
|
|
1637 |
Parameter prm = getAudioOutputChannelParameterInfo ( |
Parameter prm = getAudioOutputChannelParameterInfo ( |
1638 |
deviceID, audioChn, s.substring(0, i) |
deviceId, audioChn, s.substring(0, i) |
1639 |
); |
); |
1640 |
|
|
1641 |
s = s.substring(i + 2); |
s = s.substring(i + 2); |
1651 |
/** |
/** |
1652 |
* Gets detailed information about a specific audio output channel parameter. |
* Gets detailed information about a specific audio output channel parameter. |
1653 |
* |
* |
1654 |
* @param devID The numerical ID of the audio output device. |
* @param devId The numerical ID of the audio output device. |
1655 |
* @param chan The audio channel number. |
* @param chan The audio channel number. |
1656 |
* @param param a specific channel parameter name for which information should be obtained. |
* @param param a specific channel parameter name for which information should be obtained. |
1657 |
* |
* |
1662 |
* @throws LscpException If LSCP protocol corruption occurs. |
* @throws LscpException If LSCP protocol corruption occurs. |
1663 |
* @throws LSException If |
* @throws LSException If |
1664 |
* <ul> |
* <ul> |
1665 |
* <li><code>devID</code> is not a valid device ID; |
* <li><code>devId</code> is not a valid device ID; |
1666 |
* <li><code>chan</code> is not a valid channel number; |
* <li><code>chan</code> is not a valid channel number; |
1667 |
* <li>There is no channel parameter with the specified name. |
* <li>There is no channel parameter with the specified name. |
1668 |
* </ul> |
* </ul> |
1671 |
* @see #getAudioOutputChannelInfo |
* @see #getAudioOutputChannelInfo |
1672 |
*/ |
*/ |
1673 |
public synchronized Parameter |
public synchronized Parameter |
1674 |
getAudioOutputChannelParameterInfo(int devID, int chan, String param) |
getAudioOutputChannelParameterInfo(int devId, int chan, String param) |
1675 |
throws IOException, LscpException, LSException { |
throws IOException, LscpException, LSException { |
1676 |
|
|
1677 |
verifyConnection(); |
verifyConnection(); |
1678 |
String args = devID + " " + chan + " " + param; |
String args = devId + " " + chan + " " + param; |
1679 |
out.writeLine("GET AUDIO_OUTPUT_CHANNEL_PARAMETER INFO " + args); |
out.writeLine("GET AUDIO_OUTPUT_CHANNEL_PARAMETER INFO " + args); |
1680 |
|
if(getPrintOnlyMode()) return null; |
1681 |
|
|
1682 |
ResultSet rs = getMultiLineResultSet(); |
ResultSet rs = getMultiLineResultSet(); |
1683 |
|
|
1714 |
/** |
/** |
1715 |
* Alters a specific setting of an audio output channel. |
* Alters a specific setting of an audio output channel. |
1716 |
* |
* |
1717 |
* @param devID The numerical ID of the audio device. |
* @param devId The numerical ID of the audio device. |
1718 |
* @param chn The audio channel number. |
* @param chn The audio channel number. |
1719 |
* @param prm A <code>Parameter</code> instance containing the name of the parameter |
* @param prm A <code>Parameter</code> instance containing the name of the parameter |
1720 |
* and the new value for this parameter. |
* and the new value for this parameter. |
1723 |
* @throws LscpException If LSCP protocol corruption occurs. |
* @throws LscpException If LSCP protocol corruption occurs. |
1724 |
* @throws LSException If |
* @throws LSException If |
1725 |
* <ul> |
* <ul> |
1726 |
* <li>There is no audio output device with numerical ID <code>devID</code>; |
* <li>There is no audio output device with numerical ID <code>devId</code>; |
1727 |
* <li><code>chn</code> is not a valid channel number; |
* <li><code>chn</code> is not a valid channel number; |
1728 |
* <li>There is no channel parameter with the specified name; |
* <li>There is no channel parameter with the specified name; |
1729 |
* <li>The channel parameter is readonly; |
* <li>The channel parameter is readonly; |
1734 |
* @see #getAudioOutputChannelInfo |
* @see #getAudioOutputChannelInfo |
1735 |
*/ |
*/ |
1736 |
public synchronized void |
public synchronized void |
1737 |
setAudioOutputChannelParameter(int devID, int chn, Parameter prm) |
setAudioOutputChannelParameter(int devId, int chn, Parameter prm) |
1738 |
throws IOException, LscpException, LSException { |
throws IOException, LscpException, LSException { |
1739 |
|
|
1740 |
verifyConnection(); |
verifyConnection(); |
1741 |
String args = devID + " " + chn + " " + prm.getName() + '=' + prm.getStringValue(); |
String args = devId + " " + chn + " " + prm.getName() + '=' + prm.getStringValue(); |
1742 |
out.writeLine("SET AUDIO_OUTPUT_CHANNEL_PARAMETER " + args); |
out.writeLine("SET AUDIO_OUTPUT_CHANNEL_PARAMETER " + args); |
1743 |
|
if(getPrintOnlyMode()) return; |
1744 |
|
|
1745 |
ResultSet rs = getEmptyResultSet(); |
ResultSet rs = getEmptyResultSet(); |
1746 |
} |
} |
1756 |
getMidiInputDriverCount() throws IOException, LscpException, LSException { |
getMidiInputDriverCount() throws IOException, LscpException, LSException { |
1757 |
verifyConnection(); |
verifyConnection(); |
1758 |
out.writeLine("GET AVAILABLE_MIDI_INPUT_DRIVERS"); |
out.writeLine("GET AVAILABLE_MIDI_INPUT_DRIVERS"); |
1759 |
|
if(getPrintOnlyMode()) return -1; |
1760 |
|
|
1761 |
String s = getSingleLineResultSet().getResult(); |
String s = getSingleLineResultSet().getResult(); |
1762 |
return parseInt(s); |
return parseInt(s); |
1763 |
} |
} |
1775 |
public synchronized MidiInputDriver[] |
public synchronized MidiInputDriver[] |
1776 |
getMidiInputDrivers() throws IOException, LscpException, LSException { |
getMidiInputDrivers() throws IOException, LscpException, LSException { |
1777 |
String[] drivers = getMidiInputDriverNames(); |
String[] drivers = getMidiInputDriverNames(); |
1778 |
|
if(getPrintOnlyMode()) return null; |
1779 |
|
|
1780 |
MidiInputDriver[] mid = new MidiInputDriver[drivers.length]; |
MidiInputDriver[] mid = new MidiInputDriver[drivers.length]; |
1781 |
|
|
1782 |
for(int i = 0; i < mid.length; i++) mid[i] = getMidiInputDriverInfo(drivers[i]); |
for(int i = 0; i < mid.length; i++) mid[i] = getMidiInputDriverInfo(drivers[i]); |
1798 |
getMidiInputDriverNames() throws IOException, LscpException, LSException { |
getMidiInputDriverNames() throws IOException, LscpException, LSException { |
1799 |
verifyConnection(); |
verifyConnection(); |
1800 |
out.writeLine("LIST AVAILABLE_MIDI_INPUT_DRIVERS"); |
out.writeLine("LIST AVAILABLE_MIDI_INPUT_DRIVERS"); |
1801 |
|
if(getPrintOnlyMode()) return null; |
1802 |
|
|
1803 |
return parseList(getSingleLineResultSet().getResult()); |
return parseList(getSingleLineResultSet().getResult()); |
1804 |
} |
} |
1805 |
|
|
1820 |
getMidiInputDriverInfo(String driverName) throws IOException, LscpException, LSException { |
getMidiInputDriverInfo(String driverName) throws IOException, LscpException, LSException { |
1821 |
verifyConnection(); |
verifyConnection(); |
1822 |
out.writeLine("GET MIDI_INPUT_DRIVER INFO " + driverName); |
out.writeLine("GET MIDI_INPUT_DRIVER INFO " + driverName); |
1823 |
|
if(getPrintOnlyMode()) return null; |
1824 |
|
|
1825 |
ResultSet rs = getMultiLineResultSet(); |
ResultSet rs = getMultiLineResultSet(); |
1826 |
|
|
1827 |
MidiInputDriver mid = new MidiInputDriver(rs.getMultiLineResult()); |
MidiInputDriver mid = new MidiInputDriver(rs.getMultiLineResult()); |
1866 |
args.append(' ').append(p.getName()).append('=').append(p.getStringValue()); |
args.append(' ').append(p.getName()).append('=').append(p.getStringValue()); |
1867 |
|
|
1868 |
out.writeLine("GET MIDI_INPUT_DRIVER_PARAMETER INFO " + args.toString()); |
out.writeLine("GET MIDI_INPUT_DRIVER_PARAMETER INFO " + args.toString()); |
1869 |
|
if(getPrintOnlyMode()) return null; |
1870 |
|
|
1871 |
ResultSet rs = getMultiLineResultSet(); |
ResultSet rs = getMultiLineResultSet(); |
1872 |
|
|
1929 |
args.append(' ').append(p.getName()).append('=').append(p.getStringValue()); |
args.append(' ').append(p.getName()).append('=').append(p.getStringValue()); |
1930 |
|
|
1931 |
out.writeLine("CREATE MIDI_INPUT_DEVICE " + args.toString()); |
out.writeLine("CREATE MIDI_INPUT_DEVICE " + args.toString()); |
1932 |
|
if(getPrintOnlyMode()) return -1; |
1933 |
|
|
1934 |
ResultSet rs = getEmptyResultSet(); |
ResultSet rs = getEmptyResultSet(); |
1935 |
|
|
1936 |
return rs.getIndex(); |
return rs.getIndex(); |
1938 |
|
|
1939 |
/** |
/** |
1940 |
* Destroys already created MIDI input device. |
* Destroys already created MIDI input device. |
1941 |
* @param deviceID The numerical ID of the MIDI input device to be destroyed. |
* @param deviceId The numerical ID of the MIDI input device to be destroyed. |
1942 |
* @throws IOException If some I/O error occurs. |
* @throws IOException If some I/O error occurs. |
1943 |
* @throws LSException If the destroying of the MIDI input device failed. |
* @throws LSException If the destroying of the MIDI input device failed. |
1944 |
* @throws LscpException If LSCP protocol corruption occurs. |
* @throws LscpException If LSCP protocol corruption occurs. |
1946 |
* @see #getMidiInputDevices |
* @see #getMidiInputDevices |
1947 |
*/ |
*/ |
1948 |
public synchronized void |
public synchronized void |
1949 |
destroyMidiInputDevice(int deviceID) throws IOException, LSException, LscpException { |
destroyMidiInputDevice(int deviceId) throws IOException, LSException, LscpException { |
1950 |
verifyConnection(); |
verifyConnection(); |
1951 |
out.writeLine("DESTROY MIDI_INPUT_DEVICE " + deviceID); |
out.writeLine("DESTROY MIDI_INPUT_DEVICE " + deviceId); |
1952 |
|
if(getPrintOnlyMode()) return; |
1953 |
|
|
1954 |
ResultSet rs = getEmptyResultSet(); |
ResultSet rs = getEmptyResultSet(); |
1955 |
} |
} |
1956 |
|
|
1957 |
/** |
/** |
1958 |
* Enables/disables the specified MIDI input device. |
* Enables/disables the specified MIDI input device. |
1959 |
* @param deviceID The ID of the MIDI input device to be enabled/disabled. |
* @param deviceId The ID of the MIDI input device to be enabled/disabled. |
1960 |
* @param enable If <code>true</code> the MIDI input device is enabled, |
* @param enable If <code>true</code> the MIDI input device is enabled, |
1961 |
* else the device is disabled. |
* else the device is disabled. |
1962 |
* @throws IOException If some I/O error occurs. |
* @throws IOException If some I/O error occurs. |
1963 |
* @throws LSException If there is no MIDI input |
* @throws LSException If there is no MIDI input |
1964 |
* device with numerical ID <code>deviceID</code>. |
* device with numerical ID <code>deviceId</code>. |
1965 |
* @throws LscpException If LSCP protocol corruption occurs. |
* @throws LscpException If LSCP protocol corruption occurs. |
1966 |
*/ |
*/ |
1967 |
public void |
public void |
1968 |
enableMidiInputDevice(int deviceID, boolean enable) |
enableMidiInputDevice(int deviceId, boolean enable) |
1969 |
throws IOException, LSException, LscpException { |
throws IOException, LSException, LscpException { |
1970 |
|
|
1971 |
setMidiInputDeviceParameter(deviceID, new BoolParameter("ACTIVE", enable)); |
setMidiInputDeviceParameter(deviceId, new BoolParameter("ACTIVE", enable)); |
1972 |
} |
} |
1973 |
|
|
1974 |
/** |
/** |
1982 |
getMidiInputDeviceCount() throws IOException, LscpException, LSException { |
getMidiInputDeviceCount() throws IOException, LscpException, LSException { |
1983 |
verifyConnection(); |
verifyConnection(); |
1984 |
out.writeLine("GET MIDI_INPUT_DEVICES"); |
out.writeLine("GET MIDI_INPUT_DEVICES"); |
1985 |
|
if(getPrintOnlyMode()) return -1; |
1986 |
|
|
1987 |
String s = getSingleLineResultSet().getResult(); |
String s = getSingleLineResultSet().getResult(); |
1988 |
return parseInt(s); |
return parseInt(s); |
1989 |
} |
} |
2002 |
public synchronized MidiInputDevice[] |
public synchronized MidiInputDevice[] |
2003 |
getMidiInputDevices() throws IOException, LscpException, LSException { |
getMidiInputDevices() throws IOException, LscpException, LSException { |
2004 |
Integer[] idS = getMidiInputDeviceIDs(); |
Integer[] idS = getMidiInputDeviceIDs(); |
2005 |
|
if(getPrintOnlyMode()) return null; |
2006 |
|
|
2007 |
MidiInputDevice[] devices = new MidiInputDevice[idS.length]; |
MidiInputDevice[] devices = new MidiInputDevice[idS.length]; |
2008 |
|
|
2009 |
for(int i = 0; i < devices.length; i++) |
for(int i = 0; i < devices.length; i++) |
2027 |
getMidiInputDeviceIDs() throws IOException, LscpException, LSException { |
getMidiInputDeviceIDs() throws IOException, LscpException, LSException { |
2028 |
verifyConnection(); |
verifyConnection(); |
2029 |
out.writeLine("LIST MIDI_INPUT_DEVICES"); |
out.writeLine("LIST MIDI_INPUT_DEVICES"); |
2030 |
|
if(getPrintOnlyMode()) return null; |
2031 |
|
|
2032 |
return parseIntList(getSingleLineResultSet().getResult()); |
return parseIntList(getSingleLineResultSet().getResult()); |
2033 |
} |
} |
2034 |
|
|
2035 |
/** |
/** |
2036 |
* Gets the current settings of a specific, already created MIDI input device. |
* Gets the current settings of a specific, already created MIDI input device. |
2037 |
* |
* |
2038 |
* @param deviceID Specifies the numerical ID of the MIDI input device. |
* @param deviceId Specifies the numerical ID of the MIDI input device. |
2039 |
* |
* |
2040 |
* @return An <code>MidiInputDevice</code> instance containing information |
* @return A <code>MidiInputDevice</code> instance containing information |
2041 |
* about the specified device. |
* about the specified device. |
2042 |
* |
* |
2043 |
* @throws IOException If some I/O error occurs. |
* @throws IOException If some I/O error occurs. |
2044 |
* @throws LscpException If LSCP protocol corruption occurs. |
* @throws LscpException If LSCP protocol corruption occurs. |
2045 |
* @throws LSException If there is no MIDI input device |
* @throws LSException If there is no MIDI input device |
2046 |
* with device id <code>deviceID</code>. |
* with device id <code>deviceId</code>. |
2047 |
* |
* |
2048 |
* @see #getMidiInputDevices |
* @see #getMidiInputDevices |
2049 |
*/ |
*/ |
2050 |
public synchronized MidiInputDevice |
public synchronized MidiInputDevice |
2051 |
getMidiInputDeviceInfo(int deviceID) throws IOException, LscpException, LSException { |
getMidiInputDeviceInfo(int deviceId) throws IOException, LscpException, LSException { |
2052 |
verifyConnection(); |
verifyConnection(); |
2053 |
out.writeLine("GET MIDI_INPUT_DEVICE INFO " + deviceID); |
out.writeLine("GET MIDI_INPUT_DEVICE INFO " + deviceId); |
2054 |
|
if(getPrintOnlyMode()) return null; |
2055 |
|
|
2056 |
ResultSet rs = getMultiLineResultSet(); |
ResultSet rs = getMultiLineResultSet(); |
2057 |
|
|
2058 |
String[] lnS = rs.getMultiLineResult(); |
String[] lnS = rs.getMultiLineResult(); |
2059 |
|
|
2060 |
MidiInputDevice mid = new MidiInputDevice(); |
MidiInputDevice mid = new MidiInputDevice(); |
2061 |
mid.setDeviceID(deviceID); |
mid.setDeviceId(deviceId); |
2062 |
|
|
2063 |
String drv = getCategoryInfo(lnS, "DRIVER"); |
String drv = getCategoryInfo(lnS, "DRIVER"); |
2064 |
mid.setDriverName(drv); |
mid.setDriverName(drv); |
2075 |
MidiPort[] midiPorts = new MidiPort[ports > 0 ? ports : 0]; |
MidiPort[] midiPorts = new MidiPort[ports > 0 ? ports : 0]; |
2076 |
|
|
2077 |
for(int i = 0; i < midiPorts.length; i++) |
for(int i = 0; i < midiPorts.length; i++) |
2078 |
midiPorts[i] = getMidiInputPortInfo(deviceID, i); |
midiPorts[i] = getMidiInputPortInfo(deviceId, i); |
2079 |
|
|
2080 |
mid.setMidiPorts(midiPorts); |
mid.setMidiPorts(midiPorts); |
2081 |
} else { |
} else { |
2100 |
/** |
/** |
2101 |
* Alters a specific setting of a created MIDI input device. |
* Alters a specific setting of a created MIDI input device. |
2102 |
* |
* |
2103 |
* @param deviceID The numerical ID of the MIDI input device. |
* @param deviceId The numerical ID of the MIDI input device. |
2104 |
* @param prm A <code>Parameter</code> instance containing the name of the parameter |
* @param prm A <code>Parameter</code> instance containing the name of the parameter |
2105 |
* and the new value for this parameter. |
* and the new value for this parameter. |
2106 |
* |
* |
2108 |
* @throws LscpException If LSCP protocol corruption occurs. |
* @throws LscpException If LSCP protocol corruption occurs. |
2109 |
* @throws LSException If |
* @throws LSException If |
2110 |
* <ul> |
* <ul> |
2111 |
* <li>There is no MIDI input device with numerical ID <code>deviceID</code>; |
* <li>There is no MIDI input device with numerical ID <code>deviceId</code>; |
2112 |
* <li>There is no device parameter with the specified name; |
* <li>There is no device parameter with the specified name; |
2113 |
* <li>The device parameter is readonly; |
* <li>The device parameter is readonly; |
2114 |
* <li>The device parameter is from different type. |
* <li>The device parameter is from different type. |
2118 |
* @see #getMidiInputDeviceInfo |
* @see #getMidiInputDeviceInfo |
2119 |
*/ |
*/ |
2120 |
public synchronized void |
public synchronized void |
2121 |
setMidiInputDeviceParameter(int deviceID, Parameter prm) |
setMidiInputDeviceParameter(int deviceId, Parameter prm) |
2122 |
throws IOException, LscpException, LSException { |
throws IOException, LscpException, LSException { |
2123 |
|
|
2124 |
verifyConnection(); |
verifyConnection(); |
2125 |
String kv = prm.getName() + '=' + prm.getStringValue(); |
String kv = prm.getName() + '=' + prm.getStringValue(); |
2126 |
out.writeLine("SET MIDI_INPUT_DEVICE_PARAMETER " + deviceID + ' ' + kv); |
out.writeLine("SET MIDI_INPUT_DEVICE_PARAMETER " + deviceId + ' ' + kv); |
2127 |
|
if(getPrintOnlyMode()) return; |
2128 |
|
|
2129 |
ResultSet rs = getEmptyResultSet(); |
ResultSet rs = getEmptyResultSet(); |
2130 |
} |
} |
2131 |
|
|
2132 |
|
|
2133 |
/** |
/** |
2134 |
* Changes the ports number of the speicifed MIDI input device. |
* Changes the port number of the speicified MIDI input device. |
2135 |
* @param deviceID The numerical ID of the MIDI input device. |
* @param deviceId The numerical ID of the MIDI input device. |
2136 |
* @param ports The new number of MIDI input ports. |
* @param ports The new number of MIDI input ports. |
2137 |
* |
* |
2138 |
* @throws IOException If an I/O error occurs. |
* @throws IOException If an I/O error occurs. |
2139 |
* @throws LscpException If LSCP protocol corruption occurs. |
* @throws LscpException If LSCP protocol corruption occurs. |
2140 |
* @throws LSException If there is no device with ID <code>deviceID</code> or |
* @throws LSException If there is no device with ID <code>deviceId</code> or |
2141 |
* if <code>ports</code> number is out of range. |
* if <code>ports</code> number is out of range. |
2142 |
* |
* |
2143 |
* @see #getMidiInputPortInfo |
* @see #getMidiInputPortInfo |
2144 |
*/ |
*/ |
2145 |
public synchronized void |
public synchronized void |
2146 |
setMidiInputPortCount(int deviceID, int ports) |
setMidiInputPortCount(int deviceId, int ports) |
2147 |
throws IOException, LscpException, LSException { |
throws IOException, LscpException, LSException { |
2148 |
|
|
2149 |
setMidiInputDeviceParameter(deviceID, new IntParameter("PORTS", ports)); |
setMidiInputDeviceParameter(deviceId, new IntParameter("PORTS", ports)); |
2150 |
} |
} |
2151 |
|
|
2152 |
/** |
/** |
2153 |
* Gets detailed information about a specific MIDI input port. |
* Gets detailed information about a specific MIDI input port. |
2154 |
* @param deviceID The numerical ID of the MIDI input device. |
* @param deviceId The numerical ID of the MIDI input device. |
2155 |
* @param midiPort The MIDI input port number. |
* @param midiPort The MIDI input port number. |
2156 |
* |
* |
2157 |
* @return A <code>MidiPort</code> instance containing |
* @return A <code>MidiPort</code> instance containing |
2159 |
* |
* |
2160 |
* @throws IOException If an I/O error occurs. |
* @throws IOException If an I/O error occurs. |
2161 |
* @throws LscpException If LSCP protocol corruption occurs. |
* @throws LscpException If LSCP protocol corruption occurs. |
2162 |
* @throws LSException If there is no device with ID <code>deviceID</code> or |
* @throws LSException If there is no device with ID <code>deviceId</code> or |
2163 |
* if <code>midiPort</code> is not a valid MIDI port number. |
* if <code>midiPort</code> is not a valid MIDI port number. |
2164 |
* |
* |
2165 |
* @see #getMidiInputDevices |
* @see #getMidiInputDevices |
2166 |
*/ |
*/ |
2167 |
public synchronized MidiPort |
public synchronized MidiPort |
2168 |
getMidiInputPortInfo(int deviceID, int midiPort) |
getMidiInputPortInfo(int deviceId, int midiPort) |
2169 |
throws IOException, LscpException, LSException { |
throws IOException, LscpException, LSException { |
2170 |
|
|
2171 |
verifyConnection(); |
verifyConnection(); |
2172 |
out.writeLine("GET MIDI_INPUT_PORT INFO " + deviceID + " " + midiPort); |
out.writeLine("GET MIDI_INPUT_PORT INFO " + deviceId + " " + midiPort); |
2173 |
|
if(getPrintOnlyMode()) return null; |
2174 |
|
|
2175 |
ResultSet rs = getMultiLineResultSet(); |
ResultSet rs = getMultiLineResultSet(); |
2176 |
|
|
2177 |
MidiPort mp = new MidiPort(); |
MidiPort mp = new MidiPort(); |
2181 |
if(s.startsWith("NAME: ")) { |
if(s.startsWith("NAME: ")) { |
2182 |
s = s.substring("NAME: ".length()); |
s = s.substring("NAME: ".length()); |
2183 |
Parameter prm = getMidiInputPortParameterInfo ( |
Parameter prm = getMidiInputPortParameterInfo ( |
2184 |
deviceID, midiPort, "NAME" |
deviceId, midiPort, "NAME" |
2185 |
); |
); |
2186 |
prm.setValue(removeQuotation(s)); |
prm.setValue(removeQuotation(s)); |
2187 |
mp.setNameParameter(prm); |
mp.setNameParameter(prm); |
2192 |
); |
); |
2193 |
|
|
2194 |
Parameter prm = getMidiInputPortParameterInfo ( |
Parameter prm = getMidiInputPortParameterInfo ( |
2195 |
deviceID, midiPort, s.substring(0, i) |
deviceId, midiPort, s.substring(0, i) |
2196 |
); |
); |
2197 |
|
|
2198 |
s = s.substring(i + 2); |
s = s.substring(i + 2); |
2208 |
/** |
/** |
2209 |
* Gets detailed information about a specific MIDI input port parameter. |
* Gets detailed information about a specific MIDI input port parameter. |
2210 |
* |
* |
2211 |
* @param deviceID The numerical ID of the MIDI input device. |
* @param deviceId The numerical ID of the MIDI input device. |
2212 |
* @param port The MIDI port number. |
* @param port The MIDI port number. |
2213 |
* @param param A specific parameter name for which information should be obtained. |
* @param param A specific parameter name for which information should be obtained. |
2214 |
* |
* |
2219 |
* @throws LscpException If LSCP protocol corruption occurs. |
* @throws LscpException If LSCP protocol corruption occurs. |
2220 |
* @throws LSException If |
* @throws LSException If |
2221 |
* <ul> |
* <ul> |
2222 |
* <li>There is no MIDI input device with numerical ID <code>deviceID</code>; |
* <li>There is no MIDI input device with numerical ID <code>deviceId</code>; |
2223 |
* <li> <code>port</code> is not a valid MIDI port number; |
* <li> <code>port</code> is not a valid MIDI port number; |
2224 |
* <li><code>param</code> is not a valid parameter for the specified MIDI port. |
* <li><code>param</code> is not a valid parameter for the specified MIDI port. |
2225 |
* </ul> |
* </ul> |
2228 |
* @see #getMidiInputPortInfo |
* @see #getMidiInputPortInfo |
2229 |
*/ |
*/ |
2230 |
public synchronized Parameter |
public synchronized Parameter |
2231 |
getMidiInputPortParameterInfo(int deviceID, int port, String param) |
getMidiInputPortParameterInfo(int deviceId, int port, String param) |
2232 |
throws IOException, LscpException, LSException { |
throws IOException, LscpException, LSException { |
2233 |
|
|
2234 |
verifyConnection(); |
verifyConnection(); |
2235 |
String args = deviceID + " " + port + " " + param; |
String args = deviceId + " " + port + " " + param; |
2236 |
out.writeLine("GET MIDI_INPUT_PORT_PARAMETER INFO " + args); |
out.writeLine("GET MIDI_INPUT_PORT_PARAMETER INFO " + args); |
2237 |
|
if(getPrintOnlyMode()) return null; |
2238 |
|
|
2239 |
ResultSet rs = getMultiLineResultSet(); |
ResultSet rs = getMultiLineResultSet(); |
2240 |
|
|
2271 |
/** |
/** |
2272 |
* Alters a specific setting of a MIDI input port. |
* Alters a specific setting of a MIDI input port. |
2273 |
* |
* |
2274 |
* @param deviceID The numerical ID of the MIDI device. |
* @param deviceId The numerical ID of the MIDI device. |
2275 |
* @param port The MIDI port number. |
* @param port The MIDI port number. |
2276 |
* @param prm A <code>Parameter</code> instance containing the name of the parameter |
* @param prm A <code>Parameter</code> instance containing the name of the parameter |
2277 |
* and the new value for this parameter. |
* and the new value for this parameter. |
2280 |
* @throws LscpException If LSCP protocol corruption occurs. |
* @throws LscpException If LSCP protocol corruption occurs. |
2281 |
* @throws LSException If |
* @throws LSException If |
2282 |
* <ul> |
* <ul> |
2283 |
* <li>There is no MIDI device with numerical ID <code>deviceID</code>; |
* <li>There is no MIDI device with numerical ID <code>deviceId</code>; |
2284 |
* <li><code>port</code> is not a valid MIDI port number; |
* <li><code>port</code> is not a valid MIDI port number; |
2285 |
* <li><code>prm</code> is not a valid parameter; |
* <li><code>prm</code> is not a valid parameter; |
2286 |
* <li>The parameter is readonly; |
* <li>The parameter is readonly; |
2291 |
* @see #getMidiInputPortInfo |
* @see #getMidiInputPortInfo |
2292 |
*/ |
*/ |
2293 |
public synchronized void |
public synchronized void |
2294 |
setMidiInputPortParameter(int deviceID, int port, Parameter prm) |
setMidiInputPortParameter(int deviceId, int port, Parameter prm) |
2295 |
throws IOException, LscpException, LSException { |
throws IOException, LscpException, LSException { |
2296 |
|
|
2297 |
verifyConnection(); |
verifyConnection(); |
2298 |
String args = deviceID + " " + port + " " + |
String args = deviceId + " " + port + " " + |
2299 |
prm.getName() + '=' + prm.getStringValue(); |
prm.getName() + '=' + prm.getStringValue(); |
2300 |
out.writeLine("SET MIDI_INPUT_PORT_PARAMETER " + args); |
out.writeLine("SET MIDI_INPUT_PORT_PARAMETER " + args); |
2301 |
|
if(getPrintOnlyMode()) return; |
2302 |
|
|
2303 |
|
ResultSet rs = getEmptyResultSet(); |
2304 |
|
} |
2305 |
|
|
2306 |
|
/** |
2307 |
|
* Adds a new MIDI instrument map. |
2308 |
|
* @param name The name of this MIDI instrument map. |
2309 |
|
* @return The number of the newly MIDI instrument map. |
2310 |
|
* @throws IOException If some I/O error occurs. |
2311 |
|
* @throws LSException If the creation of the new MIDI instrument map failed. |
2312 |
|
* @throws LscpException If LSCP protocol corruption occurs. |
2313 |
|
* @see #removeMidiInstrumentMap |
2314 |
|
*/ |
2315 |
|
public synchronized int |
2316 |
|
addMidiInstrumentMap(String name) throws IOException, LSException, LscpException { |
2317 |
|
verifyConnection(); |
2318 |
|
out.writeLine("ADD MIDI_INSTRUMENT_MAP '" + name + "'"); |
2319 |
|
if(getPrintOnlyMode()) return -1; |
2320 |
|
|
2321 |
|
ResultSet rs = getEmptyResultSet(); |
2322 |
|
|
2323 |
|
return rs.getIndex(); |
2324 |
|
} |
2325 |
|
|
2326 |
|
/** |
2327 |
|
* Removes the specified MIDI instrument map. |
2328 |
|
* @param mapId The numerical ID of the MIDI instrument map to be removed. |
2329 |
|
* @throws IOException If some I/O error occurs. |
2330 |
|
* @throws LscpException If LSCP protocol corruption occurs. |
2331 |
|
* @throws LSException If the removing of the MIDI instrument map failed. |
2332 |
|
* @see #addMidiInstrumentMap |
2333 |
|
* @see #getMidiInstrumentMapIDs |
2334 |
|
*/ |
2335 |
|
public synchronized void |
2336 |
|
removeMidiInstrumentMap(int mapId) throws IOException, LscpException, LSException { |
2337 |
|
verifyConnection(); |
2338 |
|
out.writeLine("REMOVE MIDI_INSTRUMENT_MAP " + mapId); |
2339 |
|
if(getPrintOnlyMode()) return; |
2340 |
|
|
2341 |
|
ResultSet rs = getEmptyResultSet(); |
2342 |
|
} |
2343 |
|
|
2344 |
|
/** |
2345 |
|
* Removes the all MIDI instrument maps. |
2346 |
|
* @throws IOException If some I/O error occurs. |
2347 |
|
* @throws LscpException If LSCP protocol corruption occurs. |
2348 |
|
* @throws LSException If the removing of the MIDI instrument maps failed. |
2349 |
|
*/ |
2350 |
|
public synchronized void |
2351 |
|
removeAllMidiInstrumentMaps() throws IOException, LscpException, LSException { |
2352 |
|
verifyConnection(); |
2353 |
|
out.writeLine("REMOVE MIDI_INSTRUMENT_MAP ALL"); |
2354 |
|
if(getPrintOnlyMode()) return; |
2355 |
|
|
2356 |
|
ResultSet rs = getEmptyResultSet(); |
2357 |
|
} |
2358 |
|
|
2359 |
|
/** |
2360 |
|
* Gets the current number of all MIDI instrument maps. |
2361 |
|
* @return The current number of all MIDI instrument maps. |
2362 |
|
* @throws IOException If some I/O error occurs. |
2363 |
|
* @throws LscpException If LSCP protocol corruption occurs. |
2364 |
|
* @throws LSException If some other error occurs. |
2365 |
|
*/ |
2366 |
|
public synchronized int |
2367 |
|
getMidiInstrumentMapCount() throws IOException, LscpException, LSException { |
2368 |
|
verifyConnection(); |
2369 |
|
out.writeLine("GET MIDI_INSTRUMENT_MAPS"); |
2370 |
|
if(getPrintOnlyMode()) return -1; |
2371 |
|
|
2372 |
|
String s = getSingleLineResultSet().getResult(); |
2373 |
|
return parseInt(s); |
2374 |
|
} |
2375 |
|
|
2376 |
|
/** |
2377 |
|
* Gets a list of numerical IDs of all created MIDI instrument maps. |
2378 |
|
* @return An <code>Integer</code> array providing the numerical IDs of |
2379 |
|
* all created MIDI instrument maps. |
2380 |
|
* @throws IOException If some I/O error occurs. |
2381 |
|
* @throws LscpException If LSCP protocol corruption occurs. |
2382 |
|
* @throws LSException If some other error occurs. |
2383 |
|
* @see #addMidiInstrumentMap |
2384 |
|
* @see #removeMidiInstrumentMap |
2385 |
|
*/ |
2386 |
|
public synchronized Integer[] |
2387 |
|
getMidiInstrumentMapIDs() throws IOException, LscpException, LSException { |
2388 |
|
verifyConnection(); |
2389 |
|
out.writeLine("LIST MIDI_INSTRUMENT_MAPS"); |
2390 |
|
if(getPrintOnlyMode()) return null; |
2391 |
|
|
2392 |
|
return parseIntList(getSingleLineResultSet().getResult()); |
2393 |
|
} |
2394 |
|
|
2395 |
|
/** |
2396 |
|
* Gets the current settings of a specific, already created MIDI instrument map. |
2397 |
|
* @param mapId Specifies the numerical ID of the MIDI instrument map. |
2398 |
|
* @return A <code>MidiInstrumentMapInfo</code> instance containing information |
2399 |
|
* about the specified device. |
2400 |
|
* @throws IOException If some I/O error occurs. |
2401 |
|
* @throws LscpException If LSCP protocol corruption occurs. |
2402 |
|
* @throws LSException If there is no MIDI instrument map |
2403 |
|
* with map id <code>mapId</code>. |
2404 |
|
* @see #getMidiInstrumentMaps |
2405 |
|
*/ |
2406 |
|
public synchronized MidiInstrumentMapInfo |
2407 |
|
getMidiInstrumentMapInfo(int mapId) throws IOException, LscpException, LSException { |
2408 |
|
verifyConnection(); |
2409 |
|
out.writeLine("GET MIDI_INSTRUMENT_MAP INFO " + mapId); |
2410 |
|
if(getPrintOnlyMode()) return null; |
2411 |
|
|
2412 |
|
ResultSet rs = getMultiLineResultSet(); |
2413 |
|
|
2414 |
|
String[] lnS = rs.getMultiLineResult(); |
2415 |
|
|
2416 |
|
String name = ""; |
2417 |
|
boolean b = false; |
2418 |
|
|
2419 |
|
for(String s : lnS) { |
2420 |
|
if(s.startsWith("NAME: ")) { |
2421 |
|
name = s.substring("NAME: ".length()); |
2422 |
|
} else if(s.startsWith("DEFAULT: ")) { |
2423 |
|
b = Boolean.parseBoolean(s.substring("DEFAULT: ".length())); |
2424 |
|
} else { |
2425 |
|
getLogger().info(LscpI18n.getLogMsg("unknownLine", s)); |
2426 |
|
} |
2427 |
|
} |
2428 |
|
|
2429 |
|
return new MidiInstrumentMapInfo(mapId, name, b); |
2430 |
|
} |
2431 |
|
|
2432 |
|
/** |
2433 |
|
* Gets an information of all created MIDI instrument maps. |
2434 |
|
* @return A <code>MidiInstrumentMap</code> array |
2435 |
|
* providing information for all created MIDI instrument maps. |
2436 |
|
* @throws IOException If some I/O error occurs. |
2437 |
|
* @throws LscpException If LSCP protocol corruption occurs. |
2438 |
|
* @throws LSException If some other error occurs. |
2439 |
|
* @see #addMidiInstrumentMap |
2440 |
|
* @see #removeMidiInstrumentMap |
2441 |
|
*/ |
2442 |
|
public synchronized MidiInstrumentMapInfo[] |
2443 |
|
getMidiInstrumentMaps() throws IOException, LscpException, LSException { |
2444 |
|
Integer[] idS = getMidiInstrumentMapIDs(); |
2445 |
|
if(getPrintOnlyMode()) return null; |
2446 |
|
|
2447 |
|
MidiInstrumentMapInfo[] maps = new MidiInstrumentMapInfo[idS.length]; |
2448 |
|
|
2449 |
|
for(int i = 0; i < maps.length; i++) |
2450 |
|
maps[i] = getMidiInstrumentMapInfo(idS[i]); |
2451 |
|
|
2452 |
|
return maps; |
2453 |
|
} |
2454 |
|
|
2455 |
|
/** |
2456 |
|
* Sets the name of the specified MIDI instrument map. |
2457 |
|
* @param mapId The numerical ID of the MIDI instrument map. |
2458 |
|
* @param name The new name for the specified MIDI instrument map. |
2459 |
|
* @throws IOException If some I/O error occurs. |
2460 |
|
* @throws LscpException If LSCP protocol corruption occurs. |
2461 |
|
* @throws LSException If <code>mapId</code> is not a valid MIDI |
2462 |
|
* instrument map number or <code>name</code> is not a valid name; |
2463 |
|
*/ |
2464 |
|
public synchronized void |
2465 |
|
setMidiInstrumentMapName(int mapId, String name) |
2466 |
|
throws IOException, LscpException, LSException { |
2467 |
|
|
2468 |
|
verifyConnection(); |
2469 |
|
out.writeLine("SET MIDI_INSTRUMENT_MAP NAME " + + mapId + " '" + name + "'"); |
2470 |
|
if(getPrintOnlyMode()) return; |
2471 |
|
|
2472 |
|
ResultSet rs = getEmptyResultSet(); |
2473 |
|
} |
2474 |
|
|
2475 |
|
/** |
2476 |
|
* Creates or replaces a MIDI instrument map entry. |
2477 |
|
* @param mapId The ID of the map, where this instrument should be mapped. |
2478 |
|
* @param entry Specifies the position of the MIDI instrument in the MIDI instrument map. |
2479 |
|
* @param info Provides the needed information of the |
2480 |
|
* MIDI instrument, which will be mapped to the specified MIDI instrument map. |
2481 |
|
* @throws IOException If some I/O error occurs. |
2482 |
|
* @throws LSException If the mapping failed. |
2483 |
|
* @throws LscpException If LSCP protocol corruption occurs. |
2484 |
|
* @see #unmapMidiInstrument |
2485 |
|
*/ |
2486 |
|
public synchronized void |
2487 |
|
mapMidiInstrument(int mapId, MidiInstrumentEntry entry, MidiInstrumentInfo info) |
2488 |
|
throws IOException, LSException, LscpException { |
2489 |
|
|
2490 |
|
verifyConnection(); |
2491 |
|
StringBuffer cmd = new StringBuffer("MAP MIDI_INSTRUMENT "); |
2492 |
|
cmd.append(mapId).append(' '); |
2493 |
|
cmd.append(entry.getMidiBank()).append(' '); |
2494 |
|
cmd.append(entry.getMidiProgram()).append(' '); |
2495 |
|
cmd.append(info.getEngine()).append(" '"); |
2496 |
|
cmd.append(info.getFileName()).append("' "); |
2497 |
|
cmd.append(info.getInstrumentIndex()).append(' '); |
2498 |
|
cmd.append(info.getVolume()); |
2499 |
|
if(!info.getLoadMode().name().equals("DEFAULT")) { |
2500 |
|
cmd.append(' ').append(info.getLoadMode().name()); |
2501 |
|
} |
2502 |
|
if(info.getName() != null) cmd.append(" '").append(info.getName()).append("'"); |
2503 |
|
|
2504 |
|
out.writeLine(cmd.toString()); |
2505 |
|
if(getPrintOnlyMode()) return; |
2506 |
|
|
2507 |
ResultSet rs = getEmptyResultSet(); |
ResultSet rs = getEmptyResultSet(); |
2508 |
} |
} |
2509 |
|
|
2510 |
/** |
/** |
2511 |
|
* Removes an entry MIDI instrument map. |
2512 |
|
* @param mapId The ID of the map, from which |
2513 |
|
* the specified MIDI instrument should be removed. |
2514 |
|
* @param entry The entry to remove from the specified MIDI instrument map. |
2515 |
|
* @throws IOException If some I/O error occurs. |
2516 |
|
* @throws LSException If the unmapping failed. |
2517 |
|
* @throws LscpException If LSCP protocol corruption occurs. |
2518 |
|
* @see #mapMidiInstrument |
2519 |
|
*/ |
2520 |
|
public synchronized void |
2521 |
|
unmapMidiInstrument(int mapId, MidiInstrumentEntry entry) |
2522 |
|
throws IOException, LSException, LscpException { |
2523 |
|
|
2524 |
|
verifyConnection(); |
2525 |
|
StringBuffer cmd = new StringBuffer("UNMAP MIDI_INSTRUMENT "); |
2526 |
|
cmd.append(mapId).append(' '); |
2527 |
|
cmd.append(entry.getMidiBank()).append(' '); |
2528 |
|
cmd.append(entry.getMidiProgram()); |
2529 |
|
|
2530 |
|
out.writeLine(cmd.toString()); |
2531 |
|
if(getPrintOnlyMode()) return; |
2532 |
|
|
2533 |
|
ResultSet rs = getEmptyResultSet(); |
2534 |
|
} |
2535 |
|
|
2536 |
|
/** |
2537 |
|
* Gets the current number of all MIDI instrument in all maps. |
2538 |
|
* @return The current number of all MIDI instrument in all maps. |
2539 |
|
* @throws IOException If some I/O error occurs. |
2540 |
|
* @throws LscpException If LSCP protocol corruption occurs. |
2541 |
|
* @throws LSException If some other error occurs. |
2542 |
|
*/ |
2543 |
|
public synchronized int |
2544 |
|
getMidiInstrumentCount() throws IOException, LscpException, LSException { |
2545 |
|
verifyConnection(); |
2546 |
|
out.writeLine("GET MIDI_INSTRUMENTS ALL"); |
2547 |
|
if(getPrintOnlyMode()) return -1; |
2548 |
|
|
2549 |
|
String s = getSingleLineResultSet().getResult(); |
2550 |
|
return parseInt(s); |
2551 |
|
} |
2552 |
|
|
2553 |
|
/** |
2554 |
|
* Gets the current number of MIDI instrument in the specified map. |
2555 |
|
* @param mapId The ID of the map. |
2556 |
|
* @return The current number of MIDI instrument in the specified map. |
2557 |
|
* @throws IOException If some I/O error occurs. |
2558 |
|
* @throws LscpException If LSCP protocol corruption occurs. |
2559 |
|
* @throws LSException If some other error occurs. |
2560 |
|
*/ |
2561 |
|
public synchronized int |
2562 |
|
getMidiInstrumentCount(int mapId) throws IOException, LscpException, LSException { |
2563 |
|
verifyConnection(); |
2564 |
|
out.writeLine("GET MIDI_INSTRUMENTS " + String.valueOf(mapId)); |
2565 |
|
if(getPrintOnlyMode()) return -1; |
2566 |
|
|
2567 |
|
String s = getSingleLineResultSet().getResult(); |
2568 |
|
return parseInt(s); |
2569 |
|
} |
2570 |
|
|
2571 |
|
/** |
2572 |
|
* Gets all MIDI instrument from all maps. |
2573 |
|
* @return A <code>MidiInstrumentInfo</code> array providing |
2574 |
|
* all MIDI instruments from all MIDI instrument maps. |
2575 |
|
* @throws IOException If some I/O error occurs. |
2576 |
|
* @throws LscpException If LSCP protocol corruption occurs. |
2577 |
|
* @throws LSException If some other error occurs. |
2578 |
|
*/ |
2579 |
|
public synchronized MidiInstrumentInfo[] |
2580 |
|
getMidiInstruments() throws IOException, LscpException, LSException { |
2581 |
|
verifyConnection(); |
2582 |
|
out.writeLine("LIST MIDI_INSTRUMENTS ALL"); |
2583 |
|
if(getPrintOnlyMode()) return null; |
2584 |
|
|
2585 |
|
String[] entries = parseArray(getSingleLineResultSet().getResult()); |
2586 |
|
|
2587 |
|
return getMidiInstruments(entries); |
2588 |
|
} |
2589 |
|
|
2590 |
|
/** |
2591 |
|
* Gets all MIDI instrument contained int the specified MIDI instrument map. |
2592 |
|
* @param mapId The ID of the map, which instruments should be obtained. |
2593 |
|
* @return A <code>MidiInstrumentInfo</code> array providing |
2594 |
|
* all MIDI instruments from all MIDI instrument maps. |
2595 |
|
* @throws IOException If some I/O error occurs. |
2596 |
|
* @throws LscpException If LSCP protocol corruption occurs. |
2597 |
|
* @throws LSException If some other error occurs. |
2598 |
|
*/ |
2599 |
|
public synchronized MidiInstrumentInfo[] |
2600 |
|
getMidiInstruments(int mapId) throws IOException, LscpException, LSException { |
2601 |
|
verifyConnection(); |
2602 |
|
out.writeLine("LIST MIDI_INSTRUMENTS " + String.valueOf(mapId)); |
2603 |
|
if(getPrintOnlyMode()) return null; |
2604 |
|
|
2605 |
|
String[] entries = parseArray(getSingleLineResultSet().getResult()); |
2606 |
|
|
2607 |
|
return getMidiInstruments(entries); |
2608 |
|
} |
2609 |
|
|
2610 |
|
private MidiInstrumentInfo[] |
2611 |
|
getMidiInstruments(String[] entries) throws IOException, LscpException, LSException { |
2612 |
|
Vector<MidiInstrumentInfo> v = new Vector<MidiInstrumentInfo>(); |
2613 |
|
|
2614 |
|
for(String s : entries) { |
2615 |
|
Integer[] vals = parseIntList(s); |
2616 |
|
if(vals.length != 3) { |
2617 |
|
throw new LscpException(LscpI18n.getLogMsg("CommandFailed!")); |
2618 |
|
} |
2619 |
|
|
2620 |
|
v.add(getMidiInstrumentInfo(vals[0], vals[1], vals[2])); |
2621 |
|
} |
2622 |
|
|
2623 |
|
return v.toArray(new MidiInstrumentInfo[v.size()]); |
2624 |
|
} |
2625 |
|
|
2626 |
|
/** |
2627 |
|
* Gets the current settings of the specified MIDI instrument. |
2628 |
|
* @param mapId The ID of the map. |
2629 |
|
* @param bank The index of the MIDI bank. |
2630 |
|
* @param program The MIDI program number of the instrument. |
2631 |
|
* @return <code>MidiInstrumentInfo</code> instance containing |
2632 |
|
* the current settings of the specified MIDI instrument. |
2633 |
|
* @throws IOException If an I/O error occurs. |
2634 |
|
* @throws LscpException If LSCP protocol corruption occurs. |
2635 |
|
* @throws LSException If the specified MIDI instrument is missing. |
2636 |
|
*/ |
2637 |
|
public synchronized MidiInstrumentInfo |
2638 |
|
getMidiInstrumentInfo(int mapId, int bank, int program) |
2639 |
|
throws IOException, LscpException, LSException { |
2640 |
|
|
2641 |
|
verifyConnection(); |
2642 |
|
StringBuffer cmd = new StringBuffer("GET MIDI_INSTRUMENT INFO "); |
2643 |
|
cmd.append(mapId).append(' '); |
2644 |
|
cmd.append(bank).append(' '); |
2645 |
|
cmd.append(program); |
2646 |
|
|
2647 |
|
out.writeLine(cmd.toString()); |
2648 |
|
if(getPrintOnlyMode()) return null; |
2649 |
|
|
2650 |
|
ResultSet rs = getMultiLineResultSet(); |
2651 |
|
MidiInstrumentEntry entry = new MidiInstrumentEntry(bank, program); |
2652 |
|
return new MidiInstrumentInfo(mapId, entry, rs.getMultiLineResult()); |
2653 |
|
} |
2654 |
|
|
2655 |
|
/** |
2656 |
* Loads and assigns an instrument to a sampler channel. Notice that this function will |
* Loads and assigns an instrument to a sampler channel. Notice that this function will |
2657 |
* return after the instrument is fully loaded and the channel is ready to be used. |
* return after the instrument is fully loaded and the channel is ready to be used. |
|
* |
|
2658 |
* @param filename The name of the instrument file |
* @param filename The name of the instrument file |
2659 |
* on the LinuxSampler instance's host system. |
* on the LinuxSampler instance's host system. |
2660 |
* @param instrIdx The index of the instrument in the instrument file. |
* @param instrIdx The index of the instrument in the instrument file. |
2661 |
* @param samplerChn The number of the sampler channel the instrument should be assigned to. |
* @param samplerChn The number of the sampler channel the instrument should be assigned to. |
|
* |
|
2662 |
* @throws IOException If some I/O error occurs. |
* @throws IOException If some I/O error occurs. |
2663 |
* @throws LscpException If LSCP protocol corruption occurs. |
* @throws LscpException If LSCP protocol corruption occurs. |
2664 |
* @throws LSException If the loading of the instrument failed. |
* @throws LSException If the loading of the instrument failed. |
|
* |
|
2665 |
* @see #loadInstrument(String, int, int, boolean) |
* @see #loadInstrument(String, int, int, boolean) |
2666 |
* @see #getSamplerChannels |
* @see #getSamplerChannels |
2667 |
*/ |
*/ |
2699 |
String args = '\'' + filename + "' " + instrIdx + ' ' + samplerChn; |
String args = '\'' + filename + "' " + instrIdx + ' ' + samplerChn; |
2700 |
|
|
2701 |
out.writeLine(cmd + args); |
out.writeLine(cmd + args); |
2702 |
|
if(getPrintOnlyMode()) return; |
2703 |
|
|
2704 |
ResultSet rs = getEmptyResultSet(); |
ResultSet rs = getEmptyResultSet(); |
2705 |
} |
} |
2722 |
|
|
2723 |
verifyConnection(); |
verifyConnection(); |
2724 |
out.writeLine("LOAD ENGINE " + engineName + ' ' + samplerChn); |
out.writeLine("LOAD ENGINE " + engineName + ' ' + samplerChn); |
2725 |
|
if(getPrintOnlyMode()) return; |
2726 |
|
|
2727 |
ResultSet rs = getEmptyResultSet(); |
ResultSet rs = getEmptyResultSet(); |
2728 |
} |
} |
2738 |
getSamplerChannelCount() throws IOException, LscpException, LSException { |
getSamplerChannelCount() throws IOException, LscpException, LSException { |
2739 |
verifyConnection(); |
verifyConnection(); |
2740 |
out.writeLine("GET CHANNELS"); |
out.writeLine("GET CHANNELS"); |
2741 |
|
if(getPrintOnlyMode()) return -1; |
2742 |
|
|
2743 |
String s = getSingleLineResultSet().getResult(); |
String s = getSingleLineResultSet().getResult(); |
2744 |
return parseInt(s); |
return parseInt(s); |
2745 |
} |
} |
2756 |
public synchronized SamplerChannel[] |
public synchronized SamplerChannel[] |
2757 |
getSamplerChannels() throws IOException, LscpException, LSException { |
getSamplerChannels() throws IOException, LscpException, LSException { |
2758 |
Integer[] idS = getSamplerChannelIDs(); |
Integer[] idS = getSamplerChannelIDs(); |
2759 |
|
if(getPrintOnlyMode()) return null; |
2760 |
|
|
2761 |
SamplerChannel[] channels = new SamplerChannel[idS.length]; |
SamplerChannel[] channels = new SamplerChannel[idS.length]; |
2762 |
|
|
2763 |
for(int i = 0; i < channels.length; i++) |
for(int i = 0; i < channels.length; i++) |
2780 |
getSamplerChannelIDs() throws IOException, LscpException, LSException { |
getSamplerChannelIDs() throws IOException, LscpException, LSException { |
2781 |
verifyConnection(); |
verifyConnection(); |
2782 |
out.writeLine("LIST CHANNELS"); |
out.writeLine("LIST CHANNELS"); |
2783 |
|
if(getPrintOnlyMode()) return null; |
2784 |
|
|
2785 |
return parseIntList(getSingleLineResultSet().getResult()); |
return parseIntList(getSingleLineResultSet().getResult()); |
2786 |
} |
} |
2787 |
|
|
2799 |
addSamplerChannel() throws IOException, LSException, LscpException { |
addSamplerChannel() throws IOException, LSException, LscpException { |
2800 |
verifyConnection(); |
verifyConnection(); |
2801 |
out.writeLine("ADD CHANNEL"); |
out.writeLine("ADD CHANNEL"); |
2802 |
|
if(getPrintOnlyMode()) return -1; |
2803 |
|
|
2804 |
ResultSet rs = getEmptyResultSet(); |
ResultSet rs = getEmptyResultSet(); |
2805 |
|
|
2806 |
return rs.getIndex(); |
return rs.getIndex(); |
2821 |
removeSamplerChannel(int samplerChn) throws IOException, LscpException, LSException { |
removeSamplerChannel(int samplerChn) throws IOException, LscpException, LSException { |
2822 |
verifyConnection(); |
verifyConnection(); |
2823 |
out.writeLine("REMOVE CHANNEL " + samplerChn); |
out.writeLine("REMOVE CHANNEL " + samplerChn); |
2824 |
|
if(getPrintOnlyMode()) return; |
2825 |
|
|
2826 |
ResultSet rs = getEmptyResultSet(); |
ResultSet rs = getEmptyResultSet(); |
2827 |
} |
} |
2837 |
getEngineCount() throws IOException, LscpException, LSException { |
getEngineCount() throws IOException, LscpException, LSException { |
2838 |
verifyConnection(); |
verifyConnection(); |
2839 |
out.writeLine("GET AVAILABLE_ENGINES"); |
out.writeLine("GET AVAILABLE_ENGINES"); |
2840 |
|
if(getPrintOnlyMode()) return -1; |
2841 |
|
|
2842 |
String s = getSingleLineResultSet().getResult(); |
String s = getSingleLineResultSet().getResult(); |
2843 |
return parseInt(s); |
return parseInt(s); |
2844 |
} |
} |
2854 |
public synchronized SamplerEngine[] |
public synchronized SamplerEngine[] |
2855 |
getEngines() throws IOException, LscpException, LSException { |
getEngines() throws IOException, LscpException, LSException { |
2856 |
String[] engines = getEngineNames(); |
String[] engines = getEngineNames(); |
2857 |
|
if(getPrintOnlyMode()) return null; |
2858 |
|
|
2859 |
SamplerEngine[] se = new SamplerEngine[engines.length]; |
SamplerEngine[] se = new SamplerEngine[engines.length]; |
2860 |
|
|
2861 |
for(int i = 0; i < engines.length; i++) se[i] = getEngineInfo(engines[i]); |
for(int i = 0; i < engines.length; i++) se[i] = getEngineInfo(engines[i]); |
2875 |
getEngineNames() throws IOException, LscpException, LSException { |
getEngineNames() throws IOException, LscpException, LSException { |
2876 |
verifyConnection(); |
verifyConnection(); |
2877 |
out.writeLine("LIST AVAILABLE_ENGINES"); |
out.writeLine("LIST AVAILABLE_ENGINES"); |
2878 |
|
if(getPrintOnlyMode()) return null; |
2879 |
|
|
2880 |
return parseStringList(getSingleLineResultSet().getResult()); |
return parseStringList(getSingleLineResultSet().getResult()); |
2881 |
} |
} |
2882 |
|
|
2896 |
getEngineInfo(String engineName) throws IOException, LscpException, LSException { |
getEngineInfo(String engineName) throws IOException, LscpException, LSException { |
2897 |
verifyConnection(); |
verifyConnection(); |
2898 |
out.writeLine("GET ENGINE INFO " + engineName); |
out.writeLine("GET ENGINE INFO " + engineName); |
2899 |
|
if(getPrintOnlyMode()) return null; |
2900 |
|
|
2901 |
ResultSet rs = getMultiLineResultSet(); |
ResultSet rs = getMultiLineResultSet(); |
2902 |
SamplerEngine se = new SamplerEngine(rs.getMultiLineResult()); |
SamplerEngine se = new SamplerEngine(rs.getMultiLineResult()); |
2903 |
se.setName(engineName); |
se.setName(engineName); |
2920 |
getSamplerChannelInfo(int samplerChn) throws IOException, LscpException, LSException { |
getSamplerChannelInfo(int samplerChn) throws IOException, LscpException, LSException { |
2921 |
verifyConnection(); |
verifyConnection(); |
2922 |
out.writeLine("GET CHANNEL INFO " + samplerChn); |
out.writeLine("GET CHANNEL INFO " + samplerChn); |
2923 |
|
if(getPrintOnlyMode()) return null; |
2924 |
|
|
2925 |
ResultSet rs = getMultiLineResultSet(); |
ResultSet rs = getMultiLineResultSet(); |
2926 |
SamplerChannel sc = new SamplerChannel(rs.getMultiLineResult()); |
SamplerChannel sc = new SamplerChannel(rs.getMultiLineResult()); |
2927 |
sc.setChannelID(samplerChn); |
sc.setChannelId(samplerChn); |
2928 |
if(sc.getEngine() != null) sc.setEngine(getEngineInfo(sc.getEngine().getName())); |
if(sc.getEngine() != null) sc.setEngine(getEngineInfo(sc.getEngine().getName())); |
2929 |
|
|
2930 |
return sc; |
return sc; |
2944 |
getChannelVoiceCount(int samplerChn) throws IOException, LscpException, LSException { |
getChannelVoiceCount(int samplerChn) throws IOException, LscpException, LSException { |
2945 |
verifyConnection(); |
verifyConnection(); |
2946 |
out.writeLine("GET CHANNEL VOICE_COUNT " + samplerChn); |
out.writeLine("GET CHANNEL VOICE_COUNT " + samplerChn); |
2947 |
|
if(getPrintOnlyMode()) return -1; |
2948 |
|
|
2949 |
ResultSet rs = getSingleLineResultSet(); |
ResultSet rs = getSingleLineResultSet(); |
2950 |
|
|
2951 |
return parseInt(rs.getResult()); |
return parseInt(rs.getResult()); |
2966 |
getChannelStreamCount(int samplerChn) throws IOException, LscpException, LSException { |
getChannelStreamCount(int samplerChn) throws IOException, LscpException, LSException { |
2967 |
verifyConnection(); |
verifyConnection(); |
2968 |
out.writeLine("GET CHANNEL STREAM_COUNT " + samplerChn); |
out.writeLine("GET CHANNEL STREAM_COUNT " + samplerChn); |
2969 |
|
if(getPrintOnlyMode()) return -1; |
2970 |
|
|
2971 |
ResultSet rs = getSingleLineResultSet(); |
ResultSet rs = getSingleLineResultSet(); |
2972 |
|
|
2973 |
if(rs.getResult().equals("NA")) return -1; |
if(rs.getResult().equals("NA")) return -1; |
2992 |
getChannelBufferFillBytes(int samplerChn) throws IOException, LscpException, LSException { |
getChannelBufferFillBytes(int samplerChn) throws IOException, LscpException, LSException { |
2993 |
verifyConnection(); |
verifyConnection(); |
2994 |
out.writeLine("GET CHANNEL BUFFER_FILL BYTES " + samplerChn); |
out.writeLine("GET CHANNEL BUFFER_FILL BYTES " + samplerChn); |
2995 |
|
if(getPrintOnlyMode()) return null; |
2996 |
|
|
2997 |
ResultSet rs = getSingleLineResultSet(); |
ResultSet rs = getSingleLineResultSet(); |
2998 |
|
|
2999 |
if(rs.getResult().equals("NA")) return null; |
if(rs.getResult().equals("NA")) return null; |
3009 |
if(i == -1) throw new LscpException(LscpI18n.getLogMsg("CommandFailed!")); |
if(i == -1) throw new LscpException(LscpI18n.getLogMsg("CommandFailed!")); |
3010 |
|
|
3011 |
BufferFill bf = new BufferFill(); |
BufferFill bf = new BufferFill(); |
3012 |
bf.setStreamID(parseInt(s.substring(1, i))); |
bf.setStreamId(parseInt(s.substring(1, i))); |
3013 |
bf.setValue(parseInt(s.substring(i + 1))); |
bf.setValue(parseInt(s.substring(i + 1))); |
3014 |
v.add(bf); |
v.add(bf); |
3015 |
} |
} |
3036 |
|
|
3037 |
verifyConnection(); |
verifyConnection(); |
3038 |
out.writeLine("GET CHANNEL BUFFER_FILL PERCENTAGE " + samplerChn); |
out.writeLine("GET CHANNEL BUFFER_FILL PERCENTAGE " + samplerChn); |
3039 |
|
if(getPrintOnlyMode()) return null; |
3040 |
|
|
3041 |
ResultSet rs = getSingleLineResultSet(); |
ResultSet rs = getSingleLineResultSet(); |
3042 |
|
|
3043 |
return getChannelBufferFillPercentage(rs.getResult()); |
return getChannelBufferFillPercentage(rs.getResult()); |
3061 |
throw new LscpException(LscpI18n.getLogMsg("CommandFailed!")); |
throw new LscpException(LscpI18n.getLogMsg("CommandFailed!")); |
3062 |
|
|
3063 |
BufferFill bf = new BufferFill(); |
BufferFill bf = new BufferFill(); |
3064 |
bf.setStreamID(parseInt(s.substring(1, i))); |
bf.setStreamId(parseInt(s.substring(1, i))); |
3065 |
bf.setValue(parseInt(s.substring(i + 1, s.length() - 1))); |
bf.setValue(parseInt(s.substring(i + 1, s.length() - 1))); |
3066 |
v.add(bf); |
v.add(bf); |
3067 |
} |
} |
3073 |
* Sets the audio output device on the specified sampler channel. |
* Sets the audio output device on the specified sampler channel. |
3074 |
* |
* |
3075 |
* @param samplerChn The sampler channel number. |
* @param samplerChn The sampler channel number. |
3076 |
* @param devID The numerical ID of the audio output device. |
* @param devId The numerical ID of the audio output device. |
3077 |
* |
* |
3078 |
* @throws IOException If some I/O error occurs. |
* @throws IOException If some I/O error occurs. |
3079 |
* @throws LscpException If LSCP protocol corruption occurs. |
* @throws LscpException If LSCP protocol corruption occurs. |
3080 |
* @throws LSException If |
* @throws LSException If |
3081 |
* <ul> |
* <ul> |
3082 |
* <li><code>samplerChn</code> is not a valid channel number; |
* <li><code>samplerChn</code> is not a valid channel number; |
3083 |
* <li><code>devID</code> is not a valid audio output device ID; |
* <li><code>devId</code> is not a valid audio output device ID; |
3084 |
* </ul> |
* </ul> |
3085 |
* |
* |
3086 |
* @see #getSamplerChannels |
* @see #getSamplerChannels |
3087 |
* @see #getAudioOutputDevices |
* @see #getAudioOutputDevices |
3088 |
*/ |
*/ |
3089 |
public synchronized void |
public synchronized void |
3090 |
setChannelAudioOutputDevice(int samplerChn, int devID) |
setChannelAudioOutputDevice(int samplerChn, int devId) |
3091 |
throws IOException, LscpException, LSException { |
throws IOException, LscpException, LSException { |
3092 |
|
|
3093 |
verifyConnection(); |
verifyConnection(); |
3094 |
out.writeLine("SET CHANNEL AUDIO_OUTPUT_DEVICE " + samplerChn + ' ' + devID); |
out.writeLine("SET CHANNEL AUDIO_OUTPUT_DEVICE " + samplerChn + ' ' + devId); |
3095 |
|
if(getPrintOnlyMode()) return; |
3096 |
|
|
3097 |
ResultSet rs = getEmptyResultSet(); |
ResultSet rs = getEmptyResultSet(); |
3098 |
} |
} |
3123 |
verifyConnection(); |
verifyConnection(); |
3124 |
String args = " " + samplerChn + ' ' + audioOut + ' ' + audioIn; |
String args = " " + samplerChn + ' ' + audioOut + ' ' + audioIn; |
3125 |
out.writeLine("SET CHANNEL AUDIO_OUTPUT_CHANNEL" + args); |
out.writeLine("SET CHANNEL AUDIO_OUTPUT_CHANNEL" + args); |
3126 |
|
if(getPrintOnlyMode()) return; |
3127 |
|
|
3128 |
ResultSet rs = getEmptyResultSet(); |
ResultSet rs = getEmptyResultSet(); |
3129 |
} |
} |
3132 |
* Sets the MIDI input device on the specified sampler channel. |
* Sets the MIDI input device on the specified sampler channel. |
3133 |
* |
* |
3134 |
* @param samplerChn The sampler channel number. |
* @param samplerChn The sampler channel number. |
3135 |
* @param devID The numerical ID of the MIDI input device. |
* @param devId The numerical ID of the MIDI input device. |
3136 |
* |
* |
3137 |
* @throws IOException If some I/O error occurs. |
* @throws IOException If some I/O error occurs. |
3138 |
* @throws LscpException If LSCP protocol corruption occurs. |
* @throws LscpException If LSCP protocol corruption occurs. |
3139 |
* @throws LSException If |
* @throws LSException If |
3140 |
* <ul> |
* <ul> |
3141 |
* <li><code>samplerChn</code> is not a valid channel number; |
* <li><code>samplerChn</code> is not a valid channel number; |
3142 |
* <li><code>devID</code> is not a valid MIDI input device ID; |
* <li><code>devId</code> is not a valid MIDI input device ID; |
3143 |
* </ul> |
* </ul> |
3144 |
* |
* |
3145 |
* @see #getSamplerChannels |
* @see #getSamplerChannels |
3146 |
* @see #getMidiInputDevices |
* @see #getMidiInputDevices |
3147 |
*/ |
*/ |
3148 |
public synchronized void |
public synchronized void |
3149 |
setChannelMidiInputDevice(int samplerChn, int devID) |
setChannelMidiInputDevice(int samplerChn, int devId) |
3150 |
throws IOException, LscpException, LSException { |
throws IOException, LscpException, LSException { |
3151 |
|
|
3152 |
verifyConnection(); |
verifyConnection(); |
3153 |
out.writeLine("SET CHANNEL MIDI_INPUT_DEVICE " + samplerChn + ' ' + devID); |
out.writeLine("SET CHANNEL MIDI_INPUT_DEVICE " + samplerChn + ' ' + devId); |
3154 |
|
if(getPrintOnlyMode()) return; |
3155 |
|
|
3156 |
ResultSet rs = getEmptyResultSet(); |
ResultSet rs = getEmptyResultSet(); |
3157 |
} |
} |
3174 |
|
|
3175 |
verifyConnection(); |
verifyConnection(); |
3176 |
out.writeLine("SET CHANNEL MIDI_INPUT_PORT " + samplerChn + ' ' + port); |
out.writeLine("SET CHANNEL MIDI_INPUT_PORT " + samplerChn + ' ' + port); |
3177 |
|
if(getPrintOnlyMode()) return; |
3178 |
|
|
3179 |
ResultSet rs = getEmptyResultSet(); |
ResultSet rs = getEmptyResultSet(); |
3180 |
} |
} |
3199 |
String args = String.valueOf(samplerChn) + ' '; |
String args = String.valueOf(samplerChn) + ' '; |
3200 |
args += (midiChn == -1 ? "ALL" : String.valueOf(midiChn)); |
args += (midiChn == -1 ? "ALL" : String.valueOf(midiChn)); |
3201 |
out.writeLine("SET CHANNEL MIDI_INPUT_CHANNEL " + args); |
out.writeLine("SET CHANNEL MIDI_INPUT_CHANNEL " + args); |
3202 |
|
if(getPrintOnlyMode()) return; |
3203 |
|
|
3204 |
|
ResultSet rs = getEmptyResultSet(); |
3205 |
|
} |
3206 |
|
|
3207 |
|
/** |
3208 |
|
* Sets the MIDI instrument map to be used on the specified sampler channel. |
3209 |
|
* |
3210 |
|
* @param samplerChn The sampler channel number. |
3211 |
|
* @param mapId Specifies the numerical ID of the MIDI instrument |
3212 |
|
* map to assign. To remove the current map binding use <code>-1</code>. |
3213 |
|
* To set the current map to be the default map use <code>-2</code>. |
3214 |
|
* |
3215 |
|
* @throws IOException If some I/O error occurs. |
3216 |
|
* @throws LscpException If LSCP protocol corruption occurs. |
3217 |
|
* @throws LSException If |
3218 |
|
* <ul> |
3219 |
|
* <li><code>samplerChn</code> is not a valid channel number; |
3220 |
|
* <li><code>mapId</code> is not a valid MIDI instrument map ID; |
3221 |
|
* </ul> |
3222 |
|
* |
3223 |
|
* @see #getSamplerChannels |
3224 |
|
* @see #getMidiInstrumentMaps |
3225 |
|
*/ |
3226 |
|
public synchronized void |
3227 |
|
setChannelMidiInstrumentMap(int samplerChn, int mapId) |
3228 |
|
throws IOException, LscpException, LSException { |
3229 |
|
|
3230 |
|
verifyConnection(); |
3231 |
|
String s; |
3232 |
|
if(mapId == -1) { |
3233 |
|
s = " NONE"; |
3234 |
|
} else if(mapId == -2) { |
3235 |
|
s = " DEFAULT"; |
3236 |
|
} else { |
3237 |
|
s = " " + String.valueOf(mapId); |
3238 |
|
} |
3239 |
|
out.writeLine("SET CHANNEL MIDI_INSTRUMENT_MAP " + samplerChn + s); |
3240 |
|
if(getPrintOnlyMode()) return; |
3241 |
|
|
3242 |
ResultSet rs = getEmptyResultSet(); |
ResultSet rs = getEmptyResultSet(); |
3243 |
} |
} |
3260 |
|
|
3261 |
verifyConnection(); |
verifyConnection(); |
3262 |
out.writeLine("SET CHANNEL VOLUME " + samplerChn + ' ' + volume); |
out.writeLine("SET CHANNEL VOLUME " + samplerChn + ' ' + volume); |
3263 |
|
if(getPrintOnlyMode()) return; |
3264 |
|
|
3265 |
ResultSet rs = getEmptyResultSet(); |
ResultSet rs = getEmptyResultSet(); |
3266 |
} |
} |
3284 |
|
|
3285 |
verifyConnection(); |
verifyConnection(); |
3286 |
out.writeLine("SET CHANNEL MUTE " + samplerChn + ' ' + (mute ? 1 : 0)); |
out.writeLine("SET CHANNEL MUTE " + samplerChn + ' ' + (mute ? 1 : 0)); |
3287 |
|
if(getPrintOnlyMode()) return; |
3288 |
|
|
3289 |
ResultSet rs = getEmptyResultSet(); |
ResultSet rs = getEmptyResultSet(); |
3290 |
} |
} |
3308 |
|
|
3309 |
verifyConnection(); |
verifyConnection(); |
3310 |
out.writeLine("SET CHANNEL SOLO " + samplerChn + ' ' + (solo ? 1 : 0)); |
out.writeLine("SET CHANNEL SOLO " + samplerChn + ' ' + (solo ? 1 : 0)); |
3311 |
|
if(getPrintOnlyMode()) return; |
3312 |
|
|
3313 |
|
ResultSet rs = getEmptyResultSet(); |
3314 |
|
} |
3315 |
|
|
3316 |
|
/** |
3317 |
|
* Creates an additional effect send on the specified sampler channel. |
3318 |
|
* @param channel The sampler channel, on which a new effect send should be added. |
3319 |
|
* @param midiCtrl Defines the MIDI controller, which |
3320 |
|
* will be able alter the effect send level. |
3321 |
|
* @return The unique ID of the newly created effect send entity. |
3322 |
|
* @throws IOException If some I/O error occurs. |
3323 |
|
* @throws LSException If the creation of the effect send failed. |
3324 |
|
* @throws LscpException If LSCP protocol corruption occurs. |
3325 |
|
* @see #destroyFxSend |
3326 |
|
*/ |
3327 |
|
public synchronized int |
3328 |
|
createFxSend(int channel, int midiCtrl) |
3329 |
|
throws IOException, LSException, LscpException { |
3330 |
|
|
3331 |
|
return createFxSend(channel, midiCtrl, null); |
3332 |
|
} |
3333 |
|
|
3334 |
|
/** |
3335 |
|
* Creates an additional effect send on the specified sampler channel. |
3336 |
|
* @param channel The sampler channel, on which the effect send should be created on. |
3337 |
|
* @param midiCtrl Defines the MIDI controller, which can alter the effect send level. |
3338 |
|
* @param name The name of the effect send entity. The name does not have to be unique. |
3339 |
|
* @return The unique ID of the newly created effect send entity. |
3340 |
|
* @throws IOException If some I/O error occurs. |
3341 |
|
* @throws LSException If the creation of the effect send failed. |
3342 |
|
* @throws LscpException If LSCP protocol corruption occurs. |
3343 |
|
* @see #destroyFxSend |
3344 |
|
*/ |
3345 |
|
public synchronized int |
3346 |
|
createFxSend(int channel, int midiCtrl, String name) |
3347 |
|
throws IOException, LSException, LscpException { |
3348 |
|
|
3349 |
|
verifyConnection(); |
3350 |
|
String s = String.valueOf(channel) + " " + String.valueOf(midiCtrl); |
3351 |
|
if(name != null) s += " '" + name + "'"; |
3352 |
|
out.writeLine("CREATE FX_SEND " + s); |
3353 |
|
if(getPrintOnlyMode()) return -1; |
3354 |
|
|
3355 |
|
ResultSet rs = getEmptyResultSet(); |
3356 |
|
|
3357 |
|
return rs.getIndex(); |
3358 |
|
} |
3359 |
|
|
3360 |
|
/** |
3361 |
|
* Destroys the specified effect send on the specified sampler channel. |
3362 |
|
* @param channel The sampler channel, from which |
3363 |
|
* the specified effect send should be removed. |
3364 |
|
* @param fxSend The ID of the effect send that should be removed. |
3365 |
|
* @throws LSException If some other error occurs. |
3366 |
|
* @throws LscpException If LSCP protocol corruption occurs. |
3367 |
|
* @see #createFxSend |
3368 |
|
*/ |
3369 |
|
public synchronized void |
3370 |
|
destroyFxSend(int channel, int fxSend) |
3371 |
|
throws IOException, LSException, LscpException { |
3372 |
|
|
3373 |
|
verifyConnection(); |
3374 |
|
String s = String.valueOf(channel) + " " + String.valueOf(fxSend); |
3375 |
|
out.writeLine("DESTROY FX_SEND " + s); |
3376 |
|
if(getPrintOnlyMode()) return; |
3377 |
|
|
3378 |
|
ResultSet rs = getEmptyResultSet(); |
3379 |
|
} |
3380 |
|
|
3381 |
|
/** |
3382 |
|
* Gets the current number of effect sends on the specified sampler channel. |
3383 |
|
* @param channel The ID of the sampler channel. |
3384 |
|
* @return The current number of effect sends on the specified sampler channels. |
3385 |
|
* @throws IOException If some I/O error occurs. |
3386 |
|
* @throws LscpException If LSCP protocol corruption occurs. |
3387 |
|
* @throws LSException If some other error occurs. |
3388 |
|
*/ |
3389 |
|
public synchronized int |
3390 |
|
getFxSoundCount(int channel) throws IOException, LscpException, LSException { |
3391 |
|
verifyConnection(); |
3392 |
|
out.writeLine("GET FX_SENDS " + String.valueOf(channel)); |
3393 |
|
if(getPrintOnlyMode()) return -1; |
3394 |
|
|
3395 |
|
String s = getSingleLineResultSet().getResult(); |
3396 |
|
return parseInt(s); |
3397 |
|
} |
3398 |
|
|
3399 |
|
/** |
3400 |
|
* Gets a list of all created effect sends on the specified sampler channel. |
3401 |
|
* @param channel The sampler channel number. |
3402 |
|
* @return A <code>FxSend</code> array providing all created |
3403 |
|
* effect sends on the specified sampler channel. |
3404 |
|
* @throws IOException If some I/O error occurs. |
3405 |
|
* @throws LscpException If LSCP protocol corruption occurs. |
3406 |
|
* @throws LSException If <code>channel</code> is not a valid sampler channel ID. |
3407 |
|
* @see #createFxSend |
3408 |
|
* @see #destroyFxSend |
3409 |
|
*/ |
3410 |
|
public synchronized FxSend[] |
3411 |
|
getFxSends(int channel) throws IOException, LscpException, LSException { |
3412 |
|
Integer[] idS = getFxSendIDs(channel); |
3413 |
|
if(getPrintOnlyMode()) return null; |
3414 |
|
|
3415 |
|
FxSend[] fxSends = new FxSend[idS.length]; |
3416 |
|
|
3417 |
|
for(int i = 0; i < fxSends.length; i++) |
3418 |
|
fxSends[i] = getFxSendInfo(channel, idS[i]); |
3419 |
|
|
3420 |
|
return fxSends; |
3421 |
|
} |
3422 |
|
|
3423 |
|
/** |
3424 |
|
* Gets a list of effect sends on the specified sampler channel. |
3425 |
|
* @param channel The sampler channel number. |
3426 |
|
* @return An <code>Integer</code> array providing |
3427 |
|
* the numerical IDs of all effect sends on the specified sampler channel. |
3428 |
|
* @throws IOException If some I/O error occurs. |
3429 |
|
* @throws LscpException If LSCP protocol corruption occurs. |
3430 |
|
* @throws LSException If <code>channel</code> is not a valid sampler channel ID. |
3431 |
|
* @see #createFxSend |
3432 |
|
* @see #destroyFxSend |
3433 |
|
*/ |
3434 |
|
public synchronized Integer[] |
3435 |
|
getFxSendIDs(int channel) throws IOException, LscpException, LSException { |
3436 |
|
verifyConnection(); |
3437 |
|
out.writeLine("LIST FX_SENDS " + channel); |
3438 |
|
if(getPrintOnlyMode()) return null; |
3439 |
|
|
3440 |
|
return parseIntList(getSingleLineResultSet().getResult()); |
3441 |
|
} |
3442 |
|
|
3443 |
|
/** |
3444 |
|
* Gets the current settings of the specified effect send entity. |
3445 |
|
* @param channel The sampler channel number. |
3446 |
|
* @param fxSend The numerical ID of the effect send entity. |
3447 |
|
* @return <code>FxSend</code> instance containing |
3448 |
|
* the current settings of the specified effect send entity. |
3449 |
|
* @throws IOException If an I/O error occurs. |
3450 |
|
* @throws LscpException If LSCP protocol corruption occurs. |
3451 |
|
* @throws LSException If the sampler channel and/or the effect send number are invalid. |
3452 |
|
*/ |
3453 |
|
public synchronized FxSend |
3454 |
|
getFxSendInfo(int channel, int fxSend) throws IOException, LscpException, LSException { |
3455 |
|
verifyConnection(); |
3456 |
|
String s = String.valueOf(channel) + " " + String.valueOf(fxSend); |
3457 |
|
out.writeLine("GET FX_SEND INFO " + s); |
3458 |
|
if(getPrintOnlyMode()) return null; |
3459 |
|
|
3460 |
|
ResultSet rs = getMultiLineResultSet(); |
3461 |
|
FxSend fxs = new FxSend(rs.getMultiLineResult()); |
3462 |
|
fxs.setFxSendId(fxSend); |
3463 |
|
|
3464 |
|
return fxs; |
3465 |
|
} |
3466 |
|
|
3467 |
|
/** |
3468 |
|
* Sets the name of the specified effect send. |
3469 |
|
* @param channel The sampler channel number. |
3470 |
|
* @param fxSend The numerical ID of the effect send entity. |
3471 |
|
* @param name The new name for the specified effect send. |
3472 |
|
* @throws IOException If some I/O error occurs. |
3473 |
|
* @throws LscpException If LSCP protocol corruption occurs. |
3474 |
|
* @throws LSException If <code>channel</code> is not a valid channel |
3475 |
|
* number or <code>fxSend</code> is not a valid effect send ID; |
3476 |
|
*/ |
3477 |
|
public synchronized void |
3478 |
|
setFxSendName(int channel, int fxSend, String name) |
3479 |
|
throws IOException, LscpException, LSException { |
3480 |
|
|
3481 |
|
verifyConnection(); |
3482 |
|
String args = " " + channel + " " + fxSend + " '" + name + "'"; |
3483 |
|
out.writeLine("SET FX_SEND NAME" + args); |
3484 |
|
if(getPrintOnlyMode()) return; |
3485 |
|
|
3486 |
|
ResultSet rs = getEmptyResultSet(); |
3487 |
|
} |
3488 |
|
|
3489 |
|
/** |
3490 |
|
* Sets the destination of an effect send's audio channel in the specified sampler channel. |
3491 |
|
* @param channel The sampler channel number. |
3492 |
|
* @param fxSend The numerical ID of the effect send entity to be rerouted. |
3493 |
|
* @param audioSrc The numerical ID of the effect send's audio output channel, |
3494 |
|
* which should be rerouted. |
3495 |
|
* @param audioDst The audio channel of the selected audio output device |
3496 |
|
* where <code>audioSrc</code> should be routed to. |
3497 |
|
* @throws IOException If some I/O error occurs. |
3498 |
|
* @throws LscpException If LSCP protocol corruption occurs. |
3499 |
|
* @throws LSException If |
3500 |
|
* <ul> |
3501 |
|
* <li><code>channel</code> is not a valid channel number; |
3502 |
|
* <li><code>fxSend</code> is not a valid effect send ID; |
3503 |
|
* <li>There is no engine assigned yet to the specified sampler channel; |
3504 |
|
* <li>There is no audio output device connected to the specified sampler channel. |
3505 |
|
* </ul> |
3506 |
|
*/ |
3507 |
|
public synchronized void |
3508 |
|
setFxSendAudioOutputChannel(int channel, int fxSend, int audioSrc, int audioDst) |
3509 |
|
throws IOException, LscpException, LSException { |
3510 |
|
|
3511 |
|
verifyConnection(); |
3512 |
|
String args = " " + channel + " " + fxSend + " " + audioSrc + " " + audioDst; |
3513 |
|
out.writeLine("SET FX_SEND AUDIO_OUTPUT_CHANNEL" + args); |
3514 |
|
if(getPrintOnlyMode()) return; |
3515 |
|
|
3516 |
|
ResultSet rs = getEmptyResultSet(); |
3517 |
|
} |
3518 |
|
|
3519 |
|
/** |
3520 |
|
* Sets the MIDI controller, which will be able to modify |
3521 |
|
* the send level of the specified effect send in the specified sampler channel. |
3522 |
|
* @param channel The sampler channel number. |
3523 |
|
* @param fxSend The numerical ID of the effect send entity. |
3524 |
|
* @param midiCtrl The MIDI controller which shall be |
3525 |
|
* able to modify the effect send's send level. |
3526 |
|
* @throws IOException If some I/O error occurs. |
3527 |
|
* @throws LscpException If LSCP protocol corruption occurs. |
3528 |
|
* @throws LSException If |
3529 |
|
* <ul> |
3530 |
|
* <li><code>channel</code> is not a valid channel number; |
3531 |
|
* <li><code>fxSend</code> is not a valid effect send ID; |
3532 |
|
* <li><code>midiCtrl</code> is not a valid controller; |
3533 |
|
* </ul> |
3534 |
|
*/ |
3535 |
|
public synchronized void |
3536 |
|
setFxSendMidiController(int channel, int fxSend, int midiCtrl) |
3537 |
|
throws IOException, LscpException, LSException { |
3538 |
|
|
3539 |
|
verifyConnection(); |
3540 |
|
String args = " " + channel + " " + fxSend + " " + midiCtrl; |
3541 |
|
out.writeLine("SET FX_SEND MIDI_CONTROLLER" + args); |
3542 |
|
if(getPrintOnlyMode()) return; |
3543 |
|
|
3544 |
|
ResultSet rs = getEmptyResultSet(); |
3545 |
|
} |
3546 |
|
|
3547 |
|
/** |
3548 |
|
* Sets the current send level of the specified |
3549 |
|
* effect send entity in the specified sampler channel. |
3550 |
|
* @param channel The sampler channel number. |
3551 |
|
* @param fxSend The numerical ID of the effect send entity. |
3552 |
|
* @param volume The new volume value (a value smaller than 1.0 means |
3553 |
|
* attenuation, whereas a value greater than 1.0 means amplification). |
3554 |
|
* @throws IOException If some I/O error occurs. |
3555 |
|
* @throws LscpException If LSCP protocol corruption occurs. |
3556 |
|
* @throws LSException If some other error occurs. |
3557 |
|
*/ |
3558 |
|
public synchronized void |
3559 |
|
setFxSendLevel(int channel, int fxSend, float volume) |
3560 |
|
throws IOException, LscpException, LSException { |
3561 |
|
|
3562 |
|
verifyConnection(); |
3563 |
|
String args = " " + channel + " " + fxSend + " " + String.valueOf(volume); |
3564 |
|
out.writeLine("SET FX_SEND LEVEL" + args); |
3565 |
|
if(getPrintOnlyMode()) return; |
3566 |
|
|
3567 |
ResultSet rs = getEmptyResultSet(); |
ResultSet rs = getEmptyResultSet(); |
3568 |
} |
} |
3582 |
resetChannel(int samplerChn) throws IOException, LscpException, LSException { |
resetChannel(int samplerChn) throws IOException, LscpException, LSException { |
3583 |
verifyConnection(); |
verifyConnection(); |
3584 |
out.writeLine("RESET CHANNEL " + samplerChn); |
out.writeLine("RESET CHANNEL " + samplerChn); |
3585 |
|
if(getPrintOnlyMode()) return; |
3586 |
|
|
3587 |
ResultSet rs = getEmptyResultSet(); |
ResultSet rs = getEmptyResultSet(); |
3588 |
} |
} |
3597 |
resetSampler() throws IOException, LscpException { |
resetSampler() throws IOException, LscpException { |
3598 |
verifyConnection(); |
verifyConnection(); |
3599 |
out.writeLine("RESET"); |
out.writeLine("RESET"); |
3600 |
|
if(getPrintOnlyMode()) return; |
3601 |
|
|
3602 |
try { ResultSet rs = getEmptyResultSet(); } |
try { ResultSet rs = getEmptyResultSet(); } |
3603 |
catch(LSException x) { getLogger().warning(x.getMessage()); } |
catch(LSException x) { getLogger().warning(x.getMessage()); } |
3604 |
} |
} |
3614 |
getTotalVoiceCount() throws IOException, LscpException, LSException { |
getTotalVoiceCount() throws IOException, LscpException, LSException { |
3615 |
verifyConnection(); |
verifyConnection(); |
3616 |
out.writeLine("GET TOTAL_VOICE_COUNT"); |
out.writeLine("GET TOTAL_VOICE_COUNT"); |
3617 |
|
if(getPrintOnlyMode()) return -1; |
3618 |
|
|
3619 |
String s = getSingleLineResultSet().getResult(); |
String s = getSingleLineResultSet().getResult(); |
3620 |
return parseInt(s); |
return parseInt(s); |
3621 |
} |
} |
3631 |
getTotalVoiceCountMax() throws IOException, LscpException, LSException { |
getTotalVoiceCountMax() throws IOException, LscpException, LSException { |
3632 |
verifyConnection(); |
verifyConnection(); |
3633 |
out.writeLine("GET TOTAL_VOICE_COUNT_MAX"); |
out.writeLine("GET TOTAL_VOICE_COUNT_MAX"); |
3634 |
|
if(getPrintOnlyMode()) return -1; |
3635 |
|
|
3636 |
String s = getSingleLineResultSet().getResult(); |
String s = getSingleLineResultSet().getResult(); |
3637 |
return parseInt(s); |
return parseInt(s); |
3638 |
} |
} |
3651 |
getServerInfo() throws IOException, LscpException, LSException { |
getServerInfo() throws IOException, LscpException, LSException { |
3652 |
verifyConnection(); |
verifyConnection(); |
3653 |
out.writeLine("GET SERVER INFO"); |
out.writeLine("GET SERVER INFO"); |
3654 |
|
if(getPrintOnlyMode()) return null; |
3655 |
|
|
3656 |
ResultSet rs = getMultiLineResultSet(); |
ResultSet rs = getMultiLineResultSet(); |
3657 |
return new ServerInfo(rs.getMultiLineResult()); |
return new ServerInfo(rs.getMultiLineResult()); |
3658 |
} |
} |
3659 |
|
|
3660 |
/** |
/** |
3661 |
|
* Gets the golobal volume of the sampler. |
3662 |
|
* @return The golobal volume of the sampler. |
3663 |
|
* @throws IOException If some I/O error occurs. |
3664 |
|
* @throws LscpException If LSCP protocol corruption occurs. |
3665 |
|
* @throws LSException If some other error occurs. |
3666 |
|
*/ |
3667 |
|
public synchronized float |
3668 |
|
getVolume() throws IOException, LscpException, LSException { |
3669 |
|
verifyConnection(); |
3670 |
|
out.writeLine("GET VOLUME"); |
3671 |
|
if(getPrintOnlyMode()) return -1; |
3672 |
|
|
3673 |
|
String s = getSingleLineResultSet().getResult(); |
3674 |
|
return parseFloat(s); |
3675 |
|
} |
3676 |
|
|
3677 |
|
/** |
3678 |
|
* Sets the global volume of the sampler. |
3679 |
|
* @param volume The new volume value. |
3680 |
|
* @throws IOException If some I/O error occurs. |
3681 |
|
* @throws LscpException If LSCP protocol corruption occurs. |
3682 |
|
* @throws LSException If some other error occurs. |
3683 |
|
* @see #getVolume |
3684 |
|
*/ |
3685 |
|
public synchronized void |
3686 |
|
setVolume(float volume) throws IOException, LscpException, LSException { |
3687 |
|
|
3688 |
|
verifyConnection(); |
3689 |
|
out.writeLine("SET VOLUME " + volume); |
3690 |
|
if(getPrintOnlyMode()) return; |
3691 |
|
|
3692 |
|
ResultSet rs = getEmptyResultSet(); |
3693 |
|
} |
3694 |
|
|
3695 |
|
/** |
3696 |
* Returns the logger for this library. |
* Returns the logger for this library. |
3697 |
* @return The logger for this library. |
* @return The logger for this library. |
3698 |
*/ |
*/ |