34 |
import java.util.logging.Level; |
import java.util.logging.Level; |
35 |
import java.util.logging.Logger; |
import java.util.logging.Logger; |
36 |
|
|
|
import static org.linuxsampler.lscp.Parser.*; |
|
37 |
import org.linuxsampler.lscp.event.*; |
import org.linuxsampler.lscp.event.*; |
38 |
|
|
39 |
|
import static org.linuxsampler.lscp.Parser.*; |
40 |
|
|
41 |
|
|
42 |
/** |
/** |
43 |
* 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 |
543 |
if(s.startsWith("NAME ")) { |
if(s.startsWith("NAME ")) { |
544 |
String[] list; |
String[] list; |
545 |
try { |
try { |
546 |
list = parseStringList(s.substring("NAME ".length()), ' '); |
s = s.substring("NAME ".length()); |
547 |
|
list = parseEscapedStringList(s, ' '); |
548 |
if(list.length != 2) throw new LscpException(); |
if(list.length != 2) throw new LscpException(); |
549 |
|
list[1] = toNonEscapedString(list[1]); |
550 |
e = new InstrumentsDbEvent(this, list[0], list[1]); |
e = new InstrumentsDbEvent(this, list[0], list[1]); |
551 |
for(InstrumentsDbListener l : llID) { |
for(InstrumentsDbListener l : llID) { |
552 |
l.directoryNameChanged(e); |
l.directoryNameChanged(e); |
572 |
if(s.startsWith("NAME ")) { |
if(s.startsWith("NAME ")) { |
573 |
String[] list; |
String[] list; |
574 |
try { |
try { |
575 |
list = parseStringList(s.substring("NAME ".length()), ' '); |
s = s.substring("NAME ".length()); |
576 |
|
list = parseEscapedStringList(s, ' '); |
577 |
if(list.length != 2) throw new LscpException(); |
if(list.length != 2) throw new LscpException(); |
578 |
|
list[1] = toNonEscapedString(list[1]); |
579 |
e = new InstrumentsDbEvent(this, list[0], list[1]); |
e = new InstrumentsDbEvent(this, list[0], list[1]); |
580 |
for(InstrumentsDbListener l : llID) { |
for(InstrumentsDbListener l : llID) { |
581 |
l.instrumentNameChanged(e); |
l.instrumentNameChanged(e); |
1360 |
/** |
/** |
1361 |
* Gets detailed information about a specific audio output driver. |
* Gets detailed information about a specific audio output driver. |
1362 |
* @param driverName The name of the audio output driver. |
* @param driverName The name of the audio output driver. |
1363 |
* |
* @param depList An optional list of dependences parameters. |
1364 |
* @return An <code>AudioOutputDriver</code> object containing |
* @return An <code>AudioOutputDriver</code> object containing |
1365 |
* information about the specified audio output driver. |
* information about the specified audio output driver. |
1366 |
* |
* |
1370 |
* |
* |
1371 |
* @see #getAudioOutputDriverNames |
* @see #getAudioOutputDriverNames |
1372 |
*/ |
*/ |
1373 |
private synchronized AudioOutputDriver |
public synchronized AudioOutputDriver |
1374 |
getAudioOutputDriverInfo(String driverName) throws IOException, LscpException, LSException { |
getAudioOutputDriverInfo(String driverName, Parameter... depList) |
1375 |
|
throws IOException, LscpException, LSException { |
1376 |
|
|
1377 |
verifyConnection(); |
verifyConnection(); |
1378 |
out.writeLine("GET AUDIO_OUTPUT_DRIVER INFO " + driverName); |
out.writeLine("GET AUDIO_OUTPUT_DRIVER INFO " + driverName); |
1379 |
if(getPrintOnlyMode()) return null; |
if(getPrintOnlyMode()) return null; |
1383 |
aod.setName(driverName); |
aod.setName(driverName); |
1384 |
|
|
1385 |
for(String s : aod.getParameterNames()) |
for(String s : aod.getParameterNames()) |
1386 |
aod.addParameter(getAudioOutputDriverParameterInfo(driverName, s)); |
aod.addParameter(getAudioOutputDriverParameterInfo(driverName, s, depList)); |
1387 |
|
|
1388 |
return aod; |
return aod; |
1389 |
} |
} |
1417 |
StringBuffer args = new StringBuffer(driver); |
StringBuffer args = new StringBuffer(driver); |
1418 |
args.append(' ').append(param); |
args.append(' ').append(param); |
1419 |
|
|
1420 |
for(Parameter p : deplist) |
for(Parameter p : deplist) { |
1421 |
|
if(p.getValue() == null) continue; |
1422 |
args.append(' ').append(p.getName()).append('=').append(p.getStringValue()); |
args.append(' ').append(p.getName()).append('=').append(p.getStringValue()); |
1423 |
|
} |
1424 |
|
|
1425 |
out.writeLine("GET AUDIO_OUTPUT_DRIVER_PARAMETER INFO " + args.toString()); |
out.writeLine("GET AUDIO_OUTPUT_DRIVER_PARAMETER INFO " + args.toString()); |
1426 |
if(getPrintOnlyMode()) return null; |
if(getPrintOnlyMode()) return null; |
1481 |
verifyConnection(); |
verifyConnection(); |
1482 |
StringBuffer args = new StringBuffer(aoDriver); |
StringBuffer args = new StringBuffer(aoDriver); |
1483 |
|
|
1484 |
for(Parameter p : paramList) |
for(Parameter p : paramList) { |
1485 |
|
if(p.getValue() == null) continue; |
1486 |
args.append(' ').append(p.getName()).append('=').append(p.getStringValue()); |
args.append(' ').append(p.getName()).append('=').append(p.getStringValue()); |
1487 |
|
} |
1488 |
|
|
1489 |
out.writeLine("CREATE AUDIO_OUTPUT_DEVICE " + args.toString()); |
out.writeLine("CREATE AUDIO_OUTPUT_DEVICE " + args.toString()); |
1490 |
if(getPrintOnlyMode()) return -1; |
if(getPrintOnlyMode()) return -1; |
1945 |
/** |
/** |
1946 |
* Gets detailed information about a specific MIDI input driver. |
* Gets detailed information about a specific MIDI input driver. |
1947 |
* @param driverName The name of the MIDI input driver. |
* @param driverName The name of the MIDI input driver. |
1948 |
* |
* @param depList An optional list of dependences parameters. |
1949 |
* @return A <code>MidiInputDriver</code> object containing |
* @return A <code>MidiInputDriver</code> object containing |
1950 |
* information about the specified MIDI input driver. |
* information about the specified MIDI input driver. |
1951 |
* |
* |
1955 |
* |
* |
1956 |
* @see #getMidiInputDriverNames |
* @see #getMidiInputDriverNames |
1957 |
*/ |
*/ |
1958 |
private synchronized MidiInputDriver |
public synchronized MidiInputDriver |
1959 |
getMidiInputDriverInfo(String driverName) throws IOException, LscpException, LSException { |
getMidiInputDriverInfo(String driverName, Parameter... depList) |
1960 |
|
throws IOException, LscpException, LSException { |
1961 |
|
|
1962 |
verifyConnection(); |
verifyConnection(); |
1963 |
out.writeLine("GET MIDI_INPUT_DRIVER INFO " + driverName); |
out.writeLine("GET MIDI_INPUT_DRIVER INFO " + driverName); |
1964 |
if(getPrintOnlyMode()) return null; |
if(getPrintOnlyMode()) return null; |
1969 |
mid.setName(driverName); |
mid.setName(driverName); |
1970 |
|
|
1971 |
for(String s : mid.getParameterNames()) |
for(String s : mid.getParameterNames()) |
1972 |
mid.addParameter(getMidiInputDriverParameterInfo(driverName, s)); |
mid.addParameter(getMidiInputDriverParameterInfo(driverName, s, depList)); |
1973 |
|
|
1974 |
return mid; |
return mid; |
1975 |
} |
} |
2003 |
StringBuffer args = new StringBuffer(driver); |
StringBuffer args = new StringBuffer(driver); |
2004 |
args.append(' ').append(param); |
args.append(' ').append(param); |
2005 |
|
|
2006 |
for(Parameter p : deplist) |
for(Parameter p : deplist) { |
2007 |
|
if(p.getValue() == null) continue; |
2008 |
args.append(' ').append(p.getName()).append('=').append(p.getStringValue()); |
args.append(' ').append(p.getName()).append('=').append(p.getStringValue()); |
2009 |
|
} |
2010 |
|
|
2011 |
out.writeLine("GET MIDI_INPUT_DRIVER_PARAMETER INFO " + args.toString()); |
out.writeLine("GET MIDI_INPUT_DRIVER_PARAMETER INFO " + args.toString()); |
2012 |
if(getPrintOnlyMode()) return null; |
if(getPrintOnlyMode()) return null; |
2068 |
verifyConnection(); |
verifyConnection(); |
2069 |
StringBuffer args = new StringBuffer(miDriver); |
StringBuffer args = new StringBuffer(miDriver); |
2070 |
|
|
2071 |
for(Parameter p : paramList) |
for(Parameter p : paramList) { |
2072 |
|
if(p.getValue() == null) continue; |
2073 |
args.append(' ').append(p.getName()).append('=').append(p.getStringValue()); |
args.append(' ').append(p.getName()).append('=').append(p.getStringValue()); |
2074 |
|
} |
2075 |
|
|
2076 |
out.writeLine("CREATE MIDI_INPUT_DEVICE " + args.toString()); |
out.writeLine("CREATE MIDI_INPUT_DEVICE " + args.toString()); |
2077 |
if(getPrintOnlyMode()) return -1; |
if(getPrintOnlyMode()) return -1; |
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); |
2467 |
public synchronized int |
public synchronized int |
2468 |
addMidiInstrumentMap(String name) throws IOException, LSException, LscpException { |
addMidiInstrumentMap(String name) throws IOException, LSException, LscpException { |
2469 |
verifyConnection(); |
verifyConnection(); |
2470 |
out.writeLine("ADD MIDI_INSTRUMENT_MAP '" + name + "'"); |
out.writeLine("ADD MIDI_INSTRUMENT_MAP '" + toEscapedString(name) + "'"); |
2471 |
if(getPrintOnlyMode()) return -1; |
if(getPrintOnlyMode()) return -1; |
2472 |
|
|
2473 |
ResultSet rs = getEmptyResultSet(); |
ResultSet rs = getEmptyResultSet(); |
2570 |
|
|
2571 |
for(String s : lnS) { |
for(String s : lnS) { |
2572 |
if(s.startsWith("NAME: ")) { |
if(s.startsWith("NAME: ")) { |
2573 |
name = s.substring("NAME: ".length()); |
name = toNonEscapedString(s.substring("NAME: ".length())); |
2574 |
} else if(s.startsWith("DEFAULT: ")) { |
} else if(s.startsWith("DEFAULT: ")) { |
2575 |
b = Boolean.parseBoolean(s.substring("DEFAULT: ".length())); |
b = Boolean.parseBoolean(s.substring("DEFAULT: ".length())); |
2576 |
} else { |
} else { |
2618 |
throws IOException, LscpException, LSException { |
throws IOException, LscpException, LSException { |
2619 |
|
|
2620 |
verifyConnection(); |
verifyConnection(); |
2621 |
|
name = toEscapedString(name); |
2622 |
out.writeLine("SET MIDI_INSTRUMENT_MAP NAME " + + mapId + " '" + name + "'"); |
out.writeLine("SET MIDI_INSTRUMENT_MAP NAME " + + mapId + " '" + name + "'"); |
2623 |
if(getPrintOnlyMode()) return; |
if(getPrintOnlyMode()) return; |
2624 |
|
|
2674 |
if(!info.getLoadMode().name().equals("DEFAULT")) { |
if(!info.getLoadMode().name().equals("DEFAULT")) { |
2675 |
cmd.append(' ').append(info.getLoadMode().name()); |
cmd.append(' ').append(info.getLoadMode().name()); |
2676 |
} |
} |
2677 |
if(info.getName() != null) cmd.append(" '").append(info.getName()).append("'"); |
|
2678 |
|
if(info.getName() != null) { |
2679 |
|
String s = toEscapedString(info.getName()); |
2680 |
|
cmd.append(" '").append(s).append("'"); |
2681 |
|
} |
2682 |
|
|
2683 |
out.writeLine(cmd.toString()); |
out.writeLine(cmd.toString()); |
2684 |
if(getPrintOnlyMode()) return; |
if(getPrintOnlyMode()) return; |
3527 |
|
|
3528 |
verifyConnection(); |
verifyConnection(); |
3529 |
String s = String.valueOf(channel) + " " + String.valueOf(midiCtrl); |
String s = String.valueOf(channel) + " " + String.valueOf(midiCtrl); |
3530 |
if(name != null) s += " '" + name + "'"; |
if(name != null) s += " '" + toEscapedString(name) + "'"; |
3531 |
out.writeLine("CREATE FX_SEND " + s); |
out.writeLine("CREATE FX_SEND " + s); |
3532 |
if(getPrintOnlyMode()) return -1; |
if(getPrintOnlyMode()) return -1; |
3533 |
|
|
3658 |
throws IOException, LscpException, LSException { |
throws IOException, LscpException, LSException { |
3659 |
|
|
3660 |
verifyConnection(); |
verifyConnection(); |
3661 |
String args = " " + channel + " " + fxSend + " '" + name + "'"; |
String args = " " + channel + " " + fxSend + " '" + toEscapedString(name) + "'"; |
3662 |
out.writeLine("SET FX_SEND NAME" + args); |
out.writeLine("SET FX_SEND NAME" + args); |
3663 |
if(getPrintOnlyMode()) return; |
if(getPrintOnlyMode()) return; |
3664 |
|
|
3746 |
ResultSet rs = getEmptyResultSet(); |
ResultSet rs = getEmptyResultSet(); |
3747 |
} |
} |
3748 |
|
|
3749 |
|
/** |
3750 |
|
* Starts an instrument editor for editing the loaded instrument |
3751 |
|
* on the specified sampler channel. |
3752 |
|
* @param samplerChn The sampler channel number. |
3753 |
|
* @throws IOException If some I/O error occurs. |
3754 |
|
* @throws LscpException If LSCP protocol corruption occurs. |
3755 |
|
* @throws LSException If <code>samplerChn</code> is not a valid channel number or if |
3756 |
|
* there is no instrument loaded on the specified sampler channel. |
3757 |
|
* @see #getSamplerChannels |
3758 |
|
*/ |
3759 |
|
public synchronized void |
3760 |
|
editChannelInstrument(int samplerChn) throws IOException, LscpException, LSException { |
3761 |
|
verifyConnection(); |
3762 |
|
out.writeLine("EDIT CHANNEL INSTRUMENT " + samplerChn); |
3763 |
|
if(getPrintOnlyMode()) return; |
3764 |
|
|
3765 |
|
ResultSet rs = getEmptyResultSet(); |
3766 |
|
} |
3767 |
|
|
3768 |
|
|
3769 |
|
|
3770 |
/** |
/** |
3771 |
* Adds the specified directory to the instruments database. |
* Adds the specified directory to the instruments database. |
3772 |
* @param dir The absolute path name of the directory to add. |
* @param dir The absolute (escaped) path name of the directory to add. |
3773 |
* @throws IOException If some I/O error occurs. |
* @throws IOException If some I/O error occurs. |
3774 |
* @throws LSException If the creation of the directory failed. |
* @throws LSException If the creation of the directory failed. |
3775 |
* @throws LscpException If LSCP protocol corruption occurs. |
* @throws LscpException If LSCP protocol corruption occurs. |
3785 |
|
|
3786 |
/** |
/** |
3787 |
* Removes the specified directory from the instruments database. |
* Removes the specified directory from the instruments database. |
3788 |
* @param dir The absolute path name of the directory to remove. |
* @param dir The absolute (escaped) path name of the directory to remove. |
3789 |
* @throws IOException If some I/O error occurs. |
* @throws IOException If some I/O error occurs. |
3790 |
* @throws LscpException If LSCP protocol corruption occurs. |
* @throws LscpException If LSCP protocol corruption occurs. |
3791 |
* @throws LSException If the specified directory is not |
* @throws LSException If the specified directory is not |
3820 |
|
|
3821 |
/** |
/** |
3822 |
* Removes the specified directories from the instruments database. |
* Removes the specified directories from the instruments database. |
3823 |
* @param dirs The absolute path names of the directories to remove. |
* @param dirs The absolute (escaped) path names of the directories to remove. |
3824 |
* @param force If <code>true</code> forces the removal of non-empty |
* @param force If <code>true</code> forces the removal of non-empty |
3825 |
* directories. |
* directories. |
3826 |
* @throws IOException If some I/O error occurs. |
* @throws IOException If some I/O error occurs. |
3895 |
out.writeLine("LIST DB_INSTRUMENT_DIRECTORIES '" + dir + "'"); |
out.writeLine("LIST DB_INSTRUMENT_DIRECTORIES '" + dir + "'"); |
3896 |
if(getPrintOnlyMode()) return null; |
if(getPrintOnlyMode()) return null; |
3897 |
|
|
3898 |
return parseStringList(getSingleLineResultSet().getResult()); |
String[] names = parseEscapedStringList(getSingleLineResultSet().getResult()); |
3899 |
|
for(int i = 0; i < names.length; i++) { |
3900 |
|
names[i] = toNonEscapedString(names[i]); |
3901 |
|
} |
3902 |
|
return names; |
3903 |
} |
} |
3904 |
|
|
3905 |
/** |
/** |
3921 |
DbDirectoryInfo info = new DbDirectoryInfo(rs.getMultiLineResult()); |
DbDirectoryInfo info = new DbDirectoryInfo(rs.getMultiLineResult()); |
3922 |
if(dir.equals("/")) { |
if(dir.equals("/")) { |
3923 |
info.setName("/"); |
info.setName("/"); |
3924 |
} else if(dir.length() > 1 && dir.charAt(dir.length() - 1) == '/') { |
} else { |
3925 |
dir = dir.substring(0, dir.length() - 1); |
dir = removeEndingFileSeparator(dir); |
|
} |
|
|
int i = dir.lastIndexOf('/'); |
|
|
if(i != -1 && i < dir.length() - 1) { |
|
|
info.setName(dir.substring(i + 1)); |
|
|
if(i == 0) info.setParentDirectoryPath("/"); |
|
|
else info.setParentDirectoryPath(dir.substring(0, i)); |
|
3926 |
} |
} |
3927 |
|
String s = getFileName(dir); |
3928 |
|
if(s != null) info.setName(toNonEscapedFileName(s)); |
3929 |
|
s = getParentDirectory(dir); |
3930 |
|
if(s != null) info.setParentDirectoryPath(s); |
3931 |
|
|
3932 |
return info; |
return info; |
3933 |
} |
} |
3944 |
public synchronized DbDirectoryInfo[] |
public synchronized DbDirectoryInfo[] |
3945 |
getDbDirectories(String dir) throws IOException, LscpException, LSException { |
getDbDirectories(String dir) throws IOException, LscpException, LSException { |
3946 |
String[] dirS = getDbDirectoryNames(dir); |
String[] dirS = getDbDirectoryNames(dir); |
3947 |
if(dir.charAt(dir.length() - 1) != '/') dir += "/"; |
if(!hasEndingFileSeparator(dir)) dir += "/"; |
3948 |
DbDirectoryInfo[] infoS = new DbDirectoryInfo[dirS.length]; |
DbDirectoryInfo[] infoS = new DbDirectoryInfo[dirS.length]; |
3949 |
for(int i = 0; i < dirS.length; i++) infoS[i] = getDbDirectoryInfo(dir + dirS[i]); |
for(int i = 0; i < dirS.length; i++) { |
3950 |
|
infoS[i] = getDbDirectoryInfo(dir + toEscapedFileName(dirS[i])); |
3951 |
|
} |
3952 |
return infoS; |
return infoS; |
3953 |
} |
} |
3954 |
|
|
4013 |
public synchronized void |
public synchronized void |
4014 |
renameDbDirectory(String dir, String name) throws IOException, LSException, LscpException { |
renameDbDirectory(String dir, String name) throws IOException, LSException, LscpException { |
4015 |
verifyConnection(); |
verifyConnection(); |
4016 |
|
name = toEscapedString(name); |
4017 |
out.writeLine("SET DB_INSTRUMENT_DIRECTORY NAME '" + dir + "' '" + name + "'"); |
out.writeLine("SET DB_INSTRUMENT_DIRECTORY NAME '" + dir + "' '" + name + "'"); |
4018 |
if(getPrintOnlyMode()) return; |
if(getPrintOnlyMode()) return; |
4019 |
|
|
4106 |
|
|
4107 |
verifyConnection(); |
verifyConnection(); |
4108 |
String s = "SET DB_INSTRUMENT_DIRECTORY DESCRIPTION '"; |
String s = "SET DB_INSTRUMENT_DIRECTORY DESCRIPTION '"; |
4109 |
out.writeLine(s + dir + "' '" + desc + "'"); |
out.writeLine(s + dir + "' '" + toEscapedString(desc) + "'"); |
4110 |
if(getPrintOnlyMode()) return; |
if(getPrintOnlyMode()) return; |
4111 |
|
|
4112 |
ResultSet rs = getEmptyResultSet(); |
ResultSet rs = getEmptyResultSet(); |
4285 |
break; |
break; |
4286 |
} |
} |
4287 |
|
|
4288 |
sb.append(" '").append(dbDir).append("' '").append(fsDir).append("'"); |
sb.append(" '").append(dbDir).append("' '"); |
4289 |
|
sb.append(fsDir).append("'"); |
4290 |
out.writeLine(sb.toString()); |
out.writeLine(sb.toString()); |
4291 |
if(getPrintOnlyMode()) return -1; |
if(getPrintOnlyMode()) return -1; |
4292 |
|
|
4382 |
out.writeLine("LIST DB_INSTRUMENTS '" + dir + "'"); |
out.writeLine("LIST DB_INSTRUMENTS '" + dir + "'"); |
4383 |
if(getPrintOnlyMode()) return null; |
if(getPrintOnlyMode()) return null; |
4384 |
|
|
4385 |
return parseStringList(getSingleLineResultSet().getResult()); |
String[] names = parseEscapedStringList(getSingleLineResultSet().getResult()); |
4386 |
|
for(int i = 0; i < names.length; i++) { |
4387 |
|
names[i] = toNonEscapedString(names[i]); |
4388 |
|
} |
4389 |
|
return names; |
4390 |
} |
} |
4391 |
|
|
4392 |
/** |
/** |
4406 |
|
|
4407 |
ResultSet rs = getMultiLineResultSet(); |
ResultSet rs = getMultiLineResultSet(); |
4408 |
DbInstrumentInfo info = new DbInstrumentInfo(rs.getMultiLineResult()); |
DbInstrumentInfo info = new DbInstrumentInfo(rs.getMultiLineResult()); |
4409 |
int i = instr.lastIndexOf('/'); |
String s = getParentDirectory(instr); |
4410 |
if(i != -1 && i < instr.length() - 1) { |
if(s != null) info.setDirectoryPath(s); |
4411 |
info.setName(instr.substring(i + 1)); |
s = getFileName(instr); |
4412 |
if(i == 0) info.setDirectoryPath("/"); |
if(s != null) info.setName(toNonEscapedFileName(s)); |
|
else info.setDirectoryPath(instr.substring(0, i)); |
|
|
} |
|
4413 |
|
|
4414 |
return info; |
return info; |
4415 |
} |
} |
4426 |
public synchronized DbInstrumentInfo[] |
public synchronized DbInstrumentInfo[] |
4427 |
getDbInstruments(String dir) throws IOException, LscpException, LSException { |
getDbInstruments(String dir) throws IOException, LscpException, LSException { |
4428 |
String[] instrS = getDbInstrumentNames(dir); |
String[] instrS = getDbInstrumentNames(dir); |
4429 |
if(dir.charAt(dir.length() - 1) != '/') dir += "/"; |
if(!hasEndingFileSeparator(dir)) dir += "/"; |
4430 |
|
|
4431 |
DbInstrumentInfo[] infoS = new DbInstrumentInfo[instrS.length]; |
DbInstrumentInfo[] infoS = new DbInstrumentInfo[instrS.length]; |
4432 |
for(int i = 0; i < instrS.length; i++) { |
for(int i = 0; i < instrS.length; i++) { |
4433 |
infoS[i] = getDbInstrumentInfo(dir + instrS[i]); |
infoS[i] = getDbInstrumentInfo(dir + toEscapedFileName(instrS[i])); |
4434 |
} |
} |
4435 |
return infoS; |
return infoS; |
4436 |
} |
} |
4498 |
throws IOException, LSException, LscpException { |
throws IOException, LSException, LscpException { |
4499 |
|
|
4500 |
verifyConnection(); |
verifyConnection(); |
4501 |
|
name = toEscapedString(name); |
4502 |
out.writeLine("SET DB_INSTRUMENT NAME '" + instr + "' '" + name + "'"); |
out.writeLine("SET DB_INSTRUMENT NAME '" + instr + "' '" + name + "'"); |
4503 |
if(getPrintOnlyMode()) return; |
if(getPrintOnlyMode()) return; |
4504 |
|
|
4590 |
throws IOException, LSException, LscpException { |
throws IOException, LSException, LscpException { |
4591 |
|
|
4592 |
verifyConnection(); |
verifyConnection(); |
4593 |
|
desc = toEscapedString(desc); |
4594 |
out.writeLine("SET DB_INSTRUMENT DESCRIPTION '" + instr + "' '" + desc + "'"); |
out.writeLine("SET DB_INSTRUMENT DESCRIPTION '" + instr + "' '" + desc + "'"); |
4595 |
if(getPrintOnlyMode()) return; |
if(getPrintOnlyMode()) return; |
4596 |
|
|
4638 |
sb.append(" '").append(dir).append("'"); |
sb.append(" '").append(dir).append("'"); |
4639 |
|
|
4640 |
if(query.name != null && query.name.length() > 0) { |
if(query.name != null && query.name.length() > 0) { |
4641 |
sb.append(" NAME='").append(query.name).append("'"); |
sb.append(" NAME='").append(toEscapedString(query.name)).append("'"); |
4642 |
} |
} |
4643 |
|
|
4644 |
String s = query.getCreatedAfter(); |
String s = query.getCreatedAfter(); |
4662 |
} |
} |
4663 |
|
|
4664 |
if(query.description != null && query.description.length() > 0) { |
if(query.description != null && query.description.length() > 0) { |
4665 |
sb.append(" DESCRIPTION='").append(query.description).append("'"); |
sb.append(" DESCRIPTION='"); |
4666 |
|
sb.append(toEscapedString(query.description)).append("'"); |
4667 |
} |
} |
4668 |
|
|
4669 |
out.writeLine(sb.toString()); |
out.writeLine(sb.toString()); |
4670 |
if(getPrintOnlyMode()) return null; |
if(getPrintOnlyMode()) return null; |
4671 |
|
|
4672 |
String[] dirS = parseStringList(getSingleLineResultSet().getResult()); |
String[] dirS = parseEscapedStringList(getSingleLineResultSet().getResult()); |
4673 |
|
|
4674 |
DbDirectoryInfo[] infoS = new DbDirectoryInfo[dirS.length]; |
DbDirectoryInfo[] infoS = new DbDirectoryInfo[dirS.length]; |
4675 |
for(int i = 0; i < dirS.length; i++) { |
for(int i = 0; i < dirS.length; i++) { |
4719 |
sb.append(" '").append(dir).append("'"); |
sb.append(" '").append(dir).append("'"); |
4720 |
|
|
4721 |
if(query.name != null && query.name.length() > 0) { |
if(query.name != null && query.name.length() > 0) { |
4722 |
sb.append(" NAME='").append(query.name).append("'"); |
sb.append(" NAME='").append(toEscapedString(query.name)).append("'"); |
4723 |
} |
} |
4724 |
|
|
4725 |
if(query.formatFamilies.size() > 0) { |
if(query.formatFamilies.size() > 0) { |
4759 |
} |
} |
4760 |
|
|
4761 |
if(query.description != null && query.description.length() > 0) { |
if(query.description != null && query.description.length() > 0) { |
4762 |
sb.append(" DESCRIPTION='").append(query.description).append("'"); |
sb.append(" DESCRIPTION='"); |
4763 |
|
sb.append(toEscapedString(query.description)).append("'"); |
4764 |
} |
} |
4765 |
|
|
4766 |
if(query.instrumentType != DbSearchQuery.InstrumentType.BOTH) { |
if(query.instrumentType != DbSearchQuery.InstrumentType.BOTH) { |
4773 |
} |
} |
4774 |
|
|
4775 |
if(query.product != null && query.product.length() > 0) { |
if(query.product != null && query.product.length() > 0) { |
4776 |
sb.append(" PRODUCT='").append(query.product).append("'"); |
sb.append(" PRODUCT='").append(toEscapedString(query.product)).append("'"); |
4777 |
} |
} |
4778 |
|
|
4779 |
if(query.artists != null && query.artists.length() > 0) { |
if(query.artists != null && query.artists.length() > 0) { |
4780 |
sb.append(" ARTISTS='").append(query.artists).append("'"); |
sb.append(" ARTISTS='").append(toEscapedString(query.artists)).append("'"); |
4781 |
} |
} |
4782 |
|
|
4783 |
if(query.keywords != null && query.keywords.length() > 0) { |
if(query.keywords != null && query.keywords.length() > 0) { |
4784 |
sb.append(" KEYWORDS='").append(query.keywords).append("'"); |
sb.append(" KEYWORDS='"); |
4785 |
|
sb.append(toEscapedString(query.keywords)).append("'"); |
4786 |
} |
} |
4787 |
|
|
4788 |
out.writeLine(sb.toString()); |
out.writeLine(sb.toString()); |
4789 |
if(getPrintOnlyMode()) return null; |
if(getPrintOnlyMode()) return null; |
4790 |
|
|
4791 |
String[] instrS = parseStringList(getSingleLineResultSet().getResult()); |
String[] instrS = parseEscapedStringList(getSingleLineResultSet().getResult()); |
4792 |
|
|
4793 |
DbInstrumentInfo[] infoS = new DbInstrumentInfo[instrS.length]; |
DbInstrumentInfo[] infoS = new DbInstrumentInfo[instrS.length]; |
4794 |
for(int i = 0; i < instrS.length; i++) { |
for(int i = 0; i < instrS.length; i++) { |
4819 |
} |
} |
4820 |
|
|
4821 |
/** |
/** |
4822 |
|
* Removes all instruments and directories and re-creates |
4823 |
|
* the instruments database structure. |
4824 |
|
* @throws IOException If some I/O error occurs. |
4825 |
|
* @throws LscpException If LSCP protocol corruption occurs. |
4826 |
|
* @throws LSException If the formatting of the instruments database failed. |
4827 |
|
*/ |
4828 |
|
public synchronized void |
4829 |
|
formatInstrumentsDb() throws IOException, LscpException, LSException { |
4830 |
|
verifyConnection(); |
4831 |
|
out.writeLine("FORMAT INSTRUMENTS_DB"); |
4832 |
|
if(getPrintOnlyMode()) return; |
4833 |
|
|
4834 |
|
ResultSet rs = getEmptyResultSet(); |
4835 |
|
} |
4836 |
|
|
4837 |
|
/** |
4838 |
* Resets the specified sampler channel. |
* Resets the specified sampler channel. |
4839 |
* |
* |
4840 |
* @param samplerChn The sampler channel number. |
* @param samplerChn The sampler channel number. |
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(); |