/[svn]/jlscp/trunk/src/org/linuxsampler/lscp/Client.java
ViewVC logotype

Diff of /jlscp/trunk/src/org/linuxsampler/lscp/Client.java

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 784 by iliev, Mon Oct 10 14:55:44 2005 UTC revision 1202 by iliev, Thu May 24 20:17:25 2007 UTC
# Line 1  Line 1 
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   *   *
# Line 23  Line 23 
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;
# Line 39  import org.linuxsampler.lscp.event.*; Line 40  import org.linuxsampler.lscp.event.*;
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:
# Line 68  public class Client { Line 69  public class Client {
69          private String address;          private String address;
70          private int port;          private int port;
71          private Socket sock = null;          private Socket sock = null;
72          private int soTimeout = 10000;          private int soTimeout = 20000;
73                    
74          private LscpInputStream in = null;          private LscpInputStream in = null;
75          private LscpOutputStream out = null;          private LscpOutputStream out = null;
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 Vector<String> queue = new Vector<String>();
83                  private boolean terminate = false;                  private boolean terminate = false;
84                                    
85                  EventThread() { super("LSCP-Event-Thread"); }                  EventThread() { super("LSCP-Event-Thread"); }
# Line 83  public class Client { Line 87  public class Client {
87                  public void                  public void
88                  run() {                  run() {
89                          while(!mustTerminate()) {                          while(!mustTerminate()) {
90                                  try { processNotifications(); }                                  try {
91                                  catch(Exception x) {                                          processQueue();
92                                            processNotifications();
93                                    } catch(Exception x) {
94                                          getLogger().log(Level.FINE, x.getMessage(), x);                                          getLogger().log(Level.FINE, x.getMessage(), x);
95                                  }                                  }
96                                  try { synchronized(this) { wait(100); } }                                  try { synchronized(this) { wait(100); } }
# Line 102  public class Client { Line 108  public class Client {
108                          terminate = true;                          terminate = true;
109                          this.notifyAll();                          this.notifyAll();
110                  }                  }
111                    
112                    public synchronized void
113                    scheduleNotification(String s) { queue.add(s); }
114                    
115                    private void
116                    processQueue() {
117                            String[] notifications = popAllNotifications();
118                            for(String n : notifications) fireEvent(n);
119                    }
120                    
121                    private synchronized String[]
122                    popAllNotifications() {
123                            String[] notifications = queue.toArray(new String[queue.size()]);
124                            queue.removeAllElements();
125                            return notifications;
126                    }
127          }          }
128                    
129          /**          /**
# Line 133  public class Client { Line 155  public class Client {
155          }          }
156                    
157          /**          /**
158             * Creates a new instance of Client.
159             * @param printOnlyMode Determines whether the client will be in print-only mode.
160             */
161            public
162            Client(boolean printOnlyMode) {
163                    if(printOnlyMode) setPrintOnlyMode(true);
164            }
165            
166            /**
167             * Determines whether the client is in print-only mode.
168             * Print-only mode means that the client will just print all
169             * LSCP commands to the specified output stream or to the standard output stream
170             * (<code>java.lang.System.out</code>) if no output stream is specified,
171             * without taking any further actions. Thus, in print-only mode all returned
172             * values by <code>Client</code>'s methods are meaningless and should be discarded.
173             * @return <code>true</code> if the client is in
174             * print-only mode, <code>false</code> otherwise.
175             * @see #setPrintOnlyModeOutputStream
176             */
177            public synchronized boolean
178            getPrintOnlyMode() { return printOnlyMode; }
179            
180            /**
181             * Sets the print-only mode. Note that in print-only mode all returned
182             * values by <code>Client</code>'s methods are meaningless and should be discarded.
183             * The default output stream in print-only mode is <code>java.lang.System.out</code>.
184             * @param b If <code>true</code> all LSCP commands will be sent
185             * to the specified output stream or to the standard output stream
186             * (<code>java.lang.System.out</code>) if no output stream is specified,
187             * and no further actions will be taken.
188             * @throws IllegalStateException If the client is connected.
189             * @see #setPrintOnlyModeOutputStream
190             */
191            public synchronized void
192            setPrintOnlyMode(boolean b) {
193                    if(printOnlyMode == b) return;
194                    if(isConnected()) throw new IllegalStateException();
195                    
196                    printOnlyMode = b;
197                    if(b) out = new LscpOutputStream(System.out);
198            }
199            
200            /**
201             * Sets the output stream to be used in print-only mode.
202             * @param out The output stream to be used in print-only mode.
203             * @throws IllegalStateException If the client is not in print-only mode.
204             * @throws IllegalArgumentException if <code>out</code> is <code>null</code>.
205             * @see #setPrintOnlyMode
206             */
207            public synchronized void
208            setPrintOnlyModeOutputStream(OutputStream out) {
209                    if(!getPrintOnlyMode()) throw new IllegalStateException("Not in print-only mode");
210                    if(out == null) throw new IllegalArgumentException("out must be non-null");
211                    this.out = new LscpOutputStream(out);
212            }
213            
214            /**
215           * Specifies the jlscp version.           * Specifies the jlscp version.
216           * @return The jlscp version.           * @return The jlscp version.
217           */           */
# Line 180  public class Client { Line 259  public class Client {
259          public synchronized void          public synchronized void
260          connect() throws LscpException {          connect() throws LscpException {
261                  if(sock != null) disconnect();                  if(sock != null) disconnect();
262                    if(getPrintOnlyMode()) return;
263                                    
264                  // Initializing LSCP event thread                  // Initializing LSCP event thread
265                  if(eventThread.isAlive()) {                  if(eventThread.isAlive()) {
# Line 252  public class Client { Line 332  public class Client {
332                  if(hasSubscriptions()) eventThread.start();                  if(hasSubscriptions()) eventThread.start();
333                                    
334                  if(!llM.isEmpty()) subscribe("MISCELLANEOUS");                  if(!llM.isEmpty()) subscribe("MISCELLANEOUS");
335                    if(!llAODC.isEmpty()) subscribe("AUDIO_OUTPUT_DEVICE_COUNT");
336                    if(!llAODI.isEmpty()) subscribe("AUDIO_OUTPUT_DEVICE_INFO");
337                    if(!llMIDC.isEmpty()) subscribe("MIDI_INPUT_DEVICE_COUNT");
338                    if(!llMIDI.isEmpty()) subscribe("MIDI_INPUT_DEVICE_INFO");
339                  if(!llBF.isEmpty()) subscribe("BUFFER_FILL");                  if(!llBF.isEmpty()) subscribe("BUFFER_FILL");
340                  if(!llCC.isEmpty()) subscribe("CHANNEL_COUNT");                  if(!llCC.isEmpty()) subscribe("CHANNEL_COUNT");
341                  if(!llCI.isEmpty()) subscribe("CHANNEL_INFO");                  if(!llCI.isEmpty()) subscribe("CHANNEL_INFO");
342                    if(!llFSC.isEmpty()) subscribe("FX_SEND_COUNT");
343                    if(!llFSI.isEmpty()) subscribe("FX_SEND_INFO");
344                  if(!llSC.isEmpty()) subscribe("STREAM_COUNT");                  if(!llSC.isEmpty()) subscribe("STREAM_COUNT");
345                  if(!llVC.isEmpty()) subscribe("VOICE_COUNT");                  if(!llVC.isEmpty()) subscribe("VOICE_COUNT");
346                  if(!llTVC.isEmpty()) subscribe("TOTAL_VOICE_COUNT");                  if(!llTVC.isEmpty()) subscribe("TOTAL_VOICE_COUNT");
347                    if(!llMIMC.isEmpty()) subscribe("MIDI_INSTRUMENT_MAP_COUNT");
348                    if(!llMIMI.isEmpty()) subscribe("MIDI_INSTRUMENT_MAP_INFO");
349                    if(!llMIC.isEmpty()) subscribe("MIDI_INSTRUMENT_COUNT");
350                    if(!llMII.isEmpty()) subscribe("MIDI_INSTRUMENT_INFO");
351                    if(!llID.isEmpty()) {
352                            subscribe("DB_INSTRUMENT_DIRECTORY_COUNT");
353                            subscribe("DB_INSTRUMENT_DIRECTORY_INFO");
354                            subscribe("DB_INSTRUMENT_COUNT");
355                            subscribe("DB_INSTRUMENT_INFO");
356                    }
357                    if(!llGI.isEmpty()) subscribe("GLOBAL_INFO");
358          }          }
359                    
360          /**          /**
# Line 265  public class Client { Line 362  public class Client {
362           */           */
363          public synchronized void          public synchronized void
364          disconnect() {          disconnect() {
365                    if(getPrintOnlyMode()) return;
366                  try { if(sock != null) sock.close(); }                  try { if(sock != null) sock.close(); }
367                  catch(Exception x) { getLogger().log(Level.FINE, x.getMessage(), x); }                  catch(Exception x) { getLogger().log(Level.FINE, x.getMessage(), x); }
368                  sock = null;                  sock = null;
# Line 292  public class Client { Line 390  public class Client {
390           */           */
391          private void          private void
392          verifyConnection() throws IOException {          verifyConnection() throws IOException {
393                    if(getPrintOnlyMode()) return;
394                    
395                  if(!isConnected())                  if(!isConnected())
396                          throw new IOException(LscpI18n.getLogMsg("Client.notConnected!"));                          throw new IOException(LscpI18n.getLogMsg("Client.notConnected!"));
397          }          }
# Line 301  public class Client { Line 401  public class Client {
401                  String s;                  String s;
402                  for(;;) {                  for(;;) {
403                          s = in.readLine();                          s = in.readLine();
404                          if(s.startsWith("NOTIFY:")) fireEvent(s.substring("NOTIFY:".length()));                          if(s.startsWith("NOTIFY:")) {
405                                    eventThread.scheduleNotification(s.substring("NOTIFY:".length()));
406                            }
407                          else break;                          else break;
408                  }                  }
409                  return s;                  return s;
410          }          }
411                    
412          /** Processes the notifications send by LinuxSampler */          /** Processes the notifications sent by LinuxSampler */
413          private synchronized void          private synchronized void
414          processNotifications() throws IOException, LscpException {          processNotifications() throws IOException, LscpException {
415                  while(in.available() > 0) {                  while(in.available() > 0) {
# Line 366  public class Client { Line 468  public class Client {
468                  return rs;                  return rs;
469          }          }
470                    
471            /** Audio output device count listeners */
472            private final Vector<ItemCountListener> llAODC = new Vector<ItemCountListener>();
473            /** Audio output device info listeners */
474            private final Vector<ItemInfoListener> llAODI = new Vector<ItemInfoListener>();
475          private final Vector<BufferFillListener> llBF = new Vector<BufferFillListener>();          private final Vector<BufferFillListener> llBF = new Vector<BufferFillListener>();
476          private final Vector<ChannelCountListener> llCC = new Vector<ChannelCountListener>();          private final Vector<ChannelCountListener> llCC = new Vector<ChannelCountListener>();
477          private final Vector<ChannelInfoListener> llCI = new Vector<ChannelInfoListener>();          private final Vector<ChannelInfoListener> llCI = new Vector<ChannelInfoListener>();
478            private final Vector<FxSendCountListener> llFSC = new Vector<FxSendCountListener>();
479            private final Vector<FxSendInfoListener> llFSI = new Vector<FxSendInfoListener>();
480          private final Vector<MiscellaneousListener> llM = new Vector<MiscellaneousListener>();          private final Vector<MiscellaneousListener> llM = new Vector<MiscellaneousListener>();
481            /** MIDI input device count listeners */
482            private final Vector<ItemCountListener> llMIDC = new Vector<ItemCountListener>();
483            /** MIDI input device info listeners */
484            private final Vector<ItemInfoListener> llMIDI = new Vector<ItemInfoListener>();
485          private final Vector<StreamCountListener> llSC = new Vector<StreamCountListener>();          private final Vector<StreamCountListener> llSC = new Vector<StreamCountListener>();
486          private final Vector<VoiceCountListener> llVC = new Vector<VoiceCountListener>();          private final Vector<VoiceCountListener> llVC = new Vector<VoiceCountListener>();
487          private final Vector<TotalVoiceCountListener> llTVC = new Vector<TotalVoiceCountListener>();          private final Vector<TotalVoiceCountListener> llTVC = new Vector<TotalVoiceCountListener>();
488                    
489            /** MIDI instrument map count listeners */
490            private final Vector<ItemCountListener> llMIMC = new Vector<ItemCountListener>();
491            /** MIDI instrument map info listeners */
492            private final Vector<ItemInfoListener> llMIMI = new Vector<ItemInfoListener>();
493            /** MIDI instrument count listeners */
494            private final Vector<MidiInstrumentCountListener> llMIC =
495                    new Vector<MidiInstrumentCountListener>();
496            /** MIDI instrument info listeners */
497            private final Vector<MidiInstrumentInfoListener> llMII =
498                    new Vector<MidiInstrumentInfoListener>();
499            private final Vector<InstrumentsDbListener> llID = new Vector<InstrumentsDbListener>();
500            private final Vector<GlobalInfoListener> llGI = new Vector<GlobalInfoListener>();
501            
502            
503          /**          /**
504           * Determines whether there is at least one subscription for notification events.           * Determines whether there is at least one subscription for notification events.
505           * Do not forget to check for additional listeners if the LSCP specification           * Do not forget to check for additional listeners if the LSCP specification
# Line 383  public class Client { Line 509  public class Client {
509           */           */
510          private boolean          private boolean
511          hasSubscriptions() {          hasSubscriptions() {
512                  return  !llBF.isEmpty() ||                  return  !llAODC.isEmpty() ||
513                          !llCC.isEmpty() ||                          !llAODI.isEmpty() ||
514                          !llCI.isEmpty() ||                          !llBF.isEmpty()   ||
515                          !llM.isEmpty()  ||                          !llCC.isEmpty()   ||
516                          !llSC.isEmpty() ||                          !llCI.isEmpty()   ||
517                          !llVC.isEmpty() ||                          !llFSC.isEmpty()  ||
518                          !llTVC.isEmpty();                          !llFSI.isEmpty()  ||
519                            !llM.isEmpty()    ||
520                            !llMIDC.isEmpty() ||
521                            !llMIDI.isEmpty() ||
522                            !llSC.isEmpty()   ||
523                            !llVC.isEmpty()   ||
524                            !llTVC.isEmpty()  ||
525                            !llMIMC.isEmpty() ||
526                            !llMIMI.isEmpty() ||
527                            !llMIC.isEmpty()  ||
528                            !llMII.isEmpty()  ||
529                            !llID.isEmpty()   ||
530                            !llGI.isEmpty();
531          }          }
532                    
533          private void          private synchronized void
534          fireEvent(String s) {          fireEvent(String s) {
535                  if(s.startsWith("CHANNEL_COUNT:")) {                   if(s.startsWith("DB_INSTRUMENT_DIRECTORY_COUNT:")) {
536                            s = s.substring("DB_INSTRUMENT_DIRECTORY_COUNT:".length());
537                            InstrumentsDbEvent e = new InstrumentsDbEvent(this, s);
538                            for(InstrumentsDbListener l : llID) l.directoryCountChanged(e);
539                    } else if(s.startsWith("DB_INSTRUMENT_DIRECTORY_INFO:")) {
540                            InstrumentsDbEvent e;
541                            s = s.substring("DB_INSTRUMENT_DIRECTORY_INFO:".length());
542                            if(s.startsWith("NAME ")) {
543                                    String[] list;
544                                    try {
545                                            list = parseStringList(s.substring("NAME ".length()), ' ');
546                                            if(list.length != 2) throw new LscpException();
547                                            e = new InstrumentsDbEvent(this, list[0], list[1]);
548                                            for(InstrumentsDbListener l : llID) {
549                                                    l.directoryNameChanged(e);
550                                            }
551                                    } catch(LscpException x) {
552                                            getLogger().log (
553                                                    Level.WARNING,
554                                                    LscpI18n.getLogMsg("CommandFailed!"),
555                                                    x
556                                            );
557                                    }
558                            } else {
559                                    e = new InstrumentsDbEvent(this, s);
560                                    for(InstrumentsDbListener l : llID) l.directoryInfoChanged(e);
561                            }
562                    } else if(s.startsWith("DB_INSTRUMENT_COUNT:")) {
563                            s = s.substring("DB_INSTRUMENT_COUNT:".length());
564                            InstrumentsDbEvent e = new InstrumentsDbEvent(this, s);
565                            for(InstrumentsDbListener l : llID) l.instrumentCountChanged(e);
566                    } else if(s.startsWith("DB_INSTRUMENT_INFO:")) {
567                            InstrumentsDbEvent e;
568                            s = s.substring("DB_INSTRUMENT_INFO:".length());
569                            if(s.startsWith("NAME ")) {
570                                    String[] list;
571                                    try {
572                                            list = parseStringList(s.substring("NAME ".length()), ' ');
573                                            if(list.length != 2) throw new LscpException();
574                                            e = new InstrumentsDbEvent(this, list[0], list[1]);
575                                            for(InstrumentsDbListener l : llID) {
576                                                    l.instrumentNameChanged(e);
577                                            }
578                                    } catch(LscpException x) {
579                                            getLogger().log (
580                                                    Level.WARNING,
581                                                    LscpI18n.getLogMsg("CommandFailed!"),
582                                                    x
583                                            );
584                                    }
585                            } else {
586                                    e = new InstrumentsDbEvent(this, s);
587                                    for(InstrumentsDbListener l : llID) l.instrumentInfoChanged(e);
588                            }
589                    } else if(s.startsWith("DB_INSTRUMENTS_JOB_INFO:")) {
590                            s = s.substring("DB_INSTRUMENTS_JOB_INFO:".length());
591                            try {
592                                    int i = Integer.parseInt(s);
593                                    InstrumentsDbEvent e = new InstrumentsDbEvent(this, i);
594                                    for(InstrumentsDbListener l : llID) l.jobStatusChanged(e);
595                            } catch(NumberFormatException x) {
596                                    s = "Unknown DB_INSTRUMENTS_JOB_INFO format";
597                                    getLogger().log(Level.WARNING, s, x);
598                            }
599                            
600                    } else if(s.startsWith("CHANNEL_COUNT:")) {
601                          try {                          try {
602                                  int i = Integer.parseInt(s.substring("CHANNEL_COUNT:".length()));                                  int i = Integer.parseInt(s.substring("CHANNEL_COUNT:".length()));
603                                  ChannelCountEvent e = new ChannelCountEvent(this, i);                                  ChannelCountEvent e = new ChannelCountEvent(this, i);
# Line 407  public class Client { Line 610  public class Client {
610                  } else if(s.startsWith("VOICE_COUNT:")) {                  } else if(s.startsWith("VOICE_COUNT:")) {
611                          try {                          try {
612                                  s = s.substring("VOICE_COUNT:".length());                                  s = s.substring("VOICE_COUNT:".length());
613                                  int i = s.indexOf(' ');                                  Integer[] i = parseIntList(s, ' ');
614                                  if(i == -1) {                                  if(i.length != 2) {
615                                          getLogger().warning("Unknown VOICE_COUNT format");                                          getLogger().warning("Unknown VOICE_COUNT format");
616                                          return;                                          return;
617                                  }                                  }
618                                  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);  
619                                  for(VoiceCountListener l : llVC) l.voiceCountChanged(e);                                  for(VoiceCountListener l : llVC) l.voiceCountChanged(e);
620                          } catch(NumberFormatException x) {                          } catch(Exception x) {
621                                  getLogger().log(Level.WARNING, "Unknown VOICE_COUNT format", x);                                  getLogger().log(Level.WARNING, "Unknown VOICE_COUNT format", x);
622                          }                          }
623                  } else if(s.startsWith("STREAM_COUNT:")) {                  } else if(s.startsWith("STREAM_COUNT:")) {
624                          try {                          try {
625                                  s = s.substring("STREAM_COUNT:".length());                                  s = s.substring("STREAM_COUNT:".length());
626                                  int i = s.indexOf(' ');                                  Integer[] i = parseIntList(s, ' ');
627                                  if(i == -1) {                                  if(i.length != 2) {
628                                          getLogger().warning("Unknown STREAM_COUNT format");                                          getLogger().warning("Unknown STREAM_COUNT format");
629                                          return;                                          return;
630                                  }                                  }
631                                  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);  
632                                  for(StreamCountListener l : llSC) l.streamCountChanged(e);                                  for(StreamCountListener l : llSC) l.streamCountChanged(e);
633                          } catch(NumberFormatException x) {                          } catch(Exception x) {
634                                  getLogger().log(Level.WARNING, "Unknown STREAM_COUNT format", x);                                  getLogger().log(Level.WARNING, "Unknown STREAM_COUNT format", x);
635                          }                          }
636                  } else if(s.startsWith("BUFFER_FILL:")) {                  } else if(s.startsWith("BUFFER_FILL:")) {
# Line 439  public class Client { Line 638  public class Client {
638                                  s = s.substring("BUFFER_FILL:".length());                                  s = s.substring("BUFFER_FILL:".length());
639                                  int i = s.indexOf(' ');                                  int i = s.indexOf(' ');
640                                  if(i == -1) {                                  if(i == -1) {
641                                          getLogger().warning("Unknown STREAM_COUNT format");                                          getLogger().warning("Unknown BUFFER_FILL format");
642                                          return;                                          return;
643                                  }                                  }
644                                  int j = Integer.parseInt(s.substring(0, i));                                  int j = Integer.parseInt(s.substring(0, i));
# Line 448  public class Client { Line 647  public class Client {
647                                  BufferFillEvent e = new BufferFillEvent(this, j, v);                                  BufferFillEvent e = new BufferFillEvent(this, j, v);
648                                  for(BufferFillListener l : llBF) l.bufferFillChanged(e);                                  for(BufferFillListener l : llBF) l.bufferFillChanged(e);
649                          } catch(Exception x) {                          } catch(Exception x) {
650                                  getLogger().log(Level.WARNING, "Unknown STREAM_COUNT format", x);                                  getLogger().log(Level.WARNING, "Unknown BUFFER_FILL format", x);
651                          }                          }
652                  } else if(s.startsWith("CHANNEL_INFO:")) {                  } else if(s.startsWith("CHANNEL_INFO:")) {
653                          try {                          try {
# Line 456  public class Client { Line 655  public class Client {
655                                  ChannelInfoEvent e = new ChannelInfoEvent(this, i);                                  ChannelInfoEvent e = new ChannelInfoEvent(this, i);
656                                  for(ChannelInfoListener l : llCI) l.channelInfoChanged(e);                                  for(ChannelInfoListener l : llCI) l.channelInfoChanged(e);
657                          } catch(NumberFormatException x) {                          } catch(NumberFormatException x) {
658                                  getLogger().log(Level.WARNING, "Unknown STREAM_COUNT format", x);                                  getLogger().log(Level.WARNING, "Unknown CHANNEL_INFO format", x);
659                          }                          }
660                  } else if(s.startsWith("TOTAL_VOICE_COUNT:")) {                  } else if(s.startsWith("TOTAL_VOICE_COUNT:")) {
661                          try {                          try {
# Line 469  public class Client { Line 668  public class Client {
668                                          Level.WARNING, "Unknown TOTAL_VOICE_COUNT format", x                                          Level.WARNING, "Unknown TOTAL_VOICE_COUNT format", x
669                                  );                                  );
670                          }                          }
671                    } else if(s.startsWith("AUDIO_OUTPUT_DEVICE_COUNT:")) {
672                            try {
673                                    s = s.substring("AUDIO_OUTPUT_DEVICE_COUNT:".length());
674                                    int i = Integer.parseInt(s);
675                                    ItemCountEvent e = new ItemCountEvent(this, i);
676                                    for(ItemCountListener l : llAODC) l.itemCountChanged(e);
677                            } catch(NumberFormatException x) {
678                                    getLogger().log (
679                                            Level.WARNING, "Unknown AUDIO_OUTPUT_DEVICE_COUNT format", x
680                                    );
681                            }
682                    } else if(s.startsWith("AUDIO_OUTPUT_DEVICE_INFO:")) {
683                            try {
684                                    s = s.substring("AUDIO_OUTPUT_DEVICE_INFO:".length());
685                                    int i = Integer.parseInt(s);
686                                    ItemInfoEvent e = new ItemInfoEvent(this, i);
687                                    for(ItemInfoListener l : llAODI) l.itemInfoChanged(e);
688                            } catch(NumberFormatException x) {
689                                    getLogger().log (
690                                            Level.WARNING, "Unknown AUDIO_OUTPUT_DEVICE_INFO format", x
691                                    );
692                            }
693                    } else if(s.startsWith("MIDI_INPUT_DEVICE_COUNT:")) {
694                            try {
695                                    s = s.substring("MIDI_INPUT_DEVICE_COUNT:".length());
696                                    int i = Integer.parseInt(s);
697                                    ItemCountEvent e = new ItemCountEvent(this, i);
698                                    for(ItemCountListener l : llMIDC) l.itemCountChanged(e);
699                            } catch(NumberFormatException x) {
700                                    getLogger().log (
701                                            Level.WARNING, "Unknown MIDI_INPUT_DEVICE_COUNT format", x
702                                    );
703                            }
704                    } else if(s.startsWith("MIDI_INPUT_DEVICE_INFO:")) {
705                            try {
706                                    s = s.substring("MIDI_INPUT_DEVICE_INFO:".length());
707                                    int i = Integer.parseInt(s);
708                                    ItemInfoEvent e = new ItemInfoEvent(this, i);
709                                    for(ItemInfoListener l : llMIDI) l.itemInfoChanged(e);
710                            } catch(NumberFormatException x) {
711                                    getLogger().log (
712                                            Level.WARNING, "Unknown MIDI_INPUT_DEVICE_INFO format", x
713                                    );
714                            }
715                    } else if(s.startsWith("MIDI_INSTRUMENT_MAP_COUNT:")) {
716                            try {
717                                    s = s.substring("MIDI_INSTRUMENT_MAP_COUNT:".length());
718                                    int i = Integer.parseInt(s);
719                                    ItemCountEvent e = new ItemCountEvent(this, i);
720                                    for(ItemCountListener l : llMIMC) l.itemCountChanged(e);
721                            } catch(NumberFormatException x) {
722                                    getLogger().log (
723                                            Level.WARNING, "Unknown MIDI_INSTRUMENT_MAP_COUNT format", x
724                                    );
725                            }
726                    } else if(s.startsWith("MIDI_INSTRUMENT_MAP_INFO:")) {
727                            try {
728                                    s = s.substring("MIDI_INSTRUMENT_MAP_INFO:".length());
729                                    int i = Integer.parseInt(s);
730                                    ItemInfoEvent e = new ItemInfoEvent(this, i);
731                                    for(ItemInfoListener l : llMIMI) l.itemInfoChanged(e);
732                            } catch(NumberFormatException x) {
733                                    getLogger().log (
734                                            Level.WARNING, "Unknown MIDI_INSTRUMENT_MAP_INFO format", x
735                                    );
736                            }
737                    } else if(s.startsWith("MIDI_INSTRUMENT_COUNT:")) {
738                            try {
739                                    s = s.substring("MIDI_INSTRUMENT_COUNT:".length());
740                                    Integer[] i = parseIntList(s, ' ');
741                                    if(i.length != 2) {
742                                            getLogger().warning("Unknown MIDI_INSTRUMENT_COUNT format");
743                                            return;
744                                    }
745                                    
746                                    MidiInstrumentCountEvent e =
747                                            new MidiInstrumentCountEvent(this, i[0], i[1]);
748                                    
749                                    for(MidiInstrumentCountListener l : llMIC) {
750                                            l.instrumentCountChanged(e);
751                                    }
752                            } catch(Exception x) {
753                                    getLogger().log (
754                                            Level.WARNING, "Unknown MIDI_INSTRUMENT_COUNT format", x
755                                    );
756                            }
757                    } else if(s.startsWith("MIDI_INSTRUMENT_INFO:")) {
758                            try {
759                                    s = s.substring("MIDI_INSTRUMENT_INFO:".length());
760                                    Integer[] i = parseIntList(s, ' ');
761                                    if(i.length != 3) {
762                                            getLogger().warning("Unknown MIDI_INSTRUMENT_INFO format");
763                                            return;
764                                    }
765                                    
766                                    MidiInstrumentInfoEvent e =
767                                            new MidiInstrumentInfoEvent(this, i[0], i[1], i[2]);
768                                    for(MidiInstrumentInfoListener l : llMII) {
769                                            l.instrumentInfoChanged(e);
770                                    }
771                            } catch(Exception x) {
772                                    getLogger().log (
773                                            Level.WARNING, "Unknown MIDI_INSTRUMENT_INFO format", x
774                                    );
775                            }
776                    } else if(s.startsWith("FX_SEND_COUNT:")) {
777                            try {
778                                    s = s.substring("FX_SEND_COUNT:".length());
779                                    Integer[] i = parseIntList(s, ' ');
780                                    if(i.length != 2) {
781                                            getLogger().warning("Unknown FX_SEND_COUNT format");
782                                            return;
783                                    }
784                                    
785                                    FxSendCountEvent e = new FxSendCountEvent(this, i[0], i[1]);
786                                    
787                                    for(FxSendCountListener l : llFSC) l.fxSendCountChanged(e);
788                            } catch(Exception x) {
789                                    getLogger().log(Level.WARNING, "Unknown FX_SEND_COUNT format", x);
790                            }
791                    } else if(s.startsWith("FX_SEND_INFO:")) {
792                            try {
793                                    s = s.substring("FX_SEND_INFO:".length());
794                                    Integer[] i = parseIntList(s, ' ');
795                                    if(i.length != 2) {
796                                            getLogger().warning("Unknown FX_SEND_INFO format");
797                                            return;
798                                    }
799                                    
800                                    FxSendInfoEvent e = new FxSendInfoEvent(this, i[0], i[1]);
801                                    for(FxSendInfoListener l : llFSI) {
802                                            l.fxSendInfoChanged(e);
803                                    }
804                            } catch(Exception x) {
805                                    getLogger().log(Level.WARNING, "Unknown FX_SEND_INFO format", x);
806                            }
807                    } else if(s.startsWith("GLOBAL_INFO:")) {
808                            handleGlobalInfoEvent(s.substring("GLOBAL_INFO:".length()));
809                  } else if(s.startsWith("MISCELLANEOUS:")) {                  } else if(s.startsWith("MISCELLANEOUS:")) {
810                          s = s.substring("MISCELLANEOUS:".length());                          s = s.substring("MISCELLANEOUS:".length());
811                          MiscellaneousEvent e = new MiscellaneousEvent(this, s);                          MiscellaneousEvent e = new MiscellaneousEvent(this, s);
# Line 477  public class Client { Line 814  public class Client {
814          }          }
815                    
816          private void          private void
817            handleGlobalInfoEvent(String s) {
818                    try {
819                            if(s.startsWith("VOLUME ")) {
820                                    float f = Float.parseFloat(s.substring("VOLUME ".length()));
821                                    GlobalInfoEvent e = new GlobalInfoEvent(this, f);
822                                    for(GlobalInfoListener l : llGI) l.volumeChanged(e);
823                            }
824                    } catch(NumberFormatException x) {
825                            getLogger().log(Level.WARNING, "Unknown GLOBAL_INFO format", x);
826                    }
827            }
828            
829            private void
830          subscribe(String event) {          subscribe(String event) {
831                  if(!isConnected()) return;                  if(!getPrintOnlyMode()) {
832                            if(!isConnected()) return;
833                                    
834                  if(!eventThread.isAlive()) eventThread.start();                          if(!eventThread.isAlive()) eventThread.start();
835                    }
836                                    
837                  try {                  try {
838                          out.writeLine("SUBSCRIBE " + event);                          out.writeLine("SUBSCRIBE " + event);
839                          ResultSet rs = getEmptyResultSet();                          if(!getPrintOnlyMode()) getEmptyResultSet();
840                  } catch(Exception x) {                  } catch(Exception x) {
841                          getLogger().log (                          getLogger().log (
842                                  Level.WARNING,                                  Level.WARNING,
# Line 496  public class Client { Line 848  public class Client {
848                    
849          private void          private void
850          unsubscribe(String event) {          unsubscribe(String event) {
851                  if(!isConnected()) return;                  if(!getPrintOnlyMode() && !isConnected()) return;
852                                    
853                  try {                  try {
854                          out.writeLine("UNSUBSCRIBE " + event);                          out.writeLine("UNSUBSCRIBE " + event);
855                          ResultSet rs = getEmptyResultSet();                          if(!getPrintOnlyMode()) getEmptyResultSet();
856                  } catch(Exception x) {                  } catch(Exception x) {
857                          getLogger().log (                          getLogger().log (
858                                  Level.WARNING,                                  Level.WARNING,
# Line 512  public class Client { Line 864  public class Client {
864                    
865          /**          /**
866           * Registers the specified listener for receiving event messages.           * Registers the specified listener for receiving event messages.
867             * Listeners can be registered regardless of the connection state.
868             * @param l The <code>ItemCountListener</code> to register.
869             */
870            public synchronized void
871            addAudioDeviceCountListener(ItemCountListener l) {
872                    if(llAODC.isEmpty()) subscribe("AUDIO_OUTPUT_DEVICE_COUNT");
873                    llAODC.add(l);
874            }
875            
876            /**
877             * Removes the specified listener.
878             * Listeners can be removed regardless of the connection state.
879             * @param l The <code>ItemCountListener</code> to remove.
880             */
881            public synchronized void
882            removeAudioDeviceCountListener(ItemCountListener l) {
883                    boolean b = llAODC.remove(l);
884                    if(b && llAODC.isEmpty()) unsubscribe("AUDIO_OUTPUT_DEVICE_COUNT");
885            }
886            
887            /**
888             * Registers the specified listener for receiving event messages.
889             * Listeners can be registered regardless of the connection state.
890             * @param l The <code>ItemInfoListener</code> to register.
891             */
892            public synchronized void
893            addAudioDeviceInfoListener(ItemInfoListener l) {
894                    if(llAODI.isEmpty()) subscribe("AUDIO_OUTPUT_DEVICE_INFO");
895                    llAODI.add(l);
896            }
897            
898            /**
899             * Removes the specified listener.
900             * Listeners can be removed regardless of the connection state.
901             * @param l The <code>ItemInfoListener</code> to remove.
902             */
903            public synchronized void
904            removeAudioDeviceInfoListener(ItemInfoListener l) {
905                    boolean b = llAODI.remove(l);
906                    if(b && llAODI.isEmpty()) unsubscribe("AUDIO_OUTPUT_DEVICE_INFO");
907            }
908            
909            /**
910             * Registers the specified listener for receiving event messages.
911           * Listeners can be removed regardless of the connection state.           * Listeners can be removed regardless of the connection state.
912           * @param l The <code>BufferFillListener</code> to register.           * @param l The <code>BufferFillListener</code> to register.
913           */           */
# Line 579  public class Client { Line 975  public class Client {
975          /**          /**
976           * Registers the specified listener for receiving event messages.           * Registers the specified listener for receiving event messages.
977           * Listeners can be registered regardless of the connection state.           * Listeners can be registered regardless of the connection state.
978             * @param l The <code>FxSendCountListener</code> to register.
979             */
980            public synchronized void
981            addFxSendCountListener(FxSendCountListener l) {
982                    if(llFSC.isEmpty()) subscribe("FX_SEND_COUNT");
983                    llFSC.add(l);
984            }
985            
986            /**
987             * Removes the specified listener.
988             * Listeners can be removed regardless of the connection state.
989             * @param l The <code>FxSendCountListener</code> to remove.
990             */
991            public synchronized void
992            removeFxSendCountListener(FxSendCountListener l) {
993                    boolean b = llFSC.remove(l);
994                    if(b && llFSC.isEmpty()) unsubscribe("FX_SEND_COUNT");
995            }
996            
997            /**
998             * Registers the specified listener for receiving event messages.
999             * Listeners can be registered regardless of the connection state.
1000             * @param l The <code>FxSendInfoListener</code> to register.
1001             */
1002            public synchronized void
1003            addFxSendInfoListener(FxSendInfoListener l) {
1004                    if(llFSI.isEmpty()) subscribe("FX_SEND_INFO");
1005                    llFSI.add(l);
1006            }
1007            
1008            /**
1009             * Removes the specified listener.
1010             * Listeners can be removed regardless of the connection state.
1011             * @param l The <code>FxSendInfoListener</code> to remove.
1012             */
1013            public synchronized void
1014            removeFxSendInfoListener(FxSendInfoListener l) {
1015                    boolean b = llFSI.remove(l);
1016                    if(b && llFSI.isEmpty()) unsubscribe("FX_SEND_INFO");
1017            }
1018            
1019            /**
1020             * Registers the specified listener for receiving event messages.
1021             * Listeners can be registered regardless of the connection state.
1022             * @param l The <code>ItemCountListener</code> to register.
1023             */
1024            public synchronized void
1025            addMidiDeviceCountListener(ItemCountListener l) {
1026                    if(llMIDC.isEmpty()) subscribe("MIDI_INPUT_DEVICE_COUNT");
1027                    llMIDC.add(l);
1028            }
1029            
1030            /**
1031             * Removes the specified listener.
1032             * Listeners can be removed regardless of the connection state.
1033             * @param l The <code>ItemCountListener</code> to remove.
1034             */
1035            public synchronized void
1036            removeMidiDeviceCountListener(ItemCountListener l) {
1037                    boolean b = llMIDC.remove(l);
1038                    if(b && llMIDC.isEmpty()) unsubscribe("MIDI_INPUT_DEVICE_COUNT");
1039            }
1040            
1041            /**
1042             * Registers the specified listener for receiving event messages.
1043             * Listeners can be registered regardless of the connection state.
1044             * @param l The <code>ItemInfoListener</code> to register.
1045             */
1046            public synchronized void
1047            addMidiDeviceInfoListener(ItemInfoListener l) {
1048                    if(llMIDI.isEmpty()) subscribe("MIDI_INPUT_DEVICE_INFO");
1049                    llMIDI.add(l);
1050            }
1051            
1052            /**
1053             * Removes the specified listener.
1054             * Listeners can be removed regardless of the connection state.
1055             * @param l The <code>ItemInfoListener</code> to remove.
1056             */
1057            public synchronized void
1058            removeMidiDeviceInfoListener(ItemInfoListener l) {
1059                    boolean b = llMIDI.remove(l);
1060                    if(b && llMIDI.isEmpty()) unsubscribe("MIDI_INPUT_DEVICE_INFO");
1061            }
1062            
1063            /**
1064             * Registers the specified listener for receiving event messages.
1065             * Listeners can be registered regardless of the connection state.
1066           * @param l The <code>MiscellaneousListener</code> to register.           * @param l The <code>MiscellaneousListener</code> to register.
1067           */           */
1068          public synchronized void          public synchronized void
# Line 665  public class Client { Line 1149  public class Client {
1149          }          }
1150                    
1151          /**          /**
1152             * Registers the specified listener for receiving event messages.
1153             * Listeners can be registered regardless of the connection state.
1154             * @param l The <code>ItemCountListener</code> to register.
1155             */
1156            public synchronized void
1157            addMidiInstrumentMapCountListener(ItemCountListener l) {
1158                    if(llMIMC.isEmpty()) subscribe("MIDI_INSTRUMENT_MAP_COUNT");
1159                    llMIMC.add(l);
1160            }
1161            
1162            /**
1163             * Removes the specified listener.
1164             * Listeners can be removed regardless of the connection state.
1165             * @param l The <code>ItemCountListener</code> to remove.
1166             */
1167            public synchronized void
1168            removeMidiInstrumentMapCountListener(ItemCountListener l) {
1169                    boolean b = llMIMC.remove(l);
1170                    if(b && llMIMC.isEmpty()) unsubscribe("MIDI_INSTRUMENT_MAP_COUNT");
1171            }
1172            
1173            /**
1174             * Registers the specified listener for receiving event messages.
1175             * Listeners can be registered regardless of the connection state.
1176             * @param l The <code>ItemInfoListener</code> to register.
1177             */
1178            public synchronized void
1179            addMidiInstrumentMapInfoListener(ItemInfoListener l) {
1180                    if(llMIMI.isEmpty()) subscribe("MIDI_INSTRUMENT_MAP_INFO");
1181                    llMIMI.add(l);
1182            }
1183            
1184            /**
1185             * Removes the specified listener.
1186             * Listeners can be removed regardless of the connection state.
1187             * @param l The <code>ItemInfoListener</code> to remove.
1188             */
1189            public synchronized void
1190            removeMidiInstrumentMapInfoListener(ItemInfoListener l) {
1191                    boolean b = llMIMI.remove(l);
1192                    if(b && llMIMI.isEmpty()) unsubscribe("MIDI_INSTRUMENT_MAP_INFO");
1193            }
1194            
1195            /**
1196             * Registers the specified listener for receiving event messages.
1197             * Listeners can be registered regardless of the connection state.
1198             * @param l The <code>MidiInstrumentCountListener</code> to register.
1199             */
1200            public synchronized void
1201            addMidiInstrumentCountListener(MidiInstrumentCountListener l) {
1202                    if(llMIC.isEmpty()) subscribe("MIDI_INSTRUMENT_COUNT");
1203                    llMIC.add(l);
1204            }
1205            
1206            /**
1207             * Removes the specified listener.
1208             * Listeners can be removed regardless of the connection state.
1209             * @param l The <code>MidiInstrumentCountListener</code> to remove.
1210             */
1211            public synchronized void
1212            removeMidiInstrumentCountListener(MidiInstrumentCountListener l) {
1213                    boolean b = llMIC.remove(l);
1214                    if(b && llMIC.isEmpty()) unsubscribe("MIDI_INSTRUMENT_COUNT");
1215            }
1216            
1217            /**
1218             * Registers the specified listener for receiving event messages.
1219             * Listeners can be registered regardless of the connection state.
1220             * @param l The <code>MidiInstrumentInfoListener</code> to register.
1221             */
1222            public synchronized void
1223            addMidiInstrumentInfoListener(MidiInstrumentInfoListener l) {
1224                    if(llMII.isEmpty()) subscribe("MIDI_INSTRUMENT_INFO");
1225                    llMII.add(l);
1226            }
1227            
1228            /**
1229             * Removes the specified listener.
1230             * Listeners can be removed regardless of the connection state.
1231             * @param l The <code>MidiInstrumentInfoListener</code> to remove.
1232             */
1233            public synchronized void
1234            removeMidiInstrumentInfoListener(MidiInstrumentInfoListener l) {
1235                    boolean b = llMII.remove(l);
1236                    if(b && llMII.isEmpty()) unsubscribe("MIDI_INSTRUMENT_INFO");
1237            }
1238            
1239            /**
1240             * Registers the specified listener for receiving event messages.
1241             * Listeners can be registered regardless of the connection state.
1242             * @param l The <code>InstrumentsDbListener</code> to register.
1243             */
1244            public synchronized void
1245            addInstrumentsDbListener(InstrumentsDbListener l) {
1246                    if(llID.isEmpty()) {
1247                            subscribe("DB_INSTRUMENT_DIRECTORY_COUNT");
1248                            subscribe("DB_INSTRUMENT_DIRECTORY_INFO");
1249                            subscribe("DB_INSTRUMENT_COUNT");
1250                            subscribe("DB_INSTRUMENT_INFO");
1251                            subscribe("DB_INSTRUMENTS_JOB_INFO");
1252                    }
1253                    llID.add(l);
1254            }
1255            
1256            /**
1257             * Removes the specified listener.
1258             * Listeners can be removed regardless of the connection state.
1259             * @param l The <code>InstrumentsDbListener</code> to remove.
1260             */
1261            public synchronized void
1262            removeInstrumentsDbListener(InstrumentsDbListener l) {
1263                    boolean b = llID.remove(l);
1264                    if(b && llID.isEmpty()) {
1265                            unsubscribe("DB_INSTRUMENT_DIRECTORY_COUNT");
1266                            unsubscribe("DB_INSTRUMENT_DIRECTORY_INFO");
1267                            unsubscribe("DB_INSTRUMENT_COUNT");
1268                            unsubscribe("DB_INSTRUMENT_INFO");
1269                            unsubscribe("DB_INSTRUMENTS_JOB_INFO");
1270                    }
1271            }
1272            
1273            /**
1274             * Registers the specified listener for receiving event messages.
1275             * Listeners can be registered regardless of the connection state.
1276             * @param l The <code>GlobalInfoListener</code> to register.
1277             */
1278            public synchronized void
1279            addGlobalInfoListener(GlobalInfoListener l) {
1280                    if(llGI.isEmpty()) subscribe("GLOBAL_INFO");
1281                    llGI.add(l);
1282            }
1283            
1284            /**
1285             * Removes the specified listener.
1286             * Listeners can be removed regardless of the connection state.
1287             * @param l The <code>GlobalInfoListener</code> to remove.
1288             */
1289            public synchronized void
1290            removeGlobalInfoListener(GlobalInfoListener l) {
1291                    boolean b = llGI.remove(l);
1292                    if(b && llGI.isEmpty()) unsubscribe("GLOBAL_INFO");
1293            }
1294            
1295            /**
1296           * Gets the number of all audio output drivers currently           * Gets the number of all audio output drivers currently
1297           * available for the LinuxSampler instance.           * available for the LinuxSampler instance.
1298           * @return The number of all audio output drivers currently           * @return The number of all audio output drivers currently
# Line 677  public class Client { Line 1305  public class Client {
1305          getAudioOutputDriverCount() throws IOException, LscpException, LSException {          getAudioOutputDriverCount() throws IOException, LscpException, LSException {
1306                  verifyConnection();                  verifyConnection();
1307                  out.writeLine("GET AVAILABLE_AUDIO_OUTPUT_DRIVERS");                  out.writeLine("GET AVAILABLE_AUDIO_OUTPUT_DRIVERS");
1308                    
1309                    if(getPrintOnlyMode()) return -1;
1310                    
1311                  String s = getSingleLineResultSet().getResult();                  String s = getSingleLineResultSet().getResult();
1312                  return parseInt(s);                  return parseInt(s);
1313          }          }
# Line 694  public class Client { Line 1325  public class Client {
1325          public synchronized AudioOutputDriver[]          public synchronized AudioOutputDriver[]
1326          getAudioOutputDrivers() throws IOException, LscpException, LSException {          getAudioOutputDrivers() throws IOException, LscpException, LSException {
1327                  String[] drivers = getAudioOutputDriverNames();                  String[] drivers = getAudioOutputDriverNames();
1328                    if(getPrintOnlyMode()) return null;
1329                    
1330                  AudioOutputDriver[] aod = new AudioOutputDriver[drivers.length];                  AudioOutputDriver[] aod = new AudioOutputDriver[drivers.length];
1331                                    
1332                  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]);
# Line 715  public class Client { Line 1348  public class Client {
1348          getAudioOutputDriverNames() throws IOException, LscpException, LSException {          getAudioOutputDriverNames() throws IOException, LscpException, LSException {
1349                  verifyConnection();                  verifyConnection();
1350                  out.writeLine("LIST AVAILABLE_AUDIO_OUTPUT_DRIVERS");                  out.writeLine("LIST AVAILABLE_AUDIO_OUTPUT_DRIVERS");
1351                    if(getPrintOnlyMode()) return null;
1352                  return parseList(getSingleLineResultSet().getResult());                  return parseList(getSingleLineResultSet().getResult());
1353          }          }
1354                    
# Line 735  public class Client { Line 1369  public class Client {
1369          getAudioOutputDriverInfo(String driverName) throws IOException, LscpException, LSException {          getAudioOutputDriverInfo(String driverName) throws IOException, LscpException, LSException {
1370                  verifyConnection();                  verifyConnection();
1371                  out.writeLine("GET AUDIO_OUTPUT_DRIVER INFO " + driverName);                  out.writeLine("GET AUDIO_OUTPUT_DRIVER INFO " + driverName);
1372                    if(getPrintOnlyMode()) return null;
1373                    
1374                  ResultSet rs = getMultiLineResultSet();                  ResultSet rs = getMultiLineResultSet();
1375                  AudioOutputDriver aod = new AudioOutputDriver(rs.getMultiLineResult());                  AudioOutputDriver aod = new AudioOutputDriver(rs.getMultiLineResult());
1376                  aod.setName(driverName);                  aod.setName(driverName);
# Line 778  public class Client { Line 1414  public class Client {
1414                          args.append(' ').append(p.getName()).append('=').append(p.getStringValue());                          args.append(' ').append(p.getName()).append('=').append(p.getStringValue());
1415                                    
1416                  out.writeLine("GET AUDIO_OUTPUT_DRIVER_PARAMETER INFO " + args.toString());                  out.writeLine("GET AUDIO_OUTPUT_DRIVER_PARAMETER INFO " + args.toString());
1417                    if(getPrintOnlyMode()) return null;
1418                                    
1419                  ResultSet rs = getMultiLineResultSet();                  ResultSet rs = getMultiLineResultSet();
1420                                    
# Line 839  public class Client { Line 1476  public class Client {
1476                          args.append(' ').append(p.getName()).append('=').append(p.getStringValue());                          args.append(' ').append(p.getName()).append('=').append(p.getStringValue());
1477                                    
1478                  out.writeLine("CREATE AUDIO_OUTPUT_DEVICE " + args.toString());                  out.writeLine("CREATE AUDIO_OUTPUT_DEVICE " + args.toString());
1479                    if(getPrintOnlyMode()) return -1;
1480                    
1481                  ResultSet rs = getEmptyResultSet();                  ResultSet rs = getEmptyResultSet();
1482                                    
1483                  return rs.getIndex();                  return rs.getIndex();
# Line 846  public class Client { Line 1485  public class Client {
1485                    
1486          /**          /**
1487           * Destroys already created audio output device.           * Destroys already created audio output device.
1488           * @param deviceID The ID of the audio output device to be destroyed.           * @param deviceId The ID of the audio output device to be destroyed.
1489           * @throws IOException If some I/O error occurs.           * @throws IOException If some I/O error occurs.
1490           * @throws LSException If the destroying of the audio output device failed.           * @throws LSException If the destroying of the audio output device failed.
1491           * @throws LscpException If LSCP protocol corruption occurs.           * @throws LscpException If LSCP protocol corruption occurs.
1492           * @see #getAudioOutputDevices           * @see #getAudioOutputDevices
1493           */           */
1494          public synchronized void          public synchronized void
1495          destroyAudioOutputDevice(int deviceID) throws IOException, LSException, LscpException {          destroyAudioOutputDevice(int deviceId) throws IOException, LSException, LscpException {
1496                  verifyConnection();                  verifyConnection();
1497                  out.writeLine("DESTROY AUDIO_OUTPUT_DEVICE " + deviceID);                  out.writeLine("DESTROY AUDIO_OUTPUT_DEVICE " + deviceId);
1498                    if(getPrintOnlyMode()) return;
1499                    
1500                  ResultSet rs = getEmptyResultSet();                  ResultSet rs = getEmptyResultSet();
1501          }          }
1502                    
1503          /**          /**
1504           * Enables/disables the specified audio output device.           * Enables/disables the specified audio output device.
1505           * @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.
1506           * @param enable If <code>true</code> the audio output device is enabled,           * @param enable If <code>true</code> the audio output device is enabled,
1507           * else the device is disabled.           * else the device is disabled.
1508           * @throws IOException If some I/O error occurs.           * @throws IOException If some I/O error occurs.
1509           * @throws LSException If there is no audio output           * @throws LSException If there is no audio output
1510           * device with numerical ID <code>deviceID</code>.           * device with numerical ID <code>deviceId</code>.
1511           * @throws LscpException If LSCP protocol corruption occurs.           * @throws LscpException If LSCP protocol corruption occurs.
1512           */           */
1513          public void          public void
1514          enableAudioOutputDevice(int deviceID, boolean enable)          enableAudioOutputDevice(int deviceId, boolean enable)
1515                                  throws IOException, LSException, LscpException {                                  throws IOException, LSException, LscpException {
1516                                    
1517                  setAudioOutputDeviceParameter(deviceID, new BoolParameter("ACTIVE", enable));                  setAudioOutputDeviceParameter(deviceId, new BoolParameter("ACTIVE", enable));
1518          }          }
1519                    
1520          /**          /**
# Line 887  public class Client { Line 1528  public class Client {
1528          getAudioOutputDeviceCount() throws IOException, LscpException, LSException {          getAudioOutputDeviceCount() throws IOException, LscpException, LSException {
1529                  verifyConnection();                  verifyConnection();
1530                  out.writeLine("GET AUDIO_OUTPUT_DEVICES");                  out.writeLine("GET AUDIO_OUTPUT_DEVICES");
1531                    if(getPrintOnlyMode()) return -1;
1532                    
1533                  String s = getSingleLineResultSet().getResult();                  String s = getSingleLineResultSet().getResult();
1534                  return parseInt(s);                  return parseInt(s);
1535          }          }
# Line 902  public class Client { Line 1545  public class Client {
1545          public synchronized AudioOutputDevice[]          public synchronized AudioOutputDevice[]
1546          getAudioOutputDevices() throws IOException, LscpException, LSException {          getAudioOutputDevices() throws IOException, LscpException, LSException {
1547                  Integer[] idS = getAudioOutputDeviceIDs();                  Integer[] idS = getAudioOutputDeviceIDs();
1548                    if(getPrintOnlyMode()) return null;
1549                    
1550                  AudioOutputDevice[] devices = new AudioOutputDevice[idS.length];                  AudioOutputDevice[] devices = new AudioOutputDevice[idS.length];
1551                                    
1552                  for(int i = 0; i < devices.length; i++)                  for(int i = 0; i < devices.length; i++)
# Line 922  public class Client { Line 1567  public class Client {
1567          getAudioOutputDeviceIDs() throws IOException, LscpException, LSException {          getAudioOutputDeviceIDs() throws IOException, LscpException, LSException {
1568                  verifyConnection();                  verifyConnection();
1569                  out.writeLine("LIST AUDIO_OUTPUT_DEVICES");                  out.writeLine("LIST AUDIO_OUTPUT_DEVICES");
1570                    if(getPrintOnlyMode()) return null;
1571                    
1572                  return parseIntList(getSingleLineResultSet().getResult());                  return parseIntList(getSingleLineResultSet().getResult());
1573          }          }
1574                    
1575          /**          /**
1576           * Gets the current settings of a specific, already created audio output device.           * Gets the current settings of a specific, already created audio output device.
1577           *           *
1578           * @param deviceID Specifies the numerical ID of the audio output device.           * @param deviceId Specifies the numerical ID of the audio output device.
1579           *           *
1580           * @return An <code>AudioOutputDevice</code> instance containing information           * @return An <code>AudioOutputDevice</code> instance containing information
1581           * about the specified device.           * about the specified device.
# Line 936  public class Client { Line 1583  public class Client {
1583           * @throws IOException If some I/O error occurs.           * @throws IOException If some I/O error occurs.
1584           * @throws LscpException If LSCP protocol corruption occurs.           * @throws LscpException If LSCP protocol corruption occurs.
1585           * @throws LSException If there is no audio output device           * @throws LSException If there is no audio output device
1586           * with device id <code>deviceID</code>.           * with device id <code>deviceId</code>.
1587           *           *
1588           * @see #getAudioOutputDevices           * @see #getAudioOutputDevices
1589           */           */
1590          public synchronized AudioOutputDevice          public synchronized AudioOutputDevice
1591          getAudioOutputDeviceInfo(int deviceID) throws IOException, LscpException, LSException {          getAudioOutputDeviceInfo(int deviceId) throws IOException, LscpException, LSException {
1592                  verifyConnection();                  verifyConnection();
1593                  out.writeLine("GET AUDIO_OUTPUT_DEVICE INFO " + deviceID);                  out.writeLine("GET AUDIO_OUTPUT_DEVICE INFO " + deviceId);
1594                    if(getPrintOnlyMode()) return null;
1595                                    
1596                  ResultSet rs = getMultiLineResultSet();                  ResultSet rs = getMultiLineResultSet();
1597                                    
1598                  String[] lnS = rs.getMultiLineResult();                  String[] lnS = rs.getMultiLineResult();
1599                                    
1600                  AudioOutputDevice aod = new AudioOutputDevice();                  AudioOutputDevice aod = new AudioOutputDevice();
1601                  aod.setDeviceID(deviceID);                  aod.setDeviceId(deviceId);
1602                  Parameter<Integer> channels;                  Parameter<Integer> channels;
1603                  Parameter<Integer> samplerate;                  Parameter<Integer> samplerate;
1604                                    
# Line 968  public class Client { Line 1616  public class Client {
1616                                  int count = channels.getValue() > 0 ? channels.getValue() : 0;                                  int count = channels.getValue() > 0 ? channels.getValue() : 0;
1617                                  AudioOutputChannel[] aoc = new AudioOutputChannel[count];                                  AudioOutputChannel[] aoc = new AudioOutputChannel[count];
1618                                  for(int i = 0; i < count; i++) {                                  for(int i = 0; i < count; i++) {
1619                                          aoc[i] = this.getAudioOutputChannelInfo(deviceID, i);                                          aoc[i] = getAudioOutputChannelInfo(deviceId, i);
1620                                  }                                  }
1621                                  aod.setAudioChannels(aoc);                                  aod.setAudioChannels(aoc);
1622                          } else if(s.startsWith("SAMPLERATE: ")) {                          } else if(s.startsWith("SAMPLERATE: ")) {
# Line 1005  public class Client { Line 1653  public class Client {
1653          /**          /**
1654           * Alters a specific setting of a created audio output device.           * Alters a specific setting of a created audio output device.
1655           *           *
1656           * @param deviceID The numerical ID of the audio output device.           * @param deviceId The numerical ID of the audio output device.
1657           * @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
1658           * and the new value for this parameter.           * and the new value for this parameter.
1659           *           *
# Line 1013  public class Client { Line 1661  public class Client {
1661           * @throws LscpException If LSCP protocol corruption occurs.           * @throws LscpException If LSCP protocol corruption occurs.
1662           * @throws LSException If           * @throws LSException If
1663           * <ul>           * <ul>
1664           * <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>;
1665           * <li>There is no device parameter with the specified name;           * <li>There is no device parameter with the specified name;
1666           * <li>The device parameter is readonly;           * <li>The device parameter is readonly;
1667           * <li>The device parameter is from different type.           * <li>The device parameter is from different type.
# Line 1023  public class Client { Line 1671  public class Client {
1671           * @see #getAudioOutputDeviceInfo           * @see #getAudioOutputDeviceInfo
1672           */           */
1673          public synchronized void          public synchronized void
1674          setAudioOutputDeviceParameter(int deviceID, Parameter prm)          setAudioOutputDeviceParameter(int deviceId, Parameter prm)
1675                                                  throws IOException, LscpException, LSException {                                                  throws IOException, LscpException, LSException {
1676                                    
1677                  verifyConnection();                  verifyConnection();
1678                  String kv = prm.getName() + '=' + prm.getStringValue();                  String kv = prm.getName() + '=' + prm.getStringValue();
1679                  out.writeLine("SET AUDIO_OUTPUT_DEVICE_PARAMETER " + deviceID + ' ' + kv);                  out.writeLine("SET AUDIO_OUTPUT_DEVICE_PARAMETER " + deviceId + ' ' + kv);
1680                    if(getPrintOnlyMode()) return;
1681                                    
1682                  ResultSet rs = getEmptyResultSet();                  ResultSet rs = getEmptyResultSet();
1683          }          }
1684                    
1685          /**          /**
1686           * Changes the channels number of the speicifed audio output device.           * Changes the channel number of the speicifed audio output device.
1687           * @param deviceID The numerical ID of the audio output device.           * @param deviceId The numerical ID of the audio output device.
1688           * @param channels The new number of audio output channels.           * @param channels The new number of audio output channels.
1689           *           *
1690           * @throws IOException If an I/O error occurs.           * @throws IOException If an I/O error occurs.
1691           * @throws LscpException If LSCP protocol corruption occurs.           * @throws LscpException If LSCP protocol corruption occurs.
1692           * @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
1693           * if <code>channels</code> number is out of range.           * if <code>channels</code> number is out of range.
1694           *           *
1695           * @see #getAudioOutputChannelInfo           * @see #getAudioOutputChannelInfo
1696           */           */
1697          public synchronized void          public synchronized void
1698          setAudioOutputChannelCount(int deviceID, int channels)          setAudioOutputChannelCount(int deviceId, int channels)
1699                                          throws IOException, LscpException, LSException {                                          throws IOException, LscpException, LSException {
1700                                    
1701                  setAudioOutputDeviceParameter(deviceID, new IntParameter("CHANNELS", channels));                  setAudioOutputDeviceParameter(deviceId, new IntParameter("CHANNELS", channels));
1702          }          }
1703                    
1704          /**          /**
1705           * Gets information about an audio channel.           * Gets information about an audio channel.
1706           *           *
1707           * @param deviceID The numerical ID of the audio output device.           * @param deviceId The numerical ID of the audio output device.
1708           * @param audioChn The audio channel number.           * @param audioChn The audio channel number.
1709           *           *
1710           * @return An <code>AudioOutputChannel</code> instance containing the           * @return An <code>AudioOutputChannel</code> instance containing the
# Line 1065  public class Client { Line 1714  public class Client {
1714           * @throws LscpException If LSCP protocol corruption occurs.           * @throws LscpException If LSCP protocol corruption occurs.
1715           * @throws LSException If           * @throws LSException If
1716           * <ul>           * <ul>
1717           * <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>;
1718           * <li><code>audioChn</code> is not a valid channel number;           * <li><code>audioChn</code> is not a valid channel number;
1719           * </ul>           * </ul>
1720           *           *
# Line 1073  public class Client { Line 1722  public class Client {
1722           * @see #getAudioOutputDeviceInfo           * @see #getAudioOutputDeviceInfo
1723           */           */
1724          public synchronized AudioOutputChannel          public synchronized AudioOutputChannel
1725          getAudioOutputChannelInfo(int deviceID, int audioChn)          getAudioOutputChannelInfo(int deviceId, int audioChn)
1726                                                  throws IOException, LscpException, LSException {                                                  throws IOException, LscpException, LSException {
1727                                    
1728                  verifyConnection();                  verifyConnection();
1729                  out.writeLine("GET AUDIO_OUTPUT_CHANNEL INFO " + deviceID + ' ' + audioChn);                  out.writeLine("GET AUDIO_OUTPUT_CHANNEL INFO " + deviceId + ' ' + audioChn);
1730                    if(getPrintOnlyMode()) return null;
1731                                    
1732                  ResultSet rs = getMultiLineResultSet();                  ResultSet rs = getMultiLineResultSet();
1733                                    
# Line 1088  public class Client { Line 1738  public class Client {
1738                          if(s.startsWith("NAME: ")) {                          if(s.startsWith("NAME: ")) {
1739                                  s = s.substring("NAME: ".length());                                  s = s.substring("NAME: ".length());
1740                                  Parameter<String> prm = getAudioOutputChannelParameterInfo (                                  Parameter<String> prm = getAudioOutputChannelParameterInfo (
1741                                          deviceID, audioChn, "NAME"                                          deviceId, audioChn, "NAME"
1742                                  );                                  );
1743                                  prm.setValue(removeQuotation(s));                                  prm.setValue(removeQuotation(s));
1744                                  aoc.setNameParameter(prm);                                  aoc.setNameParameter(prm);
1745                          } else if(s.startsWith("IS_MIX_CHANNEL: ")) {                          } else if(s.startsWith("IS_MIX_CHANNEL: ")) {
1746                                  s = s.substring("IS_MIX_CHANNEL: ".length());                                  s = s.substring("IS_MIX_CHANNEL: ".length());
1747                                  Parameter<Boolean> prm = getAudioOutputChannelParameterInfo (                                  Parameter<Boolean> prm = getAudioOutputChannelParameterInfo (
1748                                          deviceID, audioChn, "IS_MIX_CHANNEL"                                          deviceId, audioChn, "IS_MIX_CHANNEL"
1749                                  );                                  );
1750                                  prm.setValue(Boolean.parseBoolean(s));                                  prm.setValue(Boolean.parseBoolean(s));
1751                                  aoc.setMixChannelParameter(prm);                                  aoc.setMixChannelParameter(prm);
1752                          } else if(s.startsWith("MIX_CHANNEL_DESTINATION: ")) {                          } else if(s.startsWith("MIX_CHANNEL_DESTINATION: ")) {
1753                                  s = s.substring("MIX_CHANNEL_DESTINATION: ".length());                                  s = s.substring("MIX_CHANNEL_DESTINATION: ".length());
1754                                  Parameter<Integer> prm = getAudioOutputChannelParameterInfo (                                  Parameter<Integer> prm = getAudioOutputChannelParameterInfo (
1755                                          deviceID, audioChn, "MIX_CHANNEL_DESTINATION"                                          deviceId, audioChn, "MIX_CHANNEL_DESTINATION"
1756                                  );                                  );
1757                                  prm.setValue(parseInt(s));                                  prm.setValue(parseInt(s));
1758                                  aoc.setMixChannelDestParameter(prm);                                  aoc.setMixChannelDestParameter(prm);
# Line 1113  public class Client { Line 1763  public class Client {
1763                                  );                                  );
1764                                                                    
1765                                  Parameter prm = getAudioOutputChannelParameterInfo (                                  Parameter prm = getAudioOutputChannelParameterInfo (
1766                                          deviceID, audioChn, s.substring(0, i)                                          deviceId, audioChn, s.substring(0, i)
1767                                  );                                  );
1768                                                                    
1769                                  s = s.substring(i + 2);                                  s = s.substring(i + 2);
# Line 1129  public class Client { Line 1779  public class Client {
1779          /**          /**
1780           * Gets detailed information about a specific audio output channel parameter.           * Gets detailed information about a specific audio output channel parameter.
1781           *           *
1782           * @param devID The numerical ID of the audio output device.           * @param devId The numerical ID of the audio output device.
1783           * @param chan The audio channel number.           * @param chan The audio channel number.
1784           * @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.
1785           *           *
# Line 1140  public class Client { Line 1790  public class Client {
1790           * @throws LscpException If LSCP protocol corruption occurs.           * @throws LscpException If LSCP protocol corruption occurs.
1791           * @throws LSException If           * @throws LSException If
1792           * <ul>           * <ul>
1793           * <li><code>devID</code> is not a valid device ID;           * <li><code>devId</code> is not a valid device ID;
1794           * <li><code>chan</code> is not a valid channel number;           * <li><code>chan</code> is not a valid channel number;
1795           * <li>There is no channel parameter with the specified name.           * <li>There is no channel parameter with the specified name.
1796           * </ul>           * </ul>
# Line 1149  public class Client { Line 1799  public class Client {
1799           * @see #getAudioOutputChannelInfo           * @see #getAudioOutputChannelInfo
1800           */           */
1801          public synchronized Parameter          public synchronized Parameter
1802          getAudioOutputChannelParameterInfo(int devID, int chan, String param)          getAudioOutputChannelParameterInfo(int devId, int chan, String param)
1803                                                  throws IOException, LscpException, LSException {                                                  throws IOException, LscpException, LSException {
1804                                    
1805                  verifyConnection();                  verifyConnection();
1806                  String args = devID + " " + chan + " " + param;                  String args = devId + " " + chan + " " + param;
1807                  out.writeLine("GET AUDIO_OUTPUT_CHANNEL_PARAMETER INFO " + args);                  out.writeLine("GET AUDIO_OUTPUT_CHANNEL_PARAMETER INFO " + args);
1808                    if(getPrintOnlyMode()) return null;
1809                                    
1810                  ResultSet rs = getMultiLineResultSet();                  ResultSet rs = getMultiLineResultSet();
1811                                    
# Line 1191  public class Client { Line 1842  public class Client {
1842          /**          /**
1843           * Alters a specific setting of an audio output channel.           * Alters a specific setting of an audio output channel.
1844           *           *
1845           * @param devID The numerical ID of the audio device.           * @param devId The numerical ID of the audio device.
1846           * @param chn The audio channel number.           * @param chn The audio channel number.
1847           * @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
1848           * and the new value for this parameter.           * and the new value for this parameter.
# Line 1200  public class Client { Line 1851  public class Client {
1851           * @throws LscpException If LSCP protocol corruption occurs.           * @throws LscpException If LSCP protocol corruption occurs.
1852           * @throws LSException If           * @throws LSException If
1853           * <ul>           * <ul>
1854           * <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>;
1855           * <li><code>chn</code> is not a valid channel number;           * <li><code>chn</code> is not a valid channel number;
1856           * <li>There is no channel parameter with the specified name;           * <li>There is no channel parameter with the specified name;
1857           * <li>The channel parameter is readonly;           * <li>The channel parameter is readonly;
# Line 1211  public class Client { Line 1862  public class Client {
1862           * @see #getAudioOutputChannelInfo           * @see #getAudioOutputChannelInfo
1863           */           */
1864          public synchronized void          public synchronized void
1865          setAudioOutputChannelParameter(int devID, int chn,  Parameter prm)          setAudioOutputChannelParameter(int devId, int chn,  Parameter prm)
1866                                                  throws IOException, LscpException, LSException {                                                  throws IOException, LscpException, LSException {
1867                                    
1868                  verifyConnection();                  verifyConnection();
1869                  String args = devID + " " + chn + " " + prm.getName() + '=' + prm.getStringValue();                  String args = devId + " " + chn + " " + prm.getName() + '=' + prm.getStringValue();
1870                  out.writeLine("SET AUDIO_OUTPUT_CHANNEL_PARAMETER " + args);                  out.writeLine("SET AUDIO_OUTPUT_CHANNEL_PARAMETER " + args);
1871                    if(getPrintOnlyMode()) return;
1872                                    
1873                  ResultSet rs = getEmptyResultSet();                  ResultSet rs = getEmptyResultSet();
1874          }          }
# Line 1232  public class Client { Line 1884  public class Client {
1884          getMidiInputDriverCount() throws IOException, LscpException, LSException {          getMidiInputDriverCount() throws IOException, LscpException, LSException {
1885                  verifyConnection();                  verifyConnection();
1886                  out.writeLine("GET AVAILABLE_MIDI_INPUT_DRIVERS");                  out.writeLine("GET AVAILABLE_MIDI_INPUT_DRIVERS");
1887                    if(getPrintOnlyMode()) return -1;
1888                    
1889                  String s = getSingleLineResultSet().getResult();                  String s = getSingleLineResultSet().getResult();
1890                  return parseInt(s);                  return parseInt(s);
1891          }          }
# Line 1249  public class Client { Line 1903  public class Client {
1903          public synchronized MidiInputDriver[]          public synchronized MidiInputDriver[]
1904          getMidiInputDrivers() throws IOException, LscpException, LSException {          getMidiInputDrivers() throws IOException, LscpException, LSException {
1905                  String[] drivers = getMidiInputDriverNames();                  String[] drivers = getMidiInputDriverNames();
1906                    if(getPrintOnlyMode()) return null;
1907                    
1908                  MidiInputDriver[] mid = new MidiInputDriver[drivers.length];                  MidiInputDriver[] mid = new MidiInputDriver[drivers.length];
1909                                    
1910                  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]);
# Line 1270  public class Client { Line 1926  public class Client {
1926          getMidiInputDriverNames() throws IOException, LscpException, LSException {          getMidiInputDriverNames() throws IOException, LscpException, LSException {
1927                  verifyConnection();                  verifyConnection();
1928                  out.writeLine("LIST AVAILABLE_MIDI_INPUT_DRIVERS");                  out.writeLine("LIST AVAILABLE_MIDI_INPUT_DRIVERS");
1929                    if(getPrintOnlyMode()) return null;
1930                    
1931                  return parseList(getSingleLineResultSet().getResult());                  return parseList(getSingleLineResultSet().getResult());
1932          }          }
1933                    
# Line 1290  public class Client { Line 1948  public class Client {
1948          getMidiInputDriverInfo(String driverName) throws IOException, LscpException, LSException {          getMidiInputDriverInfo(String driverName) throws IOException, LscpException, LSException {
1949                  verifyConnection();                  verifyConnection();
1950                  out.writeLine("GET MIDI_INPUT_DRIVER INFO " + driverName);                  out.writeLine("GET MIDI_INPUT_DRIVER INFO " + driverName);
1951                    if(getPrintOnlyMode()) return null;
1952                    
1953                  ResultSet rs = getMultiLineResultSet();                  ResultSet rs = getMultiLineResultSet();
1954                                    
1955                  MidiInputDriver mid = new MidiInputDriver(rs.getMultiLineResult());                  MidiInputDriver mid = new MidiInputDriver(rs.getMultiLineResult());
# Line 1334  public class Client { Line 1994  public class Client {
1994                          args.append(' ').append(p.getName()).append('=').append(p.getStringValue());                          args.append(' ').append(p.getName()).append('=').append(p.getStringValue());
1995                                    
1996                  out.writeLine("GET MIDI_INPUT_DRIVER_PARAMETER INFO " + args.toString());                  out.writeLine("GET MIDI_INPUT_DRIVER_PARAMETER INFO " + args.toString());
1997                    if(getPrintOnlyMode()) return null;
1998                                    
1999                  ResultSet rs = getMultiLineResultSet();                  ResultSet rs = getMultiLineResultSet();
2000                                    
# Line 1396  public class Client { Line 2057  public class Client {
2057                          args.append(' ').append(p.getName()).append('=').append(p.getStringValue());                          args.append(' ').append(p.getName()).append('=').append(p.getStringValue());
2058                                    
2059                  out.writeLine("CREATE MIDI_INPUT_DEVICE " + args.toString());                  out.writeLine("CREATE MIDI_INPUT_DEVICE " + args.toString());
2060                    if(getPrintOnlyMode()) return -1;
2061                    
2062                  ResultSet rs = getEmptyResultSet();                  ResultSet rs = getEmptyResultSet();
2063                                    
2064                  return rs.getIndex();                  return rs.getIndex();
# Line 1403  public class Client { Line 2066  public class Client {
2066                    
2067          /**          /**
2068           * Destroys already created MIDI input device.           * Destroys already created MIDI input device.
2069           * @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.
2070           * @throws IOException If some I/O error occurs.           * @throws IOException If some I/O error occurs.
2071           * @throws LSException If the destroying of the MIDI input device failed.           * @throws LSException If the destroying of the MIDI input device failed.
2072           * @throws LscpException If LSCP protocol corruption occurs.           * @throws LscpException If LSCP protocol corruption occurs.
# Line 1411  public class Client { Line 2074  public class Client {
2074           * @see #getMidiInputDevices           * @see #getMidiInputDevices
2075           */           */
2076          public synchronized void          public synchronized void
2077          destroyMidiInputDevice(int deviceID) throws IOException, LSException, LscpException {          destroyMidiInputDevice(int deviceId) throws IOException, LSException, LscpException {
2078                  verifyConnection();                  verifyConnection();
2079                  out.writeLine("DESTROY MIDI_INPUT_DEVICE " + deviceID);                  out.writeLine("DESTROY MIDI_INPUT_DEVICE " + deviceId);
2080                    if(getPrintOnlyMode()) return;
2081                    
2082                  ResultSet rs = getEmptyResultSet();                  ResultSet rs = getEmptyResultSet();
2083          }          }
2084                    
2085          /**          /**
2086           * Enables/disables the specified MIDI input device.           * Enables/disables the specified MIDI input device.
2087           * @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.
2088           * @param enable If <code>true</code> the MIDI input device is enabled,           * @param enable If <code>true</code> the MIDI input device is enabled,
2089           * else the device is disabled.           * else the device is disabled.
2090           * @throws IOException If some I/O error occurs.           * @throws IOException If some I/O error occurs.
2091           * @throws LSException If there is no MIDI input           * @throws LSException If there is no MIDI input
2092           * device with numerical ID <code>deviceID</code>.           * device with numerical ID <code>deviceId</code>.
2093           * @throws LscpException If LSCP protocol corruption occurs.           * @throws LscpException If LSCP protocol corruption occurs.
2094           */           */
2095          public void          public void
2096          enableMidiInputDevice(int deviceID, boolean enable)          enableMidiInputDevice(int deviceId, boolean enable)
2097                                  throws IOException, LSException, LscpException {                                  throws IOException, LSException, LscpException {
2098                                    
2099                  setMidiInputDeviceParameter(deviceID, new BoolParameter("ACTIVE", enable));                  setMidiInputDeviceParameter(deviceId, new BoolParameter("ACTIVE", enable));
2100          }          }
2101                    
2102          /**          /**
# Line 1445  public class Client { Line 2110  public class Client {
2110          getMidiInputDeviceCount() throws IOException, LscpException, LSException {          getMidiInputDeviceCount() throws IOException, LscpException, LSException {
2111                  verifyConnection();                  verifyConnection();
2112                  out.writeLine("GET MIDI_INPUT_DEVICES");                  out.writeLine("GET MIDI_INPUT_DEVICES");
2113                    if(getPrintOnlyMode()) return -1;
2114                    
2115                  String s = getSingleLineResultSet().getResult();                  String s = getSingleLineResultSet().getResult();
2116                  return parseInt(s);                  return parseInt(s);
2117          }          }
# Line 1463  public class Client { Line 2130  public class Client {
2130          public synchronized MidiInputDevice[]          public synchronized MidiInputDevice[]
2131          getMidiInputDevices() throws IOException, LscpException, LSException {          getMidiInputDevices() throws IOException, LscpException, LSException {
2132                  Integer[] idS = getMidiInputDeviceIDs();                  Integer[] idS = getMidiInputDeviceIDs();
2133                    if(getPrintOnlyMode()) return null;
2134                    
2135                  MidiInputDevice[] devices = new MidiInputDevice[idS.length];                  MidiInputDevice[] devices = new MidiInputDevice[idS.length];
2136                                    
2137                  for(int i = 0; i < devices.length; i++)                  for(int i = 0; i < devices.length; i++)
# Line 1486  public class Client { Line 2155  public class Client {
2155          getMidiInputDeviceIDs() throws IOException, LscpException, LSException {          getMidiInputDeviceIDs() throws IOException, LscpException, LSException {
2156                  verifyConnection();                  verifyConnection();
2157                  out.writeLine("LIST MIDI_INPUT_DEVICES");                  out.writeLine("LIST MIDI_INPUT_DEVICES");
2158                    if(getPrintOnlyMode()) return null;
2159                    
2160                  return parseIntList(getSingleLineResultSet().getResult());                  return parseIntList(getSingleLineResultSet().getResult());
2161          }          }
2162                    
2163          /**          /**
2164           * Gets the current settings of a specific, already created MIDI input device.           * Gets the current settings of a specific, already created MIDI input device.
2165           *           *
2166           * @param deviceID Specifies the numerical ID of the MIDI input device.           * @param deviceId Specifies the numerical ID of the MIDI input device.
2167           *           *
2168           * @return An <code>MidiInputDevice</code> instance containing information           * @return A <code>MidiInputDevice</code> instance containing information
2169           * about the specified device.           * about the specified device.
2170           *           *
2171           * @throws IOException If some I/O error occurs.           * @throws IOException If some I/O error occurs.
2172           * @throws LscpException If LSCP protocol corruption occurs.           * @throws LscpException If LSCP protocol corruption occurs.
2173           * @throws LSException If there is no MIDI input device           * @throws LSException If there is no MIDI input device
2174           * with device id <code>deviceID</code>.           * with device id <code>deviceId</code>.
2175           *           *
2176           * @see #getMidiInputDevices           * @see #getMidiInputDevices
2177           */           */
2178          public synchronized MidiInputDevice          public synchronized MidiInputDevice
2179          getMidiInputDeviceInfo(int deviceID) throws IOException, LscpException, LSException {          getMidiInputDeviceInfo(int deviceId) throws IOException, LscpException, LSException {
2180                  verifyConnection();                  verifyConnection();
2181                  out.writeLine("GET MIDI_INPUT_DEVICE INFO " + deviceID);                  out.writeLine("GET MIDI_INPUT_DEVICE INFO " + deviceId);
2182                    if(getPrintOnlyMode()) return null;
2183                                    
2184                  ResultSet rs = getMultiLineResultSet();                  ResultSet rs = getMultiLineResultSet();
2185                                    
2186                  String[] lnS = rs.getMultiLineResult();                  String[] lnS = rs.getMultiLineResult();
2187                                    
2188                  MidiInputDevice mid = new MidiInputDevice();                  MidiInputDevice mid = new MidiInputDevice();
2189                  mid.setDeviceID(deviceID);                  mid.setDeviceId(deviceId);
2190                                    
2191                  String drv = getCategoryInfo(lnS, "DRIVER");                  String drv = getCategoryInfo(lnS, "DRIVER");
2192                  mid.setDriverName(drv);                  mid.setDriverName(drv);
# Line 1531  public class Client { Line 2203  public class Client {
2203                                  MidiPort[] midiPorts = new MidiPort[ports > 0 ? ports : 0];                                  MidiPort[] midiPorts = new MidiPort[ports > 0 ? ports : 0];
2204                                                                    
2205                                  for(int i = 0; i < midiPorts.length; i++)                                  for(int i = 0; i < midiPorts.length; i++)
2206                                          midiPorts[i] = getMidiInputPortInfo(deviceID, i);                                          midiPorts[i] = getMidiInputPortInfo(deviceId, i);
2207                                                                    
2208                                  mid.setMidiPorts(midiPorts);                                  mid.setMidiPorts(midiPorts);
2209                          } else {                          } else {
# Line 1556  public class Client { Line 2228  public class Client {
2228          /**          /**
2229           * Alters a specific setting of a created MIDI input device.           * Alters a specific setting of a created MIDI input device.
2230           *           *
2231           * @param deviceID The numerical ID of the MIDI input device.           * @param deviceId The numerical ID of the MIDI input device.
2232           * @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
2233           * and the new value for this parameter.           * and the new value for this parameter.
2234           *           *
# Line 1564  public class Client { Line 2236  public class Client {
2236           * @throws LscpException If LSCP protocol corruption occurs.           * @throws LscpException If LSCP protocol corruption occurs.
2237           * @throws LSException If           * @throws LSException If
2238           * <ul>           * <ul>
2239           * <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>;
2240           * <li>There is no device parameter with the specified name;           * <li>There is no device parameter with the specified name;
2241           * <li>The device parameter is readonly;           * <li>The device parameter is readonly;
2242           * <li>The device parameter is from different type.           * <li>The device parameter is from different type.
# Line 1574  public class Client { Line 2246  public class Client {
2246           * @see #getMidiInputDeviceInfo           * @see #getMidiInputDeviceInfo
2247           */           */
2248          public synchronized void          public synchronized void
2249          setMidiInputDeviceParameter(int deviceID, Parameter prm)          setMidiInputDeviceParameter(int deviceId, Parameter prm)
2250                                                  throws IOException, LscpException, LSException {                                                  throws IOException, LscpException, LSException {
2251                                    
2252                  verifyConnection();                  verifyConnection();
2253                  String kv = prm.getName() + '=' + prm.getStringValue();                  String kv = prm.getName() + '=' + prm.getStringValue();
2254                  out.writeLine("SET MIDI_INPUT_DEVICE_PARAMETER " + deviceID + ' ' + kv);                  out.writeLine("SET MIDI_INPUT_DEVICE_PARAMETER " + deviceId + ' ' + kv);
2255                    if(getPrintOnlyMode()) return;
2256                                    
2257                  ResultSet rs = getEmptyResultSet();                  ResultSet rs = getEmptyResultSet();
2258          }          }
2259                    
2260                    
2261          /**          /**
2262           * Changes the ports number of the speicifed MIDI input device.           * Changes the port number of the speicified MIDI input device.
2263           * @param deviceID The numerical ID of the MIDI input device.           * @param deviceId The numerical ID of the MIDI input device.
2264           * @param ports The new number of MIDI input ports.           * @param ports The new number of MIDI input ports.
2265           *           *
2266           * @throws IOException If an I/O error occurs.           * @throws IOException If an I/O error occurs.
2267           * @throws LscpException If LSCP protocol corruption occurs.           * @throws LscpException If LSCP protocol corruption occurs.
2268           * @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
2269           * if <code>ports</code> number is out of range.           * if <code>ports</code> number is out of range.
2270           *           *
2271           * @see #getMidiInputPortInfo           * @see #getMidiInputPortInfo
2272           */           */
2273          public synchronized void          public synchronized void
2274          setMidiInputPortCount(int deviceID, int ports)          setMidiInputPortCount(int deviceId, int ports)
2275                                          throws IOException, LscpException, LSException {                                          throws IOException, LscpException, LSException {
2276                                    
2277                  setMidiInputDeviceParameter(deviceID, new IntParameter("PORTS", ports));                  setMidiInputDeviceParameter(deviceId, new IntParameter("PORTS", ports));
2278          }          }
2279                    
2280          /**          /**
2281           * Gets detailed information about a specific MIDI input port.           * Gets detailed information about a specific MIDI input port.
2282           * @param deviceID The numerical ID of the MIDI input device.           * @param deviceId The numerical ID of the MIDI input device.
2283           * @param midiPort The MIDI input port number.           * @param midiPort The MIDI input port number.
2284           *           *
2285           * @return A <code>MidiPort</code> instance containing           * @return A <code>MidiPort</code> instance containing
# Line 1614  public class Client { Line 2287  public class Client {
2287           *           *
2288           * @throws IOException If an I/O error occurs.           * @throws IOException If an I/O error occurs.
2289           * @throws LscpException If LSCP protocol corruption occurs.           * @throws LscpException If LSCP protocol corruption occurs.
2290           * @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
2291           * if <code>midiPort</code> is not a valid MIDI port number.           * if <code>midiPort</code> is not a valid MIDI port number.
2292           *           *
2293           * @see #getMidiInputDevices           * @see #getMidiInputDevices
2294           */           */
2295          public synchronized MidiPort          public synchronized MidiPort
2296          getMidiInputPortInfo(int deviceID, int midiPort)          getMidiInputPortInfo(int deviceId, int midiPort)
2297                                          throws IOException, LscpException, LSException {                                          throws IOException, LscpException, LSException {
2298                                    
2299                  verifyConnection();                  verifyConnection();
2300                  out.writeLine("GET MIDI_INPUT_PORT INFO " + deviceID + " " + midiPort);                  out.writeLine("GET MIDI_INPUT_PORT INFO " + deviceId + " " + midiPort);
2301                    if(getPrintOnlyMode()) return null;
2302                    
2303                  ResultSet rs = getMultiLineResultSet();                  ResultSet rs = getMultiLineResultSet();
2304                                    
2305                  MidiPort mp = new MidiPort();                  MidiPort mp = new MidiPort();
# Line 1634  public class Client { Line 2309  public class Client {
2309                          if(s.startsWith("NAME: ")) {                          if(s.startsWith("NAME: ")) {
2310                                  s = s.substring("NAME: ".length());                                  s = s.substring("NAME: ".length());
2311                                  Parameter prm = getMidiInputPortParameterInfo (                                  Parameter prm = getMidiInputPortParameterInfo (
2312                                          deviceID, midiPort, "NAME"                                          deviceId, midiPort, "NAME"
2313                                  );                                  );
2314                                  prm.setValue(removeQuotation(s));                                  prm.setValue(removeQuotation(s));
2315                                  mp.setNameParameter(prm);                                  mp.setNameParameter(prm);
# Line 1645  public class Client { Line 2320  public class Client {
2320                                  );                                  );
2321                                                                    
2322                                  Parameter prm = getMidiInputPortParameterInfo (                                  Parameter prm = getMidiInputPortParameterInfo (
2323                                          deviceID, midiPort, s.substring(0, i)                                          deviceId, midiPort, s.substring(0, i)
2324                                  );                                  );
2325                                                                    
2326                                  s = s.substring(i + 2);                                  s = s.substring(i + 2);
# Line 1661  public class Client { Line 2336  public class Client {
2336          /**          /**
2337           * Gets detailed information about a specific MIDI input port parameter.           * Gets detailed information about a specific MIDI input port parameter.
2338           *           *
2339           * @param deviceID The numerical ID of the MIDI input device.           * @param deviceId The numerical ID of the MIDI input device.
2340           * @param port The MIDI port number.           * @param port The MIDI port number.
2341           * @param param A specific parameter name for which information should be obtained.           * @param param A specific parameter name for which information should be obtained.
2342           *           *
# Line 1672  public class Client { Line 2347  public class Client {
2347           * @throws LscpException If LSCP protocol corruption occurs.           * @throws LscpException If LSCP protocol corruption occurs.
2348           * @throws LSException If           * @throws LSException If
2349           * <ul>           * <ul>
2350           * <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>;
2351           * <li> <code>port</code> is not a valid MIDI port number;           * <li> <code>port</code> is not a valid MIDI port number;
2352           * <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.
2353           * </ul>           * </ul>
# Line 1681  public class Client { Line 2356  public class Client {
2356           * @see #getMidiInputPortInfo           * @see #getMidiInputPortInfo
2357           */           */
2358          public synchronized Parameter          public synchronized Parameter
2359          getMidiInputPortParameterInfo(int deviceID, int port, String param)          getMidiInputPortParameterInfo(int deviceId, int port, String param)
2360                                                  throws IOException, LscpException, LSException {                                                  throws IOException, LscpException, LSException {
2361                                    
2362                  verifyConnection();                  verifyConnection();
2363                  String args = deviceID + " " + port + " " + param;                  String args = deviceId + " " + port + " " + param;
2364                  out.writeLine("GET MIDI_INPUT_PORT_PARAMETER INFO " + args);                  out.writeLine("GET MIDI_INPUT_PORT_PARAMETER INFO " + args);
2365                    if(getPrintOnlyMode()) return null;
2366                                    
2367                  ResultSet rs = getMultiLineResultSet();                  ResultSet rs = getMultiLineResultSet();
2368                                    
# Line 1723  public class Client { Line 2399  public class Client {
2399          /**          /**
2400           * Alters a specific setting of a MIDI input port.           * Alters a specific setting of a MIDI input port.
2401           *           *
2402           * @param deviceID The numerical ID of the MIDI device.           * @param deviceId The numerical ID of the MIDI device.
2403           * @param port The MIDI port number.           * @param port The MIDI port number.
2404           * @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
2405           * and the new value for this parameter.           * and the new value for this parameter.
# Line 1732  public class Client { Line 2408  public class Client {
2408           * @throws LscpException If LSCP protocol corruption occurs.           * @throws LscpException If LSCP protocol corruption occurs.
2409           * @throws LSException If           * @throws LSException If
2410           * <ul>           * <ul>
2411           * <li>There is no MIDI device with numerical ID <code>deviceID</code>;           * <li>There is no MIDI device with numerical ID <code>deviceId</code>;
2412           * <li><code>port</code> is not a valid MIDI port number;           * <li><code>port</code> is not a valid MIDI port number;
2413           * <li><code>prm</code> is not a valid parameter;           * <li><code>prm</code> is not a valid parameter;
2414           * <li>The parameter is readonly;           * <li>The parameter is readonly;
# Line 1743  public class Client { Line 2419  public class Client {
2419           * @see #getMidiInputPortInfo           * @see #getMidiInputPortInfo
2420           */           */
2421          public synchronized void          public synchronized void
2422          setMidiInputPortParameter(int deviceID, int port,  Parameter prm)          setMidiInputPortParameter(int deviceId, int port,  Parameter prm)
2423                                                  throws IOException, LscpException, LSException {                                                  throws IOException, LscpException, LSException {
2424                                    
2425                  verifyConnection();                  verifyConnection();
2426                  String args = deviceID + " " + port + " " +                  String args = deviceId + " " + port + " " +
2427                          prm.getName() + '=' + prm.getStringValue();                          prm.getName() + '=' + prm.getStringValue();
2428                  out.writeLine("SET MIDI_INPUT_PORT_PARAMETER " + args);                  out.writeLine("SET MIDI_INPUT_PORT_PARAMETER " + args);
2429                    if(getPrintOnlyMode()) return;
2430                    
2431                    ResultSet rs = getEmptyResultSet();
2432            }
2433            
2434            /**
2435             * Adds a new MIDI instrument map.
2436             * @param name The name of this MIDI instrument map.
2437             * @return The number of the newly MIDI instrument map.
2438             * @throws IOException If some I/O error occurs.
2439             * @throws LSException If the creation of the new MIDI instrument map failed.
2440             * @throws LscpException If LSCP protocol corruption occurs.
2441             * @see #removeMidiInstrumentMap
2442             */
2443            public synchronized int
2444            addMidiInstrumentMap(String name) throws IOException, LSException, LscpException {
2445                    verifyConnection();
2446                    out.writeLine("ADD MIDI_INSTRUMENT_MAP '" + name + "'");
2447                    if(getPrintOnlyMode()) return -1;
2448                    
2449                    ResultSet rs = getEmptyResultSet();
2450                    
2451                    return rs.getIndex();
2452            }
2453            
2454            /**
2455             * Removes the specified MIDI instrument map.
2456             * @param mapId The numerical ID of the MIDI instrument map to be removed.
2457             * @throws IOException If some I/O error occurs.
2458             * @throws LscpException If LSCP protocol corruption occurs.
2459             * @throws LSException If the removing of the MIDI instrument map failed.
2460             * @see #addMidiInstrumentMap
2461             * @see #getMidiInstrumentMapIDs
2462             */
2463            public synchronized void
2464            removeMidiInstrumentMap(int mapId) throws IOException, LscpException, LSException {
2465                    verifyConnection();
2466                    out.writeLine("REMOVE MIDI_INSTRUMENT_MAP " + mapId);
2467                    if(getPrintOnlyMode()) return;
2468                    
2469                    ResultSet rs = getEmptyResultSet();
2470            }
2471            
2472            /**
2473             * Removes the all MIDI instrument maps.
2474             * @throws IOException If some I/O error occurs.
2475             * @throws LscpException If LSCP protocol corruption occurs.
2476             * @throws LSException If the removing of the MIDI instrument maps failed.
2477             */
2478            public synchronized void
2479            removeAllMidiInstrumentMaps() throws IOException, LscpException, LSException {
2480                    verifyConnection();
2481                    out.writeLine("REMOVE MIDI_INSTRUMENT_MAP ALL");
2482                    if(getPrintOnlyMode()) return;
2483                    
2484                    ResultSet rs = getEmptyResultSet();
2485            }
2486            
2487            /**
2488             * Gets the current number of all MIDI instrument maps.
2489             * @return The current number of all MIDI instrument maps.
2490             * @throws IOException If some I/O error occurs.
2491             * @throws LscpException If LSCP protocol corruption occurs.
2492             * @throws LSException If some other error occurs.
2493             */
2494            public synchronized int
2495            getMidiInstrumentMapCount() throws IOException, LscpException, LSException {
2496                    verifyConnection();
2497                    out.writeLine("GET MIDI_INSTRUMENT_MAPS");
2498                    if(getPrintOnlyMode()) return -1;
2499                    
2500                    String s = getSingleLineResultSet().getResult();
2501                    return parseInt(s);
2502            }
2503            
2504            /**
2505             * Gets a list of numerical IDs of all created MIDI instrument maps.
2506             * @return An <code>Integer</code> array providing the numerical IDs of
2507             * all created MIDI instrument maps.
2508             * @throws IOException If some I/O error occurs.
2509             * @throws LscpException If LSCP protocol corruption occurs.
2510             * @throws LSException If some other error occurs.
2511             * @see #addMidiInstrumentMap
2512             * @see #removeMidiInstrumentMap
2513             */
2514            public synchronized Integer[]
2515            getMidiInstrumentMapIDs() throws IOException, LscpException, LSException {
2516                    verifyConnection();
2517                    out.writeLine("LIST MIDI_INSTRUMENT_MAPS");
2518                    if(getPrintOnlyMode()) return null;
2519                    
2520                    return parseIntList(getSingleLineResultSet().getResult());
2521            }
2522            
2523            /**
2524             * Gets the current settings of a specific, already created MIDI instrument map.
2525             * @param mapId Specifies the numerical ID of the MIDI instrument map.
2526             * @return A <code>MidiInstrumentMapInfo</code> instance containing information
2527             * about the specified device.
2528             * @throws IOException If some I/O error occurs.
2529             * @throws LscpException If LSCP protocol corruption occurs.
2530             * @throws LSException If there is no MIDI instrument map
2531             * with map id <code>mapId</code>.
2532             * @see #getMidiInstrumentMaps
2533             */
2534            public synchronized MidiInstrumentMapInfo
2535            getMidiInstrumentMapInfo(int mapId) throws IOException, LscpException, LSException {
2536                    verifyConnection();
2537                    out.writeLine("GET MIDI_INSTRUMENT_MAP INFO " + mapId);
2538                    if(getPrintOnlyMode()) return null;
2539                    
2540                    ResultSet rs = getMultiLineResultSet();
2541                    
2542                    String[] lnS = rs.getMultiLineResult();
2543                    
2544                    String name = "";
2545                    boolean b = false;
2546                    
2547                    for(String s : lnS) {
2548                            if(s.startsWith("NAME: ")) {
2549                                    name = s.substring("NAME: ".length());
2550                            } else if(s.startsWith("DEFAULT: ")) {
2551                                    b = Boolean.parseBoolean(s.substring("DEFAULT: ".length()));
2552                            } else {
2553                                     getLogger().info(LscpI18n.getLogMsg("unknownLine", s));
2554                            }
2555                    }
2556                    
2557                    return new MidiInstrumentMapInfo(mapId, name, b);
2558            }
2559            
2560            /**
2561             * Gets an information of all created MIDI instrument maps.
2562             * @return A <code>MidiInstrumentMap</code> array
2563             * providing information for all created MIDI instrument maps.
2564             * @throws IOException If some I/O error occurs.
2565             * @throws LscpException If LSCP protocol corruption occurs.
2566             * @throws LSException If some other error occurs.
2567             * @see #addMidiInstrumentMap
2568             * @see #removeMidiInstrumentMap
2569             */
2570            public synchronized MidiInstrumentMapInfo[]
2571            getMidiInstrumentMaps() throws IOException, LscpException, LSException {
2572                    Integer[] idS = getMidiInstrumentMapIDs();
2573                    if(getPrintOnlyMode()) return null;
2574                    
2575                    MidiInstrumentMapInfo[] maps = new MidiInstrumentMapInfo[idS.length];
2576                    
2577                    for(int i = 0; i < maps.length; i++)
2578                            maps[i] = getMidiInstrumentMapInfo(idS[i]);
2579                    
2580                    return maps;
2581            }
2582            
2583            /**
2584             * Sets the name of the specified MIDI instrument map.
2585             * @param mapId The numerical ID of the MIDI instrument map.
2586             * @param name The new name for the specified MIDI instrument map.
2587             * @throws IOException If some I/O error occurs.
2588             * @throws LscpException If LSCP protocol corruption occurs.
2589             * @throws LSException If <code>mapId</code> is not a valid MIDI
2590             * instrument map number or <code>name</code> is not a valid name;
2591             */
2592            public synchronized void
2593            setMidiInstrumentMapName(int mapId, String name)
2594                                    throws IOException, LscpException, LSException {
2595                    
2596                    verifyConnection();
2597                    out.writeLine("SET MIDI_INSTRUMENT_MAP NAME " +  + mapId + " '" + name + "'");
2598                    if(getPrintOnlyMode()) return;
2599                    
2600                    ResultSet rs = getEmptyResultSet();
2601            }
2602            
2603            
2604            
2605            /**
2606             * Creates or replaces a MIDI instrument map entry.
2607             * @param mapId The ID of the map, where this instrument should be mapped.
2608             * @param entry Specifies the position of the MIDI instrument in the MIDI instrument map.
2609             * @param info Provides the needed information of the
2610             * MIDI instrument, which will be mapped to the specified MIDI instrument map.
2611             * @throws IOException If some I/O error occurs.
2612             * @throws LSException If the mapping failed.
2613             * @throws LscpException If LSCP protocol corruption occurs.
2614             * @see #unmapMidiInstrument
2615             */
2616            public synchronized void
2617            mapMidiInstrument(int mapId, MidiInstrumentEntry entry, MidiInstrumentInfo info)
2618                                            throws IOException, LSException, LscpException {
2619                    mapMidiInstrument(mapId, entry, info, false);
2620            }
2621            
2622            /**
2623             * Creates or replaces a MIDI instrument map entry.
2624             * @param mapId The ID of the map, where this instrument should be mapped.
2625             * @param entry Specifies the position of the MIDI instrument in the MIDI instrument map.
2626             * @param info Provides the needed information of the
2627             * MIDI instrument, which will be mapped to the specified MIDI instrument map.
2628             * @param nonModal If <code>true</code> the function returns immediately
2629             * and the mapping is established in the background.
2630             * @throws IOException If some I/O error occurs.
2631             * @throws LSException If the mapping failed.
2632             * @throws LscpException If LSCP protocol corruption occurs.
2633             * @see #unmapMidiInstrument
2634             */
2635            public synchronized void
2636            mapMidiInstrument(int mapId, MidiInstrumentEntry entry, MidiInstrumentInfo info, boolean nonModal)
2637                                            throws IOException, LSException, LscpException {
2638                    
2639                    verifyConnection();
2640                    StringBuffer cmd = new StringBuffer("MAP MIDI_INSTRUMENT ");
2641                    if(nonModal) cmd.append("NON_MODAL ");
2642                    cmd.append(mapId).append(' ');
2643                    cmd.append(entry.getMidiBank()).append(' ');
2644                    cmd.append(entry.getMidiProgram()).append(' ');
2645                    cmd.append(info.getEngine()).append(" '");
2646                    cmd.append(info.getFilePath()).append("' ");
2647                    cmd.append(info.getInstrumentIndex()).append(' ');
2648                    cmd.append(info.getVolume());
2649                    if(!info.getLoadMode().name().equals("DEFAULT")) {
2650                            cmd.append(' ').append(info.getLoadMode().name());
2651                    }
2652                    if(info.getName() != null) cmd.append(" '").append(info.getName()).append("'");
2653                    
2654                    out.writeLine(cmd.toString());
2655                    if(getPrintOnlyMode()) return;
2656                    
2657                    ResultSet rs = getEmptyResultSet();
2658            }
2659            
2660            /**
2661             * Removes an entry MIDI instrument map.
2662             * @param mapId The ID of the map, from which
2663             * the specified MIDI instrument should be removed.
2664             * @param entry The entry to remove from the specified MIDI instrument map.
2665             * @throws IOException If some I/O error occurs.
2666             * @throws LSException If the unmapping failed.
2667             * @throws LscpException If LSCP protocol corruption occurs.
2668             * @see #mapMidiInstrument
2669             */
2670            public synchronized void
2671            unmapMidiInstrument(int mapId, MidiInstrumentEntry entry)
2672                                            throws IOException, LSException, LscpException {
2673                    
2674                    verifyConnection();
2675                    StringBuffer cmd = new StringBuffer("UNMAP MIDI_INSTRUMENT ");
2676                    cmd.append(mapId).append(' ');
2677                    cmd.append(entry.getMidiBank()).append(' ');
2678                    cmd.append(entry.getMidiProgram());
2679                    
2680                    out.writeLine(cmd.toString());
2681                    if(getPrintOnlyMode()) return;
2682                                    
2683                  ResultSet rs = getEmptyResultSet();                  ResultSet rs = getEmptyResultSet();
2684          }          }
2685                    
2686          /**          /**
2687             * Gets the current number of all MIDI instrument in all maps.
2688             * @return The current number of all MIDI instrument in all maps.
2689             * @throws IOException If some I/O error occurs.
2690             * @throws LscpException If LSCP protocol corruption occurs.
2691             * @throws LSException If some other error occurs.
2692             */
2693            public synchronized int
2694            getMidiInstrumentCount() throws IOException, LscpException, LSException {
2695                    verifyConnection();
2696                    out.writeLine("GET MIDI_INSTRUMENTS ALL");
2697                    if(getPrintOnlyMode()) return -1;
2698                    
2699                    String s = getSingleLineResultSet().getResult();
2700                    return parseInt(s);
2701            }
2702            
2703            /**
2704             * Gets the current number of MIDI instrument in the specified map.
2705             * @param mapId The ID of the map.
2706             * @return The current number of MIDI instrument in the specified map.
2707             * @throws IOException If some I/O error occurs.
2708             * @throws LscpException If LSCP protocol corruption occurs.
2709             * @throws LSException If some other error occurs.
2710             */
2711            public synchronized int
2712            getMidiInstrumentCount(int mapId) throws IOException, LscpException, LSException {
2713                    verifyConnection();
2714                    out.writeLine("GET MIDI_INSTRUMENTS " + String.valueOf(mapId));
2715                    if(getPrintOnlyMode()) return -1;
2716                    
2717                    String s = getSingleLineResultSet().getResult();
2718                    return parseInt(s);
2719            }
2720            
2721            /**
2722             * Gets all MIDI instrument from all maps.
2723             * @return A <code>MidiInstrumentInfo</code> array providing
2724             * all MIDI instruments from all MIDI instrument maps.
2725             * @throws IOException If some I/O error occurs.
2726             * @throws LscpException If LSCP protocol corruption occurs.
2727             * @throws LSException If some other error occurs.
2728             */
2729            public synchronized MidiInstrumentInfo[]
2730            getMidiInstruments() throws IOException, LscpException, LSException {
2731                    verifyConnection();
2732                    out.writeLine("LIST MIDI_INSTRUMENTS ALL");
2733                    if(getPrintOnlyMode()) return null;
2734                    
2735                    String[] entries = parseArray(getSingleLineResultSet().getResult());
2736                    
2737                    return getMidiInstruments(entries);
2738            }
2739            
2740            /**
2741             * Gets all MIDI instrument contained int the specified MIDI instrument map.
2742             * @param mapId The ID of the map, which instruments should be obtained.
2743             * @return A <code>MidiInstrumentInfo</code> array providing
2744             * all MIDI instruments from all MIDI instrument maps.
2745             * @throws IOException If some I/O error occurs.
2746             * @throws LscpException If LSCP protocol corruption occurs.
2747             * @throws LSException If some other error occurs.
2748             */
2749            public synchronized MidiInstrumentInfo[]
2750            getMidiInstruments(int mapId) throws IOException, LscpException, LSException {
2751                    verifyConnection();
2752                    out.writeLine("LIST MIDI_INSTRUMENTS " + String.valueOf(mapId));
2753                    if(getPrintOnlyMode()) return null;
2754                    
2755                    String[] entries = parseArray(getSingleLineResultSet().getResult());
2756                    
2757                    return getMidiInstruments(entries);
2758            }
2759            
2760            private MidiInstrumentInfo[]
2761            getMidiInstruments(String[] entries) throws IOException, LscpException, LSException {
2762                    Vector<MidiInstrumentInfo> v = new Vector<MidiInstrumentInfo>();
2763                    
2764                    for(String s : entries) {
2765                            Integer[] vals = parseIntList(s);
2766                            if(vals.length != 3) {
2767                                    throw new LscpException(LscpI18n.getLogMsg("CommandFailed!"));
2768                            }
2769                            
2770                            v.add(getMidiInstrumentInfo(vals[0], vals[1], vals[2]));
2771                    }
2772                    
2773                    return v.toArray(new MidiInstrumentInfo[v.size()]);
2774            }
2775            
2776            /**
2777             * Gets the current settings of the specified MIDI instrument.
2778             * @param mapId The ID of the map.
2779             * @param bank The index of the MIDI bank.
2780             * @param program The MIDI program number of the instrument.
2781             * @return <code>MidiInstrumentInfo</code> instance containing
2782             * the current settings of the specified MIDI instrument.
2783             * @throws IOException If an I/O error occurs.
2784             * @throws LscpException If LSCP protocol corruption occurs.
2785             * @throws LSException If the specified MIDI instrument is missing.
2786             */
2787            public synchronized MidiInstrumentInfo
2788            getMidiInstrumentInfo(int mapId, int bank, int program)
2789                                            throws IOException, LscpException, LSException {
2790            
2791                    verifyConnection();
2792                    StringBuffer cmd = new StringBuffer("GET MIDI_INSTRUMENT INFO ");
2793                    cmd.append(mapId).append(' ');
2794                    cmd.append(bank).append(' ');
2795                    cmd.append(program);
2796                    
2797                    out.writeLine(cmd.toString());
2798                    if(getPrintOnlyMode()) return null;
2799                    
2800                    ResultSet rs = getMultiLineResultSet();
2801                    MidiInstrumentEntry entry = new MidiInstrumentEntry(bank, program);
2802                    return new MidiInstrumentInfo(mapId, entry, rs.getMultiLineResult());
2803            }
2804            
2805            /**
2806           * 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
2807           * 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.
          *    
2808           * @param filename The name of the instrument file           * @param filename The name of the instrument file
2809           * on the LinuxSampler instance's host system.           * on the LinuxSampler instance's host system.
2810           * @param instrIdx The index of the instrument in the instrument file.           * @param instrIdx The index of the instrument in the instrument file.
2811           * @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.
          *  
2812           * @throws IOException If some I/O error occurs.           * @throws IOException If some I/O error occurs.
2813           * @throws LscpException If LSCP protocol corruption occurs.           * @throws LscpException If LSCP protocol corruption occurs.
2814           * @throws LSException If the loading of the instrument failed.           * @throws LSException If the loading of the instrument failed.
          *  
2815           * @see #loadInstrument(String, int, int, boolean)           * @see #loadInstrument(String, int, int, boolean)
2816           * @see #getSamplerChannels           * @see #getSamplerChannels
2817           */           */
# Line 1804  public class Client { Line 2849  public class Client {
2849                  String args = '\'' + filename + "' " + instrIdx + ' ' + samplerChn;                  String args = '\'' + filename + "' " + instrIdx + ' ' + samplerChn;
2850                                    
2851                  out.writeLine(cmd + args);                  out.writeLine(cmd + args);
2852                    if(getPrintOnlyMode()) return;
2853                                    
2854                  ResultSet rs = getEmptyResultSet();                  ResultSet rs = getEmptyResultSet();
2855          }          }
# Line 1826  public class Client { Line 2872  public class Client {
2872                                    
2873                  verifyConnection();                  verifyConnection();
2874                  out.writeLine("LOAD ENGINE " + engineName + ' ' + samplerChn);                  out.writeLine("LOAD ENGINE " + engineName + ' ' + samplerChn);
2875                    if(getPrintOnlyMode()) return;
2876                                    
2877                  ResultSet rs = getEmptyResultSet();                  ResultSet rs = getEmptyResultSet();
2878          }          }
# Line 1841  public class Client { Line 2888  public class Client {
2888          getSamplerChannelCount() throws IOException, LscpException, LSException {          getSamplerChannelCount() throws IOException, LscpException, LSException {
2889                  verifyConnection();                  verifyConnection();
2890                  out.writeLine("GET CHANNELS");                  out.writeLine("GET CHANNELS");
2891                    if(getPrintOnlyMode()) return -1;
2892                    
2893                  String s = getSingleLineResultSet().getResult();                  String s = getSingleLineResultSet().getResult();
2894                  return parseInt(s);                  return parseInt(s);
2895          }          }
# Line 1857  public class Client { Line 2906  public class Client {
2906          public synchronized SamplerChannel[]          public synchronized SamplerChannel[]
2907          getSamplerChannels() throws IOException, LscpException, LSException {          getSamplerChannels() throws IOException, LscpException, LSException {
2908                  Integer[] idS = getSamplerChannelIDs();                  Integer[] idS = getSamplerChannelIDs();
2909                    if(getPrintOnlyMode()) return null;
2910                    
2911                  SamplerChannel[] channels = new SamplerChannel[idS.length];                  SamplerChannel[] channels = new SamplerChannel[idS.length];
2912                                    
2913                  for(int i = 0; i < channels.length; i++)                  for(int i = 0; i < channels.length; i++)
# Line 1879  public class Client { Line 2930  public class Client {
2930          getSamplerChannelIDs() throws IOException, LscpException, LSException {          getSamplerChannelIDs() throws IOException, LscpException, LSException {
2931                  verifyConnection();                  verifyConnection();
2932                  out.writeLine("LIST CHANNELS");                  out.writeLine("LIST CHANNELS");
2933                    if(getPrintOnlyMode()) return null;
2934                    
2935                  return parseIntList(getSingleLineResultSet().getResult());                  return parseIntList(getSingleLineResultSet().getResult());
2936          }          }
2937                    
# Line 1896  public class Client { Line 2949  public class Client {
2949          addSamplerChannel() throws IOException, LSException, LscpException {          addSamplerChannel() throws IOException, LSException, LscpException {
2950                  verifyConnection();                  verifyConnection();
2951                  out.writeLine("ADD CHANNEL");                  out.writeLine("ADD CHANNEL");
2952                    if(getPrintOnlyMode()) return -1;
2953                    
2954                  ResultSet rs = getEmptyResultSet();                  ResultSet rs = getEmptyResultSet();
2955                                    
2956                  return rs.getIndex();                  return rs.getIndex();
# Line 1916  public class Client { Line 2971  public class Client {
2971          removeSamplerChannel(int samplerChn) throws IOException, LscpException, LSException {          removeSamplerChannel(int samplerChn) throws IOException, LscpException, LSException {
2972                  verifyConnection();                  verifyConnection();
2973                  out.writeLine("REMOVE CHANNEL " + samplerChn);                  out.writeLine("REMOVE CHANNEL " + samplerChn);
2974                    if(getPrintOnlyMode()) return;
2975                                    
2976                  ResultSet rs = getEmptyResultSet();                  ResultSet rs = getEmptyResultSet();
2977          }          }
# Line 1931  public class Client { Line 2987  public class Client {
2987          getEngineCount() throws IOException, LscpException, LSException {          getEngineCount() throws IOException, LscpException, LSException {
2988                  verifyConnection();                  verifyConnection();
2989                  out.writeLine("GET AVAILABLE_ENGINES");                  out.writeLine("GET AVAILABLE_ENGINES");
2990                    if(getPrintOnlyMode()) return -1;
2991                    
2992                  String s = getSingleLineResultSet().getResult();                  String s = getSingleLineResultSet().getResult();
2993                  return parseInt(s);                  return parseInt(s);
2994          }          }
# Line 1946  public class Client { Line 3004  public class Client {
3004          public synchronized SamplerEngine[]          public synchronized SamplerEngine[]
3005          getEngines() throws IOException, LscpException, LSException {          getEngines() throws IOException, LscpException, LSException {
3006                  String[] engines = getEngineNames();                  String[] engines = getEngineNames();
3007                    if(getPrintOnlyMode()) return null;
3008                    
3009                  SamplerEngine[] se = new SamplerEngine[engines.length];                  SamplerEngine[] se = new SamplerEngine[engines.length];
3010                                    
3011                  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]);
# Line 1965  public class Client { Line 3025  public class Client {
3025          getEngineNames() throws IOException, LscpException, LSException {          getEngineNames() throws IOException, LscpException, LSException {
3026                  verifyConnection();                  verifyConnection();
3027                  out.writeLine("LIST AVAILABLE_ENGINES");                  out.writeLine("LIST AVAILABLE_ENGINES");
3028                    if(getPrintOnlyMode()) return null;
3029                    
3030                  return parseStringList(getSingleLineResultSet().getResult());                  return parseStringList(getSingleLineResultSet().getResult());
3031          }          }
3032                    
# Line 1984  public class Client { Line 3046  public class Client {
3046          getEngineInfo(String engineName) throws IOException, LscpException, LSException {          getEngineInfo(String engineName) throws IOException, LscpException, LSException {
3047                  verifyConnection();                  verifyConnection();
3048                  out.writeLine("GET ENGINE INFO " + engineName);                  out.writeLine("GET ENGINE INFO " + engineName);
3049                    if(getPrintOnlyMode()) return null;
3050                    
3051                  ResultSet rs = getMultiLineResultSet();                  ResultSet rs = getMultiLineResultSet();
3052                  SamplerEngine se = new SamplerEngine(rs.getMultiLineResult());                  SamplerEngine se = new SamplerEngine(rs.getMultiLineResult());
3053                  se.setName(engineName);                  se.setName(engineName);
# Line 2006  public class Client { Line 3070  public class Client {
3070          getSamplerChannelInfo(int samplerChn) throws IOException, LscpException, LSException {          getSamplerChannelInfo(int samplerChn) throws IOException, LscpException, LSException {
3071                  verifyConnection();                  verifyConnection();
3072                  out.writeLine("GET CHANNEL INFO " + samplerChn);                  out.writeLine("GET CHANNEL INFO " + samplerChn);
3073                    if(getPrintOnlyMode()) return null;
3074                    
3075                  ResultSet rs = getMultiLineResultSet();                  ResultSet rs = getMultiLineResultSet();
3076                  SamplerChannel sc = new SamplerChannel(rs.getMultiLineResult());                  SamplerChannel sc = new SamplerChannel(rs.getMultiLineResult());
3077                  sc.setChannelID(samplerChn);                  sc.setChannelId(samplerChn);
3078                  if(sc.getEngine() != null) sc.setEngine(getEngineInfo(sc.getEngine().getName()));                  if(sc.getEngine() != null) sc.setEngine(getEngineInfo(sc.getEngine().getName()));
3079                                    
3080                  return sc;                  return sc;
# Line 2028  public class Client { Line 3094  public class Client {
3094          getChannelVoiceCount(int samplerChn) throws IOException, LscpException, LSException {          getChannelVoiceCount(int samplerChn) throws IOException, LscpException, LSException {
3095                  verifyConnection();                  verifyConnection();
3096                  out.writeLine("GET CHANNEL VOICE_COUNT " + samplerChn);                  out.writeLine("GET CHANNEL VOICE_COUNT " + samplerChn);
3097                    if(getPrintOnlyMode()) return -1;
3098                    
3099                  ResultSet rs = getSingleLineResultSet();                  ResultSet rs = getSingleLineResultSet();
3100                                    
3101                  return parseInt(rs.getResult());                  return parseInt(rs.getResult());
# Line 2048  public class Client { Line 3116  public class Client {
3116          getChannelStreamCount(int samplerChn) throws IOException, LscpException, LSException {          getChannelStreamCount(int samplerChn) throws IOException, LscpException, LSException {
3117                  verifyConnection();                  verifyConnection();
3118                  out.writeLine("GET CHANNEL STREAM_COUNT " + samplerChn);                  out.writeLine("GET CHANNEL STREAM_COUNT " + samplerChn);
3119                    if(getPrintOnlyMode()) return -1;
3120            
3121                  ResultSet rs = getSingleLineResultSet();                  ResultSet rs = getSingleLineResultSet();
3122                                    
3123                  if(rs.getResult().equals("NA")) return -1;                  if(rs.getResult().equals("NA")) return -1;
# Line 2072  public class Client { Line 3142  public class Client {
3142          getChannelBufferFillBytes(int samplerChn) throws IOException, LscpException, LSException {          getChannelBufferFillBytes(int samplerChn) throws IOException, LscpException, LSException {
3143                  verifyConnection();                  verifyConnection();
3144                  out.writeLine("GET CHANNEL BUFFER_FILL BYTES " + samplerChn);                  out.writeLine("GET CHANNEL BUFFER_FILL BYTES " + samplerChn);
3145                    if(getPrintOnlyMode()) return null;
3146                    
3147                  ResultSet rs = getSingleLineResultSet();                  ResultSet rs = getSingleLineResultSet();
3148                                    
3149                  if(rs.getResult().equals("NA")) return null;                  if(rs.getResult().equals("NA")) return null;
# Line 2087  public class Client { Line 3159  public class Client {
3159                          if(i == -1) throw new LscpException(LscpI18n.getLogMsg("CommandFailed!"));                          if(i == -1) throw new LscpException(LscpI18n.getLogMsg("CommandFailed!"));
3160                                                    
3161                          BufferFill bf = new BufferFill();                          BufferFill bf = new BufferFill();
3162                          bf.setStreamID(parseInt(s.substring(1, i)));                          bf.setStreamId(parseInt(s.substring(1, i)));
3163                          bf.setValue(parseInt(s.substring(i + 1)));                          bf.setValue(parseInt(s.substring(i + 1)));
3164                          v.add(bf);                          v.add(bf);
3165                  }                  }
# Line 2114  public class Client { Line 3186  public class Client {
3186                                    
3187                  verifyConnection();                  verifyConnection();
3188                  out.writeLine("GET CHANNEL BUFFER_FILL PERCENTAGE " + samplerChn);                  out.writeLine("GET CHANNEL BUFFER_FILL PERCENTAGE " + samplerChn);
3189                    if(getPrintOnlyMode()) return null;
3190                    
3191                  ResultSet rs = getSingleLineResultSet();                  ResultSet rs = getSingleLineResultSet();
3192                                    
3193                  return getChannelBufferFillPercentage(rs.getResult());                  return getChannelBufferFillPercentage(rs.getResult());
# Line 2137  public class Client { Line 3211  public class Client {
3211                                  throw new LscpException(LscpI18n.getLogMsg("CommandFailed!"));                                  throw new LscpException(LscpI18n.getLogMsg("CommandFailed!"));
3212                                                    
3213                          BufferFill bf = new BufferFill();                          BufferFill bf = new BufferFill();
3214                          bf.setStreamID(parseInt(s.substring(1, i)));                          bf.setStreamId(parseInt(s.substring(1, i)));
3215                          bf.setValue(parseInt(s.substring(i + 1, s.length() - 1)));                          bf.setValue(parseInt(s.substring(i + 1, s.length() - 1)));
3216                          v.add(bf);                          v.add(bf);
3217                  }                  }
# Line 2149  public class Client { Line 3223  public class Client {
3223           * Sets the audio output device on the specified sampler channel.           * Sets the audio output device on the specified sampler channel.
3224           *           *
3225           * @param samplerChn The sampler channel number.           * @param samplerChn The sampler channel number.
3226           * @param devID The numerical ID of the audio output device.           * @param devId The numerical ID of the audio output device.
3227           *           *
3228           * @throws IOException If some I/O error occurs.           * @throws IOException If some I/O error occurs.
3229           * @throws LscpException If LSCP protocol corruption occurs.           * @throws LscpException If LSCP protocol corruption occurs.
3230           * @throws LSException If           * @throws LSException If
3231           * <ul>           * <ul>
3232           * <li><code>samplerChn</code> is not a valid channel number;           * <li><code>samplerChn</code> is not a valid channel number;
3233           * <li><code>devID</code> is not a valid audio output device ID;           * <li><code>devId</code> is not a valid audio output device ID;
3234           * </ul>           * </ul>
3235           *           *
3236           * @see #getSamplerChannels           * @see #getSamplerChannels
3237           * @see #getAudioOutputDevices           * @see #getAudioOutputDevices
3238           */           */
3239          public synchronized void          public synchronized void
3240          setChannelAudioOutputDevice(int samplerChn, int devID)          setChannelAudioOutputDevice(int samplerChn, int devId)
3241                                  throws IOException, LscpException, LSException {                                  throws IOException, LscpException, LSException {
3242                                    
3243                  verifyConnection();                  verifyConnection();
3244                  out.writeLine("SET CHANNEL AUDIO_OUTPUT_DEVICE " + samplerChn + ' ' + devID);                  out.writeLine("SET CHANNEL AUDIO_OUTPUT_DEVICE " + samplerChn + ' ' + devId);
3245                    if(getPrintOnlyMode()) return;
3246                                    
3247                  ResultSet rs = getEmptyResultSet();                  ResultSet rs = getEmptyResultSet();
3248          }          }
# Line 2198  public class Client { Line 3273  public class Client {
3273                  verifyConnection();                  verifyConnection();
3274                  String args = " " + samplerChn + ' ' + audioOut + ' ' + audioIn;                  String args = " " + samplerChn + ' ' + audioOut + ' ' + audioIn;
3275                  out.writeLine("SET CHANNEL AUDIO_OUTPUT_CHANNEL" + args);                  out.writeLine("SET CHANNEL AUDIO_OUTPUT_CHANNEL" + args);
3276                    if(getPrintOnlyMode()) return;
3277                                    
3278                  ResultSet rs = getEmptyResultSet();                  ResultSet rs = getEmptyResultSet();
3279          }          }
# Line 2206  public class Client { Line 3282  public class Client {
3282           * Sets the MIDI input device on the specified sampler channel.           * Sets the MIDI input device on the specified sampler channel.
3283           *           *
3284           * @param samplerChn The sampler channel number.           * @param samplerChn The sampler channel number.
3285           * @param devID The numerical ID of the MIDI input device.           * @param devId The numerical ID of the MIDI input device.
3286           *           *
3287           * @throws IOException If some I/O error occurs.           * @throws IOException If some I/O error occurs.
3288           * @throws LscpException If LSCP protocol corruption occurs.           * @throws LscpException If LSCP protocol corruption occurs.
3289           * @throws LSException If           * @throws LSException If
3290           * <ul>           * <ul>
3291           * <li><code>samplerChn</code> is not a valid channel number;           * <li><code>samplerChn</code> is not a valid channel number;
3292           * <li><code>devID</code> is not a valid MIDI input device ID;           * <li><code>devId</code> is not a valid MIDI input device ID;
3293           * </ul>           * </ul>
3294           *           *
3295           * @see #getSamplerChannels           * @see #getSamplerChannels
3296           * @see #getMidiInputDevices           * @see #getMidiInputDevices
3297           */           */
3298          public synchronized void          public synchronized void
3299          setChannelMidiInputDevice(int samplerChn, int devID)          setChannelMidiInputDevice(int samplerChn, int devId)
3300                                  throws IOException, LscpException, LSException {                                  throws IOException, LscpException, LSException {
3301                                    
3302                  verifyConnection();                  verifyConnection();
3303                  out.writeLine("SET CHANNEL MIDI_INPUT_DEVICE " + samplerChn + ' ' + devID);                  out.writeLine("SET CHANNEL MIDI_INPUT_DEVICE " + samplerChn + ' ' + devId);
3304                    if(getPrintOnlyMode()) return;
3305                                    
3306                  ResultSet rs = getEmptyResultSet();                  ResultSet rs = getEmptyResultSet();
3307          }          }
# Line 2247  public class Client { Line 3324  public class Client {
3324                                    
3325                  verifyConnection();                  verifyConnection();
3326                  out.writeLine("SET CHANNEL MIDI_INPUT_PORT " + samplerChn + ' ' + port);                  out.writeLine("SET CHANNEL MIDI_INPUT_PORT " + samplerChn + ' ' + port);
3327                    if(getPrintOnlyMode()) return;
3328                                    
3329                  ResultSet rs = getEmptyResultSet();                  ResultSet rs = getEmptyResultSet();
3330          }          }
# Line 2271  public class Client { Line 3349  public class Client {
3349                  String args = String.valueOf(samplerChn) + ' ';                  String args = String.valueOf(samplerChn) + ' ';
3350                  args += (midiChn == -1 ? "ALL" : String.valueOf(midiChn));                  args += (midiChn == -1 ? "ALL" : String.valueOf(midiChn));
3351                  out.writeLine("SET CHANNEL MIDI_INPUT_CHANNEL " + args);                  out.writeLine("SET CHANNEL MIDI_INPUT_CHANNEL " + args);
3352                    if(getPrintOnlyMode()) return;
3353                    
3354                    ResultSet rs = getEmptyResultSet();
3355            }
3356            
3357            /**
3358             * Sets the MIDI instrument map to be used on the specified sampler channel.
3359             *
3360             * @param samplerChn The sampler channel number.
3361             * @param mapId Specifies the numerical ID of the MIDI instrument
3362             * map to assign. To remove the current map binding use <code>-1</code>.
3363             * To set the current map to be the default map use <code>-2</code>.
3364             *
3365             * @throws IOException If some I/O error occurs.
3366             * @throws LscpException If LSCP protocol corruption occurs.
3367             * @throws LSException If
3368             * <ul>
3369             * <li><code>samplerChn</code> is not a valid channel number;
3370             * <li><code>mapId</code> is not a valid MIDI instrument map ID;
3371             * </ul>
3372             *
3373             * @see #getSamplerChannels
3374             * @see #getMidiInstrumentMaps
3375             */
3376            public synchronized void
3377            setChannelMidiInstrumentMap(int samplerChn, int mapId)
3378                                    throws IOException, LscpException, LSException {
3379                    
3380                    verifyConnection();
3381                    String s;
3382                    if(mapId == -1) {
3383                            s = " NONE";
3384                    } else if(mapId == -2) {
3385                            s = " DEFAULT";
3386                    } else {
3387                            s = " " + String.valueOf(mapId);
3388                    }
3389                    out.writeLine("SET CHANNEL MIDI_INSTRUMENT_MAP " + samplerChn + s);
3390                    if(getPrintOnlyMode()) return;
3391                                    
3392                  ResultSet rs = getEmptyResultSet();                  ResultSet rs = getEmptyResultSet();
3393          }          }
# Line 2293  public class Client { Line 3410  public class Client {
3410                    
3411                  verifyConnection();                  verifyConnection();
3412                  out.writeLine("SET CHANNEL VOLUME " + samplerChn + ' ' + volume);                  out.writeLine("SET CHANNEL VOLUME " + samplerChn + ' ' + volume);
3413                    if(getPrintOnlyMode()) return;
3414                                    
3415                  ResultSet rs = getEmptyResultSet();                  ResultSet rs = getEmptyResultSet();
3416          }          }
# Line 2316  public class Client { Line 3434  public class Client {
3434                    
3435                  verifyConnection();                  verifyConnection();
3436                  out.writeLine("SET CHANNEL MUTE " + samplerChn + ' ' + (mute ? 1 : 0));                  out.writeLine("SET CHANNEL MUTE " + samplerChn + ' ' + (mute ? 1 : 0));
3437                    if(getPrintOnlyMode()) return;
3438                                    
3439                  ResultSet rs = getEmptyResultSet();                  ResultSet rs = getEmptyResultSet();
3440          }          }
# Line 2339  public class Client { Line 3458  public class Client {
3458                    
3459                  verifyConnection();                  verifyConnection();
3460                  out.writeLine("SET CHANNEL SOLO " + samplerChn + ' ' + (solo ? 1 : 0));                  out.writeLine("SET CHANNEL SOLO " + samplerChn + ' ' + (solo ? 1 : 0));
3461                    if(getPrintOnlyMode()) return;
3462                    
3463                    ResultSet rs = getEmptyResultSet();
3464            }
3465            
3466            /**
3467             * Creates an additional effect send on the specified sampler channel.
3468             * @param channel The sampler channel, on which a new effect send should be added.
3469             * @param midiCtrl Defines the MIDI controller, which
3470             * will be able alter the effect send level.
3471             * @return The unique ID of the newly created effect send entity.
3472             * @throws IOException If some I/O error occurs.
3473             * @throws LSException If the creation of the effect send failed.
3474             * @throws LscpException If LSCP protocol corruption occurs.
3475             * @see #destroyFxSend
3476             */
3477            public synchronized int
3478            createFxSend(int channel, int midiCtrl)
3479                            throws IOException, LSException, LscpException {
3480                    
3481                    return createFxSend(channel, midiCtrl, null);
3482            }
3483            
3484            /**
3485             * Creates an additional effect send on the specified sampler channel.
3486             * @param channel The sampler channel, on which the effect send should be created on.
3487             * @param midiCtrl Defines the MIDI controller, which can alter the effect send level.
3488             * @param name The name of the effect send entity. The name does not have to be unique.
3489             * @return The unique ID of the newly created effect send entity.
3490             * @throws IOException If some I/O error occurs.
3491             * @throws LSException If the creation of the effect send failed.
3492             * @throws LscpException If LSCP protocol corruption occurs.
3493             * @see #destroyFxSend
3494             */
3495            public synchronized int
3496            createFxSend(int channel, int midiCtrl, String name)
3497                            throws IOException, LSException, LscpException {
3498                    
3499                    verifyConnection();
3500                    String s = String.valueOf(channel) + " " + String.valueOf(midiCtrl);
3501                    if(name != null) s += " '" + name + "'";
3502                    out.writeLine("CREATE FX_SEND " + s);
3503                    if(getPrintOnlyMode()) return -1;
3504                    
3505                    ResultSet rs = getEmptyResultSet();
3506                    
3507                    return rs.getIndex();
3508            }
3509            
3510            /**
3511             * Destroys the specified effect send on the specified sampler channel.
3512             * @param channel The sampler channel, from which
3513             * the specified effect send should be removed.
3514             * @param fxSend The ID of the effect send that should be removed.
3515             * @throws LSException If some other error occurs.
3516             * @throws LscpException If LSCP protocol corruption occurs.
3517             * @see #createFxSend
3518             */
3519            public synchronized void
3520            destroyFxSend(int channel, int fxSend)
3521                            throws IOException, LSException, LscpException {
3522                    
3523                    verifyConnection();
3524                    String s = String.valueOf(channel) + " " + String.valueOf(fxSend);
3525                    out.writeLine("DESTROY FX_SEND " + s);
3526                    if(getPrintOnlyMode()) return;
3527                    
3528                    ResultSet rs = getEmptyResultSet();
3529            }
3530            
3531            /**
3532             * Gets the current number of effect sends on the specified sampler channel.
3533             * @param channel The ID of the sampler channel.
3534             * @return The current number of effect sends on the specified sampler channels.
3535             * @throws IOException If some I/O error occurs.
3536             * @throws LscpException If LSCP protocol corruption occurs.
3537             * @throws LSException If some other error occurs.
3538             */
3539            public synchronized int
3540            getFxSoundCount(int channel) throws IOException, LscpException, LSException {
3541                    verifyConnection();
3542                    out.writeLine("GET FX_SENDS " + String.valueOf(channel));
3543                    if(getPrintOnlyMode()) return -1;
3544                    
3545                    String s = getSingleLineResultSet().getResult();
3546                    return parseInt(s);
3547            }
3548            
3549            /**
3550             * Gets a list of all created effect sends on the specified sampler channel.
3551             * @param channel The sampler channel number.
3552             * @return A <code>FxSend</code> array providing all created
3553             * effect sends on the specified sampler channel.
3554             * @throws IOException If some I/O error occurs.
3555             * @throws LscpException If LSCP protocol corruption occurs.
3556             * @throws LSException If <code>channel</code> is not a valid sampler channel ID.
3557             * @see #createFxSend
3558             * @see #destroyFxSend
3559             */
3560            public synchronized FxSend[]
3561            getFxSends(int channel) throws IOException, LscpException, LSException {
3562                    Integer[] idS = getFxSendIDs(channel);
3563                    if(getPrintOnlyMode()) return null;
3564                    
3565                    FxSend[] fxSends = new FxSend[idS.length];
3566                    
3567                    for(int i = 0; i < fxSends.length; i++)
3568                            fxSends[i] = getFxSendInfo(channel, idS[i]);
3569                    
3570                    return fxSends;
3571            }
3572            
3573            /**
3574             * Gets a list of effect sends on the specified sampler channel.
3575             * @param channel The sampler channel number.
3576             * @return An <code>Integer</code> array providing
3577             * the numerical IDs of all effect sends on the specified sampler channel.
3578             * @throws IOException If some I/O error occurs.
3579             * @throws LscpException If LSCP protocol corruption occurs.
3580             * @throws LSException If <code>channel</code> is not a valid sampler channel ID.
3581             * @see #createFxSend
3582             * @see #destroyFxSend
3583             */
3584            public synchronized Integer[]
3585            getFxSendIDs(int channel) throws IOException, LscpException, LSException {
3586                    verifyConnection();
3587                    out.writeLine("LIST FX_SENDS " + channel);
3588                    if(getPrintOnlyMode()) return null;
3589                    
3590                    return parseIntList(getSingleLineResultSet().getResult());
3591            }
3592            
3593            /**
3594             * Gets the current settings of the specified effect send entity.
3595             * @param channel The sampler channel number.
3596             * @param fxSend The numerical ID of the effect send entity.
3597             * @return <code>FxSend</code> instance containing
3598             * the current settings of the specified effect send entity.
3599             * @throws IOException If an I/O error occurs.
3600             * @throws LscpException If LSCP protocol corruption occurs.
3601             * @throws LSException If the sampler channel and/or the effect send number are invalid.
3602             */
3603            public synchronized FxSend
3604            getFxSendInfo(int channel, int fxSend) throws IOException, LscpException, LSException {
3605                    verifyConnection();
3606                    String s = String.valueOf(channel) + " " + String.valueOf(fxSend);
3607                    out.writeLine("GET FX_SEND INFO " + s);
3608                    if(getPrintOnlyMode()) return null;
3609                    
3610                    ResultSet rs = getMultiLineResultSet();
3611                    FxSend fxs = new FxSend(rs.getMultiLineResult());
3612                    fxs.setFxSendId(fxSend);
3613                    
3614                    return fxs;
3615            }
3616            
3617            /**
3618             * Sets the name of the specified effect send.
3619             * @param channel The sampler channel number.
3620             * @param fxSend The numerical ID of the effect send entity.
3621             * @param name The new name for the specified effect send.
3622             * @throws IOException If some I/O error occurs.
3623             * @throws LscpException If LSCP protocol corruption occurs.
3624             * @throws LSException If <code>channel</code> is not a valid channel
3625             * number or <code>fxSend</code> is not a valid effect send ID;
3626             */
3627            public synchronized void
3628            setFxSendName(int channel, int fxSend, String name)
3629                                    throws IOException, LscpException, LSException {
3630                    
3631                    verifyConnection();
3632                    String args = " " + channel + " " + fxSend + " '" + name + "'";
3633                    out.writeLine("SET FX_SEND NAME" + args);
3634                    if(getPrintOnlyMode()) return;
3635                    
3636                    ResultSet rs = getEmptyResultSet();
3637            }
3638            
3639            /**
3640             * Sets the destination of an effect send's audio channel in the specified sampler channel.
3641             * @param channel The sampler channel number.
3642             * @param fxSend The numerical ID of the effect send entity to be rerouted.
3643             * @param audioSrc The numerical ID of the effect send's audio output channel,
3644             * which should be rerouted.
3645             * @param audioDst The audio channel of the selected audio output device
3646             * where <code>audioSrc</code> should be routed to.
3647             * @throws IOException If some I/O error occurs.
3648             * @throws LscpException If LSCP protocol corruption occurs.
3649             * @throws LSException If
3650             * <ul>
3651             * <li><code>channel</code> is not a valid channel number;
3652             * <li><code>fxSend</code> is not a valid effect send ID;
3653             * <li>There is no engine assigned yet to the specified sampler channel;
3654             * <li>There is no audio output device connected to the specified sampler channel.
3655             * </ul>
3656             */
3657            public synchronized void
3658            setFxSendAudioOutputChannel(int channel, int fxSend, int audioSrc, int audioDst)
3659                                    throws IOException, LscpException, LSException {
3660                    
3661                    verifyConnection();
3662                    String args = " " + channel + " " + fxSend + " " + audioSrc + " " + audioDst;
3663                    out.writeLine("SET FX_SEND AUDIO_OUTPUT_CHANNEL" + args);
3664                    if(getPrintOnlyMode()) return;
3665                                    
3666                  ResultSet rs = getEmptyResultSet();                  ResultSet rs = getEmptyResultSet();
3667          }          }
3668                    
3669          /**          /**
3670             * Sets the MIDI controller, which will be able to modify
3671             * the send level of the specified effect send in the specified sampler channel.
3672             * @param channel The sampler channel number.
3673             * @param fxSend The numerical ID of the effect send entity.
3674             * @param midiCtrl The MIDI controller which shall be
3675             * able to modify the effect send's send level.
3676             * @throws IOException If some I/O error occurs.
3677             * @throws LscpException If LSCP protocol corruption occurs.
3678             * @throws LSException If
3679             * <ul>
3680             * <li><code>channel</code> is not a valid channel number;
3681             * <li><code>fxSend</code> is not a valid effect send ID;
3682             * <li><code>midiCtrl</code> is not a valid controller;
3683             * </ul>
3684             */
3685            public synchronized void
3686            setFxSendMidiController(int channel, int fxSend, int midiCtrl)
3687                                    throws IOException, LscpException, LSException {
3688                    
3689                    verifyConnection();
3690                    String args = " " + channel + " " + fxSend + " " + midiCtrl;
3691                    out.writeLine("SET FX_SEND MIDI_CONTROLLER" + args);
3692                    if(getPrintOnlyMode()) return;
3693                    
3694                    ResultSet rs = getEmptyResultSet();
3695            }
3696            
3697            /**
3698             * Sets the current send level of the specified
3699             * effect send entity in the specified sampler channel.
3700             * @param channel The sampler channel number.
3701             * @param fxSend The numerical ID of the effect send entity.
3702             * @param volume The new volume value (a value smaller than 1.0 means
3703             * attenuation, whereas a value greater than 1.0 means amplification).
3704             * @throws IOException If some I/O error occurs.
3705             * @throws LscpException If LSCP protocol corruption occurs.
3706             * @throws LSException If some other error occurs.
3707             */
3708            public synchronized void
3709            setFxSendLevel(int channel, int fxSend, float volume)
3710                                    throws IOException, LscpException, LSException {
3711                    
3712                    verifyConnection();
3713                    String args = " " + channel + " " + fxSend + " " + String.valueOf(volume);
3714                    out.writeLine("SET FX_SEND LEVEL" + args);
3715                    if(getPrintOnlyMode()) return;
3716                    
3717                    ResultSet rs = getEmptyResultSet();
3718            }
3719            
3720            
3721            
3722            /**
3723             * Adds the specified directory to the instruments database.
3724             * @param dir The absolute path name of the directory to add.
3725             * @throws IOException If some I/O error occurs.
3726             * @throws LSException If the creation of the directory failed.
3727             * @throws LscpException If LSCP protocol corruption occurs.
3728             */
3729            public synchronized void
3730            addDbDirectory(String dir) throws IOException, LSException, LscpException {
3731                    verifyConnection();
3732                    out.writeLine("ADD DB_INSTRUMENT_DIRECTORY '" + dir + "'");
3733                    if(getPrintOnlyMode()) return;
3734                    
3735                    ResultSet rs = getEmptyResultSet();
3736            }
3737            
3738            /**
3739             * Removes the specified directory from the instruments database.
3740             * @param dir The absolute path name of the directory to remove.
3741             * @throws IOException If some I/O error occurs.
3742             * @throws LscpException If LSCP protocol corruption occurs.
3743             * @throws LSException If the specified directory is not
3744             * empty or if the removal of the directory failed.
3745             */
3746            public synchronized void
3747            removeDbDirectory(String dir) throws IOException, LscpException, LSException {
3748                    removeDbDirectory(dir, false);
3749            }
3750            
3751            /**
3752             * Removes the specified directory from the instruments database.
3753             * @param dir The absolute path name of the directory to remove.
3754             * @param force If <code>true</code> forces the removal of non-empty
3755             * directory and all its content.
3756             * @throws IOException If some I/O error occurs.
3757             * @throws LscpException If LSCP protocol corruption occurs.
3758             * @throws LSException If the removing of the directory failed.
3759             */
3760            public synchronized void
3761            removeDbDirectory(String dir, boolean force)
3762                                    throws IOException, LscpException, LSException {
3763                    
3764                    verifyConnection();
3765                    String s = "REMOVE DB_INSTRUMENT_DIRECTORY ";
3766                    if(force) s += "FORCE ";
3767                    out.writeLine(s + "'" + dir + "'");
3768                    if(getPrintOnlyMode()) return;
3769                    
3770                    ResultSet rs = getEmptyResultSet();
3771            }
3772            
3773            /**
3774             * Removes the specified directories from the instruments database.
3775             * @param dirs The absolute path names of the directories to remove.
3776             * @param force If <code>true</code> forces the removal of non-empty
3777             * directories.
3778             * @throws IOException If some I/O error occurs.
3779             * @throws LscpException If LSCP protocol corruption occurs.
3780             * @throws LSException If the removing of the directores failed.
3781             */
3782            public synchronized void
3783            removeDbDirectories(String[] dirs, boolean force)
3784                                    throws IOException, LscpException, LSException {
3785                    
3786                    verifyConnection();
3787                    String cmd = "REMOVE DB_INSTRUMENT_DIRECTORY ";
3788                    if(force) cmd += "FORCE ";
3789                    
3790                    for(String s : dirs) out.writeLine(cmd + "'" + s + "'");
3791                    
3792                    if(getPrintOnlyMode()) return;
3793                    
3794                    getEmptyResultSets(dirs.length, "Client.dirDeletionFailed!");
3795            }
3796            
3797            /**
3798             * Gets the number of directories in the specified directory.
3799             * @return The current number of directories in the specified directory.
3800             * @param dir The absolute path name of the directory.
3801             * @throws IOException If some I/O error occurs.
3802             * @throws LscpException If LSCP protocol corruption occurs.
3803             * @throws LSException If some other error occurs.
3804             */
3805            public synchronized int
3806            getDbDirectoryCount(String dir) throws IOException, LscpException, LSException {
3807                    return getDbDirectoryCount(dir, false);
3808            }
3809            
3810            /**
3811             * Gets the number of directories in the specified directory.
3812             * @return The current number of directories in the specified directory.
3813             * @param dir The absolute path name of the directory.
3814             * @param recursive If <code>true</code>, the number of all directories
3815             * in the specified subtree will be returned.
3816             * @throws IOException If some I/O error occurs.
3817             * @throws LscpException If LSCP protocol corruption occurs.
3818             * @throws LSException If some other error occurs.
3819             */
3820            public synchronized int
3821            getDbDirectoryCount(String dir, boolean recursive)
3822                                    throws IOException, LscpException, LSException {
3823                    
3824                    verifyConnection();
3825                    String s;
3826                    if(recursive) s = "GET DB_INSTRUMENT_DIRECTORIES RECURSIVE '";
3827                    else s = "GET DB_INSTRUMENT_DIRECTORIES '";
3828                    out.writeLine(s + dir + "'");
3829                    if(getPrintOnlyMode()) return -1;
3830                    
3831                    s = getSingleLineResultSet().getResult();
3832                    return parseInt(s);
3833            }
3834            
3835            /**
3836             * Gets the list of directories in the specified directory.
3837             * @param dir The absolute path name of the directory.
3838             * @return A <code>String</code> array providing the names of
3839             * all directories in the specified directory.
3840             * @throws IOException If some I/O error occurs.
3841             * @throws LscpException If LSCP protocol corruption occurs.
3842             * @throws LSException If the specified path name is invalid.
3843             */
3844            public synchronized String[]
3845            getDbDirectoryNames(String dir) throws IOException, LscpException, LSException {
3846                    verifyConnection();
3847                    out.writeLine("LIST DB_INSTRUMENT_DIRECTORIES '" + dir + "'");
3848                    if(getPrintOnlyMode()) return null;
3849                    
3850                    return parseStringList(getSingleLineResultSet().getResult());
3851            }
3852            
3853            /**
3854             * Gets information about the specified directory.
3855             * @param dir The absolute path name of the directory.
3856             * @return A <code>DbDirectoryInfo</code> instance providing information
3857             * about the specified directory.
3858             * @throws IOException If some I/O error occurs.
3859             * @throws LscpException If LSCP protocol corruption occurs.
3860             * @throws LSException If the specified directory is not found.
3861             */
3862            public synchronized DbDirectoryInfo
3863            getDbDirectoryInfo(String dir) throws IOException, LscpException, LSException {
3864                    verifyConnection();
3865                    out.writeLine("GET DB_INSTRUMENT_DIRECTORY INFO '" + dir + "'");
3866                    if(getPrintOnlyMode()) return null;
3867                    
3868                    ResultSet rs = getMultiLineResultSet();
3869                    DbDirectoryInfo info = new DbDirectoryInfo(rs.getMultiLineResult());
3870                    if(dir.equals("/")) {
3871                            info.setName("/");
3872                    } else if(dir.length() > 1 && dir.charAt(dir.length() - 1) == '/') {
3873                            dir = dir.substring(0, dir.length() - 1);
3874                    }
3875                    int i = dir.lastIndexOf('/');
3876                    if(i != -1 && i < dir.length() - 1) {
3877                            info.setName(dir.substring(i + 1));
3878                            if(i == 0) info.setParentDirectoryPath("/");
3879                            else info.setParentDirectoryPath(dir.substring(0, i));
3880                    }
3881                    
3882                    return info;
3883            }
3884            
3885            /**
3886             * Gets the list of directories in the specified directory.
3887             * @param dir The absolute path name of the directory.
3888             * @return A <code>DbDirectoryInfo</code> array providing
3889             * information about all directories in the specified directory.
3890             * @throws IOException If some I/O error occurs.
3891             * @throws LscpException If LSCP protocol corruption occurs.
3892             * @throws LSException If the specified path name is invalid.
3893             */
3894            public synchronized DbDirectoryInfo[]
3895            getDbDirectories(String dir) throws IOException, LscpException, LSException {
3896                    String[] dirS = getDbDirectoryNames(dir);
3897                    if(dir.charAt(dir.length() - 1) != '/') dir += "/";
3898                    DbDirectoryInfo[] infoS = new DbDirectoryInfo[dirS.length];
3899                    for(int i = 0; i < dirS.length; i++) infoS[i] = getDbDirectoryInfo(dir + dirS[i]);
3900                    return infoS;
3901            }
3902            
3903            /**
3904             * Gets the list of directories in the specified directory.
3905             * @param dir The absolute path name of the directory.
3906             * @return A <code>DbDirectoryInfo</code> array providing
3907             * information about all directories in the specified directory.
3908             * @throws IOException If some I/O error occurs.
3909             * @throws LscpException If LSCP protocol corruption occurs.
3910             * @throws LSException If the specified path name is invalid.
3911             *
3912            public synchronized DbDirectoryInfo[]
3913            getDbDirectories(String dir) throws IOException, LscpException, LSException {
3914                    String[] dirS = getDbDirectoryNames(dir);
3915                    if(dirS.length == 0) return new DbDirectoryInfo[0];
3916                    
3917                    if(dir.charAt(dir.length() - 1) != '/') dir += "/";
3918                    
3919                    for(int i = 0; i < dirS.length; i++) {
3920                            out.writeLine("GET DB_INSTRUMENT_DIRECTORY INFO '" + dir + dirS[i] + "'");
3921                    }
3922                    
3923                    if(getPrintOnlyMode()) return null;
3924                    
3925                    if(dir.length() > 1) dir = dir.substring(0, dir.length() - 1);
3926                    StringBuffer sb = new StringBuffer();
3927                    DbDirectoryInfo[] infoS = new DbDirectoryInfo[dirS.length];
3928                    for(int i = 0; i < dirS.length; i++) {
3929                            try {
3930                                    ResultSet rs = getMultiLineResultSet();
3931                                    infoS[i] = new DbDirectoryInfo(rs.getMultiLineResult());
3932                                    infoS[i].setName(dirS[i]);
3933                                    infoS[i].setParentDirectoryPath(dir);
3934                            } catch (SocketTimeoutException e) {
3935                                    getLogger().log(Level.FINE, e.getMessage(), e);
3936                                    sb.append(e.getMessage()).append("\n");
3937                                    break;
3938                            } catch (Exception e) {
3939                                    getLogger().log(Level.FINE, e.getMessage(), e);
3940                                    sb.append(e.getMessage()).append("\n");
3941                            }
3942                    }
3943                    
3944                    String details = sb.toString();
3945                    if(details.length() > 0) {
3946                            String err = LscpI18n.getLogMsg("Client.getInstrsInfoFailed!");
3947                            throw new LSException(0, err, details);
3948                    }
3949                    
3950                    return infoS;
3951            }*/
3952            
3953            /**
3954             * Renames the specified directory.
3955             * @param dir The absolute path name of the directory to rename.
3956             * @param name The new name for the directory.
3957             * @throws IOException If some I/O error occurs.
3958             * @throws LSException If the renaming of the directory failed.
3959             * @throws LscpException If LSCP protocol corruption occurs.
3960             */
3961            public synchronized void
3962            renameDbDirectory(String dir, String name) throws IOException, LSException, LscpException {
3963                    verifyConnection();
3964                    out.writeLine("SET DB_INSTRUMENT_DIRECTORY NAME '" + dir + "' '" + name + "'");
3965                    if(getPrintOnlyMode()) return;
3966                    
3967                    ResultSet rs = getEmptyResultSet();
3968            }
3969            
3970            /**
3971             * Moves the specified directory into the specified location.
3972             * @param dir The absolute path name of the directory to move.
3973             * @param dst The location where the directory will be moved to.
3974             * @throws IOException If some I/O error occurs.
3975             * @throws LSException If the operation failed.
3976             * @throws LscpException If LSCP protocol corruption occurs.
3977             */
3978            public synchronized void
3979            moveDbDirectory(String dir, String dst) throws IOException, LSException, LscpException {
3980                    verifyConnection();
3981                    out.writeLine("MOVE DB_INSTRUMENT_DIRECTORY '" + dir + "' '" + dst + "'");
3982                    if(getPrintOnlyMode()) return;
3983                    
3984                    ResultSet rs = getEmptyResultSet();
3985            }
3986            
3987            /**
3988             * Moves the specified directories into the specified location.
3989             * @param dirs The absolute path names of the directories to move.
3990             * @param dst The location where the directories will be moved to.
3991             * @throws IOException If some I/O error occurs.
3992             * @throws LSException If the operation failed.
3993             * @throws LscpException If LSCP protocol corruption occurs.
3994             */
3995            public synchronized void
3996            moveDbDirectories(String dirs[], String dst) throws IOException, LSException, LscpException {
3997                    verifyConnection();
3998                    for(String s : dirs) {
3999                            out.writeLine("MOVE DB_INSTRUMENT_DIRECTORY '" + s + "' '" + dst + "'");
4000                    }
4001                    if(getPrintOnlyMode()) return;
4002                    
4003                    getEmptyResultSets(dirs.length, "Client.dirMovingFailed!");
4004            }
4005            
4006            /**
4007             * Copies the specified directory into the specified location.
4008             * @param dir The absolute path name of the directory to copy.
4009             * @param dst The location where the directory will be copied to.
4010             * @throws IOException If some I/O error occurs.
4011             * @throws LSException If the operation failed.
4012             * @throws LscpException If LSCP protocol corruption occurs.
4013             */
4014            public synchronized void
4015            copyDbDirectory(String dir, String dst) throws IOException, LSException, LscpException {
4016                    verifyConnection();
4017                    out.writeLine("COPY DB_INSTRUMENT_DIRECTORY '" + dir + "' '" + dst + "'");
4018                    if(getPrintOnlyMode()) return;
4019                    
4020                    ResultSet rs = getEmptyResultSet();
4021            }
4022            
4023            /**
4024             * Copies the specified directories into the specified location.
4025             * @param dirs The absolute path names of the directories to copy.
4026             * @param dst The location where the directories will be copied to.
4027             * @throws IOException If some I/O error occurs.
4028             * @throws LSException If the operation failed.
4029             * @throws LscpException If LSCP protocol corruption occurs.
4030             */
4031            public synchronized void
4032            copyDbDirectories(String[] dirs, String dst) throws IOException, LSException, LscpException {
4033                    verifyConnection();
4034                    for(String s : dirs) {
4035                            out.writeLine("COPY DB_INSTRUMENT_DIRECTORY '" + s + "' '" + dst + "'");
4036                    }
4037                    if(getPrintOnlyMode()) return;
4038                    
4039                    getEmptyResultSets(dirs.length, "Client.dirCopyingFailed!");
4040            }
4041            
4042            /**
4043             * Changes the description of the specified directory.
4044             * @param dir The absolute path name of the directory.
4045             * @param desc The new description for the directory.
4046             * @throws IOException If some I/O error occurs.
4047             * @throws LSException If failed to change the description.
4048             * @throws LscpException If LSCP protocol corruption occurs.
4049             */
4050            public synchronized void
4051            setDbDirectoryDescription(String dir, String desc)
4052                                    throws IOException, LSException, LscpException {
4053                    
4054                    verifyConnection();
4055                    String s = "SET DB_INSTRUMENT_DIRECTORY DESCRIPTION '";
4056                    out.writeLine(s + dir + "' '" + desc + "'");
4057                    if(getPrintOnlyMode()) return;
4058                    
4059                    ResultSet rs = getEmptyResultSet();
4060            }
4061            
4062            public static enum ScanMode {
4063                    RECURSIVE, NON_RECURSIVE, FLAT
4064            }
4065            
4066            /**
4067             * Adds the specified instrument to the specified instruments database directory.
4068             * @param dbDir The absolute path name of the database directory in which the
4069             * specified instrument will be added.
4070             * @param filePath The absolute path name of the instrument file.
4071             * @param instrIndex The index of the instrument (in the given instrument file) to add.
4072             * @throws IOException If some I/O error occurs.
4073             * @throws LSException If the operation failed.
4074             * @throws LscpException If LSCP protocol corruption occurs.
4075             */
4076            public synchronized void
4077            addDbInstrument(String dbDir, String filePath, int instrIndex)
4078                                            throws IOException, LSException, LscpException {
4079                    
4080                    addDbInstrument(dbDir, filePath, instrIndex, false);
4081            }
4082            
4083            /**
4084             * Adds the specified instrument to the specified instruments database directory.
4085             * @param dbDir The absolute path name of the database directory in which the
4086             * specified instrument will be added.
4087             * @param filePath The absolute path name of the instrument file.
4088             * @param instrIndex The index of the instrument (in the given instrument file) to add.
4089             * @param background If <code>true</code>, the scan will be done
4090             * in background and this method may return before the job is finished.
4091             * @return If <code>background</code> is <code>true</code>, the ID
4092             * of the scan job.
4093             * @throws IOException If some I/O error occurs.
4094             * @throws LSException If the operation failed.
4095             * @throws LscpException If LSCP protocol corruption occurs.
4096             * @see #addInstrumentsDbListener
4097             */
4098            public synchronized int
4099            addDbInstrument(String dbDir, String filePath, int instrIndex, boolean background)
4100                                            throws IOException, LSException, LscpException {
4101                    
4102                    verifyConnection();
4103                    String s = "ADD DB_INSTRUMENTS";
4104                    if(background) s += " NON_MODAL";
4105                    s += " '" + dbDir + "' '" + filePath + "' ";
4106                    out.writeLine(s + String.valueOf(instrIndex));
4107                    if(getPrintOnlyMode()) return -1;
4108                    
4109                    ResultSet rs = getEmptyResultSet();
4110                    return rs.getIndex();
4111            }
4112            
4113            /**
4114             * Adds the instruments in the specified file to the specified
4115             * instruments database directory.
4116             * @param dbDir The absolute path name of the database directory
4117             * in which the the supported instruments will be added.
4118             * @param filePath The absolute path name of the file to scan for instruments.
4119             * @throws IOException If some I/O error occurs.
4120             * @throws LSException If the operation failed.
4121             * @throws LscpException If LSCP protocol corruption occurs.
4122             */
4123            public synchronized void
4124            addDbInstruments(String dbDir, String filePath)
4125                                            throws IOException, LSException, LscpException {
4126                    
4127                    addDbInstruments(dbDir, filePath, false);
4128            }
4129            
4130            /**
4131             * Adds the instruments in the specified file to the specified
4132             * instruments database directory.
4133             * @param dbDir The absolute path name of the database directory
4134             * in which the the supported instruments will be added.
4135             * @param filePath The absolute path name of the file to scan for instruments.
4136             * @param background If <code>true</code>, the scan will be done
4137             * in background and this method may return before the job is finished.
4138             * @return If <code>background</code> is <code>true</code>, the ID
4139             * of the scan job.
4140             * @throws IOException If some I/O error occurs.
4141             * @throws LSException If the operation failed.
4142             * @throws LscpException If LSCP protocol corruption occurs.
4143             * @see #addInstrumentsDbListener
4144             */
4145            public synchronized int
4146            addDbInstruments(String dbDir, String filePath, boolean background)
4147                                            throws IOException, LSException, LscpException {
4148                    
4149                    verifyConnection();
4150                    String s = "ADD DB_INSTRUMENTS";
4151                    if(background) s += " NON_MODAL";
4152                    out.writeLine(s + " '" + dbDir + "' '" + filePath + "'");
4153                    if(getPrintOnlyMode()) return -1;
4154                    
4155                    ResultSet rs = getEmptyResultSet();
4156                    return rs.getIndex();
4157            }
4158            
4159            /**
4160             * Adds the instruments in the specified file system directory
4161             * to the specified instruments database directory.
4162             * @param mode Determines the scanning mode. If RECURSIVE is
4163             * specified, all supported instruments in the specified file system
4164             * direcotry will be added to the specified instruments database
4165             * directory, including the instruments in subdirectories
4166             * of the supplied directory. If NON_RECURSIVE is specified,
4167             * the instruments in the subdirectories will not be processed.
4168             * If FLAT is specified, all supported instruments in the specified
4169             * file system direcotry will be added, including the instruments in
4170             * subdirectories of the supplied directory, but the respective
4171             * subdirectory structure will not be recreated in the instruments
4172             * database and all instruments will be added directly in the
4173             * specified database directory.
4174             * @param dbDir The absolute path name of the database directory
4175             * in which the supported instruments will be added.
4176             * @param fsDir The absolute path name of the file system directory.
4177             * @throws IOException If some I/O error occurs.
4178             * @throws LSException If the operation failed.
4179             * @throws LscpException If LSCP protocol corruption occurs.
4180             */
4181            public synchronized void
4182            addDbInstruments(ScanMode mode, String dbDir, String fsDir)
4183                                            throws IOException, LSException, LscpException {
4184                    
4185                    addDbInstruments(mode, dbDir, fsDir, false);
4186            }
4187            
4188            /**
4189             * Adds the instruments in the specified file system directory
4190             * to the specified instruments database directory.
4191             * @param mode Determines the scanning mode. If RECURSIVE is
4192             * specified, all supported instruments in the specified file system
4193             * direcotry will be added to the specified instruments database
4194             * directory, including the instruments in subdirectories
4195             * of the supplied directory. If NON_RECURSIVE is specified,
4196             * the instruments in the subdirectories will not be processed.
4197             * If FLAT is specified, all supported instruments in the specified
4198             * file system direcotry will be added, including the instruments in
4199             * subdirectories of the supplied directory, but the respective
4200             * subdirectory structure will not be recreated in the instruments
4201             * database and all instruments will be added directly in the
4202             * specified database directory.
4203             * @param dbDir The absolute path name of the database directory
4204             * in which the supported instruments will be added.
4205             * @param fsDir The absolute path name of the file system directory.
4206             * @param background If <code>true</code>, the scan will be done
4207             * in background and this method may return before the job is finished.
4208             * @return If <code>background</code> is <code>true</code>, the ID
4209             * of the scan job.
4210             * @throws IOException If some I/O error occurs.
4211             * @throws LSException If the operation failed.
4212             * @throws LscpException If LSCP protocol corruption occurs.
4213             * @see #addInstrumentsDbListener
4214             */
4215            public synchronized int
4216            addDbInstruments(ScanMode mode, String dbDir, String fsDir, boolean background)
4217                                            throws IOException, LSException, LscpException {
4218                    
4219                    verifyConnection();
4220                    StringBuffer sb = new StringBuffer("ADD DB_INSTRUMENTS");
4221                    if(background) sb.append(" NON_MODAL");
4222                    
4223                    switch(mode) {
4224                            case RECURSIVE:
4225                                    sb.append(" RECURSIVE");
4226                                    break;
4227                            case NON_RECURSIVE:
4228                                    sb.append(" NON_RECURSIVE");
4229                                    break;
4230                            case FLAT:
4231                                    sb.append(" FLAT");
4232                                    break;
4233                    }
4234                    
4235                    sb.append(" '").append(dbDir).append("' '").append(fsDir).append("'");
4236                    out.writeLine(sb.toString());
4237                    if(getPrintOnlyMode()) return -1;
4238                    
4239                    ResultSet rs = getEmptyResultSet();
4240                    return rs.getIndex();
4241            }
4242            
4243            /**
4244             * Removes the specified instrument from the instruments database.
4245             * @param instr The absolute path name of the instrument to remove.
4246             * @throws IOException If some I/O error occurs.
4247             * @throws LscpException If LSCP protocol corruption occurs.
4248             * @throws LSException If the removing of the instrument failed.
4249             */
4250            public synchronized void
4251            removeDbInstrument(String instr) throws IOException, LscpException, LSException {
4252                    
4253                    verifyConnection();
4254                    out.writeLine("REMOVE DB_INSTRUMENT '" + instr + "'");
4255                    if(getPrintOnlyMode()) return;
4256                    
4257                    ResultSet rs = getEmptyResultSet();
4258            }
4259            
4260            /**
4261             * Removes the specified instruments from the instruments database.
4262             * @param instrs The absolute path names of the instruments to remove.
4263             * @throws IOException If some I/O error occurs.
4264             * @throws LscpException If LSCP protocol corruption occurs.
4265             * @throws LSException If the removing of the instruments failed.
4266             */
4267            public synchronized void
4268            removeDbInstruments(String[] instrs) throws IOException, LscpException, LSException {
4269                    verifyConnection();
4270                    for(String s : instrs) {
4271                            out.writeLine("REMOVE DB_INSTRUMENT '" + s + "'");
4272                    }
4273                    if(getPrintOnlyMode()) return;
4274                    
4275                    getEmptyResultSets(instrs.length, "Client.instrDeletionFailed!");
4276            }
4277            
4278            /**
4279             * Gets the number of instruments in the specified directory.
4280             * @return The current number of instruments in the specified directory.
4281             * @param dir The absolute path name of the directory.
4282             * @throws IOException If some I/O error occurs.
4283             * @throws LscpException If LSCP protocol corruption occurs.
4284             * @throws LSException If some other error occurs.
4285             */
4286            public synchronized int
4287            getDbInstrumentCount(String dir) throws IOException, LscpException, LSException {
4288                    return getDbInstrumentCount(dir, false);
4289            }
4290            
4291            /**
4292             * Gets the number of instruments in the specified directory.
4293             * @return The current number of instruments in the specified directory.
4294             * @param dir The absolute path name of the directory.
4295             * @param recursive If <code>true</code>, the number of all instruments
4296             * in the specified subtree will be returned.
4297             * @throws IOException If some I/O error occurs.
4298             * @throws LscpException If LSCP protocol corruption occurs.
4299             * @throws LSException If some other error occurs.
4300             */
4301            public synchronized int
4302            getDbInstrumentCount(String dir, boolean recursive)
4303                                    throws IOException, LscpException, LSException {
4304                    
4305                    verifyConnection();
4306                    String s;
4307                    if(recursive) s = "GET DB_INSTRUMENTS RECURSIVE '";
4308                    else s = "GET DB_INSTRUMENTS '";
4309                    out.writeLine(s + dir + "'");
4310                    if(getPrintOnlyMode()) return -1;
4311                    
4312                    s = getSingleLineResultSet().getResult();
4313                    return parseInt(s);
4314            }
4315            
4316            /**
4317             * Gets the list of instruments in the specified directory.
4318             * @param dir The absolute path name of the directory.
4319             * @return A <code>String</code> array providing the names of
4320             * all instruments in the specified directory.
4321             * @throws IOException If some I/O error occurs.
4322             * @throws LscpException If LSCP protocol corruption occurs.
4323             * @throws LSException If the specified path name is invalid.
4324             */
4325            public synchronized String[]
4326            getDbInstrumentNames(String dir) throws IOException, LscpException, LSException {
4327                    verifyConnection();
4328                    out.writeLine("LIST DB_INSTRUMENTS '" + dir + "'");
4329                    if(getPrintOnlyMode()) return null;
4330                    
4331                    return parseStringList(getSingleLineResultSet().getResult());
4332            }
4333            
4334            /**
4335             * Gets information about the specified instrument.
4336             * @param instr The absolute path name of the instrument.
4337             * @return A <code>DbInstrumentInfo</code> instance providing information
4338             * about the specified instrument.
4339             * @throws IOException If some I/O error occurs.
4340             * @throws LscpException If LSCP protocol corruption occurs.
4341             * @throws LSException If the specified instrument is not found.
4342             */
4343            public synchronized DbInstrumentInfo
4344            getDbInstrumentInfo(String instr) throws IOException, LscpException, LSException {
4345                    verifyConnection();
4346                    out.writeLine("GET DB_INSTRUMENT INFO '" + instr + "'");
4347                    if(getPrintOnlyMode()) return null;
4348                    
4349                    ResultSet rs = getMultiLineResultSet();
4350                    DbInstrumentInfo info = new DbInstrumentInfo(rs.getMultiLineResult());
4351                    int i = instr.lastIndexOf('/');
4352                    if(i != -1 && i < instr.length() - 1) {
4353                            info.setName(instr.substring(i + 1));
4354                            if(i == 0) info.setDirectoryPath("/");
4355                            else info.setDirectoryPath(instr.substring(0, i));
4356                    }
4357                    
4358                    return info;
4359            }
4360            
4361            /**
4362             * Gets the list of instruments in the specified directory.
4363             * @param dir The absolute path name of the directory.
4364             * @return A <code>DbInstrumentInfo</code> array providing
4365             * information about all instruments in the specified directory.
4366             * @throws IOException If some I/O error occurs.
4367             * @throws LscpException If LSCP protocol corruption occurs.
4368             * @throws LSException If the specified path name is invalid.
4369             */
4370            public synchronized DbInstrumentInfo[]
4371            getDbInstruments(String dir) throws IOException, LscpException, LSException {
4372                    String[] instrS = getDbInstrumentNames(dir);
4373                    if(dir.charAt(dir.length() - 1) != '/') dir += "/";
4374                    
4375                    DbInstrumentInfo[] infoS = new DbInstrumentInfo[instrS.length];
4376                    for(int i = 0; i < instrS.length; i++) {
4377                            infoS[i] = getDbInstrumentInfo(dir + instrS[i]);
4378                    }
4379                    return infoS;
4380            }
4381            
4382            /**
4383             * Gets the list of instruments in the specified directory.
4384             * @param dir The absolute path name of the directory.
4385             * @return A <code>DbInstrumentInfo</code> array providing
4386             * information about all instruments in the specified directory.
4387             * @throws IOException If some I/O error occurs.
4388             * @throws LscpException If LSCP protocol corruption occurs.
4389             * @throws LSException If the specified path name is invalid.
4390             *
4391            public synchronized DbInstrumentInfo[]
4392            getDbInstruments(String dir) throws IOException, LscpException, LSException {
4393                    String[] instrS = getDbInstrumentNames(dir);
4394                    if(instrS.length == 0) return new DbInstrumentInfo[0];
4395                    
4396                    if(dir.charAt(dir.length() - 1) != '/') dir += "/";
4397                    
4398                    for(int i = 0; i < instrS.length; i++) {
4399                            out.writeLine("GET DB_INSTRUMENT INFO '" + dir + instrS[i] + "'");
4400                    }
4401                    
4402                    if(getPrintOnlyMode()) return null;
4403                    
4404                    if(dir.length() > 1) dir = dir.substring(0, dir.length() - 1);
4405                    StringBuffer sb = new StringBuffer();
4406                    DbInstrumentInfo[] infoS = new DbInstrumentInfo[instrS.length];
4407                    for(int i = 0; i < instrS.length; i++) {
4408                            try {
4409                                    ResultSet rs = getMultiLineResultSet();
4410                                    infoS[i] = new DbInstrumentInfo(rs.getMultiLineResult());
4411                                    infoS[i].setName(instrS[i]);
4412                                    infoS[i].setDirectoryPath(dir);
4413                            } catch (SocketTimeoutException e) {
4414                                    getLogger().log(Level.FINE, e.getMessage(), e);
4415                                    sb.append(e.getMessage()).append("\n");
4416                                    break;
4417                            } catch (Exception e) {
4418                                    getLogger().log(Level.FINE, e.getMessage(), e);
4419                                    sb.append(e.getMessage()).append("\n");
4420                            }
4421                    }
4422                    
4423                    String details = sb.toString();
4424                    if(details.length() > 0) {
4425                            String err = LscpI18n.getLogMsg("Client.getInstrsInfoFailed!");
4426                            throw new LSException(0, err, details);
4427                    }
4428                    
4429                    return infoS;
4430            }*/
4431            
4432            /**
4433             * Renames the specified instrument.
4434             * @param instr The absolute path name of the instrument to rename.
4435             * @param name The new name for the instrument.
4436             * @throws IOException If some I/O error occurs.
4437             * @throws LSException If the renaming of the instrument failed.
4438             * @throws LscpException If LSCP protocol corruption occurs.
4439             */
4440            public synchronized void
4441            renameDbInstrument(String instr, String name)
4442                                    throws IOException, LSException, LscpException {
4443                    
4444                    verifyConnection();
4445                    out.writeLine("SET DB_INSTRUMENT NAME '" + instr + "' '" + name + "'");
4446                    if(getPrintOnlyMode()) return;
4447                    
4448                    ResultSet rs = getEmptyResultSet();
4449            }
4450            
4451            /**
4452             * Moves the specified instrument into the specified location.
4453             * @param instr The absolute path name of the instrument to move.
4454             * @param dst The directory where the specified instrument will be moved to.
4455             * @throws IOException If some I/O error occurs.
4456             * @throws LSException If the operation failed.
4457             * @throws LscpException If LSCP protocol corruption occurs.
4458             */
4459            public synchronized void
4460            moveDbInstrument(String instr, String dst) throws IOException, LSException, LscpException {
4461                    verifyConnection();
4462                    out.writeLine("MOVE DB_INSTRUMENT '" + instr + "' '" + dst + "'");
4463                    if(getPrintOnlyMode()) return;
4464                    
4465                    ResultSet rs = getEmptyResultSet();
4466            }
4467            
4468            /**
4469             * Moves the specified instruments into the specified location.
4470             * @param instrs The absolute path names of the instruments to move.
4471             * @param dst The directory where the specified instruments will be moved to.
4472             * @throws IOException If some I/O error occurs.
4473             * @throws LSException If the operation failed.
4474             * @throws LscpException If LSCP protocol corruption occurs.
4475             */
4476            public synchronized void
4477            moveDbInstruments(String[] instrs, String dst) throws IOException, LSException, LscpException {
4478                    verifyConnection();
4479                    for(String s : instrs) {
4480                            out.writeLine("MOVE DB_INSTRUMENT '" + s + "' '" + dst + "'");
4481                    }
4482                    if(getPrintOnlyMode()) return;
4483                    
4484                    getEmptyResultSets(instrs.length, "Client.instrMovingFailed!");
4485            }
4486            
4487            /**
4488             * Copies the specified instrument into the specified location.
4489             * @param instr The absolute path name of the instrument to copy.
4490             * @param dst The directory where the specified instrument will be copied to.
4491             * @throws IOException If some I/O error occurs.
4492             * @throws LSException If the operation failed.
4493             * @throws LscpException If LSCP protocol corruption occurs.
4494             */
4495            public synchronized void
4496            copyDbInstrument(String instr, String dst) throws IOException, LSException, LscpException {
4497                    verifyConnection();
4498                    out.writeLine("COPY DB_INSTRUMENT '" + instr + "' '" + dst + "'");
4499                    if(getPrintOnlyMode()) return;
4500                    
4501                    ResultSet rs = getEmptyResultSet();
4502            }
4503            
4504            /**
4505             * Copies the specified instruments into the specified location.
4506             * @param instrs The absolute path name of the instruments to copy.
4507             * @param dst The directory where the specified instruments will be copied to.
4508             * @throws IOException If some I/O error occurs.
4509             * @throws LSException If the operation failed.
4510             * @throws LscpException If LSCP protocol corruption occurs.
4511             */
4512            public synchronized void
4513            copyDbInstruments(String[] instrs, String dst) throws IOException, LSException, LscpException {
4514                    verifyConnection();
4515                    for(String s : instrs) {
4516                            out.writeLine("COPY DB_INSTRUMENT '" + s + "' '" + dst + "'");
4517                    }
4518                    if(getPrintOnlyMode()) return;
4519                    
4520                    getEmptyResultSets(instrs.length, "Client.instrCopyingFailed!");
4521            }
4522            
4523            /**
4524             * Changes the description of the specified instrument.
4525             * @param instr The absolute path name of the instrument.
4526             * @param desc The new description for the instrument.
4527             * @throws IOException If some I/O error occurs.
4528             * @throws LSException If failed to change the description.
4529             * @throws LscpException If LSCP protocol corruption occurs.
4530             */
4531            public synchronized void
4532            setDbInstrumentDescription(String instr, String desc)
4533                                    throws IOException, LSException, LscpException {
4534                    
4535                    verifyConnection();
4536                    out.writeLine("SET DB_INSTRUMENT DESCRIPTION '" + instr + "' '" + desc + "'");
4537                    if(getPrintOnlyMode()) return;
4538                    
4539                    ResultSet rs = getEmptyResultSet();
4540            }
4541            
4542            /**
4543             * Finds all directories in the specified directory
4544             * that corresponds to the specified search criterias.
4545             * @param dir The absolute path name of the directory to search.
4546             * @param query Provides the search criterias.
4547             * @return A <code>DbDirectoryInfo</code> array providing
4548             * information about all directories that are found in the specified directory.
4549             * @throws IOException If some I/O error occurs.
4550             * @throws LscpException If LSCP protocol corruption occurs.
4551             * @throws LSException If the specified path name is invalid.
4552             */
4553            public synchronized DbDirectoryInfo[]
4554            findDbDirectories(String dir, DbSearchQuery query)
4555                                    throws IOException, LscpException, LSException {
4556                    
4557                    return findDbDirectories(dir, query, false);
4558            }
4559            
4560            /**
4561             * Finds all directories in the specified directory
4562             * that corresponds to the specified search criterias.
4563             * @param dir The absolute path name of the directory to search.
4564             * @param query Provides the search criterias.
4565             * @param nonRecursive If <code>true</code>, the search will be non-recursive.
4566             * @return A <code>DbDirectoryInfo</code> array providing
4567             * information about all directories that are found in the specified directory.
4568             * @throws IOException If some I/O error occurs.
4569             * @throws LscpException If LSCP protocol corruption occurs.
4570             * @throws LSException If the specified path name is invalid.
4571             */
4572            public synchronized DbDirectoryInfo[]
4573            findDbDirectories(String dir, DbSearchQuery query, boolean nonRecursive)
4574                                    throws IOException, LscpException, LSException {
4575                    
4576                    verifyConnection();
4577                    StringBuffer sb = new StringBuffer();
4578                    sb.append("FIND DB_INSTRUMENT_DIRECTORIES");
4579                    if(nonRecursive) sb.append(" NON_RECURSIVE");
4580                    sb.append(" '").append(dir).append("'");
4581                    
4582                    if(query.name != null && query.name.length() > 0) {
4583                            sb.append(" NAME='").append(query.name).append("'");
4584                    }
4585                    
4586                    String s = query.getCreatedAfter();
4587                    String s2 = query.getCreatedBefore();
4588                    if(s != null || s2 != null) {
4589                            sb.append(" CREATED='");
4590                            if(s != null) sb.append(s);
4591                            sb.append("..");
4592                            if(s2 != null) sb.append(s2);
4593                            sb.append("'");
4594                    }
4595                    
4596                    s = query.getModifiedAfter();
4597                    s2 = query.getModifiedBefore();
4598                    if(s != null || s2 != null) {
4599                            sb.append(" MODIFIED='");
4600                            if(s != null) sb.append(s);
4601                            sb.append("..");
4602                            if(s2 != null) sb.append(s2);
4603                            sb.append("'");
4604                    }
4605                    
4606                    if(query.description != null && query.description.length() > 0) {
4607                            sb.append(" DESCRIPTION='").append(query.description).append("'");
4608                    }
4609                    
4610                    out.writeLine(sb.toString());
4611                    if(getPrintOnlyMode()) return null;
4612                    
4613                    String[] dirS = parseStringList(getSingleLineResultSet().getResult());
4614                    
4615                    DbDirectoryInfo[] infoS = new DbDirectoryInfo[dirS.length];
4616                    for(int i = 0; i < dirS.length; i++) {
4617                            infoS[i] = getDbDirectoryInfo(dirS[i]);
4618                    }
4619                    return infoS;
4620            }
4621            
4622            /**
4623             * Finds all instruments in the specified directory
4624             * that corresponds to the specified search criterias.
4625             * @param dir The absolute path name of the directory to search.
4626             * @param query Provides the search criterias.
4627             * @return A <code>DbInstrumentInfo</code> array providing
4628             * information about all instruments that are found in the specified directory.
4629             * @throws IOException If some I/O error occurs.
4630             * @throws LscpException If LSCP protocol corruption occurs.
4631             * @throws LSException If the specified path name is invalid.
4632             */
4633            public synchronized DbInstrumentInfo[]
4634            findDbInstruments(String dir, DbSearchQuery query)
4635                                    throws IOException, LscpException, LSException {
4636                    
4637                    return findDbInstruments(dir, query, false);
4638            }
4639            
4640            /**
4641             * Finds all instruments in the specified directory
4642             * that corresponds to the specified search criterias.
4643             * @param dir The absolute path name of the directory to search.
4644             * @param query Provides the search criterias.
4645             * @param nonRecursive If <code>true</code>, the search will be non-recursive.
4646             * @return A <code>DbInstrumentInfo</code> array providing
4647             * information about all instruments that are found in the specified directory.
4648             * @throws IOException If some I/O error occurs.
4649             * @throws LscpException If LSCP protocol corruption occurs.
4650             * @throws LSException If the specified path name is invalid.
4651             */
4652            public synchronized DbInstrumentInfo[]
4653            findDbInstruments(String dir, DbSearchQuery query, boolean nonRecursive)
4654                                    throws IOException, LscpException, LSException {
4655                    
4656                    verifyConnection();
4657                    StringBuffer sb = new StringBuffer();
4658                    sb.append("FIND DB_INSTRUMENTS");
4659                    if(nonRecursive) sb.append(" NON_RECURSIVE");
4660                    sb.append(" '").append(dir).append("'");
4661                    
4662                    if(query.name != null && query.name.length() > 0) {
4663                            sb.append(" NAME='").append(query.name).append("'");
4664                    }
4665                    
4666                    if(query.formatFamilies.size() > 0) {
4667                            sb.append(" FORMAT_FAMILIES='").append(query.formatFamilies.get(0));
4668                            for(int i = 1; i < query.formatFamilies.size(); i++) {
4669                                    sb.append(',').append(query.formatFamilies.get(i));
4670                            }
4671                            sb.append("'");
4672                    }
4673                    
4674                    if(query.minSize != -1 || query.maxSize != -1) {
4675                            sb.append(" SIZE='");
4676                            if(query.minSize != -1) sb.append(query.minSize);
4677                            sb.append("..");
4678                            if(query.maxSize != -1) sb.append(query.maxSize);
4679                            sb.append("'");
4680                    }
4681                    
4682                    String s = query.getCreatedAfter();
4683                    String s2 = query.getCreatedBefore();
4684                    if(s != null || s2 != null) {
4685                            sb.append(" CREATED='");
4686                            if(s != null) sb.append(s);
4687                            sb.append("..");
4688                            if(s2 != null) sb.append(s2);
4689                            sb.append("'");
4690                    }
4691                    
4692                    s = query.getModifiedAfter();
4693                    s2 = query.getModifiedBefore();
4694                    if(s != null || s2 != null) {
4695                            sb.append(" MODIFIED='");
4696                            if(s != null) sb.append(s);
4697                            sb.append("..");
4698                            if(s2 != null) sb.append(s2);
4699                            sb.append("'");
4700                    }
4701                    
4702                    if(query.description != null && query.description.length() > 0) {
4703                            sb.append(" DESCRIPTION='").append(query.description).append("'");
4704                    }
4705                    
4706                    if(query.instrumentType != DbSearchQuery.InstrumentType.BOTH) {
4707                            sb.append(" IS_DRUM=");
4708                            if(query.instrumentType == DbSearchQuery.InstrumentType.DRUM) {
4709                                    sb.append("'true'");
4710                            } else {
4711                                    sb.append("'false'");
4712                            }
4713                    }
4714                    
4715                    if(query.product != null && query.product.length() > 0) {
4716                            sb.append(" PRODUCT='").append(query.product).append("'");
4717                    }
4718                    
4719                    if(query.artists != null && query.artists.length() > 0) {
4720                            sb.append(" ARTISTS='").append(query.artists).append("'");
4721                    }
4722                    
4723                    if(query.keywords != null && query.keywords.length() > 0) {
4724                            sb.append(" KEYWORDS='").append(query.keywords).append("'");
4725                    }
4726                    
4727                    out.writeLine(sb.toString());
4728                    if(getPrintOnlyMode()) return null;
4729                    
4730                    String[] instrS = parseStringList(getSingleLineResultSet().getResult());
4731                    
4732                    DbInstrumentInfo[] infoS = new DbInstrumentInfo[instrS.length];
4733                    for(int i = 0; i < instrS.length; i++) {
4734                            infoS[i] = getDbInstrumentInfo(instrS[i]);
4735                    }
4736                    return infoS;
4737            }
4738            
4739            /**
4740             * Gets status information about the specified job.
4741             * @param jobId The ID of the job.
4742             * @return A <code>ScanJobInfo</code> instance providing information
4743             * about the specified job.
4744             * @throws IOException If some I/O error occurs.
4745             * @throws LscpException If LSCP protocol corruption occurs.
4746             * @throws LSException If the specified job is not found.
4747             */
4748            public synchronized ScanJobInfo
4749            getDbInstrumentsJobInfo(int jobId) throws IOException, LscpException, LSException {
4750                    verifyConnection();
4751                    out.writeLine("GET DB_INSTRUMENTS_JOB INFO " + String.valueOf(jobId));
4752                    if(getPrintOnlyMode()) return null;
4753                    
4754                    ResultSet rs = getMultiLineResultSet();
4755                    ScanJobInfo info = new ScanJobInfo(rs.getMultiLineResult());
4756                    
4757                    return info;
4758            }
4759            
4760            /**
4761           * Resets the specified sampler channel.           * Resets the specified sampler channel.
4762           *           *
4763           * @param samplerChn The sampler channel number.           * @param samplerChn The sampler channel number.
# Line 2358  public class Client { Line 4772  public class Client {
4772          resetChannel(int samplerChn) throws IOException, LscpException, LSException {          resetChannel(int samplerChn) throws IOException, LscpException, LSException {
4773                  verifyConnection();                  verifyConnection();
4774                  out.writeLine("RESET CHANNEL " + samplerChn);                  out.writeLine("RESET CHANNEL " + samplerChn);
4775                    if(getPrintOnlyMode()) return;
4776                                    
4777                  ResultSet rs = getEmptyResultSet();                  ResultSet rs = getEmptyResultSet();
4778          }          }
# Line 2372  public class Client { Line 4787  public class Client {
4787          resetSampler() throws IOException, LscpException {          resetSampler() throws IOException, LscpException {
4788                  verifyConnection();                  verifyConnection();
4789                  out.writeLine("RESET");                  out.writeLine("RESET");
4790                    if(getPrintOnlyMode()) return;
4791                    
4792                  try { ResultSet rs = getEmptyResultSet(); }                  try { ResultSet rs = getEmptyResultSet(); }
4793                  catch(LSException x) { getLogger().warning(x.getMessage()); }                  catch(LSException x) { getLogger().warning(x.getMessage()); }
4794          }          }
# Line 2387  public class Client { Line 4804  public class Client {
4804          getTotalVoiceCount() throws IOException, LscpException, LSException {          getTotalVoiceCount() throws IOException, LscpException, LSException {
4805                  verifyConnection();                  verifyConnection();
4806                  out.writeLine("GET TOTAL_VOICE_COUNT");                  out.writeLine("GET TOTAL_VOICE_COUNT");
4807                    if(getPrintOnlyMode()) return -1;
4808                    
4809                  String s = getSingleLineResultSet().getResult();                  String s = getSingleLineResultSet().getResult();
4810                  return parseInt(s);                  return parseInt(s);
4811          }          }
# Line 2402  public class Client { Line 4821  public class Client {
4821          getTotalVoiceCountMax() throws IOException, LscpException, LSException {          getTotalVoiceCountMax() throws IOException, LscpException, LSException {
4822                  verifyConnection();                  verifyConnection();
4823                  out.writeLine("GET TOTAL_VOICE_COUNT_MAX");                  out.writeLine("GET TOTAL_VOICE_COUNT_MAX");
4824                    if(getPrintOnlyMode()) return -1;
4825                    
4826                  String s = getSingleLineResultSet().getResult();                  String s = getSingleLineResultSet().getResult();
4827                  return parseInt(s);                  return parseInt(s);
4828          }          }
# Line 2420  public class Client { Line 4841  public class Client {
4841          getServerInfo() throws IOException, LscpException, LSException {          getServerInfo() throws IOException, LscpException, LSException {
4842                  verifyConnection();                  verifyConnection();
4843                  out.writeLine("GET SERVER INFO");                  out.writeLine("GET SERVER INFO");
4844                    if(getPrintOnlyMode()) return null;
4845                    
4846                  ResultSet rs = getMultiLineResultSet();                  ResultSet rs = getMultiLineResultSet();
4847                  return new ServerInfo(rs.getMultiLineResult());                  return new ServerInfo(rs.getMultiLineResult());
4848          }          }
4849                    
4850          /**          /**
4851             * Gets the golobal volume of the sampler.
4852             * @return The golobal volume of the sampler.
4853             * @throws IOException If some I/O error occurs.
4854             * @throws LscpException If LSCP protocol corruption occurs.
4855             * @throws LSException If some other error occurs.
4856             */
4857            public synchronized float
4858            getVolume() throws IOException, LscpException, LSException {
4859                    verifyConnection();
4860                    out.writeLine("GET VOLUME");
4861                    if(getPrintOnlyMode()) return -1;
4862                    
4863                    String s = getSingleLineResultSet().getResult();
4864                    return parseFloat(s);
4865            }
4866            
4867            /**
4868             * Sets the global volume of the sampler.
4869             * @param volume The new volume value.
4870             * @throws IOException If some I/O error occurs.
4871             * @throws LscpException If LSCP protocol corruption occurs.
4872             * @throws LSException If some other error occurs.
4873             * @see #getVolume
4874             */
4875            public synchronized void
4876            setVolume(float volume) throws IOException, LscpException, LSException {
4877            
4878                    verifyConnection();
4879                    out.writeLine("SET VOLUME " + volume);
4880                    if(getPrintOnlyMode()) return;
4881                    
4882                    ResultSet rs = getEmptyResultSet();
4883            }
4884            
4885            private void
4886            getEmptyResultSets(int count, String err) throws LSException {
4887                    StringBuffer sb = new StringBuffer();
4888                    for(int i = 0; i < count; i++) {
4889                            try { getEmptyResultSet(); }
4890                            catch (SocketTimeoutException e) {
4891                                    getLogger().log(Level.FINE, e.getMessage(), e);
4892                                    sb.append(e.getMessage()).append("\n");
4893                                    break;
4894                            } catch (Exception e) {
4895                                    getLogger().log(Level.FINE, e.getMessage(), e);
4896                                    sb.append(e.getMessage()).append("\n");
4897                            }
4898                    }
4899                    
4900                    String details = sb.toString();
4901                    if(details.length() > 0) {
4902                            String s = LscpI18n.getLogMsg(err);
4903                            throw new LSException(0, s, details);
4904                    }
4905            }
4906            
4907            /**
4908           * Returns the logger for this library.           * Returns the logger for this library.
4909           * @return The logger for this library.           * @return The logger for this library.
4910           */           */

Legend:
Removed from v.784  
changed lines
  Added in v.1202

  ViewVC Help
Powered by ViewVC