--- jsampler/trunk/src/org/jsampler/CC.java 2007/09/08 18:33:05 1329 +++ jsampler/trunk/src/org/jsampler/CC.java 2007/12/06 19:37:41 1567 @@ -265,6 +265,9 @@ getClient().removeVoiceCountListener(getHandler()); getClient().addVoiceCountListener(getHandler()); + getClient().removeTotalStreamCountListener(getHandler()); + getClient().addTotalStreamCountListener(getHandler()); + getClient().removeTotalVoiceCountListener(getHandler()); getClient().addTotalVoiceCountListener(getHandler()); @@ -403,6 +406,7 @@ try { String s = getJSamplerHome(); if(s == null) return; + getOrchestras().addOrchestraListListener(getHandler()); File f = new File(s + File.separator + "orchestras.xml.bkp"); if(f.isFile()) HF.createBackup("orchestras.xml.bkp", "orchestras.xml.rec"); @@ -431,7 +435,6 @@ for(int i = 0; i < getOrchestras().getOrchestraCount(); i++) { getOrchestras().getOrchestra(i).addOrchestraListener(getHandler()); } - getOrchestras().addOrchestraListListener(getHandler()); } private static void @@ -610,6 +613,9 @@ gfs.addTaskListener(new GetFxSendsListener()); getTaskQueue().add(gfs); } + + // TODO: This should be done after the fx sends are set + //CC.getSamplerModel().setModified(false); } }); @@ -690,6 +696,8 @@ public static String exportSessionToLscpScript() { + CC.getSamplerModel().setModified(false); + StringBuffer sb = new StringBuffer("# Exported by: "); sb.append("JSampler - a java front-end for LinuxSampler\r\n# Version: "); sb.append(JSampler.VERSION).append("\r\n"); @@ -729,7 +737,7 @@ SamplerChannelModel[] channels = getSamplerModel().getChannels(); for(int i = 0; i < channels.length; i++) { - SamplerChannelModel scm = getSamplerModel().getChannelById(i); + SamplerChannelModel scm = channels[i]; exportChannelToLscpScript(scm.getChannelInfo(), i, lscpClient); sb.append(out.toString()); out.reset(); @@ -797,14 +805,28 @@ try { lscpCLient.addSamplerChannel(); - int i = chn.getMidiInputDevice(); - if(i != -1) lscpCLient.setChannelMidiInputDevice(chnId, i); - lscpCLient.setChannelMidiInputPort(chnId, chn.getMidiInputPort()); - lscpCLient.setChannelMidiInputChannel(chnId, chn.getMidiInputChannel()); - - i = chn.getAudioOutputDevice(); - if(i != -1) { - lscpCLient.setChannelAudioOutputDevice(chnId, i); + SamplerModel sm = CC.getSamplerModel(); + int id = chn.getMidiInputDevice(); + if(id != -1) { + for(int i = 0; i < sm.getMidiDeviceCount(); i++) { + if(sm.getMidiDevice(i).getDeviceId() == id) { + lscpCLient.setChannelMidiInputDevice(chnId, i); + break; + } + } + lscpCLient.setChannelMidiInputPort(chnId, chn.getMidiInputPort()); + lscpCLient.setChannelMidiInputChannel(chnId, chn.getMidiInputChannel()); + } + + id = chn.getAudioOutputDevice(); + if(id != -1) { + for(int i = 0; i < sm.getAudioDeviceCount(); i++) { + if(sm.getAudioDevice(i).getDeviceId() == id) { + lscpCLient.setChannelAudioOutputDevice(chnId, i); + break; + } + } + Integer[] routing = chn.getAudioOutputRouting(); for(int j = 0; j < routing.length; j++) { @@ -821,7 +843,7 @@ } String s = chn.getInstrumentFile(); - i = chn.getInstrumentIndex(); + int i = chn.getInstrumentIndex(); if(s != null) lscpCLient.loadInstrument(s, i, chnId, true); if(chn.isMuted()) lscpCLient.setChannelMute(chnId, true); @@ -858,8 +880,8 @@ private static class EventHandler implements ChannelCountListener, ChannelInfoListener, FxSendCountListener, FxSendInfoListener, StreamCountListener, VoiceCountListener, - TotalVoiceCountListener, TaskQueueListener, OrchestraListener, - ListListener, MidiInstrumentCountListener, + TotalStreamCountListener, TotalVoiceCountListener, TaskQueueListener, + OrchestraListener, ListListener, MidiInstrumentCountListener, MidiInstrumentInfoListener, GlobalInfoListener { /** Invoked when the number of channels has changed. */ @@ -964,6 +986,12 @@ scm.setVoiceCount(e.getVoiceCount()); } + /** Invoked when the total number of active streams has changed. */ + public void + totalStreamCountChanged(TotalStreamCountEvent e) { + getSamplerModel().updateActiveStreamsInfo(e.getTotalStreamCount()); + } + /** Invoked when the total number of active voices has changed. */ public void totalVoiceCountChanged(TotalVoiceCountEvent e) {