1 |
/* |
/* |
2 |
* JSampler - a java front-end for LinuxSampler |
* JSampler - a java front-end for LinuxSampler |
3 |
* |
* |
4 |
* Copyright (C) 2005-2006 Grigor Iliev <grigor@grigoriliev.com> |
* Copyright (C) 2005-2007 Grigor Iliev <grigor@grigoriliev.com> |
5 |
* |
* |
6 |
* This file is part of JSampler. |
* This file is part of JSampler. |
7 |
* |
* |
24 |
|
|
25 |
import java.awt.Cursor; |
import java.awt.Cursor; |
26 |
import java.awt.Dimension; |
import java.awt.Dimension; |
27 |
|
import java.awt.Graphics; |
28 |
import java.awt.Insets; |
import java.awt.Insets; |
29 |
|
|
30 |
import java.awt.event.ActionEvent; |
import java.awt.event.ActionEvent; |
32 |
import java.awt.event.MouseAdapter; |
import java.awt.event.MouseAdapter; |
33 |
import java.awt.event.MouseEvent; |
import java.awt.event.MouseEvent; |
34 |
|
|
35 |
|
import java.beans.PropertyChangeEvent; |
36 |
|
import java.beans.PropertyChangeListener; |
37 |
|
|
38 |
import java.util.logging.Level; |
import java.util.logging.Level; |
39 |
|
|
40 |
|
import javax.swing.Action; |
41 |
import javax.swing.BorderFactory; |
import javax.swing.BorderFactory; |
42 |
import javax.swing.Box; |
import javax.swing.Box; |
43 |
import javax.swing.BoxLayout; |
import javax.swing.BoxLayout; |
45 |
import javax.swing.JButton; |
import javax.swing.JButton; |
46 |
import javax.swing.JComboBox; |
import javax.swing.JComboBox; |
47 |
import javax.swing.JLabel; |
import javax.swing.JLabel; |
48 |
|
import javax.swing.JMenuItem; |
49 |
import javax.swing.JPanel; |
import javax.swing.JPanel; |
50 |
|
import javax.swing.JPopupMenu; |
51 |
import javax.swing.JToggleButton; |
import javax.swing.JToggleButton; |
52 |
|
import javax.swing.JToolBar; |
53 |
import javax.swing.SwingConstants; |
import javax.swing.SwingConstants; |
54 |
|
|
55 |
import javax.swing.event.ChangeEvent; |
import javax.swing.event.ChangeEvent; |
56 |
import javax.swing.event.ChangeListener; |
import javax.swing.event.ChangeListener; |
57 |
|
|
58 |
import net.sf.juife.Dial; |
import net.sf.juife.Dial; |
59 |
|
import net.sf.juife.InformationDialog; |
60 |
import net.sf.juife.JuifeUtils; |
import net.sf.juife.JuifeUtils; |
61 |
import net.sf.juife.TitleBar; |
import net.sf.juife.TitleBar; |
62 |
|
|
63 |
|
import org.jdesktop.swingx.JXCollapsiblePane; |
64 |
|
|
65 |
import org.jsampler.AudioDeviceModel; |
import org.jsampler.AudioDeviceModel; |
66 |
import org.jsampler.CC; |
import org.jsampler.CC; |
67 |
import org.jsampler.MidiDeviceModel; |
import org.jsampler.MidiDeviceModel; |
68 |
|
import org.jsampler.MidiInstrumentMap; |
69 |
import org.jsampler.SamplerChannelModel; |
import org.jsampler.SamplerChannelModel; |
70 |
import org.jsampler.SamplerModel; |
import org.jsampler.SamplerModel; |
71 |
|
|
72 |
import org.jsampler.event.ListEvent; |
import org.jsampler.event.ListEvent; |
73 |
import org.jsampler.event.ListListener; |
import org.jsampler.event.ListListener; |
74 |
|
import org.jsampler.event.MidiDeviceEvent; |
75 |
import org.jsampler.event.MidiDeviceListEvent; |
import org.jsampler.event.MidiDeviceListEvent; |
76 |
import org.jsampler.event.MidiDeviceListListener; |
import org.jsampler.event.MidiDeviceListListener; |
77 |
|
import org.jsampler.event.MidiDeviceListener; |
78 |
|
import org.jsampler.event.SamplerAdapter; |
79 |
import org.jsampler.event.SamplerChannelAdapter; |
import org.jsampler.event.SamplerChannelAdapter; |
80 |
import org.jsampler.event.SamplerChannelEvent; |
import org.jsampler.event.SamplerChannelEvent; |
81 |
|
import org.jsampler.event.SamplerChannelListEvent; |
82 |
|
import org.jsampler.event.SamplerChannelListListener; |
83 |
import org.jsampler.event.SamplerChannelListener; |
import org.jsampler.event.SamplerChannelListener; |
84 |
|
import org.jsampler.event.SamplerEvent; |
85 |
|
import org.jsampler.event.SamplerListener; |
86 |
|
|
87 |
|
import org.jsampler.view.std.JSChannelOutputRoutingDlg; |
88 |
|
import org.jsampler.view.std.JSFxSendsPane; |
89 |
|
import org.jsampler.view.std.JSInstrumentChooser; |
90 |
|
|
91 |
|
import org.jvnet.lafwidget.animation.FadeConfigurationManager; |
92 |
|
import org.jvnet.lafwidget.animation.FadeKind; |
93 |
|
|
94 |
|
import org.jvnet.substance.SubstanceImageCreator; |
95 |
|
import org.jvnet.substance.SubstanceLookAndFeel; |
96 |
|
|
97 |
import org.linuxsampler.lscp.AudioOutputDevice; |
import org.linuxsampler.lscp.AudioOutputDevice; |
98 |
import org.linuxsampler.lscp.MidiInputDevice; |
import org.linuxsampler.lscp.MidiInputDevice; |
101 |
import org.linuxsampler.lscp.SamplerEngine; |
import org.linuxsampler.lscp.SamplerEngine; |
102 |
|
|
103 |
import static org.jsampler.view.fantasia.FantasiaI18n.i18n; |
import static org.jsampler.view.fantasia.FantasiaI18n.i18n; |
104 |
|
import static org.jsampler.view.fantasia.FantasiaPrefs.*; |
105 |
|
|
106 |
|
|
107 |
/** |
/** |
109 |
* @author Grigor Iliev |
* @author Grigor Iliev |
110 |
*/ |
*/ |
111 |
public class Channel extends org.jsampler.view.JSChannel { |
public class Channel extends org.jsampler.view.JSChannel { |
112 |
|
private final JXCollapsiblePane mainPane; |
113 |
private final ChannelScreen screen = new ChannelScreen(this); |
private final ChannelScreen screen = new ChannelScreen(this); |
114 |
private final ChannelOptions optionsPane = new ChannelOptions(this); |
private final ChannelOptions optionsPane = new ChannelOptions(this); |
115 |
|
|
133 |
super(model); |
super(model); |
134 |
|
|
135 |
setLayout(new BoxLayout(this, BoxLayout.Y_AXIS)); |
setLayout(new BoxLayout(this, BoxLayout.Y_AXIS)); |
136 |
JPanel p = new JPanel(); |
ChannelPane p = new ChannelPane(); |
|
p.setName("Channel"); |
|
137 |
p.setLayout(new BoxLayout(p, BoxLayout.X_AXIS)); |
p.setLayout(new BoxLayout(p, BoxLayout.X_AXIS)); |
138 |
|
|
139 |
//p.add(Box.createRigidArea(new Dimension(3, 0))); |
//p.add(Box.createRigidArea(new Dimension(3, 0))); |
140 |
|
|
141 |
btnPower.setAlignmentY(JPanel.TOP_ALIGNMENT); |
btnPower.setAlignmentY(JPanel.TOP_ALIGNMENT); |
142 |
|
|
143 |
TitleBar tb = new TitleBar(); |
JPanel tb = new JPanel(); |
144 |
tb.setBorder(BorderFactory.createEmptyBorder(3, 3, 0, 4)); |
tb.setBorder(BorderFactory.createEmptyBorder(3, 3, 0, 4)); |
145 |
tb.setLayout(new BoxLayout(tb, BoxLayout.X_AXIS)); |
tb.setLayout(new BoxLayout(tb, BoxLayout.X_AXIS)); |
146 |
tb.setOpaque(false); |
tb.setOpaque(false); |
172 |
p2.setLayout(new BoxLayout(p2, BoxLayout.Y_AXIS)); |
p2.setLayout(new BoxLayout(p2, BoxLayout.Y_AXIS)); |
173 |
p2.setAlignmentY(JPanel.TOP_ALIGNMENT); |
p2.setAlignmentY(JPanel.TOP_ALIGNMENT); |
174 |
p2.setBorder(BorderFactory.createEmptyBorder(4, 0, 0, 0)); |
p2.setBorder(BorderFactory.createEmptyBorder(4, 0, 0, 0)); |
175 |
p2.add(new JLabel(Res.iconMuteTitle)); |
p2.add(new JLabel(Res.gfxMuteTitle)); |
176 |
p2.add(btnMute); |
p2.add(btnMute); |
177 |
p2.add(new JLabel(Res.iconSoloTitle)); |
p2.add(new JLabel(Res.gfxSoloTitle)); |
178 |
p2.add(btnSolo); |
p2.add(btnSolo); |
179 |
|
|
180 |
p.add(p2); |
p.add(p2); |
186 |
p2.setLayout(new BoxLayout(p2, BoxLayout.Y_AXIS)); |
p2.setLayout(new BoxLayout(p2, BoxLayout.Y_AXIS)); |
187 |
p2.setAlignmentY(JPanel.TOP_ALIGNMENT); |
p2.setAlignmentY(JPanel.TOP_ALIGNMENT); |
188 |
p2.setBorder(BorderFactory.createEmptyBorder(4, 0, 0, 0)); |
p2.setBorder(BorderFactory.createEmptyBorder(4, 0, 0, 0)); |
189 |
JLabel l = new JLabel(Res.iconVolumeTitle); |
JLabel l = new JLabel(Res.gfxVolumeTitle); |
190 |
l.setAlignmentX(JPanel.CENTER_ALIGNMENT); |
l.setAlignmentX(JPanel.CENTER_ALIGNMENT); |
191 |
l.setBorder(BorderFactory.createEmptyBorder(0, 0, 2, 0)); |
l.setBorder(BorderFactory.createEmptyBorder(0, 0, 2, 0)); |
192 |
p2.add(l); |
p2.add(l); |
193 |
dialVolume.setDialPixmap(Res.iconVolumeDial, 30, 330); |
dialVolume.setDialPixmap(Res.gfxVolumeDial, 30, 330); |
194 |
dialVolume.setAlignmentX(JPanel.CENTER_ALIGNMENT); |
dialVolume.setAlignmentX(JPanel.CENTER_ALIGNMENT); |
195 |
p2.add(dialVolume); |
p2.add(dialVolume); |
196 |
p.add(p2); |
p.add(p2); |
202 |
p2.setLayout(new BoxLayout(p2, BoxLayout.Y_AXIS)); |
p2.setLayout(new BoxLayout(p2, BoxLayout.Y_AXIS)); |
203 |
p2.setAlignmentY(JPanel.TOP_ALIGNMENT); |
p2.setAlignmentY(JPanel.TOP_ALIGNMENT); |
204 |
p2.setBorder(BorderFactory.createEmptyBorder(27, 0, 0, 0)); |
p2.setBorder(BorderFactory.createEmptyBorder(27, 0, 0, 0)); |
205 |
l = new JLabel(Res.iconOptionsTitle); |
l = new JLabel(Res.gfxOptionsTitle); |
206 |
l.setAlignmentX(JPanel.CENTER_ALIGNMENT); |
l.setAlignmentX(JPanel.CENTER_ALIGNMENT); |
207 |
l.setBorder(BorderFactory.createEmptyBorder(0, 0, 2, 0)); |
l.setBorder(BorderFactory.createEmptyBorder(0, 0, 2, 0)); |
208 |
p2.add(l); |
p2.add(l); |
221 |
|
|
222 |
p.setAlignmentX(JPanel.CENTER_ALIGNMENT); |
p.setAlignmentX(JPanel.CENTER_ALIGNMENT); |
223 |
optionsPane.setAlignmentX(JPanel.CENTER_ALIGNMENT); |
optionsPane.setAlignmentX(JPanel.CENTER_ALIGNMENT); |
|
add(p); |
|
|
add(optionsPane); |
|
224 |
|
|
225 |
setOpaque(true); |
mainPane = new JXCollapsiblePane(); |
226 |
|
mainPane.getContentPane().setLayout ( |
227 |
|
new BoxLayout(mainPane.getContentPane(), BoxLayout.Y_AXIS) |
228 |
|
); |
229 |
|
|
230 |
|
mainPane.add(p); |
231 |
|
mainPane.add(optionsPane); |
232 |
|
|
233 |
|
setOpaque(false); |
234 |
|
|
235 |
getModel().addSamplerChannelListener(getHandler()); |
getModel().addSamplerChannelListener(getHandler()); |
236 |
|
|
237 |
updateChannelInfo(); |
updateChannelInfo(); |
238 |
|
|
239 |
|
add(mainPane); |
240 |
|
|
241 |
|
mainPane.setAnimated(false); |
242 |
|
mainPane.setCollapsed(true); |
243 |
|
mainPane.setAnimated(preferences().getBoolProperty(ANIMATED)); |
244 |
|
mainPane.setCollapsed(false); |
245 |
|
|
246 |
|
preferences().addPropertyChangeListener(ANIMATED, new PropertyChangeListener() { |
247 |
|
public void |
248 |
|
propertyChange(PropertyChangeEvent e) { |
249 |
|
mainPane.setAnimated(preferences().getBoolProperty(ANIMATED)); |
250 |
|
} |
251 |
|
}); |
252 |
} |
} |
253 |
|
|
254 |
private JPanel |
private JPanel |
255 |
createVSeparator() { |
createVSeparator() { |
256 |
JPanel p = new JPanel(); |
PixmapPane p = new PixmapPane(Res.gfxVLine); |
|
p.setName("VSeparator"); |
|
|
p.setOpaque(false); |
|
257 |
p.setAlignmentY(JPanel.TOP_ALIGNMENT); |
p.setAlignmentY(JPanel.TOP_ALIGNMENT); |
258 |
p.setPreferredSize(new Dimension(2, 60)); |
p.setPreferredSize(new Dimension(2, 60)); |
259 |
p.setMinimumSize(p.getPreferredSize()); |
p.setMinimumSize(p.getPreferredSize()); |
281 |
|
|
282 |
/** Shows the channel properties. */ |
/** Shows the channel properties. */ |
283 |
public void |
public void |
284 |
expandChannel() { if(!btnOptions.isSelected()) btnOptions.doClick(); } |
expandChannel() { expandChannel(optionsPane.isAnimated()); } |
285 |
|
|
286 |
|
/** Shows the channel properties. */ |
287 |
|
public void |
288 |
|
expandChannel(boolean animated) { |
289 |
|
if(btnOptions.isSelected()) return; |
290 |
|
|
291 |
|
boolean b = optionsPane.isAnimated(); |
292 |
|
optionsPane.setAnimated(animated); |
293 |
|
btnOptions.doClick(); |
294 |
|
optionsPane.setAnimated(b); |
295 |
|
} |
296 |
|
|
297 |
|
|
298 |
/** Invoked when the user changes the volume */ |
/** Invoked when the user changes the volume */ |
328 |
screen.updateScreenInfo(sc); |
screen.updateScreenInfo(sc); |
329 |
updateMuteIcon(sc); |
updateMuteIcon(sc); |
330 |
|
|
331 |
if(sc.isSoloChannel()) btnSolo.setIcon(Res.iconSoloOn); |
if(sc.isSoloChannel()) btnSolo.setIcon(Res.gfxSoloOn); |
332 |
else btnSolo.setIcon(Res.iconSoloOff); |
else btnSolo.setIcon(Res.gfxSoloOff); |
333 |
|
|
334 |
dialVolume.setValue((int)(sc.getVolume() * 100)); |
dialVolume.setValue((int)(sc.getVolume() * 100)); |
335 |
|
|
347 |
*/ |
*/ |
348 |
private void |
private void |
349 |
updateMuteIcon(SamplerChannel channel) { |
updateMuteIcon(SamplerChannel channel) { |
350 |
if(channel.isMutedBySolo()) btnMute.setIcon(Res.iconMutedBySolo); |
if(channel.isMutedBySolo()) btnMute.setIcon(Res.gfxMutedBySolo); |
351 |
else if(channel.isMuted()) btnMute.setIcon(Res.iconMuteOn); |
else if(channel.isMuted()) btnMute.setIcon(Res.gfxMuteOn); |
352 |
else btnMute.setIcon(Res.iconMuteOff); |
else btnMute.setIcon(Res.gfxMuteOff); |
353 |
} |
} |
354 |
|
|
355 |
private class EnhancedDial extends Dial { |
private class EnhancedDial extends Dial { |
416 |
} |
} |
417 |
|
|
418 |
|
|
419 |
private class PowerButton extends PixmapToggleButton implements ActionListener { |
private class PowerButton extends PixmapToggleButton |
420 |
|
implements ActionListener, PropertyChangeListener { |
421 |
|
|
422 |
PowerButton() { |
PowerButton() { |
423 |
super(Res.iconPowerOff, Res.iconPowerOn); |
super(Res.gfxPowerOff, Res.gfxPowerOn); |
424 |
|
|
425 |
setSelected(true); |
setSelected(true); |
426 |
addActionListener(this); |
addActionListener(this); |
428 |
|
|
429 |
public void |
public void |
430 |
actionPerformed(ActionEvent e) { |
actionPerformed(ActionEvent e) { |
431 |
CC.getSamplerModel().removeBackendChannel(getChannelId()); |
if(!mainPane.isAnimated()) { |
432 |
|
CC.getSamplerModel().removeBackendChannel(getChannelId()); |
433 |
|
return; |
434 |
|
} |
435 |
|
|
436 |
|
String s = JXCollapsiblePane.ANIMATION_STATE_KEY; |
437 |
|
mainPane.addPropertyChangeListener(s, this); |
438 |
|
mainPane.setCollapsed(true); |
439 |
|
} |
440 |
|
|
441 |
|
public void |
442 |
|
propertyChange(PropertyChangeEvent e) { |
443 |
|
if(e.getNewValue() == "collapsed") { |
444 |
|
CC.getSamplerModel().removeBackendChannel(getChannelId()); |
445 |
|
} |
446 |
} |
} |
447 |
|
|
448 |
public boolean |
public boolean |
451 |
|
|
452 |
private class MuteButton extends PixmapButton implements ActionListener { |
private class MuteButton extends PixmapButton implements ActionListener { |
453 |
MuteButton() { |
MuteButton() { |
454 |
super(Res.iconMuteOff); |
super(Res.gfxMuteOff); |
455 |
setDisabledIcon(Res.iconMuteSoloDisabled); |
//setDisabledIcon(Res.gfxMuteSoloDisabled); |
456 |
|
setDisabledIcon ( |
457 |
|
SubstanceImageCreator.makeTransparent(this, Res.gfxMuteOff, 0.4) |
458 |
|
); |
459 |
addActionListener(this); |
addActionListener(this); |
460 |
} |
} |
461 |
|
|
472 |
b = false; |
b = false; |
473 |
boolean hasSolo = CC.getSamplerModel().hasSoloChannel(); |
boolean hasSolo = CC.getSamplerModel().hasSoloChannel(); |
474 |
|
|
475 |
if(sc.isSoloChannel() || !hasSolo) setIcon(Res.iconMuteOff); |
if(sc.isSoloChannel() || !hasSolo) setIcon(Res.gfxMuteOff); |
476 |
else setIcon(Res.iconMutedBySolo); |
else setIcon(Res.gfxMutedBySolo); |
477 |
} else setIcon(Res.iconMuteOn); |
} else setIcon(Res.gfxMuteOn); |
478 |
|
|
479 |
Channel.this.getModel().setBackendMute(b); |
Channel.this.getModel().setBackendMute(b); |
480 |
} |
} |
485 |
|
|
486 |
private class SoloButton extends PixmapButton implements ActionListener { |
private class SoloButton extends PixmapButton implements ActionListener { |
487 |
SoloButton() { |
SoloButton() { |
488 |
super(Res.iconSoloOff); |
super(Res.gfxSoloOff); |
489 |
setDisabledIcon(Res.iconMuteSoloDisabled); |
//setDisabledIcon(Res.gfxMuteSoloDisabled); |
490 |
|
setDisabledIcon ( |
491 |
|
SubstanceImageCreator.makeTransparent(this, Res.gfxSoloOff, 0.4) |
492 |
|
); |
493 |
addActionListener(this); |
addActionListener(this); |
494 |
} |
} |
495 |
|
|
503 |
* leaving the work to the notification mechanism of the LinuxSampler. |
* leaving the work to the notification mechanism of the LinuxSampler. |
504 |
*/ |
*/ |
505 |
if(b) { |
if(b) { |
506 |
setIcon(Res.iconSoloOn); |
setIcon(Res.gfxSoloOn); |
507 |
if(sc.isMutedBySolo()) btnMute.setIcon(Res.iconMuteOff); |
if(sc.isMutedBySolo()) btnMute.setIcon(Res.gfxMuteOff); |
508 |
} else { |
} else { |
509 |
setIcon(Res.iconSoloOff); |
setIcon(Res.gfxSoloOff); |
510 |
if(!sc.isMuted() && CC.getSamplerModel().getSoloChannelCount() > 1) |
if(!sc.isMuted() && CC.getSamplerModel().getSoloChannelCount() > 1) |
511 |
btnMute.setIcon(Res.iconMutedBySolo); |
btnMute.setIcon(Res.gfxMutedBySolo); |
512 |
} |
} |
513 |
|
|
514 |
Channel.this.getModel().setBackendSolo(b); |
Channel.this.getModel().setBackendSolo(b); |
520 |
|
|
521 |
private class OptionsButton extends PixmapToggleButton implements ActionListener { |
private class OptionsButton extends PixmapToggleButton implements ActionListener { |
522 |
OptionsButton() { |
OptionsButton() { |
523 |
super(Res.iconOptionsOff, Res.iconOptionsOn); |
super(Res.gfxOptionsOff, Res.gfxOptionsOn); |
524 |
setRolloverIcon(Res.iconOptionsOffRO); |
setRolloverIcon(Res.gfxOptionsOffRO); |
525 |
this.setRolloverSelectedIcon(Res.iconOptionsOnRO); |
this.setRolloverSelectedIcon(Res.gfxOptionsOnRO); |
526 |
addActionListener(this); |
addActionListener(this); |
527 |
} |
} |
528 |
|
|
539 |
|
|
540 |
private void |
private void |
541 |
showOptionsPane(boolean show) { |
showOptionsPane(boolean show) { |
542 |
optionsPane.setVisible(show); |
optionsPane.setCollapsed(!show); |
|
MainFrame.repack(CC.getMainFrame()); |
|
543 |
} |
} |
544 |
|
|
545 |
public boolean |
public boolean |
547 |
} |
} |
548 |
} |
} |
549 |
|
|
550 |
class ChannelScreen extends JPanel { |
class ChannelPane extends PixmapPane { |
551 |
|
ChannelPane() { |
552 |
|
super(Res.gfxChannel); |
553 |
|
setPixmapInsets(new Insets(3, 3, 3, 3)); |
554 |
|
} |
555 |
|
} |
556 |
|
|
557 |
|
class ChannelScreen extends PixmapPane { |
558 |
private final Channel channel; |
private final Channel channel; |
559 |
private JButton btnInstr = new ScreenButton(i18n.getButtonLabel("ChannelScreen.btnInstr")); |
private JButton btnInstr = new ScreenButton(i18n.getButtonLabel("ChannelScreen.btnInstr")); |
|
private JButton btnReset = new ScreenButton(i18n.getButtonLabel("ChannelScreen.btnReset")); |
|
|
private JButton btnDuplicate = |
|
|
new ScreenButton(i18n.getButtonLabel("ChannelScreen.btnDuplicate")); |
|
|
|
|
|
private final JLabel lVolume = new JLabel(); |
|
|
private final JLabel lStreams = new JLabel("--"); |
|
|
private final JLabel lVoices = new JLabel("--"); |
|
560 |
|
|
561 |
ChannelScreen(Channel channel) { |
private final JButton btnFxSends = |
562 |
|
new ScreenButton(i18n.getButtonLabel("ChannelScreen.btnFxSends")); |
563 |
|
|
564 |
|
private final JButton btnEngine |
565 |
|
= new ScreenButton(i18n.getButtonLabel("ChannelScreen.btnEngine")); |
566 |
|
|
567 |
|
private final JPopupMenu menuEngines = new JPopupMenu(); |
568 |
|
|
569 |
|
private final JLabel lVolume = new Label(); |
570 |
|
private final JLabel lStreams = new Label("--"); |
571 |
|
private final JLabel lVoices = new Label("--"); |
572 |
|
|
573 |
|
private InformationDialog fxSendsDlg = null; |
574 |
|
|
575 |
|
private Dimension dimVolume; |
576 |
|
|
577 |
|
class Label extends JLabel { |
578 |
|
Label() { this(""); } |
579 |
|
|
580 |
|
Label(String s) { |
581 |
|
super(s); |
582 |
|
setFont(Res.fontScreen); |
583 |
|
setForeground(new java.awt.Color(0xFFA300)); |
584 |
|
} |
585 |
|
} |
586 |
|
|
587 |
|
ChannelScreen(final Channel channel) { |
588 |
|
super(Res.gfxChannelScreen); |
589 |
|
setPixmapInsets(new Insets(6, 6, 6, 6)); |
590 |
|
setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); |
591 |
|
|
592 |
this.channel = channel; |
this.channel = channel; |
593 |
|
|
594 |
setName("ChannelScreen"); |
setOpaque(false); |
|
setOpaque(true); |
|
595 |
|
|
596 |
setLayout(new BoxLayout(this, BoxLayout.Y_AXIS)); |
setLayout(new BoxLayout(this, BoxLayout.Y_AXIS)); |
597 |
|
|
|
btnInstr.setBorder(BorderFactory.createEmptyBorder(10, 0, 0, 0)); |
|
598 |
btnInstr.setAlignmentX(CENTER_ALIGNMENT); |
btnInstr.setAlignmentX(CENTER_ALIGNMENT); |
599 |
|
btnInstr.setRolloverEnabled(false); |
600 |
|
btnInstr.setBorder(BorderFactory.createEmptyBorder(3, 0, 0, 0)); |
601 |
|
|
602 |
add(btnInstr); |
add(btnInstr); |
603 |
|
|
604 |
JPanel p = new JPanel(); |
JPanel p = new JPanel(); |
|
p.setOpaque(false); |
|
605 |
p.setLayout(new BoxLayout(p, BoxLayout.X_AXIS)); |
p.setLayout(new BoxLayout(p, BoxLayout.X_AXIS)); |
606 |
p.setAlignmentX(CENTER_ALIGNMENT); |
p.setAlignmentX(CENTER_ALIGNMENT); |
607 |
p.setBorder(BorderFactory.createEmptyBorder(10, 0, 0, 0)); |
p.setBorder(BorderFactory.createEmptyBorder(5, 0, 0, 0)); |
|
//lVolume.setFont(lVolume.getFont().deriveFont(java.awt.Font.PLAIN)); |
|
608 |
|
|
609 |
p.add(btnDuplicate); |
btnFxSends.setToolTipText(i18n.getButtonLabel("ChannelScreen.btnFxSends.tt")); |
610 |
|
btnFxSends.addActionListener(new ActionListener() { |
611 |
|
public void |
612 |
|
actionPerformed(ActionEvent e) { |
613 |
|
if(fxSendsDlg != null && fxSendsDlg.isVisible()) { |
614 |
|
fxSendsDlg.toFront(); |
615 |
|
return; |
616 |
|
} |
617 |
|
FxSendsPane p = new FxSendsPane(channel.getModel()); |
618 |
|
int id = channel.getModel().getChannelId(); |
619 |
|
fxSendsDlg = new InformationDialog(CC.getMainFrame(), p); |
620 |
|
fxSendsDlg.setTitle(i18n.getLabel("FxSendsDlg.title", id)); |
621 |
|
fxSendsDlg.setModal(false); |
622 |
|
fxSendsDlg.showCloseButton(false); |
623 |
|
fxSendsDlg.setVisible(true); |
624 |
|
} |
625 |
|
}); |
626 |
|
|
627 |
|
p.add(btnFxSends); |
628 |
|
|
629 |
p.add(Box.createRigidArea(new Dimension(6, 0))); |
p.add(Box.createRigidArea(new Dimension(6, 0))); |
630 |
|
|
631 |
p.add(new JLabel("|")); |
btnEngine.setIcon(Res.iconEngine12); |
632 |
|
p.add(btnEngine); |
633 |
|
//p.add(new Label("|")); |
634 |
|
|
635 |
p.add(Box.createRigidArea(new Dimension(6, 0))); |
//p.add(Box.createRigidArea(new Dimension(6, 0))); |
636 |
|
|
637 |
p.add(btnReset); |
//p.add(btnReset); |
638 |
|
|
639 |
p.add(Box.createGlue()); |
p.add(Box.createGlue()); |
640 |
|
|
641 |
p.add(lStreams); |
p.add(lStreams); |
642 |
p.add(new JLabel("/")); |
p.add(new Label("/")); |
643 |
p.add(lVoices); |
p.add(lVoices); |
644 |
|
|
645 |
p.add(Box.createRigidArea(new Dimension(12, 0))); |
p.add(Box.createRigidArea(new Dimension(12, 0))); |
646 |
|
|
647 |
|
lVolume.setIcon(Res.iconVolume14); |
648 |
lVolume.setAlignmentX(RIGHT_ALIGNMENT); |
lVolume.setAlignmentX(RIGHT_ALIGNMENT); |
649 |
|
updateVolumeInfo(100); |
650 |
|
dimVolume = lVolume.getPreferredSize(); |
651 |
p.add(lVolume); |
p.add(lVolume); |
652 |
p.setPreferredSize(new Dimension(250, p.getPreferredSize().height)); |
p.setPreferredSize(new Dimension(250, p.getPreferredSize().height)); |
653 |
p.setMinimumSize(p.getPreferredSize()); |
p.setMinimumSize(p.getPreferredSize()); |
654 |
p.setMaximumSize(p.getPreferredSize()); |
p.setMaximumSize(p.getPreferredSize()); |
655 |
|
|
656 |
|
//btnInstr.setBorder(BorderFactory.createEmptyBorder(3, 3, 3, 3)); |
657 |
|
p.setOpaque(false); |
658 |
add(p); |
add(p); |
659 |
|
|
660 |
|
|
662 |
setMinimumSize(getPreferredSize()); |
setMinimumSize(getPreferredSize()); |
663 |
setMaximumSize(getPreferredSize()); |
setMaximumSize(getPreferredSize()); |
664 |
|
|
665 |
|
createEngineMenu(); |
666 |
installListeners(); |
installListeners(); |
667 |
} |
} |
668 |
|
|
669 |
private void |
private void |
670 |
|
createEngineMenu() { |
671 |
|
for(final SamplerEngine engine : CC.getSamplerModel().getEngines()) { |
672 |
|
JMenuItem mi = new JMenuItem(engine.getDescription()); |
673 |
|
|
674 |
|
mi.addActionListener(new ActionListener() { |
675 |
|
public void |
676 |
|
actionPerformed(ActionEvent e) { |
677 |
|
channel.getModel().setBackendEngineType(engine.getName()); |
678 |
|
} |
679 |
|
}); |
680 |
|
|
681 |
|
menuEngines.add(mi); |
682 |
|
} |
683 |
|
} |
684 |
|
|
685 |
|
private void |
686 |
installListeners() { |
installListeners() { |
687 |
btnInstr.addActionListener(new ActionListener() { |
btnInstr.addActionListener(new ActionListener() { |
688 |
public void |
public void |
689 |
actionPerformed(ActionEvent e) { loadInstrument(); } |
actionPerformed(ActionEvent e) { loadInstrument(); } |
690 |
}); |
}); |
|
|
|
|
btnReset.addActionListener(new ActionListener() { |
|
|
public void |
|
|
actionPerformed(ActionEvent e) { channel.getModel().resetBackendChannel(); } |
|
|
}); |
|
691 |
|
|
692 |
btnDuplicate.addActionListener(new ActionListener() { |
btnEngine.addActionListener(new ActionListener() { |
693 |
public void |
public void |
694 |
actionPerformed(ActionEvent e) { |
actionPerformed(ActionEvent e) { |
695 |
channel.getModel().duplicateBackendChannel(); |
int y = btnEngine.getHeight() + 1; |
696 |
|
menuEngines.show(btnEngine, 0, y); |
697 |
} |
} |
698 |
}); |
}); |
699 |
} |
} |
700 |
|
|
701 |
private void |
private void |
702 |
loadInstrument() { |
loadInstrument() { |
703 |
InstrumentChooser dlg = new InstrumentChooser(CC.getMainFrame()); |
JSInstrumentChooser dlg = new JSInstrumentChooser(CC.getMainFrame()); |
704 |
dlg.setVisible(true); |
dlg.setVisible(true); |
705 |
|
|
706 |
if(!dlg.isCancelled()) { |
if(!dlg.isCancelled()) { |
707 |
SamplerChannelModel m = channel.getModel(); |
SamplerChannelModel m = channel.getModel(); |
708 |
m.loadBackendInstrument(dlg.getFileName(), dlg.getInstrumentIndex()); |
m.loadBackendInstrument(dlg.getInstrumentFile(), dlg.getInstrumentIndex()); |
709 |
} |
} |
710 |
} |
} |
711 |
|
|
723 |
else btnInstr.setText(i18n.getButtonLabel("ChannelScreen.btnInstr")); |
else btnInstr.setText(i18n.getButtonLabel("ChannelScreen.btnInstr")); |
724 |
} |
} |
725 |
|
|
726 |
|
if(sc.getEngine() != null) { |
727 |
|
String s = sc.getEngine().getDescription(); |
728 |
|
if(!s.equals(btnEngine.getText())) btnEngine.setText(s); |
729 |
|
} |
730 |
|
|
731 |
} |
} |
732 |
|
|
733 |
protected void |
protected void |
734 |
updateVolumeInfo(int volume) { |
updateVolumeInfo(int volume) { |
735 |
lVolume.setText(i18n.getLabel("ChannelScreen.volume", volume)); |
lVolume.setText(i18n.getLabel("ChannelScreen.volume", volume)); |
736 |
|
lVolume.setMinimumSize(dimVolume); |
737 |
|
lVolume.setPreferredSize(dimVolume); |
738 |
|
|
739 |
} |
} |
740 |
|
|
766 |
lVoices.setMaximumSize(d); |
lVoices.setMaximumSize(d); |
767 |
} |
} |
768 |
|
|
769 |
|
class FxSendsPane extends JSFxSendsPane { |
770 |
|
FxSendsPane(SamplerChannelModel model) { |
771 |
|
super(model); |
772 |
|
|
773 |
|
actionAddFxSend.putValue(Action.SMALL_ICON, Res.iconNew16); |
774 |
|
actionRemoveFxSend.putValue(Action.SMALL_ICON, Res.iconDelete16); |
775 |
|
} |
776 |
|
|
777 |
|
protected JToolBar |
778 |
|
createToolBar() { |
779 |
|
JToolBar tb = new JToolBar(); |
780 |
|
Dimension d = new Dimension(Short.MAX_VALUE, tb.getPreferredSize().height); |
781 |
|
tb.setMaximumSize(d); |
782 |
|
tb.setFloatable(false); |
783 |
|
tb.setAlignmentX(JPanel.RIGHT_ALIGNMENT); |
784 |
|
|
785 |
|
tb.add(new ToolbarButton(actionAddFxSend)); |
786 |
|
tb.add(new ToolbarButton(actionRemoveFxSend)); |
787 |
|
|
788 |
|
return tb; |
789 |
|
} |
790 |
|
} |
791 |
|
|
792 |
static class ScreenButton extends JButton { |
static class ScreenButton extends JButton { |
793 |
ScreenButton(String s) { |
ScreenButton(String s) { |
794 |
super(s); |
super(s); |
796 |
setFocusPainted(false); |
setFocusPainted(false); |
797 |
setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0)); |
setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0)); |
798 |
setMargin(new Insets(0, 0, 0, 0)); |
setMargin(new Insets(0, 0, 0, 0)); |
799 |
|
|
800 |
|
putClientProperty ( |
801 |
|
SubstanceLookAndFeel.BUTTON_NO_MIN_SIZE_PROPERTY, Boolean.TRUE |
802 |
|
); |
803 |
|
|
804 |
|
putClientProperty ( |
805 |
|
SubstanceLookAndFeel.BUTTON_PAINT_NEVER_PROPERTY, Boolean.TRUE |
806 |
|
); |
807 |
|
|
808 |
|
putClientProperty(SubstanceLookAndFeel.FLAT_PROPERTY, Boolean.TRUE); |
809 |
|
|
810 |
|
FadeConfigurationManager.getInstance().disallowFades(FadeKind.ROLLOVER, this); |
811 |
|
|
812 |
setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); |
setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); |
813 |
|
setFont(Res.fontScreen); |
814 |
|
setForeground(new java.awt.Color(0xFFA300)); |
815 |
} |
} |
816 |
} |
} |
817 |
} |
} |
818 |
|
|
819 |
class ChannelOptions extends JPanel { |
class ChannelOptions extends JXCollapsiblePane { |
820 |
private final Channel channel; |
private final Channel channel; |
821 |
|
private MidiDeviceModel midiDevice = null; |
822 |
|
|
823 |
|
private final JComboBox cbMidiDevice = new FantasiaComboBox(); |
824 |
|
private final JComboBox cbMidiPort = new FantasiaComboBox(); |
825 |
|
private final JComboBox cbMidiChannel = new FantasiaComboBox(); |
826 |
|
private final JComboBox cbInstrumentMap = new FantasiaComboBox(); |
827 |
|
private final JComboBox cbAudioDevice = new FantasiaComboBox(); |
828 |
|
|
829 |
private final JComboBox cbMidiDevice = new JComboBox(); |
private final PixmapButton btnChannelRouting; |
|
private final JComboBox cbMidiPort = new JComboBox(); |
|
|
private final JComboBox cbMidiChannel = new JComboBox(); |
|
|
private final JComboBox cbEngine = new JComboBox(); |
|
|
private final JComboBox cbAudioDevice = new JComboBox(); |
|
830 |
|
|
831 |
private boolean update = false; |
private boolean update = false; |
832 |
|
|
833 |
ChannelOptions(Channel channel) { |
private final SamplerListener samplerListener; |
834 |
|
private final MapListListener mapListListener = new MapListListener(); |
835 |
|
|
836 |
|
private class NoMap { |
837 |
|
public String |
838 |
|
toString() { return "[None]"; } |
839 |
|
} |
840 |
|
|
841 |
|
private NoMap noMap = new NoMap(); |
842 |
|
|
843 |
|
private class DefaultMap { |
844 |
|
public String |
845 |
|
toString() { return "[Default]"; } |
846 |
|
} |
847 |
|
|
848 |
|
private DefaultMap defaultMap = new DefaultMap(); |
849 |
|
|
850 |
|
ChannelOptions(final Channel channel) { |
851 |
|
setAnimated(false); |
852 |
|
setCollapsed(true); |
853 |
|
setAnimated(preferences().getBoolProperty(ANIMATED)); |
854 |
|
|
855 |
|
preferences().addPropertyChangeListener(ANIMATED, new PropertyChangeListener() { |
856 |
|
public void |
857 |
|
propertyChange(PropertyChangeEvent e) { |
858 |
|
setAnimated(preferences().getBoolProperty(ANIMATED)); |
859 |
|
} |
860 |
|
}); |
861 |
|
|
862 |
|
PixmapPane bgp = new PixmapPane(Res.gfxChannelOptions); |
863 |
|
bgp.setPixmapInsets(new Insets(1, 1, 1, 1)); |
864 |
|
|
865 |
this.channel = channel; |
this.channel = channel; |
866 |
|
|
867 |
setName("ChannelOptions"); |
bgp.setBorder(BorderFactory.createEmptyBorder(5, 4, 5, 4)); |
868 |
setVisible(false); |
bgp.setLayout(new BoxLayout(bgp, BoxLayout.X_AXIS)); |
|
setBorder(BorderFactory.createEmptyBorder(5, 4, 5, 4)); |
|
|
setLayout(new BoxLayout(this, BoxLayout.X_AXIS)); |
|
869 |
|
|
870 |
setPreferredSize(new Dimension(420, 44)); |
bgp.setPreferredSize(new Dimension(420, 44)); |
871 |
setMinimumSize(getPreferredSize()); |
bgp.setMinimumSize(getPreferredSize()); |
872 |
setMaximumSize(getPreferredSize()); |
bgp.setMaximumSize(getPreferredSize()); |
873 |
|
|
874 |
JPanel p = new JPanel(); |
JPanel p = new JPanel(); |
|
p.setOpaque(true); |
|
875 |
p.setBorder(BorderFactory.createEmptyBorder(3, 4, 3, 4)); |
p.setBorder(BorderFactory.createEmptyBorder(3, 4, 3, 4)); |
876 |
p.setLayout(new BoxLayout(p, BoxLayout.Y_AXIS)); |
p.setLayout(new BoxLayout(p, BoxLayout.Y_AXIS)); |
877 |
JLabel l = new JLabel(Res.iconMidiInputTitle); |
JLabel l = new JLabel(Res.gfxMidiInputTitle); |
878 |
l.setAlignmentX(LEFT_ALIGNMENT); |
l.setAlignmentX(LEFT_ALIGNMENT); |
879 |
p.add(l); |
p.add(l); |
880 |
|
|
895 |
o = cbMidiPort.getRenderer(); |
o = cbMidiPort.getRenderer(); |
896 |
if(o instanceof JLabel) ((JLabel )o).setHorizontalAlignment(SwingConstants.CENTER); |
if(o instanceof JLabel) ((JLabel )o).setHorizontalAlignment(SwingConstants.CENTER); |
897 |
|
|
898 |
cbMidiPort.setPreferredSize(new Dimension(67, 18)); |
cbMidiPort.setPreferredSize(new Dimension(62, 18)); |
899 |
cbMidiPort.setMinimumSize(cbMidiPort.getPreferredSize()); |
cbMidiPort.setMinimumSize(cbMidiPort.getPreferredSize()); |
900 |
cbMidiPort.setMaximumSize(cbMidiPort.getPreferredSize()); |
cbMidiPort.setMaximumSize(cbMidiPort.getPreferredSize()); |
901 |
p2.add(cbMidiPort); |
p2.add(cbMidiPort); |
913 |
|
|
914 |
p2.add(cbMidiChannel); |
p2.add(cbMidiChannel); |
915 |
p2.setAlignmentX(LEFT_ALIGNMENT); |
p2.setAlignmentX(LEFT_ALIGNMENT); |
916 |
|
p2.setOpaque(false); |
917 |
p.add(p2); |
p.add(p2); |
918 |
|
p.setBackground(new java.awt.Color(0x818181)); |
919 |
|
|
920 |
add(p); |
bgp.add(p); |
921 |
|
|
922 |
add(Box.createRigidArea(new Dimension(4, 0))); |
bgp.add(Box.createRigidArea(new Dimension(4, 0))); |
923 |
|
|
924 |
p = new JPanel(); |
p = new JPanel(); |
925 |
p.setOpaque(true); |
p.setOpaque(true); |
926 |
p.setBorder(BorderFactory.createEmptyBorder(3, 4, 3, 4)); |
p.setBorder(BorderFactory.createEmptyBorder(3, 4, 3, 4)); |
927 |
p.setLayout(new BoxLayout(p, BoxLayout.Y_AXIS)); |
p.setLayout(new BoxLayout(p, BoxLayout.Y_AXIS)); |
928 |
l = new JLabel(Res.iconEngineTitle); |
l = new JLabel(Res.gfxInstrumentMapTitle); |
929 |
l.setAlignmentX(LEFT_ALIGNMENT); |
l.setAlignmentX(LEFT_ALIGNMENT); |
930 |
l.setAlignmentX(LEFT_ALIGNMENT); |
l.setAlignmentX(LEFT_ALIGNMENT); |
931 |
p.add(l); |
p.add(l); |
932 |
|
|
933 |
p.add(Box.createRigidArea(new Dimension(0, 3))); |
p.add(Box.createRigidArea(new Dimension(0, 3))); |
934 |
|
|
935 |
o = cbEngine.getRenderer(); |
//o = cbInstrumentMap.getRenderer(); |
936 |
if(o instanceof JLabel) ((JLabel )o).setHorizontalAlignment(SwingConstants.CENTER); |
//if(o instanceof JLabel) ((JLabel )o).setHorizontalAlignment(SwingConstants.CENTER); |
937 |
|
|
938 |
for(SamplerEngine e : CC.getSamplerModel().getEngines()) cbEngine.addItem(e); |
cbInstrumentMap.setPreferredSize(new Dimension(126, 18)); |
939 |
cbEngine.setPreferredSize(new Dimension(125, 18)); |
cbInstrumentMap.setMinimumSize(cbInstrumentMap.getPreferredSize()); |
940 |
cbEngine.setMinimumSize(cbEngine.getPreferredSize()); |
cbInstrumentMap.setMaximumSize(cbInstrumentMap.getPreferredSize()); |
941 |
cbEngine.setMaximumSize(cbEngine.getPreferredSize()); |
cbInstrumentMap.setAlignmentX(LEFT_ALIGNMENT); |
942 |
cbEngine.setAlignmentX(LEFT_ALIGNMENT); |
p.add(cbInstrumentMap); |
943 |
p.add(cbEngine); |
p.setBackground(new java.awt.Color(0x818181)); |
944 |
|
bgp.add(p); |
945 |
|
|
946 |
add(p); |
bgp.add(Box.createRigidArea(new Dimension(4, 0))); |
|
|
|
|
add(Box.createRigidArea(new Dimension(4, 0))); |
|
947 |
|
|
948 |
p = new JPanel(); |
p = new JPanel(); |
949 |
p.setOpaque(true); |
p.setOpaque(true); |
950 |
p.setBorder(BorderFactory.createEmptyBorder(3, 4, 3, 4)); |
p.setBorder(BorderFactory.createEmptyBorder(3, 4, 3, 4)); |
951 |
p.setLayout(new BoxLayout(p, BoxLayout.Y_AXIS)); |
p.setLayout(new BoxLayout(p, BoxLayout.Y_AXIS)); |
952 |
l = new JLabel(Res.iconAudioOutputTitle); |
l = new JLabel(Res.gfxAudioOutputTitle); |
|
l.setAlignmentX(LEFT_ALIGNMENT); |
|
953 |
l.setAlignmentX(LEFT_ALIGNMENT); |
l.setAlignmentX(LEFT_ALIGNMENT); |
954 |
p.add(l); |
p.add(l); |
955 |
|
|
956 |
p.add(Box.createRigidArea(new Dimension(0, 3))); |
//p.add(Box.createRigidArea(new Dimension(0, 3))); |
957 |
|
|
958 |
|
p2 = new JPanel(); |
959 |
|
p2.setBorder(BorderFactory.createEmptyBorder(3, 0, 0, 0)); |
960 |
|
p2.setLayout(new BoxLayout(p2, BoxLayout.X_AXIS)); |
961 |
|
p2.setOpaque(false); |
962 |
|
p2.setAlignmentX(LEFT_ALIGNMENT); |
963 |
|
|
964 |
o = cbAudioDevice.getRenderer(); |
o = cbAudioDevice.getRenderer(); |
965 |
if(o instanceof JLabel) ((JLabel )o).setHorizontalAlignment(SwingConstants.RIGHT); |
if(o instanceof JLabel) ((JLabel )o).setHorizontalAlignment(SwingConstants.RIGHT); |
966 |
|
|
967 |
cbAudioDevice.setPreferredSize(new Dimension(61, 18)); |
cbAudioDevice.setPreferredSize(new Dimension(40, 18)); |
968 |
cbAudioDevice.setMinimumSize(cbAudioDevice.getPreferredSize()); |
cbAudioDevice.setMinimumSize(cbAudioDevice.getPreferredSize()); |
969 |
cbAudioDevice.setMaximumSize(cbAudioDevice.getPreferredSize()); |
cbAudioDevice.setMaximumSize(cbAudioDevice.getPreferredSize()); |
|
cbAudioDevice.setAlignmentX(LEFT_ALIGNMENT); |
|
|
p.add(cbAudioDevice); |
|
970 |
|
|
971 |
add(p); |
p2.add(cbAudioDevice); |
972 |
|
p2.add(Box.createRigidArea(new Dimension(3, 0))); |
973 |
|
btnChannelRouting = new PixmapButton(Res.gfxBtnCr, Res.gfxBtnCrRO); |
974 |
|
btnChannelRouting.setPressedIcon(Res.gfxBtnCrRO); |
975 |
|
btnChannelRouting.setEnabled(false); |
976 |
|
btnChannelRouting.setToolTipText(i18n.getLabel("ChannelOptions.routing")); |
977 |
|
|
978 |
|
btnChannelRouting.addActionListener(new ActionListener() { |
979 |
|
public void |
980 |
|
actionPerformed(ActionEvent e) { |
981 |
|
SamplerChannel c = channel.getChannelInfo(); |
982 |
|
new JSChannelOutputRoutingDlg(CC.getMainFrame(), c).setVisible(true); |
983 |
|
|
984 |
|
} |
985 |
|
}); |
986 |
|
|
987 |
|
p2.add(btnChannelRouting); |
988 |
|
|
989 |
|
p.add(p2); |
990 |
|
p.setBackground(new java.awt.Color(0x818181)); |
991 |
|
p2 = new JPanel(); |
992 |
|
p2.setLayout(new java.awt.BorderLayout()); |
993 |
|
p.add(p2); |
994 |
|
bgp.add(p); |
995 |
|
|
996 |
|
setContentPane(bgp); |
997 |
|
|
998 |
cbMidiDevice.addActionListener(new ActionListener() { |
cbMidiDevice.addActionListener(new ActionListener() { |
999 |
public void |
public void |
1010 |
actionPerformed(ActionEvent e) { setMidiChannel(); } |
actionPerformed(ActionEvent e) { setMidiChannel(); } |
1011 |
}); |
}); |
1012 |
|
|
1013 |
cbEngine.addActionListener(new ActionListener() { |
samplerListener = new SamplerAdapter() { |
1014 |
|
/** Invoked when the default MIDI instrument map is changed. */ |
1015 |
|
public void |
1016 |
|
defaultMapChanged(SamplerEvent e) { |
1017 |
|
updateCbInstrumentMapToolTipText(); |
1018 |
|
|
1019 |
|
} |
1020 |
|
}; |
1021 |
|
|
1022 |
|
CC.getSamplerModel().addSamplerListener(samplerListener); |
1023 |
|
|
1024 |
|
cbInstrumentMap.addItem(noMap); |
1025 |
|
cbInstrumentMap.addItem(defaultMap); |
1026 |
|
for(MidiInstrumentMap map : CC.getSamplerModel().getMidiInstrumentMaps()) { |
1027 |
|
cbInstrumentMap.addItem(map); |
1028 |
|
} |
1029 |
|
|
1030 |
|
int map = channel.getModel().getChannelInfo().getMidiInstrumentMapId(); |
1031 |
|
cbInstrumentMap.setSelectedItem(CC.getSamplerModel().getMidiInstrumentMapById(map)); |
1032 |
|
if(cbInstrumentMap.getSelectedItem() == null) { |
1033 |
|
if(map == -1) cbInstrumentMap.setSelectedItem(noMap); |
1034 |
|
else if(map == -2) { |
1035 |
|
cbInstrumentMap.setSelectedItem(defaultMap); |
1036 |
|
} |
1037 |
|
} |
1038 |
|
|
1039 |
|
updateCbInstrumentMapToolTipText(); |
1040 |
|
|
1041 |
|
if(channel.getModel().getChannelInfo().getEngine() == null) { |
1042 |
|
cbInstrumentMap.setEnabled(false); |
1043 |
|
} |
1044 |
|
|
1045 |
|
cbInstrumentMap.addActionListener(new ActionListener() { |
1046 |
public void |
public void |
1047 |
actionPerformed(ActionEvent e) { setEngineType(); } |
actionPerformed(ActionEvent e) { updateInstrumentMap(); } |
1048 |
}); |
}); |
1049 |
|
|
1050 |
|
CC.getSamplerModel().addSamplerChannelListListener(getHandler()); |
1051 |
|
CC.getSamplerModel().addMidiInstrumentMapListListener(mapListListener); |
1052 |
|
|
1053 |
cbAudioDevice.addActionListener(new ActionListener() { |
cbAudioDevice.addActionListener(new ActionListener() { |
1054 |
public void |
public void |
1055 |
actionPerformed(ActionEvent e) { setBackendAudioDevice(); } |
actionPerformed(ActionEvent e) { setBackendAudioDevice(); } |
1087 |
try { |
try { |
1088 |
cbMidiDevice.setSelectedItem(mm == null ? null : mm.getDeviceInfo()); |
cbMidiDevice.setSelectedItem(mm == null ? null : mm.getDeviceInfo()); |
1089 |
|
|
|
cbEngine.setSelectedItem(sc.getEngine()); |
|
|
|
|
1090 |
cbAudioDevice.setSelectedItem(am == null ? null : am.getDeviceInfo()); |
cbAudioDevice.setSelectedItem(am == null ? null : am.getDeviceInfo()); |
1091 |
|
btnChannelRouting.setEnabled(am != null); |
1092 |
} catch(Exception x) { |
} catch(Exception x) { |
1093 |
CC.getLogger().log(Level.WARNING, "Unkown error", x); |
CC.getLogger().log(Level.WARNING, "Unkown error", x); |
1094 |
} |
} |
1095 |
|
|
1096 |
|
if(sc.getEngine() != null) { |
1097 |
|
cbInstrumentMap.setEnabled(true); |
1098 |
|
int id = sc.getMidiInstrumentMapId(); |
1099 |
|
Object o; |
1100 |
|
if(id == -2) o = defaultMap; |
1101 |
|
else if(id == -1) o = noMap; |
1102 |
|
else o = CC.getSamplerModel().getMidiInstrumentMapById(id); |
1103 |
|
|
1104 |
|
if(cbInstrumentMap.getSelectedItem() != o) { |
1105 |
|
cbInstrumentMap.setSelectedItem(o); |
1106 |
|
} |
1107 |
|
} else { |
1108 |
|
cbInstrumentMap.setSelectedItem(noMap); |
1109 |
|
cbInstrumentMap.setEnabled(false); |
1110 |
|
} |
1111 |
|
|
1112 |
setUpdate(false); |
setUpdate(false); |
1113 |
} |
} |
1114 |
|
|
1137 |
setUpdate(false); |
setUpdate(false); |
1138 |
} |
} |
1139 |
|
|
1140 |
|
|
1141 |
|
private void |
1142 |
|
updateInstrumentMap() { |
1143 |
|
updateCbInstrumentMapToolTipText(); |
1144 |
|
|
1145 |
|
int id = channel.getModel().getChannelInfo().getMidiInstrumentMapId(); |
1146 |
|
Object o = cbInstrumentMap.getSelectedItem(); |
1147 |
|
if(o == null && id == -1) return; |
1148 |
|
|
1149 |
|
int cbId; |
1150 |
|
if(o == null || o == noMap) cbId = -1; |
1151 |
|
else if(o == defaultMap) cbId = -2; |
1152 |
|
else cbId = ((MidiInstrumentMap)o).getMapId(); |
1153 |
|
|
1154 |
|
if(cbId == id) return; |
1155 |
|
|
1156 |
|
channel.getModel().setBackendMidiInstrumentMap(cbId); |
1157 |
|
} |
1158 |
|
|
1159 |
|
private void |
1160 |
|
updateCbInstrumentMapToolTipText() { |
1161 |
|
if(cbInstrumentMap.getSelectedItem() != defaultMap) { |
1162 |
|
cbInstrumentMap.setToolTipText(null); |
1163 |
|
return; |
1164 |
|
} |
1165 |
|
|
1166 |
|
MidiInstrumentMap m = CC.getSamplerModel().getDefaultMidiInstrumentMap(); |
1167 |
|
if(m != null) { |
1168 |
|
String s = i18n.getLabel("Channel.ttDefault", m.getName()); |
1169 |
|
cbInstrumentMap.setToolTipText(s); |
1170 |
|
} else { |
1171 |
|
cbInstrumentMap.setToolTipText(null); |
1172 |
|
} |
1173 |
|
} |
1174 |
|
|
1175 |
/** |
/** |
1176 |
* Updates the audio device list. |
* Updates the audio device list. |
1177 |
*/ |
*/ |
1209 |
return; |
return; |
1210 |
} |
} |
1211 |
|
|
1212 |
|
if(midiDevice != null) midiDevice.removeMidiDeviceListener(getHandler()); |
1213 |
|
|
1214 |
cbMidiPort.removeAllItems(); |
cbMidiPort.removeAllItems(); |
1215 |
|
|
1216 |
if(mid == null) { |
if(mid == null) { |
1217 |
|
midiDevice = null; |
1218 |
cbMidiPort.setEnabled(false); |
cbMidiPort.setEnabled(false); |
1219 |
|
|
1220 |
cbMidiChannel.setSelectedItem(null); |
cbMidiChannel.setSelectedItem(null); |
1221 |
cbMidiChannel.setEnabled(false); |
cbMidiChannel.setEnabled(false); |
1222 |
} else { |
} else { |
1223 |
|
midiDevice = CC.getSamplerModel().getMidiDeviceById(mid.getDeviceId()); |
1224 |
|
if(midiDevice != null) midiDevice.addMidiDeviceListener(getHandler()); |
1225 |
|
|
1226 |
cbMidiPort.setEnabled(true); |
cbMidiPort.setEnabled(true); |
1227 |
|
|
1228 |
MidiPort[] ports = mid.getMidiPorts(); |
MidiPort[] ports = mid.getMidiPorts(); |
1257 |
channel.getModel().setBackendMidiInputChannel(c); |
channel.getModel().setBackendMidiInputChannel(c); |
1258 |
} |
} |
1259 |
|
|
|
/** Invoked when the user selects an engine. */ |
|
|
private void |
|
|
setEngineType() { |
|
|
Object oldEngine = channel.getModel().getChannelInfo().getEngine(); |
|
|
SamplerEngine newEngine = (SamplerEngine)cbEngine.getSelectedItem(); |
|
|
|
|
|
if(oldEngine != null) { if(oldEngine.equals(newEngine)) return; } |
|
|
else if(newEngine == null) return; |
|
|
|
|
|
channel.getModel().setBackendEngineType(newEngine.getName()); |
|
|
|
|
|
} |
|
|
|
|
1260 |
private void |
private void |
1261 |
setBackendAudioDevice() { |
setBackendAudioDevice() { |
1262 |
if(isUpdate()) return; |
if(isUpdate()) return; |
1286 |
private Handler |
private Handler |
1287 |
getHandler() { return handler; } |
getHandler() { return handler; } |
1288 |
|
|
1289 |
private class Handler implements MidiDeviceListListener, ListListener<AudioDeviceModel> { |
private class Handler implements MidiDeviceListListener, ListListener<AudioDeviceModel>, |
1290 |
|
SamplerChannelListListener, MidiDeviceListener { |
1291 |
/** |
/** |
1292 |
* Invoked when a new MIDI device is created. |
* Invoked when a new MIDI device is created. |
1293 |
* @param e A <code>MidiDeviceListEvent</code> |
* @param e A <code>MidiDeviceListEvent</code> |
1327 |
entryRemoved(ListEvent<AudioDeviceModel> e) { |
entryRemoved(ListEvent<AudioDeviceModel> e) { |
1328 |
cbAudioDevice.removeItem(e.getEntry().getDeviceInfo()); |
cbAudioDevice.removeItem(e.getEntry().getDeviceInfo()); |
1329 |
} |
} |
1330 |
|
|
1331 |
|
/** |
1332 |
|
* Invoked when a new sampler channel is created. |
1333 |
|
* @param e A <code>SamplerChannelListEvent</code> |
1334 |
|
* instance providing the event information. |
1335 |
|
*/ |
1336 |
|
public void |
1337 |
|
channelAdded(SamplerChannelListEvent e) { } |
1338 |
|
|
1339 |
|
/** |
1340 |
|
* Invoked when a sampler channel is removed. |
1341 |
|
* @param e A <code>SamplerChannelListEvent</code> |
1342 |
|
* instance providing the event information. |
1343 |
|
*/ |
1344 |
|
public void |
1345 |
|
channelRemoved(SamplerChannelListEvent e) { |
1346 |
|
// Some cleanup when the channel is removed. |
1347 |
|
if(e.getChannelModel().getChannelId() == channel.getChannelId()) { |
1348 |
|
SamplerModel sm = CC.getSamplerModel(); |
1349 |
|
|
1350 |
|
sm.removeMidiDeviceListListener(getHandler()); |
1351 |
|
sm.removeAudioDeviceListListener(getHandler()); |
1352 |
|
sm.removeMidiInstrumentMapListListener(mapListListener); |
1353 |
|
sm.removeSamplerListener(samplerListener); |
1354 |
|
sm.removeSamplerChannelListListener(getHandler()); |
1355 |
|
|
1356 |
|
if(midiDevice != null) { |
1357 |
|
midiDevice.removeMidiDeviceListener(getHandler()); |
1358 |
|
} |
1359 |
|
} |
1360 |
|
} |
1361 |
|
|
1362 |
|
public void |
1363 |
|
settingsChanged(MidiDeviceEvent e) { |
1364 |
|
if(isUpdate()) { |
1365 |
|
CC.getLogger().warning("Invalid update state"); |
1366 |
|
return; |
1367 |
|
} |
1368 |
|
|
1369 |
|
setUpdate(true); |
1370 |
|
int idx = cbMidiPort.getSelectedIndex(); |
1371 |
|
MidiInputDevice d = e.getMidiDeviceModel().getDeviceInfo(); |
1372 |
|
|
1373 |
|
cbMidiPort.removeAllItems(); |
1374 |
|
for(MidiPort port : d.getMidiPorts()) cbMidiPort.addItem(port); |
1375 |
|
|
1376 |
|
if(idx >= cbMidiPort.getModel().getSize()) idx = 0; |
1377 |
|
|
1378 |
|
setUpdate(false); |
1379 |
|
|
1380 |
|
if(cbMidiPort.getModel().getSize() > 0) cbMidiPort.setSelectedIndex(idx); |
1381 |
|
} |
1382 |
|
} |
1383 |
|
|
1384 |
|
private class MapListListener implements ListListener<MidiInstrumentMap> { |
1385 |
|
/** Invoked when a new MIDI instrument map is added to a list. */ |
1386 |
|
public void |
1387 |
|
entryAdded(ListEvent<MidiInstrumentMap> e) { |
1388 |
|
cbInstrumentMap.insertItemAt(e.getEntry(), cbInstrumentMap.getItemCount()); |
1389 |
|
boolean b = channel.getModel().getChannelInfo().getEngine() != null; |
1390 |
|
if(b && !cbInstrumentMap.isEnabled()) cbInstrumentMap.setEnabled(true); |
1391 |
|
} |
1392 |
|
|
1393 |
|
/** Invoked when a new MIDI instrument map is removed from a list. */ |
1394 |
|
public void |
1395 |
|
entryRemoved(ListEvent<MidiInstrumentMap> e) { |
1396 |
|
cbInstrumentMap.removeItem(e.getEntry()); |
1397 |
|
if(cbInstrumentMap.getItemCount() == 0) { // TODO: ? |
1398 |
|
cbInstrumentMap.setSelectedItem(noMap); |
1399 |
|
cbInstrumentMap.setEnabled(false); |
1400 |
|
} |
1401 |
|
} |
1402 |
} |
} |
1403 |
} |
} |