Subversion Repositories svn.mios

Rev

Rev 712 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
213 tk 1
/*
2
 * @(#)SIDV2librarian.java  beta1   2008/01/21
3
 *
4
 * Copyright (C) 2008    Rutger Vlek (rutgervlek@hotmail.com)
5
 *
6
 * This application is free software; you can redistribute it and/or modify
7
 * it under the terms of the GNU General Public License as published by
8
 * the Free Software Foundation; either version 2 of the License, or
9
 * (at your option) any later version.
10
 *
11
 * This application is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 *
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
18
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
19
 */
20
 
21
package org.midibox.sidedit;
22
 
23
import java.util.Vector;
24
 
25
import org.midibox.sidlibr.Patch;
26
 
27
public class MultiSpecs {
28
    // Control types:
29
    private static int rotary = 0;
30
    private static int button = 1;
31
    private static int simplebutton = 2;
628 adamjking 32
    private static int slider = 3;
33
    private static int waveselect = 4;
213 tk 34
    private static int lfoselect = 5;
35
    private static int combo = 6;
36
    private static int simplerotary = 7;
628 adamjking 37
 
213 tk 38
    public static Vector createMSTR(Patch patch) {
628 adamjking 39
        Vector drumControl = new Vector();
738 adamjking 40
        drumControl.add(new SIDSysexParameterControl(rotary, null, 0, patch,
41
                82, 0, 7, "Volume"));
213 tk 42
        return drumControl;
43
    }
628 adamjking 44
 
213 tk 45
    public static Vector createInstrument(Patch patch, int offset) {
46
        Vector multiControl = new Vector();
47
        // Master
738 adamjking 48
        multiControl.add(new SIDSysexParameterControl(button, null, 0, patch,
49
                112 + offset, 3, 1, "Poly", "Switches between Poly/Mono mode"));
50
        multiControl.add(new SIDSysexParameterControl(button, null, 0, patch,
51
                112 + offset, 0, 1, "Legato"));
52
        multiControl.add(new SIDSysexParameterControl(button, null, 0, patch,
53
                112 + offset, 2, 1, "Fingered Portamento"));
54
        multiControl.add(new SIDSysexParameterControl(button, null, 0, patch,
55
                112 + offset, 1, 1, "Wavetable only"));
56
        multiControl.add(new SIDSysexParameterControl(rotary, null, 0, patch,
57
                113 + offset, 0, 4, "Voice Assign", "Voice assignment"));
58
        multiControl.add(new SIDSysexParameterControl(combo,
59
                SIDSysexInfo.multiParams, 0, patch, 114 + offset, 0, 8,
60
                "Velocity Assign", "Velocity parameter assignment"));
61
        multiControl.add(new SIDSysexParameterControl(combo,
62
                SIDSysexInfo.multiParams, 0, patch, 115 + offset, 0, 8,
63
                "PitchB. Assign", "Pitch Bender assignment"));
628 adamjking 64
 
65
        // LFO 1&2
66
        for (int i = 0; i < 2; i++) {
738 adamjking 67
            multiControl.add(new SIDSysexParameterControl(button, null, 0,
68
                    patch, 116 + (7 * i) + offset, 0, 1, "On/Off",
69
                    "Enable/disable LFO"));
70
            multiControl.add(new SIDSysexParameterControl(button, null, 0,
71
                    patch, 116 + (7 * i) + offset, 1, 1, "Key Sync",
72
                    "Key synchronisation"));
73
            multiControl.add(new SIDSysexParameterControl(button, null, 0,
74
                    patch, 116 + (7 * i) + offset, 2, 1, "MIDI Sync",
75
                    "Global clock synchronisation"));
76
            multiControl.add(new SIDSysexParameterControl(button, null, 0,
77
                    patch, 116 + (7 * i) + offset, 3, 1, "Oneshot",
78
                    "Oneshot mode"));
79
            multiControl.add(new SIDSysexParameterControl(lfoselect, null, 0,
80
                    patch, 116 + (7 * i) + offset, 4, 4, "Waveform"));
81
            multiControl.add(new SIDSysexParameterControl(rotary, null, -128,
82
                    patch, 117 + (7 * i) + offset, 0, 8, "Pitch Depth",
83
                    "Pitch modulation depth"));
84
            multiControl.add(new SIDSysexParameterControl(rotary, null, 0,
85
                    patch, 118 + (7 * i) + offset, 0, 8, "Rate"));
86
            multiControl.add(new SIDSysexParameterControl(rotary, null, 0,
87
                    patch, 119 + (7 * i) + offset, 0, 8, "Delay"));
88
            multiControl.add(new SIDSysexParameterControl(rotary, null, 0,
89
                    patch, 120 + (7 * i) + offset, 0, 8, "Phase"));
90
            multiControl.add(new SIDSysexParameterControl(rotary, null, -128,
91
                    patch, 121 + (7 * i) + offset, 0, 8, "PWM Depth",
92
                    "Pulse width modulation depth"));
93
            multiControl.add(new SIDSysexParameterControl(rotary, null, -128,
94
                    patch, 122 + (7 * i) + offset, 0, 8, "Cutoff Depth",
95
                    "Filter cutoff modulation depth"));
213 tk 96
        }
628 adamjking 97
 
213 tk 98
        // Envelope
738 adamjking 99
        multiControl.add(new SIDSysexParameterControl(button, null, 0, patch,
100
                130 + offset, 4, 1, "Curve to Attack",
101
                "Curve assigned to Attack rate"));
102
        multiControl.add(new SIDSysexParameterControl(button, null, 0, patch,
103
                130 + offset, 5, 1, "Curve to Decay",
104
                "Curve assigned to Decay rate"));
105
        multiControl.add(new SIDSysexParameterControl(button, null, 0, patch,
106
                130 + offset, 6, 1, "Curve to Sustain",
107
                "Curve assigned to Sustain rate"));
108
        multiControl
109
                .add(new SIDSysexParameterControl(button, null, 0, patch,
110
                        130 + offset, 7, 1, "MIDI Sync",
111
                        "Global clock synchronisation"));
112
        multiControl.add(new SIDSysexParameterControl(rotary, null, -128,
113
                patch, 131 + offset, 0, 8, "Depth Pitch",
114
                "Pitch modulation depth"));
115
        multiControl.add(new SIDSysexParameterControl(rotary, null, -128,
116
                patch, 132 + offset, 0, 8, "Depth PWM",
117
                "Pulse width modulation depth"));
118
        multiControl.add(new SIDSysexParameterControl(rotary, null, -128,
119
                patch, 133 + offset, 0, 8, "Depth Cutoff",
120
                "Filter cutoff modulation depth"));
121
        multiControl.add(new SIDSysexParameterControl(slider, null, 0, patch,
122
                134 + offset, 0, 8, "Attack", "Attack rate"));
123
        multiControl.add(new SIDSysexParameterControl(slider, null, 0, patch,
124
                135 + offset, 0, 8, "Decay", "Decay rate"));
125
        multiControl.add(new SIDSysexParameterControl(slider, null, 0, patch,
126
                136 + offset, 0, 8, "Sustain", "Sustain level"));
127
        multiControl.add(new SIDSysexParameterControl(slider, null, 0, patch,
128
                137 + offset, 0, 8, "Release", "Release rate"));
129
        multiControl.add(new SIDSysexParameterControl(rotary, null, -128,
130
                patch, 138 + offset, 0, 8, "Curve"));
303 tk 131
 
213 tk 132
        // Wavetable
738 adamjking 133
        multiControl.add(new SIDSysexParameterControl(rotary, createDividers(),
134
                0, patch, 139 + offset, 0, 6, "Clock Divider",
135
                "Clock divider (sets tempo)"));
136
        multiControl.add(new SIDSysexParameterControl(button, null, 0, patch,
137
                139 + offset, 6, 1, "reserved", "Reserved"));
138
        multiControl.add(new SIDSysexParameterControl(button, null, 0, patch,
139
                139 + offset, 7, 1, "reserved", "Reserved"));
140
        multiControl.add(new SIDSysexParameterControl(combo,
141
                SIDSysexInfo.multiParams, 0, patch, 140 + offset, 0, 8,
142
                "Assign", "Parameter assignment"));
143
        multiControl
144
                .add(new SIDSysexParameterControl(rotary, null, 0, patch,
145
                        141 + offset, 0, 7, "Start Pos",
146
                        "Start position in wavetable"));
147
        multiControl.add(new SIDSysexParameterControl(button, null, 0, patch,
148
                141 + offset, 7, 1, "reserved", "reserved flag"));
149
        multiControl.add(new SIDSysexParameterControl(rotary, null, 0, patch,
150
                142 + offset, 0, 7, "End Pos", "End position in wavetable"));
151
        multiControl.add(new SIDSysexParameterControl(rotary, null, 0, patch,
152
                143 + offset, 0, 7, "Loop Pos", "Loop position in wavetable"));
153
        multiControl.add(new SIDSysexParameterControl(button, null, 0, patch,
154
                143 + offset, 7, 1, "Oneshot"));
628 adamjking 155
 
213 tk 156
        return multiControl;
157
    }
628 adamjking 158
 
213 tk 159
    public static Vector createWTdata(Patch patch) {
628 adamjking 160
        Vector wtControl = new Vector();
213 tk 161
        // Wavetable data
628 adamjking 162
        for (int c = 0; c < 128; c++) {
738 adamjking 163
            wtControl.add(new SIDSysexParameterControl(slider, createWTStr(),
164
                    0, patch, 384 + c, 0, 8, Integer.toString(c)));
628 adamjking 165
        }
213 tk 166
        return wtControl;
167
    }
628 adamjking 168
 
213 tk 169
    private static String[] createWTStr() {
170
        String[] wtStr = new String[256];
628 adamjking 171
        String[] notes = { "c-", "c#", "d-", "d#", "e-", "f-", "f#", "g-",
172
                "g#", "a-", "a#", "b-" };
173
 
213 tk 174
        for (int i = 0; i < 256; i++) {
628 adamjking 175
            if (i < 64) {
176
                wtStr[i] = Integer.toString(i - 64);
177
            } else if (i < 128) {
178
                wtStr[i] = "+" + Integer.toString(i - 64);
179
            } else if (i == 128) {
213 tk 180
                wtStr[i] = "---";
628 adamjking 181
            } else if (i == 129) {
213 tk 182
                wtStr[i] = "+++";
628 adamjking 183
            } else if (i < 252) {
184
                int octave = (int) Math.floor((i - 128) / 12) - 2;
213 tk 185
                if (octave < 0) {
628 adamjking 186
                    wtStr[i] = notes[(i - 128) % 12] + Math.abs(octave);
187
                } else {
188
                    wtStr[i] = notes[(i - 128) % 12].toUpperCase()
189
                            + Math.abs(octave);
213 tk 190
                }
628 adamjking 191
            } else if (i < 256) {
192
                wtStr[i] = "Ky" + Integer.toString(i - 251);
213 tk 193
            }
194
        }
195
        return wtStr;
196
    }
712 tk 197
 
198
    public static String[] createDividers() {
199
        String[] s = new String[64];
200
        for (int i = 0; i < s.length; i++) {
201
            s[i] = Integer.toString(i + 1);
202
        }
203
        return s;
204
    }
213 tk 205
}