1 |
/* |
/* |
2 |
* JSampler - a java front-end for LinuxSampler |
* JSampler - a java front-end for LinuxSampler |
3 |
* |
* |
4 |
* Copyright (C) 2005-2007 Grigor Iliev <grigor@grigoriliev.com> |
* Copyright (C) 2005-2008 Grigor Iliev <grigor@grigoriliev.com> |
5 |
* |
* |
6 |
* This file is part of JSampler. |
* This file is part of JSampler. |
7 |
* |
* |
154 |
public static JSViewConfig |
public static JSViewConfig |
155 |
getViewConfig() { return viewConfig; } |
getViewConfig() { return viewConfig; } |
156 |
|
|
157 |
private static JSPrefs |
public static JSPrefs |
158 |
preferences() { return getViewConfig().preferences(); } |
preferences() { return getViewConfig().preferences(); } |
159 |
|
|
160 |
/** |
/** |
241 |
run() { if(handler != null) handler.flush(); } |
run() { if(handler != null) handler.flush(); } |
242 |
}, 1000, 1000); |
}, 1000, 1000); |
243 |
|
|
244 |
CC.getLogger().fine("CC.jsStarted"); |
getLogger().fine("CC.jsStarted"); |
245 |
|
|
246 |
HF.setUIDefaultFont(Prefs.getInterfaceFont()); |
HF.setUIDefaultFont(Prefs.getInterfaceFont()); |
247 |
|
|
324 |
} |
} |
325 |
} |
} |
326 |
|
|
327 |
CC.getMainFrame().installJSamplerHome(); |
getMainFrame().installJSamplerHome(); |
328 |
} |
} |
329 |
|
|
330 |
/** |
/** |
409 |
*/ |
*/ |
410 |
public static InstrumentsDbTreeModel |
public static InstrumentsDbTreeModel |
411 |
getInstrumentsDbTreeModel() { |
getInstrumentsDbTreeModel() { |
412 |
if(CC.getSamplerModel().getServerInfo() == null) return null; |
if(getSamplerModel().getServerInfo() == null) return null; |
413 |
if(!CC.getSamplerModel().getServerInfo().hasInstrumentsDbSupport()) return null; |
if(!getSamplerModel().getServerInfo().hasInstrumentsDbSupport()) return null; |
414 |
|
|
415 |
if(instrumentsDbTreeModel == null) { |
if(instrumentsDbTreeModel == null) { |
416 |
instrumentsDbTreeModel = new InstrumentsDbTreeModel(); |
instrumentsDbTreeModel = new InstrumentsDbTreeModel(); |
605 |
*/ |
*/ |
606 |
public static void |
public static void |
607 |
cleanExit(int i) { |
cleanExit(int i) { |
608 |
CC.getLogger().fine("CC.jsEnded"); |
getLogger().fine("CC.jsEnded"); |
609 |
System.exit(i); |
System.exit(i); |
610 |
} |
} |
611 |
|
|
675 |
setCurrentServer(Server server) { currentServer = server; } |
setCurrentServer(Server server) { currentServer = server; } |
676 |
|
|
677 |
/** |
/** |
678 |
|
* Sets the LSCP client's read timeout. |
679 |
|
* @param timeout The new timeout value (in seconds). |
680 |
|
*/ |
681 |
|
public static void |
682 |
|
setClientReadTimeout(int timeout) { |
683 |
|
getTaskQueue().add(new Global.SetClientReadTimeout(timeout)); |
684 |
|
} |
685 |
|
|
686 |
|
/** |
687 |
* This method updates the information about the backend state. |
* This method updates the information about the backend state. |
688 |
*/ |
*/ |
689 |
private static void |
private static void |
809 |
ssa.addTaskListener(new TaskListener() { |
ssa.addTaskListener(new TaskListener() { |
810 |
public void |
public void |
811 |
taskPerformed(TaskEvent e) { |
taskPerformed(TaskEvent e) { |
812 |
|
int t = preferences().getIntProperty(JSPrefs.SOCKET_READ_TIMEOUT); |
813 |
|
CC.setClientReadTimeout(t * 1000); |
814 |
CC.getTaskQueue().add(cnt); |
CC.getTaskQueue().add(cnt); |
815 |
} |
} |
816 |
}); |
}); |
875 |
exportInstrMapsToLscpScript(Client lscpClient) { |
exportInstrMapsToLscpScript(Client lscpClient) { |
876 |
try { |
try { |
877 |
lscpClient.removeAllMidiInstrumentMaps(); |
lscpClient.removeAllMidiInstrumentMaps(); |
878 |
MidiInstrumentMap[] maps = CC.getSamplerModel().getMidiInstrumentMaps(); |
MidiInstrumentMap[] maps = getSamplerModel().getMidiInstrumentMaps(); |
879 |
for(int i = 0; i < maps.length; i++) { |
for(int i = 0; i < maps.length; i++) { |
880 |
lscpClient.addMidiInstrumentMap(maps[i].getName()); |
lscpClient.addMidiInstrumentMap(maps[i].getName()); |
881 |
exportInstrumentsToLscpScript(i, maps[i], lscpClient); |
exportInstrumentsToLscpScript(i, maps[i], lscpClient); |
882 |
} |
} |
883 |
} catch(Exception e) { |
} catch(Exception e) { |
884 |
CC.getLogger().log(Level.FINE, HF.getErrorMessage(e), e); |
getLogger().log(Level.FINE, HF.getErrorMessage(e), e); |
885 |
HF.showErrorMessage(e); |
HF.showErrorMessage(e); |
886 |
} |
} |
887 |
} |
} |
890 |
exportInstrumentsToLscpScript(int mapId, MidiInstrumentMap map, Client lscpClient) |
exportInstrumentsToLscpScript(int mapId, MidiInstrumentMap map, Client lscpClient) |
891 |
throws Exception { |
throws Exception { |
892 |
|
|
893 |
|
boolean b = preferences().getBoolProperty(JSPrefs.LOAD_MIDI_INSTRUMENTS_IN_BACKGROUND); |
894 |
|
|
895 |
for(MidiInstrument i : map.getAllMidiInstruments()) { |
for(MidiInstrument i : map.getAllMidiInstruments()) { |
896 |
lscpClient.mapMidiInstrument(mapId, i.getInfo().getEntry(), i.getInfo()); |
lscpClient.mapMidiInstrument(mapId, i.getInfo().getEntry(), i.getInfo(), b); |
897 |
} |
} |
898 |
} |
} |
899 |
|
|
900 |
public static String |
public static String |
901 |
exportSessionToLscpScript() { |
exportSessionToLscpScript() { |
902 |
CC.getSamplerModel().setModified(false); |
getSamplerModel().setModified(false); |
903 |
|
|
904 |
StringBuffer sb = new StringBuffer("# Exported by: "); |
StringBuffer sb = new StringBuffer("# Exported by: "); |
905 |
sb.append("JSampler - a java front-end for LinuxSampler\r\n# Version: "); |
sb.append("JSampler - a java front-end for LinuxSampler\r\n# Version: "); |
915 |
sb.append(out.toString()); |
sb.append(out.toString()); |
916 |
out.reset(); |
out.reset(); |
917 |
sb.append("\r\n"); |
sb.append("\r\n"); |
918 |
lscpClient.setVolume(CC.getSamplerModel().getVolume()); |
lscpClient.setVolume(getSamplerModel().getVolume()); |
919 |
sb.append(out.toString()); |
sb.append(out.toString()); |
920 |
out.reset(); |
out.reset(); |
921 |
sb.append("\r\n"); |
sb.append("\r\n"); |
922 |
} catch(Exception e) { CC.getLogger().log(Level.FINE, HF.getErrorMessage(e), e); } |
} catch(Exception e) { getLogger().log(Level.FINE, HF.getErrorMessage(e), e); } |
923 |
|
|
924 |
MidiDeviceModel[] mDevs = getSamplerModel().getMidiDevices(); |
MidiDeviceModel[] mDevs = getSamplerModel().getMidiDevices(); |
925 |
for(int i = 0; i < mDevs.length; i++) { |
for(int i = 0; i < mDevs.length; i++) { |
937 |
sb.append("\r\n"); |
sb.append("\r\n"); |
938 |
} |
} |
939 |
|
|
940 |
exportInstrMapsToLscpScript(lscpClient); |
boolean b = preferences().getBoolProperty(JSPrefs.EXPORT_MIDI_MAPS_TO_SESSION_SCRIPT); |
941 |
sb.append(out.toString()); |
if(b) { |
942 |
out.reset(); |
exportInstrMapsToLscpScript(lscpClient); |
943 |
sb.append("\r\n"); |
sb.append(out.toString()); |
944 |
|
out.reset(); |
945 |
|
sb.append("\r\n"); |
946 |
|
} |
947 |
|
|
948 |
SamplerChannelModel[] channels = getSamplerModel().getChannels(); |
SamplerChannelModel[] channels = getSamplerModel().getChannels(); |
949 |
|
|
962 |
sb.append("\r\n"); |
sb.append("\r\n"); |
963 |
} |
} |
964 |
|
|
965 |
|
//sb.append(getViewConfig().exportSessionViewConfig()); |
966 |
|
|
967 |
return sb.toString(); |
return sb.toString(); |
968 |
} |
} |
969 |
|
|
985 |
} |
} |
986 |
} |
} |
987 |
} catch(Exception e) { |
} catch(Exception e) { |
988 |
CC.getLogger().log(Level.FINE, HF.getErrorMessage(e), e); |
getLogger().log(Level.FINE, HF.getErrorMessage(e), e); |
989 |
} |
} |
990 |
} |
} |
991 |
|
|
1005 |
} |
} |
1006 |
} |
} |
1007 |
} catch(Exception e) { |
} catch(Exception e) { |
1008 |
CC.getLogger().log(Level.FINE, HF.getErrorMessage(e), e); |
getLogger().log(Level.FINE, HF.getErrorMessage(e), e); |
1009 |
} |
} |
1010 |
} |
} |
1011 |
|
|
1014 |
try { |
try { |
1015 |
lscpCLient.addSamplerChannel(); |
lscpCLient.addSamplerChannel(); |
1016 |
|
|
1017 |
SamplerModel sm = CC.getSamplerModel(); |
SamplerModel sm = getSamplerModel(); |
1018 |
int id = chn.getMidiInputDevice(); |
int id = chn.getMidiInputDevice(); |
1019 |
if(id != -1) { |
if(id != -1) { |
1020 |
for(int i = 0; i < sm.getMidiDeviceCount(); i++) { |
for(int i = 0; i < sm.getMidiDeviceCount(); i++) { |
1060 |
if(chn.isMuted()) lscpCLient.setChannelMute(chnId, true); |
if(chn.isMuted()) lscpCLient.setChannelMute(chnId, true); |
1061 |
if(chn.isSoloChannel()) lscpCLient.setChannelSolo(chnId, true); |
if(chn.isSoloChannel()) lscpCLient.setChannelSolo(chnId, true); |
1062 |
} catch(Exception e) { |
} catch(Exception e) { |
1063 |
CC.getLogger().log(Level.FINE, HF.getErrorMessage(e), e); |
getLogger().log(Level.FINE, HF.getErrorMessage(e), e); |
1064 |
} |
} |
1065 |
} |
} |
1066 |
|
|
1079 |
} |
} |
1080 |
} |
} |
1081 |
} catch(Exception e) { |
} catch(Exception e) { |
1082 |
CC.getLogger().log(Level.FINE, HF.getErrorMessage(e), e); |
getLogger().log(Level.FINE, HF.getErrorMessage(e), e); |
1083 |
} |
} |
1084 |
} |
} |
1085 |
|
|
1093 |
} |
} |
1094 |
}); |
}); |
1095 |
|
|
1096 |
CC.getTaskQueue().add(dummy); |
getTaskQueue().add(dummy); |
1097 |
} |
} |
1098 |
|
|
1099 |
public static boolean |
public static boolean |