47 |
|
|
48 |
import org.jsampler.CC; |
import org.jsampler.CC; |
49 |
import org.jsampler.DefaultOrchestraModel; |
import org.jsampler.DefaultOrchestraModel; |
50 |
import org.jsampler.Instrument; |
import org.jsampler.OrchestraInstrument; |
51 |
import org.jsampler.MidiInstrumentMap; |
import org.jsampler.MidiInstrumentMap; |
52 |
import org.jsampler.OrchestraModel; |
import org.jsampler.OrchestraModel; |
53 |
import org.jsampler.SamplerChannelModel; |
import org.jsampler.SamplerChannelModel; |
141 |
instrumentTable.getModel().setOrchestraModel(orchestra); |
instrumentTable.getModel().setOrchestraModel(orchestra); |
142 |
} |
} |
143 |
|
|
144 |
public Instrument |
public OrchestraInstrument |
145 |
getSelectedInstrument() { return instrumentTable.getSelectedInstrument(); } |
getSelectedInstrument() { return instrumentTable.getSelectedInstrument(); } |
146 |
|
|
147 |
/** |
/** |
149 |
* @return The instrument to add |
* @return The instrument to add |
150 |
* or <code>null</code> if the user cancelled the task. |
* or <code>null</code> if the user cancelled the task. |
151 |
*/ |
*/ |
152 |
public Instrument |
public OrchestraInstrument |
153 |
createInstrument() { |
createInstrument() { |
154 |
JSAddOrEditInstrumentDlg dlg = new JSAddOrEditInstrumentDlg(); |
JSAddOrEditInstrumentDlg dlg = new JSAddOrEditInstrumentDlg(); |
155 |
dlg.setVisible(true); |
dlg.setVisible(true); |
159 |
} |
} |
160 |
|
|
161 |
public void |
public void |
162 |
editInstrument(Instrument instr) { |
editInstrument(OrchestraInstrument instr) { |
163 |
JSAddOrEditInstrumentDlg dlg = new JSAddOrEditInstrumentDlg(instr); |
JSAddOrEditInstrumentDlg dlg = new JSAddOrEditInstrumentDlg(instr); |
164 |
dlg.setVisible(true); |
dlg.setVisible(true); |
165 |
} |
} |
196 |
|
|
197 |
public void |
public void |
198 |
actionPerformed(ActionEvent e) { |
actionPerformed(ActionEvent e) { |
199 |
Instrument instr = createInstrument(); |
OrchestraInstrument instr = createInstrument(); |
200 |
if(instr == null) return; |
if(instr == null) return; |
201 |
orchestra.addInstrument(instr); |
orchestra.addInstrument(instr); |
202 |
} |
} |
230 |
|
|
231 |
public void |
public void |
232 |
actionPerformed(ActionEvent e) { |
actionPerformed(ActionEvent e) { |
233 |
Instrument instr = instrumentTable.getSelectedInstrument(); |
OrchestraInstrument instr = instrumentTable.getSelectedInstrument(); |
234 |
if(instr == null) return; |
if(instr == null) return; |
235 |
|
int i = instrumentTable.getSelectedRow(); |
236 |
orchestra.removeInstrument(instr); |
orchestra.removeInstrument(instr); |
237 |
|
|
238 |
|
if(instrumentTable.getRowCount() > i) { |
239 |
|
instrumentTable.getSelectionModel().setSelectionInterval(i, i); |
240 |
|
} |
241 |
} |
} |
242 |
} |
} |
243 |
|
|
253 |
|
|
254 |
public void |
public void |
255 |
actionPerformed(ActionEvent e) { |
actionPerformed(ActionEvent e) { |
256 |
Instrument instr = instrumentTable.getSelectedInstrument(); |
OrchestraInstrument instr = instrumentTable.getSelectedInstrument(); |
257 |
instrumentTable.getModel().getOrchestraModel().moveInstrumentUp(instr); |
instrumentTable.getModel().getOrchestraModel().moveInstrumentUp(instr); |
258 |
instrumentTable.setSelectedInstrument(instr); |
instrumentTable.setSelectedInstrument(instr); |
259 |
} |
} |
271 |
|
|
272 |
public void |
public void |
273 |
actionPerformed(ActionEvent e) { |
actionPerformed(ActionEvent e) { |
274 |
Instrument instr = instrumentTable.getSelectedInstrument(); |
OrchestraInstrument instr = instrumentTable.getSelectedInstrument(); |
275 |
instrumentTable.getModel().getOrchestraModel().moveInstrumentDown(instr); |
instrumentTable.getModel().getOrchestraModel().moveInstrumentDown(instr); |
276 |
instrumentTable.setSelectedInstrument(instr); |
instrumentTable.setSelectedInstrument(instr); |
277 |
} |
} |
290 |
|
|
291 |
public void |
public void |
292 |
actionPerformed(ActionEvent e) { |
actionPerformed(ActionEvent e) { |
293 |
Instrument instr = instrumentTable.getSelectedInstrument(); |
OrchestraInstrument instr = instrumentTable.getSelectedInstrument(); |
294 |
if(instr == null) return; |
if(instr == null) return; |
295 |
|
|
296 |
int idx = instr.getInstrumentIndex(); |
int idx = instr.getInstrumentIndex(); |
297 |
channelModel.setBackendEngineType(instr.getEngine()); |
channelModel.setBackendEngineType(instr.getEngine()); |
298 |
channelModel.loadBackendInstrument(instr.getPath(), idx); |
channelModel.loadBackendInstrument(instr.getFilePath(), idx); |
299 |
} |
} |
300 |
} |
} |
301 |
|
|
309 |
|
|
310 |
public void |
public void |
311 |
actionPerformed(ActionEvent e) { |
actionPerformed(ActionEvent e) { |
312 |
Instrument instr = instrumentTable.getSelectedInstrument(); |
OrchestraInstrument instr = instrumentTable.getSelectedInstrument(); |
313 |
if(instr == null) return; |
if(instr == null) return; |
314 |
|
|
315 |
JSAddMidiInstrumentDlg dlg; |
JSAddMidiInstrumentDlg dlg; |
316 |
Window w = JuifeUtils.getWindow(JSOrchestraPane.this); |
Window w = JuifeUtils.getWindow(JSOrchestraPane.this); |
317 |
if(w instanceof Dialog) { |
if(w instanceof Dialog) { |
318 |
dlg = new JSAddMidiInstrumentDlg((Dialog)w); |
dlg = new JSAddMidiInstrumentDlg((Dialog)w, midiMap, instr); |
319 |
} else if(w instanceof Frame) { |
} else if(w instanceof Frame) { |
320 |
dlg = new JSAddMidiInstrumentDlg((Frame)w); |
dlg = new JSAddMidiInstrumentDlg((Frame)w, midiMap, instr); |
321 |
} else { |
} else { |
322 |
dlg = new JSAddMidiInstrumentDlg((Frame)null); |
dlg = new JSAddMidiInstrumentDlg((Frame)null, midiMap, instr); |
323 |
} |
} |
324 |
|
|
|
dlg.setInstrumentName(instr.getName()); |
|
|
MidiInstrumentEntry entry = midiMap.getAvailableEntry(); |
|
|
if(entry != null) { |
|
|
dlg.setMidiBank(entry.getMidiBank()); |
|
|
dlg.setMidiProgram(entry.getMidiProgram()); |
|
|
} |
|
325 |
dlg.setVisible(true); |
dlg.setVisible(true); |
|
if(dlg.isCancelled()) return; |
|
|
|
|
|
MidiInstrumentInfo instrInfo = new MidiInstrumentInfo(); |
|
|
instrInfo.setName(dlg.getInstrumentName()); |
|
|
instrInfo.setFilePath(instr.getPath()); |
|
|
instrInfo.setInstrumentIndex(instr.getInstrumentIndex()); |
|
|
instrInfo.setEngine(instr.getEngine()); |
|
|
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); |
|
326 |
} |
} |
327 |
} |
} |
328 |
|
|
392 |
|
|
393 |
private void |
private void |
394 |
updateLoadInstrumentMenuState(JMenu menu) { |
updateLoadInstrumentMenuState(JMenu menu) { |
395 |
Instrument instr = instrumentTable.getSelectedInstrument(); |
OrchestraInstrument instr = instrumentTable.getSelectedInstrument(); |
396 |
boolean b = instr == null; |
boolean b = instr == null; |
397 |
b = b || CC.getSamplerModel().getChannelCount() == 0; |
b = b || CC.getSamplerModel().getChannelCount() == 0; |
398 |
menu.setEnabled(!b); |
menu.setEnabled(!b); |
411 |
|
|
412 |
private void |
private void |
413 |
updateAddToMidiMapMenuState(JMenu menu) { |
updateAddToMidiMapMenuState(JMenu menu) { |
414 |
Instrument instr = instrumentTable.getSelectedInstrument(); |
OrchestraInstrument instr = instrumentTable.getSelectedInstrument(); |
415 |
boolean b = instr == null; |
boolean b = instr == null; |
416 |
b = b || CC.getSamplerModel().getMidiInstrumentMapCount() == 0; |
b = b || CC.getSamplerModel().getMidiInstrumentMapCount() == 0; |
417 |
menu.setEnabled(!b); |
menu.setEnabled(!b); |