42 |
|
|
43 |
import javax.swing.Timer; |
import javax.swing.Timer; |
44 |
|
|
45 |
|
import javax.swing.event.ChangeEvent; |
46 |
|
import javax.swing.event.ChangeListener; |
47 |
|
|
48 |
import net.sf.juife.Task; |
import net.sf.juife.Task; |
49 |
import net.sf.juife.TaskQueue; |
import net.sf.juife.TaskQueue; |
50 |
|
|
62 |
|
|
63 |
import org.jsampler.view.JSMainFrame; |
import org.jsampler.view.JSMainFrame; |
64 |
import org.jsampler.view.JSProgress; |
import org.jsampler.view.JSProgress; |
65 |
|
import org.jsampler.view.JSViewConfig; |
66 |
import org.jsampler.view.InstrumentsDbTreeModel; |
import org.jsampler.view.InstrumentsDbTreeModel; |
67 |
|
|
68 |
import org.linuxsampler.lscp.AudioOutputChannel; |
import org.linuxsampler.lscp.AudioOutputChannel; |
80 |
import org.w3c.dom.Node; |
import org.w3c.dom.Node; |
81 |
|
|
82 |
import static org.jsampler.JSI18n.i18n; |
import static org.jsampler.JSI18n.i18n; |
83 |
|
import static org.jsampler.JSPrefs.MANUAL_SERVER_SELECT_ON_STARTUP; |
84 |
|
|
85 |
|
|
86 |
/** |
/** |
92 |
private static Handler handler; |
private static Handler handler; |
93 |
private static FileOutputStream fos; |
private static FileOutputStream fos; |
94 |
|
|
95 |
|
private static JSViewConfig viewConfig = null; |
96 |
private static JSMainFrame mainFrame = null; |
private static JSMainFrame mainFrame = null; |
97 |
private static JSProgress progress = null; |
private static JSProgress progress = null; |
98 |
|
|
136 |
scheduleTask(Task t) { |
scheduleTask(Task t) { |
137 |
while(getTaskQueue().removeTask(t)) { } |
while(getTaskQueue().removeTask(t)) { } |
138 |
|
|
|
if(getTaskQueue().getPendingTaskCount() == 0) { |
|
|
if(t.equals(getTaskQueue().getRunningTask())) return; |
|
|
} |
|
|
|
|
139 |
getTaskQueue().add(t); |
getTaskQueue().add(t); |
140 |
} |
} |
141 |
|
|
142 |
/** |
/** |
143 |
|
* Gets the configuration of the current view. |
144 |
|
*/ |
145 |
|
public static JSViewConfig |
146 |
|
getViewConfig() { return viewConfig; } |
147 |
|
|
148 |
|
private static JSPrefs |
149 |
|
preferences() { return getViewConfig().preferences(); } |
150 |
|
|
151 |
|
/** |
152 |
|
* Sets the configuration of the current view. |
153 |
|
*/ |
154 |
|
public static void |
155 |
|
setViewConfig(JSViewConfig viewConfig) { CC.viewConfig = viewConfig; } |
156 |
|
|
157 |
|
/** |
158 |
* Returns the main window of this application. |
* Returns the main window of this application. |
159 |
* @return The main window of this application. |
* @return The main window of this application. |
160 |
*/ |
*/ |
236 |
|
|
237 |
HF.setUIDefaultFont(Prefs.getInterfaceFont()); |
HF.setUIDefaultFont(Prefs.getInterfaceFont()); |
238 |
|
|
|
getClient().setServerAddress(Prefs.getLSAddress()); |
|
|
getClient().setServerPort(Prefs.getLSPort()); |
|
|
|
|
239 |
timer.setRepeats(false); |
timer.setRepeats(false); |
240 |
|
|
241 |
timer.addActionListener(new ActionListener() { |
timer.addActionListener(new ActionListener() { |
265 |
getClient().removeVoiceCountListener(getHandler()); |
getClient().removeVoiceCountListener(getHandler()); |
266 |
getClient().addVoiceCountListener(getHandler()); |
getClient().addVoiceCountListener(getHandler()); |
267 |
|
|
268 |
|
getClient().removeTotalStreamCountListener(getHandler()); |
269 |
|
getClient().addTotalStreamCountListener(getHandler()); |
270 |
|
|
271 |
getClient().removeTotalVoiceCountListener(getHandler()); |
getClient().removeTotalVoiceCountListener(getHandler()); |
272 |
getClient().addTotalVoiceCountListener(getHandler()); |
getClient().addTotalVoiceCountListener(getHandler()); |
273 |
|
|
310 |
checkJSamplerHome() { |
checkJSamplerHome() { |
311 |
if(getJSamplerHome() != null) { |
if(getJSamplerHome() != null) { |
312 |
File f = new File(getJSamplerHome()); |
File f = new File(getJSamplerHome()); |
313 |
if(f.isDirectory()) return; |
if(f.exists() && f.isDirectory()) { |
314 |
|
return; |
315 |
|
} |
316 |
} |
} |
317 |
|
|
318 |
CC.getMainFrame().installJSamplerHome(); |
CC.getMainFrame().installJSamplerHome(); |
328 |
public static void |
public static void |
329 |
changeJSamplerHome(String path) { |
changeJSamplerHome(String path) { |
330 |
File fNew = new File(path); |
File fNew = new File(path); |
331 |
if(fNew.isFile()) { |
if(fNew.exists() && fNew.isFile()) { |
332 |
HF.showErrorMessage(i18n.getError("CC.JSamplerHomeIsNotDir!")); |
HF.showErrorMessage(i18n.getError("CC.JSamplerHomeIsNotDir!")); |
333 |
return; |
return; |
334 |
} |
} |
335 |
|
|
336 |
if(!fNew.isDirectory()) { |
if(!fNew.exists()) { |
337 |
if(!fNew.mkdir()) { |
if(!fNew.mkdir()) { |
338 |
String s = fNew.getAbsolutePath(); |
String s = fNew.getAbsolutePath(); |
339 |
HF.showErrorMessage(i18n.getError("CC.mkdirFailed", s)); |
HF.showErrorMessage(i18n.getError("CC.mkdirFailed", s)); |
341 |
} |
} |
342 |
} |
} |
343 |
|
|
344 |
if(getJSamplerHome() == null) { |
if(getJSamplerHome() == null || path.equals(getJSamplerHome())) { |
345 |
setJSamplerHome(fNew.getAbsolutePath()); |
setJSamplerHome(fNew.getAbsolutePath()); |
346 |
return; |
return; |
347 |
} |
} |
348 |
|
|
349 |
File fOld = new File(getJSamplerHome()); |
File fOld = new File(getJSamplerHome()); |
350 |
if(!fOld.isDirectory()) { |
if(!fOld.exists() || !fOld.isDirectory()) { |
351 |
setJSamplerHome(fNew.getAbsolutePath()); |
setJSamplerHome(fNew.getAbsolutePath()); |
352 |
return; |
return; |
353 |
} |
} |
372 |
public static OrchestraListModel |
public static OrchestraListModel |
373 |
getOrchestras() { return orchestras; } |
getOrchestras() { return orchestras; } |
374 |
|
|
375 |
|
private final static ServerList servers = new ServerList(); |
376 |
|
|
377 |
|
/** Returns the server list. */ |
378 |
|
public static ServerList |
379 |
|
getServerList() { return servers; } |
380 |
|
|
381 |
|
private static ServerListListener serverListListener = new ServerListListener(); |
382 |
|
|
383 |
|
private static class ServerListListener implements ChangeListener { |
384 |
|
public void |
385 |
|
stateChanged(ChangeEvent e) { |
386 |
|
saveServerList(); |
387 |
|
} |
388 |
|
} |
389 |
|
|
390 |
|
private static final Vector<ChangeListener> idtmListeners = new Vector<ChangeListener>(); |
391 |
private static InstrumentsDbTreeModel instrumentsDbTreeModel = null; |
private static InstrumentsDbTreeModel instrumentsDbTreeModel = null; |
392 |
|
|
393 |
/** |
/** |
394 |
* Gets the tree model of the instruments database. |
* Gets the tree model of the instruments database. |
395 |
* If the currently used view doesn't have instruments |
* If the currently used view doesn't have instruments |
396 |
* database support the tree model is initialized on first use. |
* database support the tree model is initialized on first use. |
397 |
* @return The tree model of the instruments database or |
* @return The tree model of the instruments database or |
398 |
* <code>null</code> if the backend doesn't have instruments database support. |
* <code>null</code> if the backend doesn't have instruments database support. |
399 |
* @see org.jsampler.view.JSMainFrame#getInstrumentsDbSupport |
* @see org.jsampler.view.JSViewConfig#getInstrumentsDbSupport |
400 |
*/ |
*/ |
401 |
public static InstrumentsDbTreeModel |
public static InstrumentsDbTreeModel |
402 |
getInstrumentsDbTreeModel() { |
getInstrumentsDbTreeModel() { |
404 |
|
|
405 |
if(instrumentsDbTreeModel == null) { |
if(instrumentsDbTreeModel == null) { |
406 |
instrumentsDbTreeModel = new InstrumentsDbTreeModel(); |
instrumentsDbTreeModel = new InstrumentsDbTreeModel(); |
407 |
|
for(ChangeListener l : idtmListeners) l.stateChanged(null); |
408 |
} |
} |
409 |
|
|
410 |
return instrumentsDbTreeModel; |
return instrumentsDbTreeModel; |
411 |
} |
} |
412 |
|
|
413 |
|
public static void |
414 |
|
addInstrumentsDbChangeListener(ChangeListener l) { |
415 |
|
idtmListeners.add(l); |
416 |
|
} |
417 |
|
|
418 |
|
public static void |
419 |
|
removeInstrumentsDbChangeListener(ChangeListener l) { |
420 |
|
idtmListeners.remove(l); |
421 |
|
} |
422 |
|
|
423 |
/** |
/** |
424 |
* Loads the orchestras described in <code><jsampler_home>/orchestras.xml</code>. |
* Loads the orchestras described in <code><jsampler_home>/orchestras.xml</code>. |
425 |
* If file with name <code>orchestras.xml.bkp</code> exist in the JSampler's home |
* If file with name <code>orchestras.xml.bkp</code> exist in the JSampler's home |
431 |
loadOrchestras() { |
loadOrchestras() { |
432 |
if(getJSamplerHome() == null) return; |
if(getJSamplerHome() == null) return; |
433 |
|
|
|
//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; |
|
|
} |
|
|
/////// |
|
|
|
|
434 |
try { |
try { |
435 |
String s = getJSamplerHome(); |
String s = getJSamplerHome(); |
|
if(s == null) return; |
|
436 |
|
|
437 |
File f = new File(s + File.separator + "orchestras.xml.bkp"); |
File f = new File(s + File.separator + "orchestras.xml.bkp"); |
438 |
if(f.isFile()) HF.createBackup("orchestras.xml.bkp", "orchestras.xml.rec"); |
if(f.isFile()) HF.createBackup("orchestras.xml.bkp", "orchestras.xml.rec"); |
445 |
} catch(Exception x) { |
} catch(Exception x) { |
446 |
getLogger().log(Level.INFO, HF.getErrorMessage(x), x); |
getLogger().log(Level.INFO, HF.getErrorMessage(x), x); |
447 |
} |
} |
448 |
|
|
449 |
|
getOrchestras().addOrchestraListListener(getHandler()); |
450 |
} |
} |
451 |
|
|
452 |
|
|
463 |
for(int i = 0; i < getOrchestras().getOrchestraCount(); i++) { |
for(int i = 0; i < getOrchestras().getOrchestraCount(); i++) { |
464 |
getOrchestras().getOrchestra(i).addOrchestraListener(getHandler()); |
getOrchestras().getOrchestra(i).addOrchestraListener(getHandler()); |
465 |
} |
} |
|
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: "); } |
|
466 |
} |
} |
467 |
|
|
468 |
private static void |
private static void |
497 |
} |
} |
498 |
|
|
499 |
/** |
/** |
500 |
|
* Loads the servers' info described in <code><jsampler_home>/servers.xml</code>. |
501 |
|
* If file with name <code>servers.xml.bkp</code> exist in the JSampler's home |
502 |
|
* directory, this means that the last save has failed. In that case a recovery file |
503 |
|
* <code>servers.xml.rec</code> is created and a recovery procedure |
504 |
|
* will be initiated. |
505 |
|
*/ |
506 |
|
public static void |
507 |
|
loadServerList() { |
508 |
|
if(getJSamplerHome() == null) return; |
509 |
|
|
510 |
|
try { |
511 |
|
String s = getJSamplerHome(); |
512 |
|
|
513 |
|
File f = new File(s + File.separator + "servers.xml.bkp"); |
514 |
|
if(f.isFile()) HF.createBackup("servers.xml.bkp", "servers.xml.rec"); |
515 |
|
|
516 |
|
FileInputStream fis; |
517 |
|
fis = new FileInputStream(s + File.separator + "servers.xml"); |
518 |
|
|
519 |
|
loadServerList(fis); |
520 |
|
fis.close(); |
521 |
|
} catch(Exception x) { |
522 |
|
getLogger().log(Level.INFO, HF.getErrorMessage(x), x); |
523 |
|
} |
524 |
|
|
525 |
|
getServerList().addChangeListener(serverListListener); |
526 |
|
|
527 |
|
/* We should have at least one server to connect. */ |
528 |
|
if(getServerList().getServerCount() == 0) { |
529 |
|
Server server = new Server(); |
530 |
|
server.setName("127.0.0.1:8888"); |
531 |
|
server.setAddress("127.0.0.1"); |
532 |
|
server.setPort(8888); |
533 |
|
getServerList().addServer(server); |
534 |
|
} |
535 |
|
} |
536 |
|
|
537 |
|
|
538 |
|
private static void |
539 |
|
loadServerList(InputStream in) { |
540 |
|
Document doc = DOMUtils.readObject(in); |
541 |
|
|
542 |
|
try { getServerList().readObject(doc.getDocumentElement()); } |
543 |
|
catch(Exception x) { |
544 |
|
HF.showErrorMessage(x, "Loading server list: "); |
545 |
|
return; |
546 |
|
} |
547 |
|
} |
548 |
|
|
549 |
|
private static void |
550 |
|
saveServerList() { |
551 |
|
try { |
552 |
|
String s = getJSamplerHome(); |
553 |
|
if(s == null) return; |
554 |
|
|
555 |
|
HF.createBackup("servers.xml", "servers.xml.bkp"); |
556 |
|
|
557 |
|
FileOutputStream fos; |
558 |
|
fos = new FileOutputStream(s + File.separator + "servers.xml", false); |
559 |
|
|
560 |
|
Document doc = DOMUtils.createEmptyDocument(); |
561 |
|
|
562 |
|
Node node = doc.createElement("temp"); |
563 |
|
doc.appendChild(node); |
564 |
|
|
565 |
|
getServerList().writeObject(doc, doc.getDocumentElement()); |
566 |
|
|
567 |
|
doc.replaceChild(node.getFirstChild(), node); |
568 |
|
|
569 |
|
DOMUtils.writeObject(doc, fos); |
570 |
|
|
571 |
|
fos.close(); |
572 |
|
|
573 |
|
HF.deleteFile("servers.xml.bkp"); |
574 |
|
} catch(Exception x) { |
575 |
|
HF.showErrorMessage(x, "Saving server list: "); |
576 |
|
return; |
577 |
|
} |
578 |
|
} |
579 |
|
|
580 |
|
/** |
581 |
* The exit point of the application which ensures clean exit with default exit status 0. |
* The exit point of the application which ensures clean exit with default exit status 0. |
582 |
* @see #cleanExit(int i) |
* @see #cleanExit(int i) |
583 |
*/ |
*/ |
633 |
getSamplerModel() { return samplerModel; } |
getSamplerModel() { return samplerModel; } |
634 |
|
|
635 |
/** |
/** |
636 |
|
* Connects to LinuxSampler. |
637 |
|
*/ |
638 |
|
public static void |
639 |
|
connect() { initSamplerModel(); } |
640 |
|
|
641 |
|
/** |
642 |
* Reconnects to LinuxSampler. |
* Reconnects to LinuxSampler. |
643 |
*/ |
*/ |
644 |
public static void |
public static void |
645 |
reconnect() { |
reconnect() { initSamplerModel(getCurrentServer()); } |
646 |
initSamplerModel(); |
|
647 |
fireReconnectEvent(); |
private static Server currentServer = null; |
|
} |
|
648 |
|
|
649 |
/** |
/** |
650 |
* This method updates the information about the backend state. |
* Gets the server, to which the frontend is going to connect |
651 |
|
* or is already connected. |
652 |
|
*/ |
653 |
|
public static Server |
654 |
|
getCurrentServer() { return currentServer; } |
655 |
|
|
656 |
|
/** |
657 |
|
* Sets the current server. |
658 |
*/ |
*/ |
659 |
public static void |
public static void |
660 |
|
setCurrentServer(Server server) { currentServer = server; } |
661 |
|
|
662 |
|
/** |
663 |
|
* This method updates the information about the backend state. |
664 |
|
*/ |
665 |
|
private static void |
666 |
initSamplerModel() { |
initSamplerModel() { |
667 |
|
Server srv = getMainFrame().getServer(); |
668 |
|
if(srv == null) return; |
669 |
|
initSamplerModel(srv); |
670 |
|
} |
671 |
|
|
672 |
|
/** |
673 |
|
* This method updates the information about the backend state. |
674 |
|
*/ |
675 |
|
private static void |
676 |
|
initSamplerModel(Server srv) { |
677 |
|
setCurrentServer(srv); |
678 |
|
final SetServerAddress ssa = new SetServerAddress(srv.getAddress(), srv.getPort()); |
679 |
|
|
680 |
final DefaultSamplerModel model = (DefaultSamplerModel)getSamplerModel(); |
final DefaultSamplerModel model = (DefaultSamplerModel)getSamplerModel(); |
681 |
|
|
682 |
final Global.GetServerInfo gsi = new Global.GetServerInfo(); |
final Global.GetServerInfo gsi = new Global.GetServerInfo(); |
687 |
|
|
688 |
model.setServerInfo(gsi.getResult()); |
model.setServerInfo(gsi.getResult()); |
689 |
|
|
690 |
if(CC.getMainFrame().getInstrumentsDbSupport()) { |
if(CC.getViewConfig().getInstrumentsDbSupport()) { |
691 |
getInstrumentsDbTreeModel(); |
getInstrumentsDbTreeModel(); |
692 |
} |
} |
693 |
} |
} |
753 |
gfs.addTaskListener(new GetFxSendsListener()); |
gfs.addTaskListener(new GetFxSendsListener()); |
754 |
getTaskQueue().add(gfs); |
getTaskQueue().add(gfs); |
755 |
} |
} |
756 |
|
|
757 |
|
// TODO: This should be done after the fx sends are set |
758 |
|
//CC.getSamplerModel().setModified(false); |
759 |
} |
} |
760 |
}); |
}); |
761 |
|
|
764 |
cnt.addTaskListener(new TaskListener() { |
cnt.addTaskListener(new TaskListener() { |
765 |
public void |
public void |
766 |
taskPerformed(TaskEvent e) { |
taskPerformed(TaskEvent e) { |
767 |
if(cnt.doneWithErrors()) return; |
if(cnt.doneWithErrors()) { |
768 |
|
setCurrentServer(null); |
769 |
|
retryToConnect(); |
770 |
|
return; |
771 |
|
} |
772 |
|
|
773 |
getTaskQueue().add(gsi); |
getTaskQueue().add(gsi); |
774 |
getTaskQueue().add(gaod); |
getTaskQueue().add(gaod); |
781 |
getTaskQueue().add(uc); |
getTaskQueue().add(uc); |
782 |
} |
} |
783 |
}); |
}); |
784 |
getTaskQueue().add(cnt); |
|
785 |
|
ssa.addTaskListener(new TaskListener() { |
786 |
|
public void |
787 |
|
taskPerformed(TaskEvent e) { |
788 |
|
CC.getTaskQueue().add(cnt); |
789 |
|
} |
790 |
|
}); |
791 |
|
|
792 |
|
getSamplerModel().reset(); |
793 |
|
if(instrumentsDbTreeModel != null) { |
794 |
|
instrumentsDbTreeModel.reset(); |
795 |
|
instrumentsDbTreeModel = null; |
796 |
|
} |
797 |
|
|
798 |
|
getTaskQueue().removePendingTasks(); |
799 |
|
getTaskQueue().add(ssa); |
800 |
|
|
801 |
|
fireReconnectEvent(); |
802 |
|
} |
803 |
|
|
804 |
|
private static void |
805 |
|
retryToConnect() { |
806 |
|
javax.swing.SwingUtilities.invokeLater(new Runnable() { |
807 |
|
public void |
808 |
|
run() { changeBackend(); } |
809 |
|
}); |
810 |
|
} |
811 |
|
|
812 |
|
public static void |
813 |
|
changeBackend() { |
814 |
|
Server s = getMainFrame().getServer(true); |
815 |
|
if(s != null) initSamplerModel(s); |
816 |
} |
} |
817 |
|
|
818 |
private static class GetFxSendsListener implements TaskListener { |
private static class GetFxSendsListener implements TaskListener { |
871 |
|
|
872 |
public static String |
public static String |
873 |
exportSessionToLscpScript() { |
exportSessionToLscpScript() { |
874 |
|
CC.getSamplerModel().setModified(false); |
875 |
|
|
876 |
StringBuffer sb = new StringBuffer("# Exported by: "); |
StringBuffer sb = new StringBuffer("# Exported by: "); |
877 |
sb.append("JSampler - a java front-end for LinuxSampler\r\n# Version: "); |
sb.append("JSampler - a java front-end for LinuxSampler\r\n# Version: "); |
878 |
sb.append(JSampler.VERSION).append("\r\n"); |
sb.append(JSampler.VERSION).append("\r\n"); |
909 |
sb.append("\r\n"); |
sb.append("\r\n"); |
910 |
} |
} |
911 |
|
|
912 |
|
exportInstrMapsToLscpScript(lscpClient); |
913 |
|
sb.append(out.toString()); |
914 |
|
out.reset(); |
915 |
|
sb.append("\r\n"); |
916 |
|
|
917 |
SamplerChannelModel[] channels = getSamplerModel().getChannels(); |
SamplerChannelModel[] channels = getSamplerModel().getChannels(); |
918 |
|
|
919 |
for(int i = 0; i < channels.length; i++) { |
for(int i = 0; i < channels.length; i++) { |
920 |
SamplerChannelModel scm = getSamplerModel().getChannelById(i); |
SamplerChannelModel scm = channels[i]; |
921 |
exportChannelToLscpScript(scm.getChannelInfo(), i, lscpClient); |
exportChannelToLscpScript(scm.getChannelInfo(), i, lscpClient); |
922 |
sb.append(out.toString()); |
sb.append(out.toString()); |
923 |
out.reset(); |
out.reset(); |
931 |
sb.append("\r\n"); |
sb.append("\r\n"); |
932 |
} |
} |
933 |
|
|
|
exportInstrMapsToLscpScript(lscpClient); |
|
|
sb.append(out.toString()); |
|
|
out.reset(); |
|
|
|
|
934 |
return sb.toString(); |
return sb.toString(); |
935 |
} |
} |
936 |
|
|
981 |
try { |
try { |
982 |
lscpCLient.addSamplerChannel(); |
lscpCLient.addSamplerChannel(); |
983 |
|
|
984 |
int i = chn.getMidiInputDevice(); |
SamplerModel sm = CC.getSamplerModel(); |
985 |
if(i != -1) lscpCLient.setChannelMidiInputDevice(chnId, i); |
int id = chn.getMidiInputDevice(); |
986 |
lscpCLient.setChannelMidiInputPort(chnId, chn.getMidiInputPort()); |
if(id != -1) { |
987 |
lscpCLient.setChannelMidiInputChannel(chnId, chn.getMidiInputChannel()); |
for(int i = 0; i < sm.getMidiDeviceCount(); i++) { |
988 |
|
if(sm.getMidiDevice(i).getDeviceId() == id) { |
989 |
i = chn.getAudioOutputDevice(); |
lscpCLient.setChannelMidiInputDevice(chnId, i); |
990 |
if(i != -1) { |
break; |
991 |
lscpCLient.setChannelAudioOutputDevice(chnId, i); |
} |
992 |
|
} |
993 |
|
lscpCLient.setChannelMidiInputPort(chnId, chn.getMidiInputPort()); |
994 |
|
lscpCLient.setChannelMidiInputChannel(chnId, chn.getMidiInputChannel()); |
995 |
|
} |
996 |
|
|
997 |
|
if(chn.getEngine() != null) { |
998 |
|
lscpCLient.loadSamplerEngine(chn.getEngine().getName(), chnId); |
999 |
|
lscpCLient.setChannelVolume(chnId, chn.getVolume()); |
1000 |
|
int mapId = chn.getMidiInstrumentMapId(); |
1001 |
|
lscpCLient.setChannelMidiInstrumentMap(chnId, mapId); |
1002 |
|
} |
1003 |
|
|
1004 |
|
id = chn.getAudioOutputDevice(); |
1005 |
|
if(id != -1) { |
1006 |
|
for(int i = 0; i < sm.getAudioDeviceCount(); i++) { |
1007 |
|
if(sm.getAudioDevice(i).getDeviceId() == id) { |
1008 |
|
lscpCLient.setChannelAudioOutputDevice(chnId, i); |
1009 |
|
break; |
1010 |
|
} |
1011 |
|
} |
1012 |
|
|
1013 |
Integer[] routing = chn.getAudioOutputRouting(); |
Integer[] routing = chn.getAudioOutputRouting(); |
1014 |
|
|
1015 |
for(int j = 0; j < routing.length; j++) { |
for(int j = 0; j < routing.length; j++) { |
1020 |
} |
} |
1021 |
} |
} |
1022 |
|
|
|
if(chn.getEngine() != null) { |
|
|
lscpCLient.loadSamplerEngine(chn.getEngine().getName(), chnId); |
|
|
lscpCLient.setChannelVolume(chnId, chn.getVolume()); |
|
|
} |
|
|
|
|
1023 |
String s = chn.getInstrumentFile(); |
String s = chn.getInstrumentFile(); |
1024 |
i = chn.getInstrumentIndex(); |
int i = chn.getInstrumentIndex(); |
1025 |
if(s != null) lscpCLient.loadInstrument(s, i, chnId, true); |
if(s != null) lscpCLient.loadInstrument(s, i, chnId, true); |
1026 |
|
|
1027 |
if(chn.isMuted()) lscpCLient.setChannelMute(chnId, true); |
if(chn.isMuted()) lscpCLient.setChannelMute(chnId, true); |
1050 |
} |
} |
1051 |
} |
} |
1052 |
|
|
1053 |
|
public static void |
1054 |
|
scheduleInTaskQueue(final Runnable r) { |
1055 |
|
Task dummy = new Global.DummyTask(); |
1056 |
|
dummy.addTaskListener(new TaskListener() { |
1057 |
|
public void |
1058 |
|
taskPerformed(TaskEvent e) { |
1059 |
|
javax.swing.SwingUtilities.invokeLater(r); |
1060 |
|
} |
1061 |
|
}); |
1062 |
|
|
1063 |
|
CC.getTaskQueue().add(dummy); |
1064 |
|
} |
1065 |
|
|
1066 |
|
public static boolean |
1067 |
|
verifyConnection() { |
1068 |
|
if(getCurrentServer() == null) { |
1069 |
|
HF.showErrorMessage(i18n.getError("CC.notConnected")); |
1070 |
|
return false; |
1071 |
|
} |
1072 |
|
|
1073 |
|
return true; |
1074 |
|
} |
1075 |
|
|
1076 |
|
|
1077 |
private final static EventHandler eventHandler = new EventHandler(); |
private final static EventHandler eventHandler = new EventHandler(); |
1078 |
|
|
1081 |
|
|
1082 |
private static class EventHandler implements ChannelCountListener, ChannelInfoListener, |
private static class EventHandler implements ChannelCountListener, ChannelInfoListener, |
1083 |
FxSendCountListener, FxSendInfoListener, StreamCountListener, VoiceCountListener, |
FxSendCountListener, FxSendInfoListener, StreamCountListener, VoiceCountListener, |
1084 |
TotalVoiceCountListener, TaskQueueListener, OrchestraListener, |
TotalStreamCountListener, TotalVoiceCountListener, TaskQueueListener, |
1085 |
ListListener<OrchestraModel>, MidiInstrumentCountListener, |
OrchestraListener, ListListener<OrchestraModel>, MidiInstrumentCountListener, |
1086 |
MidiInstrumentInfoListener, GlobalInfoListener { |
MidiInstrumentInfoListener, GlobalInfoListener { |
1087 |
|
|
1088 |
/** Invoked when the number of channels has changed. */ |
/** Invoked when the number of channels has changed. */ |
1187 |
scm.setVoiceCount(e.getVoiceCount()); |
scm.setVoiceCount(e.getVoiceCount()); |
1188 |
} |
} |
1189 |
|
|
1190 |
|
/** Invoked when the total number of active streams has changed. */ |
1191 |
|
public void |
1192 |
|
totalStreamCountChanged(TotalStreamCountEvent e) { |
1193 |
|
getSamplerModel().updateActiveStreamsInfo(e.getTotalStreamCount()); |
1194 |
|
} |
1195 |
|
|
1196 |
/** Invoked when the total number of active voices has changed. */ |
/** Invoked when the total number of active voices has changed. */ |
1197 |
public void |
public void |
1198 |
totalVoiceCountChanged(TotalVoiceCountEvent e) { |
totalVoiceCountChanged(TotalVoiceCountEvent e) { |
1202 |
/** Invoked when the number of MIDI instruments in a MIDI instrument map is changed. */ |
/** Invoked when the number of MIDI instruments in a MIDI instrument map is changed. */ |
1203 |
public void |
public void |
1204 |
instrumentCountChanged(MidiInstrumentCountEvent e) { |
instrumentCountChanged(MidiInstrumentCountEvent e) { |
1205 |
getTaskQueue().add(new Midi.UpdateInstruments(e.getMapId())); |
scheduleTask(new Midi.UpdateInstruments(e.getMapId())); |
1206 |
} |
} |
1207 |
|
|
1208 |
/** Invoked when a MIDI instrument in a MIDI instrument map is changed. */ |
/** Invoked when a MIDI instrument in a MIDI instrument map is changed. */ |
1236 |
case TASK_DONE: |
case TASK_DONE: |
1237 |
EnhancedTask t = (EnhancedTask)e.getSource(); |
EnhancedTask t = (EnhancedTask)e.getSource(); |
1238 |
if(t.doneWithErrors() && !t.isStopped()) { |
if(t.doneWithErrors() && !t.isStopped()) { |
1239 |
if(t.getErrorDetails() == null) { |
showError(t); |
|
HF.showErrorMessage(t.getErrorMessage()); |
|
|
} else { |
|
|
getMainFrame().showDetailedErrorMessage ( |
|
|
getMainFrame(), |
|
|
t.getErrorMessage(), |
|
|
t.getErrorDetails() |
|
|
); |
|
|
} |
|
1240 |
} |
} |
1241 |
break; |
break; |
1242 |
case NOT_IDLE: |
case NOT_IDLE: |
1249 |
} |
} |
1250 |
} |
} |
1251 |
|
|
1252 |
|
private void |
1253 |
|
showError(final Task t) { |
1254 |
|
javax.swing.SwingUtilities.invokeLater(new Runnable() { |
1255 |
|
public void |
1256 |
|
run() { |
1257 |
|
if(t.getErrorDetails() == null) { |
1258 |
|
HF.showErrorMessage(t.getErrorMessage()); |
1259 |
|
} else { |
1260 |
|
getMainFrame().showDetailedErrorMessage ( |
1261 |
|
getMainFrame(), |
1262 |
|
t.getErrorMessage(), |
1263 |
|
t.getErrorDetails() |
1264 |
|
); |
1265 |
|
} |
1266 |
|
} |
1267 |
|
}); |
1268 |
|
} |
1269 |
|
|
1270 |
/** Invoked when the name of orchestra is changed. */ |
/** Invoked when the name of orchestra is changed. */ |
1271 |
public void |
public void |
1272 |
nameChanged(OrchestraEvent e) { saveOrchestras(); } |
nameChanged(OrchestraEvent e) { saveOrchestras(); } |