59 |
|
|
60 |
import org.jsampler.view.JSMainFrame; |
import org.jsampler.view.JSMainFrame; |
61 |
import org.jsampler.view.JSProgress; |
import org.jsampler.view.JSProgress; |
62 |
|
import org.jsampler.view.JSViewConfig; |
63 |
import org.jsampler.view.InstrumentsDbTreeModel; |
import org.jsampler.view.InstrumentsDbTreeModel; |
64 |
|
|
65 |
import org.linuxsampler.lscp.AudioOutputChannel; |
import org.linuxsampler.lscp.AudioOutputChannel; |
88 |
private static Handler handler; |
private static Handler handler; |
89 |
private static FileOutputStream fos; |
private static FileOutputStream fos; |
90 |
|
|
91 |
|
private static JSViewConfig viewConfig = null; |
92 |
private static JSMainFrame mainFrame = null; |
private static JSMainFrame mainFrame = null; |
93 |
private static JSProgress progress = null; |
private static JSProgress progress = null; |
94 |
|
|
140 |
} |
} |
141 |
|
|
142 |
/** |
/** |
143 |
|
* Gets the configuration of the current view. |
144 |
|
*/ |
145 |
|
public static JSViewConfig |
146 |
|
getViewConfig() { return viewConfig; } |
147 |
|
|
148 |
|
/** |
149 |
|
* Sets the configuration of the current view. |
150 |
|
*/ |
151 |
|
public static void |
152 |
|
setViewConfig(JSViewConfig viewConfig) { CC.viewConfig = viewConfig; } |
153 |
|
|
154 |
|
/** |
155 |
* Returns the main window of this application. |
* Returns the main window of this application. |
156 |
* @return The main window of this application. |
* @return The main window of this application. |
157 |
*/ |
*/ |
307 |
checkJSamplerHome() { |
checkJSamplerHome() { |
308 |
if(getJSamplerHome() != null) { |
if(getJSamplerHome() != null) { |
309 |
File f = new File(getJSamplerHome()); |
File f = new File(getJSamplerHome()); |
310 |
if(f.isDirectory()) return; |
if(f.exists() && f.isDirectory()) { |
311 |
|
return; |
312 |
|
} |
313 |
} |
} |
314 |
|
|
315 |
CC.getMainFrame().installJSamplerHome(); |
CC.getMainFrame().installJSamplerHome(); |
325 |
public static void |
public static void |
326 |
changeJSamplerHome(String path) { |
changeJSamplerHome(String path) { |
327 |
File fNew = new File(path); |
File fNew = new File(path); |
328 |
if(fNew.isFile()) { |
if(fNew.exists() && fNew.isFile()) { |
329 |
HF.showErrorMessage(i18n.getError("CC.JSamplerHomeIsNotDir!")); |
HF.showErrorMessage(i18n.getError("CC.JSamplerHomeIsNotDir!")); |
330 |
return; |
return; |
331 |
} |
} |
332 |
|
|
333 |
if(!fNew.isDirectory()) { |
if(!fNew.exists()) { |
334 |
if(!fNew.mkdir()) { |
if(!fNew.mkdir()) { |
335 |
String s = fNew.getAbsolutePath(); |
String s = fNew.getAbsolutePath(); |
336 |
HF.showErrorMessage(i18n.getError("CC.mkdirFailed", s)); |
HF.showErrorMessage(i18n.getError("CC.mkdirFailed", s)); |
338 |
} |
} |
339 |
} |
} |
340 |
|
|
341 |
if(getJSamplerHome() == null) { |
if(getJSamplerHome() == null || path.equals(getJSamplerHome())) { |
342 |
setJSamplerHome(fNew.getAbsolutePath()); |
setJSamplerHome(fNew.getAbsolutePath()); |
343 |
return; |
return; |
344 |
} |
} |
345 |
|
|
346 |
File fOld = new File(getJSamplerHome()); |
File fOld = new File(getJSamplerHome()); |
347 |
if(!fOld.isDirectory()) { |
if(!fOld.exists() || !fOld.isDirectory()) { |
348 |
setJSamplerHome(fNew.getAbsolutePath()); |
setJSamplerHome(fNew.getAbsolutePath()); |
349 |
return; |
return; |
350 |
} |
} |
376 |
* database support the tree model is initialized on first use. |
* database support the tree model is initialized on first use. |
377 |
* @return The tree model of the instruments database or |
* @return The tree model of the instruments database or |
378 |
* <code>null</code> if the backend doesn't have instruments database support. |
* <code>null</code> if the backend doesn't have instruments database support. |
379 |
* @see org.jsampler.view.JSMainFrame#getInstrumentsDbSupport |
* @see org.jsampler.view.JSViewConfig#getInstrumentsDbSupport |
380 |
*/ |
*/ |
381 |
public static InstrumentsDbTreeModel |
public static InstrumentsDbTreeModel |
382 |
getInstrumentsDbTreeModel() { |
getInstrumentsDbTreeModel() { |
400 |
loadOrchestras() { |
loadOrchestras() { |
401 |
if(getJSamplerHome() == null) return; |
if(getJSamplerHome() == null) return; |
402 |
|
|
|
//TODO: This should be removed in the next release (including loadOrchestras0()) |
|
|
File f2 = new File(getJSamplerHome() + File.separator + "orchestras.xml"); |
|
|
if(!f2.isFile()) { |
|
|
loadOrchestras0(); |
|
|
saveOrchestras(); |
|
|
return; |
|
|
} |
|
|
/////// |
|
|
|
|
403 |
try { |
try { |
404 |
String s = getJSamplerHome(); |
String s = getJSamplerHome(); |
405 |
if(s == null) return; |
if(s == null) return; |
406 |
|
getOrchestras().addOrchestraListListener(getHandler()); |
407 |
|
|
408 |
File f = new File(s + File.separator + "orchestras.xml.bkp"); |
File f = new File(s + File.separator + "orchestras.xml.bkp"); |
409 |
if(f.isFile()) HF.createBackup("orchestras.xml.bkp", "orchestras.xml.rec"); |
if(f.isFile()) HF.createBackup("orchestras.xml.bkp", "orchestras.xml.rec"); |
432 |
for(int i = 0; i < getOrchestras().getOrchestraCount(); i++) { |
for(int i = 0; i < getOrchestras().getOrchestraCount(); i++) { |
433 |
getOrchestras().getOrchestra(i).addOrchestraListener(getHandler()); |
getOrchestras().getOrchestra(i).addOrchestraListener(getHandler()); |
434 |
} |
} |
|
getOrchestras().addOrchestraListListener(getHandler()); |
|
|
} |
|
|
|
|
|
private static void |
|
|
loadOrchestras0() { |
|
|
String s = Prefs.getOrchestras(); |
|
|
if(s == null) return; |
|
|
|
|
|
ByteArrayInputStream bais = new ByteArrayInputStream(s.getBytes()); |
|
|
Document doc = DOMUtils.readObject(bais); |
|
|
|
|
|
try { getOrchestras().readObject(doc.getDocumentElement()); } |
|
|
catch(Exception x) { HF.showErrorMessage(x, "Loading orchestras: "); } |
|
435 |
} |
} |
436 |
|
|
437 |
private static void |
private static void |
544 |
|
|
545 |
model.setServerInfo(gsi.getResult()); |
model.setServerInfo(gsi.getResult()); |
546 |
|
|
547 |
if(CC.getMainFrame().getInstrumentsDbSupport()) { |
if(CC.getViewConfig().getInstrumentsDbSupport()) { |
548 |
getInstrumentsDbTreeModel(); |
getInstrumentsDbTreeModel(); |
549 |
} |
} |
550 |
} |
} |
729 |
SamplerChannelModel[] channels = getSamplerModel().getChannels(); |
SamplerChannelModel[] channels = getSamplerModel().getChannels(); |
730 |
|
|
731 |
for(int i = 0; i < channels.length; i++) { |
for(int i = 0; i < channels.length; i++) { |
732 |
SamplerChannelModel scm = getSamplerModel().getChannelById(i); |
SamplerChannelModel scm = channels[i]; |
733 |
exportChannelToLscpScript(scm.getChannelInfo(), i, lscpClient); |
exportChannelToLscpScript(scm.getChannelInfo(), i, lscpClient); |
734 |
sb.append(out.toString()); |
sb.append(out.toString()); |
735 |
out.reset(); |
out.reset(); |
797 |
try { |
try { |
798 |
lscpCLient.addSamplerChannel(); |
lscpCLient.addSamplerChannel(); |
799 |
|
|
800 |
int i = chn.getMidiInputDevice(); |
SamplerModel sm = CC.getSamplerModel(); |
801 |
if(i != -1) lscpCLient.setChannelMidiInputDevice(chnId, i); |
int id = chn.getMidiInputDevice(); |
802 |
|
if(id != -1) { |
803 |
|
for(int i = 0; i < sm.getMidiDeviceCount(); i++) { |
804 |
|
if(sm.getMidiDevice(i).getDeviceId() == id) { |
805 |
|
lscpCLient.setChannelMidiInputDevice(chnId, i); |
806 |
|
break; |
807 |
|
} |
808 |
|
} |
809 |
|
} |
810 |
lscpCLient.setChannelMidiInputPort(chnId, chn.getMidiInputPort()); |
lscpCLient.setChannelMidiInputPort(chnId, chn.getMidiInputPort()); |
811 |
lscpCLient.setChannelMidiInputChannel(chnId, chn.getMidiInputChannel()); |
lscpCLient.setChannelMidiInputChannel(chnId, chn.getMidiInputChannel()); |
812 |
|
|
813 |
i = chn.getAudioOutputDevice(); |
id = chn.getAudioOutputDevice(); |
814 |
if(i != -1) { |
if(id != -1) { |
815 |
lscpCLient.setChannelAudioOutputDevice(chnId, i); |
for(int i = 0; i < sm.getAudioDeviceCount(); i++) { |
816 |
|
if(sm.getAudioDevice(i).getDeviceId() == id) { |
817 |
|
lscpCLient.setChannelAudioOutputDevice(chnId, i); |
818 |
|
break; |
819 |
|
} |
820 |
|
} |
821 |
|
|
822 |
Integer[] routing = chn.getAudioOutputRouting(); |
Integer[] routing = chn.getAudioOutputRouting(); |
823 |
|
|
824 |
for(int j = 0; j < routing.length; j++) { |
for(int j = 0; j < routing.length; j++) { |
835 |
} |
} |
836 |
|
|
837 |
String s = chn.getInstrumentFile(); |
String s = chn.getInstrumentFile(); |
838 |
i = chn.getInstrumentIndex(); |
int i = chn.getInstrumentIndex(); |
839 |
if(s != null) lscpCLient.loadInstrument(s, i, chnId, true); |
if(s != null) lscpCLient.loadInstrument(s, i, chnId, true); |
840 |
|
|
841 |
if(chn.isMuted()) lscpCLient.setChannelMute(chnId, true); |
if(chn.isMuted()) lscpCLient.setChannelMute(chnId, true); |
1021 |
case TASK_DONE: |
case TASK_DONE: |
1022 |
EnhancedTask t = (EnhancedTask)e.getSource(); |
EnhancedTask t = (EnhancedTask)e.getSource(); |
1023 |
if(t.doneWithErrors() && !t.isStopped()) { |
if(t.doneWithErrors() && !t.isStopped()) { |
1024 |
if(t.getErrorDetails() == null) { |
showError(t); |
|
HF.showErrorMessage(t.getErrorMessage()); |
|
|
} else { |
|
|
getMainFrame().showDetailedErrorMessage ( |
|
|
getMainFrame(), |
|
|
t.getErrorMessage(), |
|
|
t.getErrorDetails() |
|
|
); |
|
|
} |
|
1025 |
} |
} |
1026 |
break; |
break; |
1027 |
case NOT_IDLE: |
case NOT_IDLE: |
1034 |
} |
} |
1035 |
} |
} |
1036 |
|
|
1037 |
|
private void |
1038 |
|
showError(final Task t) { |
1039 |
|
javax.swing.SwingUtilities.invokeLater(new Runnable() { |
1040 |
|
public void |
1041 |
|
run() { |
1042 |
|
if(t.getErrorDetails() == null) { |
1043 |
|
HF.showErrorMessage(t.getErrorMessage()); |
1044 |
|
} else { |
1045 |
|
getMainFrame().showDetailedErrorMessage ( |
1046 |
|
getMainFrame(), |
1047 |
|
t.getErrorMessage(), |
1048 |
|
t.getErrorDetails() |
1049 |
|
); |
1050 |
|
} |
1051 |
|
} |
1052 |
|
}); |
1053 |
|
} |
1054 |
|
|
1055 |
/** Invoked when the name of orchestra is changed. */ |
/** Invoked when the name of orchestra is changed. */ |
1056 |
public void |
public void |
1057 |
nameChanged(OrchestraEvent e) { saveOrchestras(); } |
nameChanged(OrchestraEvent e) { saveOrchestras(); } |