Skip to content
This repository
branch: master
Fetching contributors…

Cannot retrieve contributors at this time

file 386 lines (326 sloc) 9.041 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386
/*

LiCK Library for ChucK.
Copyright (c) 2007-2014 held jointly by the individual authors.

This file is part of LiCK.

LiCK is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

LiCK is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with LiCK. If not, see <http://www.gnu.org/licenses/>.

*/

public class AlesisQX25
{
    MidiIn min;
    MidiMsg msg;

    // cached values
    int _lastPitchBend[2];
    int _lastModulation;
    int _lastRotary[9];
    int _lastKey[125];
    int _lastSlider;
    int _lastSustainPedal;

    // assign custom procedures
    IntIntProcedure pitchBend;
    IntProcedure modulation;
    IntProcedure rotary1;
    IntProcedure rotary2;
    IntProcedure rotary3;
    IntProcedure rotary4;
    IntProcedure rotary5;
    IntProcedure rotary6;
    IntProcedure rotary7;
    IntProcedure rotary8;
    IntProcedure pad1;
    IntProcedure pad2;
    IntProcedure pad3;
    IntProcedure pad4;
    Procedure loop;
    Procedure rewind;
    Procedure fastForward;
    Procedure stop;
    Procedure play;
    Procedure record;
    IntProcedure slider;
    IntIntProcedure keyOn;
    IntProcedure keyOff;
    Procedure sustainPedalOn;
    Procedure sustainPedalOff;

    fun int[] getPitchBend()
    {
        return _lastPitchBend;
    }

    fun int getModulation()
    {
        return _lastModulation;
    }

    fun int getRotary1()
    {
        return _lastRotary[1];
    }

    fun int getRotary2()
    {
        return _lastRotary[2];
    }

    fun int getRotary3()
    {
        return _lastRotary[3];
    }

    fun int getRotary4()
    {
        return _lastRotary[4];
    }

    fun int getRotary5()
    {
        return _lastRotary[5];
    }

    fun int getRotary6()
    {
        return _lastRotary[6];
    }

    fun int getRotary7()
    {
        return _lastRotary[7];
    }

    fun int getRotary8()
    {
        return _lastRotary[8];
    }

    fun int isKeyOn(int key)
    {
        return (_lastKey[key] > 0);
    }

    fun int isKeyOff(int key)
    {
        return (_lastKey[key] == 0);
    }

    fun int getVelocity(int key)
    {
        return _lastKey[key];
    }

    fun int getSlider()
    {
        return _lastSlider;
    }

    fun int isSustainPedalOn()
    {
        return _lastSustainPedal;
    }

    fun int isSustainPedalOff()
    {
        return !_lastSustainPedal;
    }

    fun int open(int device)
    {
        min.open(device);

        while (true)
        {
            min => now;
            while (min.recv(msg))
            {
                msg.data1 => int control;
                msg.data2 => int note;
                msg.data3 => int velocity;

                // see notes below
                if (control == 144)
                {
                    if (velocity == 0)
                    {
                        0 => _lastKey[note];
                        spork ~ keyOff.run(note);
                    }
                    else
                    {
                        if (note == 60)
                        {
                            spork ~ pad1.run(velocity);
                        }
                        else if (note == 61)
                        {
                            spork ~ pad2.run(velocity);
                        }
                        else if (note == 62)
                        {
                            spork ~ pad3.run(velocity);
                        }
                        else if (note == 63)
                        {
                            spork ~ pad4.run(velocity);
                        }
                        velocity => _lastKey[note];
                        spork ~ keyOn.run(note, velocity);
                    }
                }
                else if (control == 224)
                {
                    note => _lastPitchBend[0];
                    velocity => _lastPitchBend[1];
                    spork ~ pitchBend.run(note, velocity);
                }
                else if (control == 176)
                {
                    if (note == 1)
                    {
                        velocity => _lastModulation;
                        spork ~ modulation.run(velocity);
                    }
                    else if (note == 14) // k1
                    {
                        velocity => _lastRotary[1];
                        spork ~ rotary1.run(velocity);
                    }
                    else if (note == 15) // k2
                    {
                        velocity => _lastRotary[2];
                        spork ~ rotary2.run(velocity);
                    }
                    else if (note == 16) // k3
                    {
                        velocity => _lastRotary[3];
                        spork ~ rotary3.run(velocity);
                    }
                    else if (note == 17) // k4
                    {
                        velocity => _lastRotary[4];
                        spork ~ rotary4.run(velocity);
                    }
                    else if (note == 18) // k5
                    {
                        velocity => _lastRotary[5];
                        spork ~ rotary5.run(velocity);
                    }
                    else if (note == 19) // k6
                    {
                        velocity => _lastRotary[6];
                        spork ~ rotary6.run(velocity);
                    }
                    else if (note == 20) // k7
                    {
                        velocity => _lastRotary[7];
                        spork ~ rotary7.run(velocity);
                    }
                    else if (note == 21) // k8
                    {
                        velocity => _lastRotary[8];
                        spork ~ rotary8.run(velocity);
                    }
                    else if (note == 22) // slider
                    {
                        velocity => _lastSlider;
                        spork ~ slider.run(velocity);
                    }
                    else if (note == 119) // loop
                    {
                        if (velocity == 127)
                        {
                            spork ~ loop.run();
                        }
                    }
                    else if (note == 118) // rewind
                    {
                        if (velocity == 127)
                        {
                            spork ~ rewind.run();
                        }
                    }
                    else if (note == 117) // fast forward
                    {
                        if (velocity == 127)
                        {
                            spork ~ fastForward.run();
                        }
                    }
                    else if (note == 114) // stop
                    {
                        if (velocity == 127)
                        {
                            spork ~ stop.run();
                        }
                    }
                    else if (note == 115) // play
                    {
                        if (velocity == 127)
                        {
                            spork ~ play.run();
                        }
                    }
                    else if (note == 116) // record
                    {
                        if (velocity == 127)
                        {
                            spork ~ record.run();
                        }
                    }
                    else if (note == 64) // sustain pedal
                    {
                        if (velocity == 127)
                        {
                            true => _lastSustainPedal;
                            spork ~ sustainPedalOn.run();
                        }
                        else if (velocity == 0)
                        {
                            false => _lastSustainPedal;
                            spork ~ sustainPedalOff.run();
                        }
                    }
                }
            }
        }
    }
}

/**

Alesis QX25 Notes

Keys:

144, key (0 - 120), velocity

Rotary:

K1
CC14

K2
CC15

K3
CC16

K4
CC17

K5
CC18

K6
CC19

K7
CC20

K8
CC21

Pads:

P1
C4 note on/off 60

P2
C#4 note on/off 61

P3
D4 note on/off 62

P4
D#4 note on/off 63

Transport:

1 loop
CC119 127 followed by CC119 0

2 rewind
CC118 127 followed by CC118 0

3 fast forward
CC117 127 followed by CC117 0

A stop
CC114 127 followed by CC114 0

B play
CC115 127 followed by CC115 0

C record
CC116 127 followed by CC116 0

Slider:

S1
CC22

Mod wheel:

CC1

Pitch wheel:

Sustain pedal:

*/
Something went wrong with that request. Please try again.