Subversion Repositories svn.mios

Rev

Rev 696 | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 696 Rev 738
Line 16... Line 16...
16
 * You should have received a copy of the GNU General Public License
16
 * You should have received a copy of the GNU General Public License
17
 * along with this application; if not, write to the Free Software
17
 * along with this application; if not, write to the Free Software
18
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
18
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
19
 */
19
 */
20
package org.midibox.sidedit;
20
package org.midibox.sidedit;
-
 
21
-
 
22
import java.util.Arrays;
21
23
22
import javax.sound.midi.MidiMessage;
24
import javax.sound.midi.MidiMessage;
23
25
24
import org.midibox.midi.MidiUtils;
26
import org.midibox.midi.MidiUtils;
25
import org.midibox.sidlibr.Patch;
27
import org.midibox.sidlibr.Patch;
26
import java.util.Arrays;
-
 
27
import java.util.Vector;
-
 
28
28
29
public class SIDSysexParameterControl extends SIDSysexParameter {
29
public class SIDSysexParameterControl extends SIDSysexParameter {
30
30
31
    public final static Object RECEIVE = new Object();
31
    public final static Object RECEIVE = new Object();
32
32
Line 48... Line 48...
48
48
49
    protected String tooltip;
49
    protected String tooltip;
50
   
50
51
    protected Object tooltipListener;
51
    protected Object tooltipListener;
52
52
53
    public SIDSysexParameterControl(int type, String[] valAlias, int offset, Patch patch, int addres, int start_bit, int reso, String name, String tooltip) {
53
    public SIDSysexParameterControl(int type, String[] valAlias, int offset,
-
 
54
            Patch patch, int addres, int start_bit, int reso, String name,
-
 
55
            String tooltip) {
54
        super(patch, addres, start_bit, reso, name);
56
        super(patch, addres, start_bit, reso, name);
55
        setReceive(true);
57
        setReceive(true);
56
        setSend(true);
58
        setSend(true);
57
        this.tooltip = tooltip;
59
        this.tooltip = tooltip;
58
        this.type = type;
60
        this.type = type;
Line 61... Line 63...
61
            this.valAlias = valAlias;
63
            this.valAlias = valAlias;
62
            sparseMatrix = generateSparseMatrix(valAlias);
64
            sparseMatrix = generateSparseMatrix(valAlias);
63
        }              
65
        }
64
    }
66
    }
65
67
66
    public SIDSysexParameterControl(int type, String[] valAlias, int offset, Patch patch, int addres, int start_bit, int reso, String name) {
68
    public SIDSysexParameterControl(int type, String[] valAlias, int offset,
-
 
69
            Patch patch, int addres, int start_bit, int reso, String name) {
67
        super(patch, addres, start_bit, reso, name);
70
        super(patch, addres, start_bit, reso, name);
68
        setReceive(true);
71
        setReceive(true);
69
        setSend(true);
72
        setSend(true);
70
        this.tooltip = name;
73
        this.tooltip = name;
71
        this.type = type;
74
        this.type = type;
Line 123... Line 126...
123
    }
126
    }
124
   
127
125
    public String getMidiValueWithAlias() {
128
    public String getMidiValueWithAlias() {
126
        if (snap) {
129
        if (snap) {
127
            if (snapAlias==null) {             
130
            if (snapAlias == null) {
128
                return Integer.toString(snapVals[getMidiValSnapIndex()]+valueOffset);              
131
                return Integer.toString(snapVals[getMidiValSnapIndex()]
-
 
132
                        + valueOffset);
129
            } else {
133
            } else {
130
                return snapAlias[getMidiValSnapIndex()];
134
                return snapAlias[getMidiValSnapIndex()];
131
            }
135
            }
132
        } else {
136
        } else {
133
            if (valAlias==null) {
137
            if (valAlias == null) {
Line 139... Line 143...
139
    }
143
    }
140
       
144
141
    public void SetMidiValueWithAlias(String s) {
145
    public void SetMidiValueWithAlias(String s) {
142
        int val = getMidiValue();
146
        int val = getMidiValue();
143
        if (snap) {
147
        if (snap) {
-
 
148
            if ((snapAlias == null)
144
            if ((snapAlias==null) && (Arrays.binarySearch(snapVals,Integer.valueOf(s)-valueOffset)!=-1)) {             
149
                    && (Arrays.binarySearch(snapVals, Integer.valueOf(s)
-
 
150
                            - valueOffset) != -1)) {
145
                val =  Integer.valueOf(s)-valueOffset;
151
                val = Integer.valueOf(s) - valueOffset;
146
            } else {
152
            } else {
147
                val = snapVals[searchStringArray(snapAlias,s,val)];
153
                val = snapVals[searchStringArray(snapAlias, s, val)];
148
            }
154
            }
149
        } else {
155
        } else {
Line 156... Line 162...
156
        setMidiValue(val,true);
162
        setMidiValue(val, true);
157
    }
163
    }
158
   
164
159
    public int getMidiValSnapIndex() {
165
    public int getMidiValSnapIndex() {
160
        int i = Arrays.binarySearch(snapVals,getMidiValue());
166
        int i = Arrays.binarySearch(snapVals, getMidiValue());
161
        if (i==-1) {i = 0;}
167
        if (i == -1) {
-
 
168
            i = 0;
-
 
169
        }
162
        return i;
170
        return i;
163
    }
171
    }
164
   
172
165
    private int searchStringArray(String[] sarray, String s, int def) {
173
    private int searchStringArray(String[] sarray, String s, int def) {
166
        int val = def;
174
        int val = def;
Line 214... Line 222...
214
        }
222
        }
215
        return sparseMat;
223
        return sparseMat;
216
    }
224
    }
217
   
225
218
    public void send(MidiMessage message, long lTimeStamp) {
226
    public void send(MidiMessage message, long lTimeStamp) {
219
        String m = MidiUtils.getHexString(message.getMessage()).replace(" ", "");
227
        String m = MidiUtils.getHexString(message.getMessage())
-
 
228
                .replace(" ", "");
220
        if (m.indexOf(SIDSysexInfo.acknowledgedSysex.replace("<device>", "00")) == 0) {
229
        if (m.indexOf(SIDSysexInfo.acknowledgedSysex.replace("<device>", "00")) == 0) {
221
            // System.out.println("MBSID: Acknowdledged!");
230
            // System.out.println("MBSID: Acknowdledged!");
222
        } else if (m.equals(SIDSysexInfo.error1Sysex.replace("<device>", "00"))) {
231
        } else if (m.equals(SIDSysexInfo.error1Sysex.replace("<device>", "00"))) {
223
            System.out.println("MBSID: Received less bytes then expected");
232
            System.out.println("MBSID: Received less bytes then expected");
224
        } else if (m.equals(SIDSysexInfo.error2Sysex.replace("<device>", "00"))) {
233
        } else if (m.equals(SIDSysexInfo.error2Sysex.replace("<device>", "00"))) {
225
            System.out.println("MBSID: Wrong checksum");
234
            System.out.println("MBSID: Wrong checksum");
226
        } else if (m.equals(SIDSysexInfo.error3Sysex.replace("<device>", "00"))) {
235
        } else if (m.equals(SIDSysexInfo.error3Sysex.replace("<device>", "00"))) {
-
 
236
            System.out
227
            System.out.println("MBSID: Bankstick or patch/drumset/ensemble not available");
237
                    .println("MBSID: Bankstick or patch/drumset/ensemble not available");
228
        } else if (m.equals(SIDSysexInfo.error4Sysex.replace("<device>", "00"))) {
238
        } else if (m.equals(SIDSysexInfo.error4Sysex.replace("<device>", "00"))) {
229
            System.out.println("MBSID: Parameter not available");
239
            System.out.println("MBSID: Parameter not available");
230
        } else if (m.equals(SIDSysexInfo.error5Sysex.replace("<device>", "00"))) {
240
        } else if (m.equals(SIDSysexInfo.error5Sysex.replace("<device>", "00"))) {
231
            System.out.println("MBSID: RAM access not supported");
241
            System.out.println("MBSID: RAM access not supported");
232
        } else if (m.equals(SIDSysexInfo.error6Sysex.replace("<device>", "00"))) {
242
        } else if (m.equals(SIDSysexInfo.error6Sysex.replace("<device>", "00"))) {