/[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 1421 by iliev, Sun Oct 14 18:08:45 2007 UTC revision 1539 by iliev, Mon Dec 3 22:59:39 2007 UTC
# Line 2216  public class Client { Line 2216  public class Client {
2216                                  mid.setActive(Boolean.parseBoolean(s));                                  mid.setActive(Boolean.parseBoolean(s));
2217                          } else if(s.startsWith("PORTS: ")) {                          } else if(s.startsWith("PORTS: ")) {
2218                                  s = s.substring("PORTS: ".length());                                  s = s.substring("PORTS: ".length());
2219                                  int ports = Parser.parseInt(s);                                  
2220                                  MidiPort[] midiPorts = new MidiPort[ports > 0 ? ports : 0];                                  Parameter<Integer> ports = (Parameter<Integer>)
2221                                            getMidiInputDriverParameterInfo(drv, "PORTS");
2222                                    
2223                                    ports.parseValue(s);
2224                                    mid.setPortsParameter(ports);
2225                                    
2226                                    int j = ports.getValue();
2227                                    MidiPort[] midiPorts = new MidiPort[j > 0 ? j : 0];
2228                                                                    
2229                                  for(int i = 0; i < midiPorts.length; i++)                                  for(int i = 0; i < midiPorts.length; i++)
2230                                          midiPorts[i] = getMidiInputPortInfo(deviceId, i);                                          midiPorts[i] = getMidiInputPortInfo(deviceId, i);
# Line 4952  public class Client { Line 4959  public class Client {
4959                  ResultSet rs = getEmptyResultSet();                  ResultSet rs = getEmptyResultSet();
4960          }          }
4961                    
4962            /**
4963             * Gets the number of instruments in the specified instrument file.
4964             * @param filename The absolute path name of the instrument file.
4965             * @return The number of instruments in the specified instrument file.
4966             * @throws IOException If some I/O error occurs.
4967             * @throws LscpException If LSCP protocol corruption occurs.
4968             * @throws LSException If the file is not found, or other error occur.
4969             */
4970            public synchronized int
4971            getFileInstrumentCount(String filename) throws IOException, LscpException, LSException {
4972                    verifyConnection();
4973                    out.writeLine("GET FILE INSTRUMENTS '" + filename +"'");
4974                    if(getPrintOnlyMode()) return -1;
4975                    
4976                    String s = getSingleLineResultSet().getResult();
4977                    return parseInt(s);
4978            }
4979            
4980            /**
4981             * Gets information about the instrument with index
4982             * <code>instrIdx</code> in the specified instrument file.
4983             * @param filename The absolute path name of the instrument file.
4984             * @param instrIdx The index of the instrument in the specified instrument file.
4985             * @throws IOException If some I/O error occurs.
4986             * @throws LscpException If LSCP protocol corruption occurs.
4987             * @throws LSException If failed to retrieve information.
4988             */
4989            public synchronized Instrument
4990            getFileInstrumentInfo(String filename, int instrIdx)
4991                                    throws IOException, LscpException, LSException {
4992                    
4993                    verifyConnection();
4994                    out.writeLine("GET FILE INSTRUMENT INFO '" + filename + "' " + String.valueOf(instrIdx));
4995                    if(getPrintOnlyMode()) return null;
4996                    
4997                    ResultSet rs = getMultiLineResultSet();
4998                    Instrument instr = new FileInstrument(rs.getMultiLineResult()) { };
4999                    
5000                    return instr;
5001            }
5002            
5003            /**
5004             * Gets the list of instruments in the specified instrument file.
5005             * @param filename The absolute path name of the instrument file.
5006             * @return An <code>Instrument</code> array providing
5007             * information about all instruments in the specified instrument file.
5008             * @throws IOException If some I/O error occurs.
5009             * @throws LscpException If LSCP protocol corruption occurs.
5010             * @throws LSException If the specified file name is invalid.
5011             */
5012            public synchronized Instrument[]
5013            getFileInstruments(String filename) throws IOException, LscpException, LSException {
5014                    int l = getFileInstrumentCount(filename);
5015                    if(l < 0) return null;
5016                    Instrument[] instrS = new FileInstrument[l];
5017                    
5018                    for(int i = 0; i < instrS.length; i++) {
5019                            instrS[i] = getFileInstrumentInfo(filename, i);
5020                    }
5021                    return instrS;
5022            }
5023            
5024            private static class FileInstrument extends AbstractInstrument {
5025                    FileInstrument(String[] resultSet) throws LscpException {
5026                            super(resultSet);
5027                    }
5028                    
5029                    public String
5030                    getEngine() {
5031                            // TODO: engine lookup?
5032                            return getFormatFamily();
5033                    }
5034                    
5035                    public boolean
5036                    parse(String s) throws LscpException {
5037                            if(s.startsWith("PRODUCT: ") || s.startsWith("ARTISTS: ")) return true;
5038                            return super.parse(s);
5039                    }
5040            }
5041            
5042          private void          private void
5043          getEmptyResultSets(int count, String err) throws LSException {          getEmptyResultSets(int count, String err) throws LSException {
5044                  StringBuffer sb = new StringBuffer();                  StringBuffer sb = new StringBuffer();

Legend:
Removed from v.1421  
changed lines
  Added in v.1539

  ViewVC Help
Powered by ViewVC