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 |
546 |
s = s.substring("NAME ".length()); |
s = s.substring("NAME ".length()); |
547 |
list = parseEscapedStringList(s, ' '); |
list = parseEscapedStringList(s, ' '); |
548 |
if(list.length != 2) throw new LscpException(); |
if(list.length != 2) throw new LscpException(); |
549 |
list[1] = toNonEscapedText(list[1]); |
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); |
575 |
s = s.substring("NAME ".length()); |
s = s.substring("NAME ".length()); |
576 |
list = parseEscapedStringList(s, ' '); |
list = parseEscapedStringList(s, ' '); |
577 |
if(list.length != 2) throw new LscpException(); |
if(list.length != 2) throw new LscpException(); |
578 |
list[1] = toNonEscapedText(list[1]); |
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); |
2460 |
public synchronized int |
public synchronized int |
2461 |
addMidiInstrumentMap(String name) throws IOException, LSException, LscpException { |
addMidiInstrumentMap(String name) throws IOException, LSException, LscpException { |
2462 |
verifyConnection(); |
verifyConnection(); |
2463 |
out.writeLine("ADD MIDI_INSTRUMENT_MAP '" + name + "'"); |
out.writeLine("ADD MIDI_INSTRUMENT_MAP '" + toEscapedString(name) + "'"); |
2464 |
if(getPrintOnlyMode()) return -1; |
if(getPrintOnlyMode()) return -1; |
2465 |
|
|
2466 |
ResultSet rs = getEmptyResultSet(); |
ResultSet rs = getEmptyResultSet(); |
2563 |
|
|
2564 |
for(String s : lnS) { |
for(String s : lnS) { |
2565 |
if(s.startsWith("NAME: ")) { |
if(s.startsWith("NAME: ")) { |
2566 |
name = s.substring("NAME: ".length()); |
name = toNonEscapedString(s.substring("NAME: ".length())); |
2567 |
} else if(s.startsWith("DEFAULT: ")) { |
} else if(s.startsWith("DEFAULT: ")) { |
2568 |
b = Boolean.parseBoolean(s.substring("DEFAULT: ".length())); |
b = Boolean.parseBoolean(s.substring("DEFAULT: ".length())); |
2569 |
} else { |
} else { |
2611 |
throws IOException, LscpException, LSException { |
throws IOException, LscpException, LSException { |
2612 |
|
|
2613 |
verifyConnection(); |
verifyConnection(); |
2614 |
|
name = toEscapedString(name); |
2615 |
out.writeLine("SET MIDI_INSTRUMENT_MAP NAME " + + mapId + " '" + name + "'"); |
out.writeLine("SET MIDI_INSTRUMENT_MAP NAME " + + mapId + " '" + name + "'"); |
2616 |
if(getPrintOnlyMode()) return; |
if(getPrintOnlyMode()) return; |
2617 |
|
|
2667 |
if(!info.getLoadMode().name().equals("DEFAULT")) { |
if(!info.getLoadMode().name().equals("DEFAULT")) { |
2668 |
cmd.append(' ').append(info.getLoadMode().name()); |
cmd.append(' ').append(info.getLoadMode().name()); |
2669 |
} |
} |
2670 |
if(info.getName() != null) cmd.append(" '").append(info.getName()).append("'"); |
|
2671 |
|
if(info.getName() != null) { |
2672 |
|
String s = toEscapedString(info.getName()); |
2673 |
|
cmd.append(" '").append(s).append("'"); |
2674 |
|
} |
2675 |
|
|
2676 |
out.writeLine(cmd.toString()); |
out.writeLine(cmd.toString()); |
2677 |
if(getPrintOnlyMode()) return; |
if(getPrintOnlyMode()) return; |
2867 |
loadInstrument(String filename, int instrIdx, int samplerChn, boolean nonModal) |
loadInstrument(String filename, int instrIdx, int samplerChn, boolean nonModal) |
2868 |
throws IOException, LscpException, LSException { |
throws IOException, LscpException, LSException { |
2869 |
|
|
|
filename = toEscapedString(filename); |
|
2870 |
String cmd = nonModal ? "LOAD INSTRUMENT NON_MODAL " : "LOAD INSTRUMENT "; |
String cmd = nonModal ? "LOAD INSTRUMENT NON_MODAL " : "LOAD INSTRUMENT "; |
2871 |
String args = '\'' + filename + "' " + instrIdx + ' ' + samplerChn; |
String args = '\'' + filename + "' " + instrIdx + ' ' + samplerChn; |
2872 |
|
|
3049 |
out.writeLine("LIST AVAILABLE_ENGINES"); |
out.writeLine("LIST AVAILABLE_ENGINES"); |
3050 |
if(getPrintOnlyMode()) return null; |
if(getPrintOnlyMode()) return null; |
3051 |
|
|
3052 |
return parseQuotedStringList(getSingleLineResultSet().getResult()); |
return parseStringList(getSingleLineResultSet().getResult()); |
3053 |
} |
} |
3054 |
|
|
3055 |
/** |
/** |
3520 |
|
|
3521 |
verifyConnection(); |
verifyConnection(); |
3522 |
String s = String.valueOf(channel) + " " + String.valueOf(midiCtrl); |
String s = String.valueOf(channel) + " " + String.valueOf(midiCtrl); |
3523 |
if(name != null) s += " '" + name + "'"; |
if(name != null) s += " '" + toEscapedString(name) + "'"; |
3524 |
out.writeLine("CREATE FX_SEND " + s); |
out.writeLine("CREATE FX_SEND " + s); |
3525 |
if(getPrintOnlyMode()) return -1; |
if(getPrintOnlyMode()) return -1; |
3526 |
|
|
3651 |
throws IOException, LscpException, LSException { |
throws IOException, LscpException, LSException { |
3652 |
|
|
3653 |
verifyConnection(); |
verifyConnection(); |
3654 |
String args = " " + channel + " " + fxSend + " '" + name + "'"; |
String args = " " + channel + " " + fxSend + " '" + toEscapedString(name) + "'"; |
3655 |
out.writeLine("SET FX_SEND NAME" + args); |
out.writeLine("SET FX_SEND NAME" + args); |
3656 |
if(getPrintOnlyMode()) return; |
if(getPrintOnlyMode()) return; |
3657 |
|
|
3750 |
* @see #getSamplerChannels |
* @see #getSamplerChannels |
3751 |
*/ |
*/ |
3752 |
public synchronized void |
public synchronized void |
3753 |
editInstrument(int samplerChn) throws IOException, LscpException, LSException { |
editChannelInstrument(int samplerChn) throws IOException, LscpException, LSException { |
3754 |
verifyConnection(); |
verifyConnection(); |
3755 |
out.writeLine("EDIT INSTRUMENT " + samplerChn); |
out.writeLine("EDIT CHANNEL INSTRUMENT " + samplerChn); |
3756 |
if(getPrintOnlyMode()) return; |
if(getPrintOnlyMode()) return; |
3757 |
|
|
3758 |
ResultSet rs = getEmptyResultSet(); |
ResultSet rs = getEmptyResultSet(); |
3890 |
|
|
3891 |
String[] names = parseEscapedStringList(getSingleLineResultSet().getResult()); |
String[] names = parseEscapedStringList(getSingleLineResultSet().getResult()); |
3892 |
for(int i = 0; i < names.length; i++) { |
for(int i = 0; i < names.length; i++) { |
3893 |
names[i] = toNonEscapedText(names[i]); |
names[i] = toNonEscapedString(names[i]); |
3894 |
} |
} |
3895 |
return names; |
return names; |
3896 |
} |
} |
4148 |
verifyConnection(); |
verifyConnection(); |
4149 |
String s = "ADD DB_INSTRUMENTS"; |
String s = "ADD DB_INSTRUMENTS"; |
4150 |
if(background) s += " NON_MODAL"; |
if(background) s += " NON_MODAL"; |
4151 |
s += " '" + dbDir + "' '" + toEscapedString(filePath) + "' "; |
s += " '" + dbDir + "' '" + filePath + "' "; |
4152 |
out.writeLine(s + String.valueOf(instrIndex)); |
out.writeLine(s + String.valueOf(instrIndex)); |
4153 |
if(getPrintOnlyMode()) return -1; |
if(getPrintOnlyMode()) return -1; |
4154 |
|
|
4195 |
verifyConnection(); |
verifyConnection(); |
4196 |
String s = "ADD DB_INSTRUMENTS"; |
String s = "ADD DB_INSTRUMENTS"; |
4197 |
if(background) s += " NON_MODAL"; |
if(background) s += " NON_MODAL"; |
4198 |
out.writeLine(s + " '" + dbDir + "' '" + toEscapedString(filePath) + "'"); |
out.writeLine(s + " '" + dbDir + "' '" + filePath + "'"); |
4199 |
if(getPrintOnlyMode()) return -1; |
if(getPrintOnlyMode()) return -1; |
4200 |
|
|
4201 |
ResultSet rs = getEmptyResultSet(); |
ResultSet rs = getEmptyResultSet(); |
4279 |
} |
} |
4280 |
|
|
4281 |
sb.append(" '").append(dbDir).append("' '"); |
sb.append(" '").append(dbDir).append("' '"); |
4282 |
sb.append(toEscapedString(fsDir)).append("'"); |
sb.append(fsDir).append("'"); |
4283 |
out.writeLine(sb.toString()); |
out.writeLine(sb.toString()); |
4284 |
if(getPrintOnlyMode()) return -1; |
if(getPrintOnlyMode()) return -1; |
4285 |
|
|
4377 |
|
|
4378 |
String[] names = parseEscapedStringList(getSingleLineResultSet().getResult()); |
String[] names = parseEscapedStringList(getSingleLineResultSet().getResult()); |
4379 |
for(int i = 0; i < names.length; i++) { |
for(int i = 0; i < names.length; i++) { |
4380 |
names[i] = toNonEscapedText(names[i]); |
names[i] = toNonEscapedString(names[i]); |
4381 |
} |
} |
4382 |
return names; |
return names; |
4383 |
} |
} |
4812 |
} |
} |
4813 |
|
|
4814 |
/** |
/** |
4815 |
|
* Removes all instruments and directories and re-creates |
4816 |
|
* the instruments database structure. |
4817 |
|
* @throws IOException If some I/O error occurs. |
4818 |
|
* @throws LscpException If LSCP protocol corruption occurs. |
4819 |
|
* @throws LSException If the formatting of the instruments database failed. |
4820 |
|
*/ |
4821 |
|
public synchronized void |
4822 |
|
formatInstrumentsDb() throws IOException, LscpException, LSException { |
4823 |
|
verifyConnection(); |
4824 |
|
out.writeLine("FORMAT INSTRUMENTS_DB"); |
4825 |
|
if(getPrintOnlyMode()) return; |
4826 |
|
|
4827 |
|
ResultSet rs = getEmptyResultSet(); |
4828 |
|
} |
4829 |
|
|
4830 |
|
/** |
4831 |
* Resets the specified sampler channel. |
* Resets the specified sampler channel. |
4832 |
* |
* |
4833 |
* @param samplerChn The sampler channel number. |
* @param samplerChn The sampler channel number. |