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 |
* |
* |
66 |
|
|
67 |
import org.jsampler.CC; |
import org.jsampler.CC; |
68 |
import org.jsampler.HF; |
import org.jsampler.HF; |
69 |
import org.jsampler.Instrument; |
import org.jsampler.OrchestraInstrument; |
70 |
import org.jsampler.MidiInstrumentMap; |
import org.jsampler.MidiInstrumentMap; |
71 |
import org.jsampler.OrchestraModel; |
import org.jsampler.OrchestraModel; |
72 |
import org.jsampler.SamplerChannelModel; |
import org.jsampler.SamplerChannelModel; |
422 |
actionPerformed(ActionEvent e) { |
actionPerformed(ActionEvent e) { |
423 |
DbDirectoryTreeNode n = instrumentsDbTree.getSelectedDirectoryNode(); |
DbDirectoryTreeNode n = instrumentsDbTree.getSelectedDirectoryNode(); |
424 |
if(n == null) return; |
if(n == null) return; |
425 |
instrumentsDbTree.refreshDirectoryContent(n.getInfo().getDirectoryPath()); |
final String path = n.getInfo().getDirectoryPath(); |
426 |
|
instrumentsDbTree.refreshDirectoryContent(path); |
427 |
|
CC.scheduleInTaskQueue(new Runnable() { |
428 |
|
public void |
429 |
|
run() { instrumentsDbTree.setSelectedDirectory(path); } |
430 |
|
}); |
431 |
} |
} |
432 |
|
|
433 |
public void |
public void |
626 |
|
|
627 |
LoadInstrumentAction(SamplerChannelModel model) { |
LoadInstrumentAction(SamplerChannelModel model) { |
628 |
String s = "instrumentsdb.actions.loadInstrument.onChannel"; |
String s = "instrumentsdb.actions.loadInstrument.onChannel"; |
629 |
putValue(Action.NAME, i18n.getMenuLabel(s, model.getChannelId())); |
int i = CC.getSamplerModel().getChannelIndex(model) + 1; |
630 |
|
putValue(Action.NAME, i18n.getMenuLabel(s, i)); |
631 |
channelModel = model; |
channelModel = model; |
632 |
} |
} |
633 |
|
|
652 |
|
|
653 |
public void |
public void |
654 |
actionPerformed(ActionEvent e) { |
actionPerformed(ActionEvent e) { |
655 |
Object obj = getLeadObject(); |
DbInstrumentInfo[] instruments = getSelectedInstruments(); |
656 |
if(obj == null || !(obj instanceof DbInstrumentInfo)) return; |
int l = instruments.length; |
657 |
|
if(l == 0) return; |
658 |
DbInstrumentInfo info = (DbInstrumentInfo)obj; |
|
659 |
|
if(l > 4) { |
660 |
|
String s = "JSInstrumentsDbTable.confirmAddToMidiMap"; |
661 |
|
s = i18n.getMessage(s, l, midiMap.getName()); |
662 |
|
if(!HF.showYesNoDialog(JSInstrumentsDbTable.this, s)) return; |
663 |
|
} |
664 |
|
|
665 |
JSAddMidiInstrumentDlg dlg; |
JSAddMidiInstrumentDlg dlg; |
666 |
Window w = JuifeUtils.getWindow(JSInstrumentsDbTable.this); |
Window w = JuifeUtils.getWindow(JSInstrumentsDbTable.this); |
667 |
if(w instanceof Dialog) { |
|
668 |
dlg = new JSAddMidiInstrumentDlg((Dialog)w); |
for(DbInstrumentInfo i : instruments) { |
669 |
} else if(w instanceof Frame) { |
if(w instanceof Dialog) { |
670 |
dlg = new JSAddMidiInstrumentDlg((Frame)w); |
dlg = new JSAddMidiInstrumentDlg((Dialog)w, midiMap, i); |
671 |
} else { |
} else if(w instanceof Frame) { |
672 |
dlg = new JSAddMidiInstrumentDlg((Frame)null); |
dlg = new JSAddMidiInstrumentDlg((Frame)w, midiMap, i); |
673 |
|
} else { |
674 |
|
dlg = new JSAddMidiInstrumentDlg((Frame)null, midiMap, i); |
675 |
|
} |
676 |
|
|
677 |
|
dlg.setVisible(true); |
678 |
} |
} |
|
|
|
|
dlg.setInstrumentName(info.getName()); |
|
|
dlg.setVisible(true); |
|
|
if(dlg.isCancelled()) return; |
|
|
|
|
|
MidiInstrumentInfo instrInfo = new MidiInstrumentInfo(); |
|
|
instrInfo.setName(dlg.getInstrumentName()); |
|
|
instrInfo.setFilePath(info.getFilePath()); |
|
|
instrInfo.setInstrumentIndex(info.getInstrumentIndex()); |
|
|
instrInfo.setEngine(info.getFormatFamily()); // TODO: this should be fixed |
|
|
instrInfo.setVolume(dlg.getVolume()); |
|
|
instrInfo.setLoadMode(dlg.getLoadMode()); |
|
|
|
|
|
int id = midiMap.getMapId(); |
|
|
int b = dlg.getMidiBank(); |
|
|
int p = dlg.getMidiProgram(); |
|
|
CC.getSamplerModel().mapBackendMidiInstrument(id, b, p, instrInfo); |
|
679 |
} |
} |
680 |
} |
} |
681 |
|
|
689 |
|
|
690 |
public void |
public void |
691 |
actionPerformed(ActionEvent e) { |
actionPerformed(ActionEvent e) { |
692 |
Object obj = getLeadObject(); |
DbInstrumentInfo[] instruments = getSelectedInstruments(); |
693 |
if(obj == null || !(obj instanceof DbInstrumentInfo)) return; |
int l = instruments.length; |
694 |
DbInstrumentInfo info = (DbInstrumentInfo)obj; |
if(l == 0) return; |
695 |
Instrument instr = new Instrument(); |
|
696 |
instr.setPath(info.getFilePath()); |
if(l > 1) { |
697 |
instr.setInstrumentIndex(info.getInstrumentIndex()); |
String s = "JSInstrumentsDbTable.confirmAddToOrchestra"; |
698 |
instr.setName(info.getName()); |
s = i18n.getMessage(s, l, orchestraModel.getName()); |
699 |
instr.setDescription(info.getDescription()); |
if(!HF.showYesNoDialog(JSInstrumentsDbTable.this, s)) return; |
700 |
instr.setEngine(info.getFormatFamily()); // TODO: this should be fixed |
} |
701 |
orchestraModel.addInstrument(instr); |
|
702 |
|
for(DbInstrumentInfo i : instruments) { |
703 |
|
OrchestraInstrument instr = new OrchestraInstrument(); |
704 |
|
instr.setFilePath(i.getFilePath()); |
705 |
|
instr.setInstrumentIndex(i.getInstrumentIndex()); |
706 |
|
instr.setName(i.getName()); |
707 |
|
instr.setDescription(i.getDescription()); |
708 |
|
instr.setEngine(i.getFormatFamily()); // TODO: this should be fixed |
709 |
|
orchestraModel.addInstrument(instr); |
710 |
|
} |
711 |
} |
} |
712 |
} |
} |
713 |
|
|
1029 |
|
|
1030 |
public void |
public void |
1031 |
channelAdded(SamplerChannelListEvent e) { |
channelAdded(SamplerChannelListEvent e) { |
1032 |
|
if(CC.getSamplerModel().getChannelListIsAdjusting()) return; |
1033 |
updateLoadInstrumentMenus(); |
updateLoadInstrumentMenus(); |
1034 |
} |
} |
1035 |
|
|