Subversion Repositories svn.mios

Rev

Rev 303 | Rev 696 | Go to most recent revision | 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();
40
        drumControl.add(new SIDSysexParameterControl(rotary, null, patch, 82,
41
                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
628 adamjking 48
        multiControl.add(new SIDSysexParameterControl(button, null, patch,
49
                112 + offset, 3, 1, "Poly", "Switches between Poly/Mono mode"));
50
        multiControl.add(new SIDSysexParameterControl(button, null, patch,
51
                112 + offset, 0, 1, "Legato"));
52
        multiControl.add(new SIDSysexParameterControl(button, null, patch,
53
                112 + offset, 2, 1, "Fingered Portamento"));
54
        multiControl.add(new SIDSysexParameterControl(button, null, patch,
55
                112 + offset, 1, 1, "Wavetable only"));
56
        multiControl.add(new SIDSysexParameterControl(rotary,
57
                SIDSysexInfo.voiceAssign, patch, 113 + offset, 0, 4,
58
                "Voice Assign", "Voice assignment"));
59
        multiControl.add(new SIDSysexParameterControl(combo,
60
                SIDSysexInfo.multiParams, patch, 114 + offset, 0, 8,
61
                "Velocity Assign", "Velocity parameter assignment"));
62
        multiControl.add(new SIDSysexParameterControl(combo,
63
                SIDSysexInfo.multiParams, patch, 115 + offset, 0, 8,
64
                "PitchB. Assign", "Pitch Bender assignment"));
65
 
66
        // LFO 1&2
67
        for (int i = 0; i < 2; i++) {
68
            multiControl.add(new SIDSysexParameterControl(button, null, patch,
69
                    116 + (7 * i) + offset, 0, 1, "On/Off",
70
                    "Enable/disable LFO"));
71
            multiControl.add(new SIDSysexParameterControl(button, null, patch,
72
                    116 + (7 * i) + offset, 1, 1, "Key Sync",
73
                    "Key synchronisation"));
74
            multiControl.add(new SIDSysexParameterControl(button, null, patch,
75
                    116 + (7 * i) + offset, 2, 1, "MIDI Sync",
76
                    "Global clock synchronisation"));
77
            multiControl.add(new SIDSysexParameterControl(button, null, patch,
78
                    116 + (7 * i) + offset, 3, 1, "Oneshot", "Oneshot mode"));
79
            multiControl.add(new SIDSysexParameterControl(lfoselect, null,
80
                    patch, 116 + (7 * i) + offset, 4, 4, "Waveform"));
81
            multiControl.add(new SIDSysexParameterControl(rotary, null, patch,
82
                    117 + (7 * i) + offset, 0, -8, "Pitch Depth",
83
                    "Pitch modulation depth"));
84
            multiControl.add(new SIDSysexParameterControl(rotary,
85
                    createRateStr(), patch, 118 + (7 * i) + offset, 0, 8,
86
                    "Rate")); // Let op CSn flag!
87
            multiControl.add(new SIDSysexParameterControl(rotary, null, patch,
88
                    119 + (7 * i) + offset, 0, 8, "Delay"));
89
            multiControl.add(new SIDSysexParameterControl(rotary, null, patch,
90
                    120 + (7 * i) + offset, 0, 8, "Phase"));
91
            multiControl.add(new SIDSysexParameterControl(rotary, null, patch,
92
                    121 + (7 * i) + offset, 0, -8, "PWM Depth",
93
                    "Pulse width modulation depth"));
94
            multiControl.add(new SIDSysexParameterControl(rotary, null, patch,
95
                    122 + (7 * i) + offset, 0, -8, "Cutoff Depth",
96
                    "Filter cutoff modulation depth"));
213 tk 97
        }
628 adamjking 98
 
213 tk 99
        // Envelope
628 adamjking 100
        multiControl.add(new SIDSysexParameterControl(button, null, patch,
101
                130 + offset, 4, 1, "Curve to Attack",
102
                "Curve assigned to Attack rate"));
103
        multiControl.add(new SIDSysexParameterControl(button, null, patch,
104
                130 + offset, 5, 1, "Curve to Decay",
105
                "Curve assigned to Decay rate"));
106
        multiControl.add(new SIDSysexParameterControl(button, null, patch,
107
                130 + offset, 6, 1, "Curve to Sustain",
108
                "Curve assigned to Sustain rate"));
109
        multiControl
110
                .add(new SIDSysexParameterControl(button, null, patch,
111
                        130 + offset, 7, 1, "MIDI Sync",
112
                        "Global clock synchronisation"));
113
        multiControl.add(new SIDSysexParameterControl(rotary, null, patch,
114
                131 + offset, 0, -8, "Depth Pitch", "Pitch modulation depth"));
115
        multiControl.add(new SIDSysexParameterControl(rotary, null, patch,
116
                132 + offset, 0, -8, "Depth PWM",
117
                "Pulse width modulation depth"));
118
        multiControl.add(new SIDSysexParameterControl(rotary, null, patch,
119
                133 + offset, 0, -8, "Depth Cutoff",
120
                "Filter cutoff modulation depth"));
121
        multiControl.add(new SIDSysexParameterControl(slider, null, patch,
122
                134 + offset, 0, 8, "Attack", "Attack rate"));
123
        multiControl.add(new SIDSysexParameterControl(slider, null, patch,
124
                135 + offset, 0, 8, "Decay", "Decay rate"));
125
        multiControl.add(new SIDSysexParameterControl(slider, null, patch,
126
                136 + offset, 0, 8, "Sustain", "Sustain level"));
127
        multiControl.add(new SIDSysexParameterControl(slider, null, patch,
128
                137 + offset, 0, 8, "Release", "Release rate"));
129
        multiControl.add(new SIDSysexParameterControl(rotary, null, patch,
130
                138 + offset, 0, -8, "Curve"));
303 tk 131
 
213 tk 132
        // Wavetable
628 adamjking 133
        multiControl.add(new SIDSysexParameterControl(rotary, null, patch,
134
                139 + offset, 0, 6, "Clock Divider",
135
                "Clock divider (sets tempo)"));
136
        multiControl.add(new SIDSysexParameterControl(button, null, patch,
137
                139 + offset, 6, 1, "reserved", "Reserved"));
138
        multiControl.add(new SIDSysexParameterControl(button, null, patch,
139
                139 + offset, 7, 1, "reserved", "Reserved"));
140
        multiControl.add(new SIDSysexParameterControl(combo,
141
                SIDSysexInfo.multiParams, patch, 140 + offset, 0, 8, "Assign",
142
                "Parameter assignment"));
143
        multiControl
144
                .add(new SIDSysexParameterControl(rotary, null, patch,
145
                        141 + offset, 0, 7, "Start Pos",
146
                        "Start position in wavetable"));
147
        multiControl.add(new SIDSysexParameterControl(button, null, patch,
148
                141 + offset, 7, 1, "reserved", "reserved flag"));
149
        multiControl.add(new SIDSysexParameterControl(rotary, null, patch,
150
                142 + offset, 0, 7, "End Pos", "End position in wavetable"));
151
        multiControl.add(new SIDSysexParameterControl(rotary, null, patch,
152
                143 + offset, 0, 7, "Loop Pos", "Loop position in wavetable"));
153
        multiControl.add(new SIDSysexParameterControl(button, null, patch,
154
                143 + offset, 7, 1, "Oneshot"));
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++) {
163
            wtControl.add(new SIDSysexParameterControl(slider, createWTStr(),
164
                    patch, 384 + c, 0, 8, Integer.toString(c)));
165
        }
213 tk 166
        return wtControl;
167
    }
628 adamjking 168
 
213 tk 169
    private static String[] createRateStr() {
628 adamjking 170
        String[] rateStr = new String[256];
171
        for (int c = 0; c < rateStr.length; c++) {
172
 
213 tk 173
            if (c < 245) {
174
                rateStr[c] = Integer.toString(c);
628 adamjking 175
            } else {
176
                rateStr[c] = SIDSysexInfo.rates[c - 245];
213 tk 177
            }
178
        }
179
        return rateStr;
180
    }
628 adamjking 181
 
213 tk 182
    private static String[] createWTStr() {
183
        String[] wtStr = new String[256];
628 adamjking 184
        String[] notes = { "c-", "c#", "d-", "d#", "e-", "f-", "f#", "g-",
185
                "g#", "a-", "a#", "b-" };
186
 
213 tk 187
        for (int i = 0; i < 256; i++) {
628 adamjking 188
            if (i < 64) {
189
                wtStr[i] = Integer.toString(i - 64);
190
            } else if (i < 128) {
191
                wtStr[i] = "+" + Integer.toString(i - 64);
192
            } else if (i == 128) {
213 tk 193
                wtStr[i] = "---";
628 adamjking 194
            } else if (i == 129) {
213 tk 195
                wtStr[i] = "+++";
628 adamjking 196
            } else if (i < 252) {
197
                int octave = (int) Math.floor((i - 128) / 12) - 2;
213 tk 198
                if (octave < 0) {
628 adamjking 199
                    wtStr[i] = notes[(i - 128) % 12] + Math.abs(octave);
200
                } else {
201
                    wtStr[i] = notes[(i - 128) % 12].toUpperCase()
202
                            + Math.abs(octave);
213 tk 203
                }
628 adamjking 204
            } else if (i < 256) {
205
                wtStr[i] = "Ky" + Integer.toString(i - 251);
213 tk 206
            }
207
        }
208
        return wtStr;
209
    }
210
}