/[svn]/jsampler/trunk/src/org/jsampler/view/std/JSMidiBankChooser.java
ViewVC logotype

Contents of /jsampler/trunk/src/org/jsampler/view/std/JSMidiBankChooser.java

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1767 - (show annotations) (download)
Mon Sep 8 00:19:27 2008 UTC (15 years, 7 months ago) by iliev
File size: 4414 byte(s)
* Added `Copy To' and `Move To' commands to the MIDI bank context menu
  and to the MIDI instrument context menu
* Added commands to the MIDI instrument context menu for moving
  a MIDI instrument to another program
  (right-click on a MIDI instrument and choose `Change Program')
* Added option to choose between zero-based and one-based
  MIDI bank/program numbering
  (choose Edit/Preferences, then click the `Advanced' button)
* Added option to choose whether to include MIDI instrument
  mappings when exporting a sampler configuration to LSCP script.
  (choose Edit/Preferences, then click the `Advanced' button)
* Added option to set the MIDI instrument loading in background
  when exporting MIDI instrument mappings to LSCP script.
  (choose Edit/Preferences, then click the `Advanced' button)
* Implemented an option to change the socket read timeout
  (choose Edit/Preferences, then click the `Backend' tab)
* Updated LscpTree
* Fantasia: Added option to hide the active stream/voice count statistic
  in the sampler channel's small view
  (choose Edit/Preferences, then click the `Channels' tab)
* Fantasia: `Turn off animation effects' checkbox moved to the `View' tab

1 /*
2 * JSampler - a java front-end for LinuxSampler
3 *
4 * Copyright (C) 2005-2008 Grigor Iliev <grigor@grigoriliev.com>
5 *
6 * This file is part of JSampler.
7 *
8 * JSampler is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2
10 * as published by the Free Software Foundation.
11 *
12 * JSampler is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with JSampler; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
20 * MA 02111-1307 USA
21 */
22
23 package org.jsampler.view.std;
24
25 import java.awt.GridBagConstraints;
26 import java.awt.GridBagLayout;
27 import java.awt.Insets;
28
29 import javax.swing.JComboBox;
30 import javax.swing.JLabel;
31 import javax.swing.JPanel;
32 import javax.swing.JSpinner;
33 import javax.swing.SpinnerNumberModel;
34
35 import net.sf.juife.OkCancelDialog;
36
37 import org.jsampler.CC;
38 import org.jsampler.MidiInstrumentMap;
39
40 import org.jsampler.event.ListEvent;
41 import org.jsampler.event.ListListener;
42
43 import static org.jsampler.view.std.StdI18n.i18n;
44
45 /**
46 *
47 * @author Grigor Iliev
48 */
49 public class JSMidiBankChooser extends OkCancelDialog implements ListListener<MidiInstrumentMap> {
50 private final JLabel lMap = new JLabel(i18n.getLabel("JSMidiBankChooser.lMap"));
51 private final JLabel lBank = new JLabel(i18n.getLabel("JSMidiBankChooser.lBank"));
52
53 private final JComboBox cbMap = new JComboBox();
54 private final JSpinner spinnerBank;
55
56 /** Creates a new instance of <code>JSMidiBankChooser</code> */
57 public
58 JSMidiBankChooser() {
59 super(CC.getMainFrame());
60 int i = CC.getViewConfig().getFirstMidiBankNumber();
61 spinnerBank = new JSpinner(new SpinnerNumberModel(i, i, 16383 + i, 1));
62
63 JPanel mainPane = new JPanel();
64 GridBagLayout gridbag = new GridBagLayout();
65 GridBagConstraints c = new GridBagConstraints();
66
67 mainPane.setLayout(gridbag);
68
69 c.fill = GridBagConstraints.NONE;
70
71 c.gridx = 0;
72 c.gridy = 0;
73 c.anchor = GridBagConstraints.EAST;
74 c.insets = new Insets(3, 3, 3, 3);
75 gridbag.setConstraints(lMap, c);
76 mainPane.add(lMap);
77
78 c.gridx = 0;
79 c.gridy = 1;
80 gridbag.setConstraints(lBank, c);
81 mainPane.add(lBank);
82
83 c.fill = GridBagConstraints.HORIZONTAL;
84 c.gridx = 1;
85 c.gridy = 0;
86 c.weightx = 1.0;
87 c.insets = new Insets(3, 3, 3, 3);
88 c.anchor = GridBagConstraints.WEST;
89 gridbag.setConstraints(cbMap, c);
90 mainPane.add(cbMap);
91
92 c.gridx = 1;
93 c.gridy = 1;
94 gridbag.setConstraints(spinnerBank, c);
95 mainPane.add(spinnerBank);
96
97 for(i = 0; i < CC.getSamplerModel().getMidiInstrumentMapCount(); i++) {
98 cbMap.addItem(CC.getSamplerModel().getMidiInstrumentMap(i));
99 }
100 if(cbMap.getItemCount() == 0) {
101 btnOk.setEnabled(false);
102 cbMap.setEnabled(false);
103 }
104
105 CC.getSamplerModel().addMidiInstrumentMapListListener(this);
106
107 mainPane.setMinimumSize(mainPane.getPreferredSize());
108 setMainPane(mainPane);
109
110 setResizable(true);
111 }
112
113 /**
114 * Gets the selected MIDI instrument map.
115 */
116 public MidiInstrumentMap
117 getSelectedMidiInstrumentMap() { return (MidiInstrumentMap)cbMap.getSelectedItem(); }
118
119 public void
120 setSelectedMidiInstrumentMap(MidiInstrumentMap map) {
121 cbMap.setSelectedItem(map);
122 }
123
124 /**
125 * Sets the selected MIDI bank (always zero-based).
126 */
127 public void
128 setMidiBank(int bank) {
129 spinnerBank.setValue(bank + CC.getViewConfig().getFirstMidiBankNumber());
130 }
131
132 /**
133 * Gets the selected MIDI bank (always zero-based).
134 */
135 public int
136 getMidiBank() {
137 int i = CC.getViewConfig().getFirstMidiBankNumber();
138 return Integer.parseInt(spinnerBank.getValue().toString()) - i;
139 }
140
141 protected void
142 onOk() {
143 if(!btnOk.isEnabled()) return;
144
145 setVisible(false);
146 setCancelled(false);
147 }
148
149 protected void
150 onCancel() { setVisible(false); }
151
152 public void
153 entryAdded(ListEvent<MidiInstrumentMap> e) {
154 if(cbMap.getItemCount() == 0) {
155 btnOk.setEnabled(true);
156 cbMap.setEnabled(true);
157 }
158 cbMap.addItem(e.getEntry());
159 }
160
161 public void
162 entryRemoved(ListEvent<MidiInstrumentMap> e) {
163 cbMap.removeItem(e.getEntry());
164 if(cbMap.getItemCount() == 0) {
165 btnOk.setEnabled(false);
166 cbMap.setEnabled(false);
167 }
168 }
169 }

  ViewVC Help
Powered by ViewVC