casiotone 401 / Mbed 2 deprecated OSCtoCVConverter

Dependencies:   Bonjour OSCReceiver TextLCD mbed mbed-rpc BurstSPI DebouncedInterrupt FastIO MIDI OSC OSCtoCV ClockControl

Committer:
casiotone401
Date:
Thu Feb 25 11:22:24 2016 +0000
Revision:
29:8b61b87b9676
Parent:
27:65e873bf8307
Child:
31:0595b7456780
minor change

Who changed what in which revision?

UserRevisionLine numberNew contents of line
casiotone401 0:a4d93cd4c30d 1 //-------------------------------------------------------------
casiotone401 20:a44f4a024902 2 // TI DAC8568 OSCtoCV Converter
casiotone401 0:a4d93cd4c30d 3 //
casiotone401 0:a4d93cd4c30d 4 // DAC8568 16bit Octal DAC http://www.ti.com/product/dac8568
casiotone401 0:a4d93cd4c30d 5 //
casiotone401 0:a4d93cd4c30d 6 // referred to
casiotone401 0:a4d93cd4c30d 7 // xshige's OSCReceiver
casiotone401 0:a4d93cd4c30d 8 // http://mbed.org/users/xshige/programs/OSCReceiver/
casiotone401 0:a4d93cd4c30d 9 // radiojunkbox's OSC-CV_Example
casiotone401 0:a4d93cd4c30d 10 // http://mbed.org/users/radiojunkbox/code/KAMUI_OSC-CV_Example/
casiotone401 0:a4d93cd4c30d 11 // Robin Price's Homebrew midi-cv box
casiotone401 0:a4d93cd4c30d 12 // http://crx091081gb.net/?p=69
casiotone401 0:a4d93cd4c30d 13 // Masahiro Hattori's TextLCD Module Functions
casiotone401 0:a4d93cd4c30d 14 // http://www.eleclabo.com/denshi/device/lcd1602/gcram.html
casiotone401 0:a4d93cd4c30d 15 // Dirk-Willem van Gulik's BonjourLib
casiotone401 0:a4d93cd4c30d 16 // http://mbed.org/users/dirkx/code/BonjourLib/file/bb6472f455e8/services/mDNS
casiotone401 0:a4d93cd4c30d 17 //
casiotone401 0:a4d93cd4c30d 18 // Released under the MIT License: http://mbed.org/license/mit
casiotone401 0:a4d93cd4c30d 19 //-------------------------------------------------------------
casiotone401 0:a4d93cd4c30d 20
casiotone401 0:a4d93cd4c30d 21 #pragma O3
casiotone401 0:a4d93cd4c30d 22 #pragma Otime
casiotone401 0:a4d93cd4c30d 23
casiotone401 0:a4d93cd4c30d 24 #include "mbed.h"
casiotone401 15:3e4bc47d6a39 25 #include "FastIO.h"
casiotone401 20:a44f4a024902 26 //#include "FastAnalogIn.h"
casiotone401 15:3e4bc47d6a39 27 #include "DebouncedInterrupt.h"
casiotone401 0:a4d93cd4c30d 28 #include "TextLCD.h" //edit "writeCommand" "writeData" protected -> public
casiotone401 0:a4d93cd4c30d 29 #include "EthernetNetIf.h"
casiotone401 0:a4d93cd4c30d 30 #include "HTTPServer.h"
casiotone401 0:a4d93cd4c30d 31 #include "mDNSResponder.h" // mDNS response to announce oneselve
casiotone401 0:a4d93cd4c30d 32 #include "UDPSocket.h"
casiotone401 0:a4d93cd4c30d 33 #include "OSCReceiver.h"
casiotone401 15:3e4bc47d6a39 34 #include "mbedOSC.h"
casiotone401 15:3e4bc47d6a39 35 #include "MIDI.h"
casiotone401 24:99045b0f7c4a 36 #include "ClockControl.h" // https://developer.mbed.org/users/JST2011/code/ClockControl/
casiotone401 20:a44f4a024902 37 #include "OSCtoCV.h"
casiotone401 20:a44f4a024902 38 #include "OSCtoCV_Sequencer.h"
casiotone401 20:a44f4a024902 39 #include "OSCtoCV_GateSequencer.h"
casiotone401 20:a44f4a024902 40 #include "OSCtoCV_Euclidean.h"
casiotone401 21:2273c3676f1b 41 #include "OSCtoCV_Random.h"
casiotone401 21:2273c3676f1b 42 #include "OSCtoCV_LFO.h"
casiotone401 20:a44f4a024902 43
casiotone401 0:a4d93cd4c30d 44 #include <stdlib.h>
casiotone401 0:a4d93cd4c30d 45 #include <ctype.h>
casiotone401 1:fd4f70088311 46 #include <math.h>
casiotone401 0:a4d93cd4c30d 47
casiotone401 0:a4d93cd4c30d 48 //-------------------------------------------------------------
casiotone401 20:a44f4a024902 49 // Macros
casiotone401 0:a4d93cd4c30d 50
casiotone401 26:8673d5254f7d 51 #define MODE_CLB 0 // Calibration (for VCO Tuning)
casiotone401 15:3e4bc47d6a39 52 #define MODE_OSC 1 // Mode OSCtoCV
casiotone401 15:3e4bc47d6a39 53 #define MODE_SEQ 2 // Mode Shift Sequencer
casiotone401 15:3e4bc47d6a39 54 #define MODE_185 3 // Mode M185 Sequencer
casiotone401 24:99045b0f7c4a 55 #define MODE_437 4 // Mode 437 Sequencer
casiotone401 24:99045b0f7c4a 56 #define MODE_EUC 5 // Mode Euclidean Sequencer
casiotone401 24:99045b0f7c4a 57 #define MODE_RND 6 // Mode xshift Random Generator
casiotone401 24:99045b0f7c4a 58 #define MODE_LFO 7 // Mode Stepped LFO
casiotone401 15:3e4bc47d6a39 59
casiotone401 24:99045b0f7c4a 60 #define MODE_TOTAL 8 // Modes
casiotone401 0:a4d93cd4c30d 61
casiotone401 0:a4d93cd4c30d 62 //-------------------------------------------------------------
casiotone401 0:a4d93cd4c30d 63 // Functions
casiotone401 0:a4d93cd4c30d 64
casiotone401 15:3e4bc47d6a39 65 void InitOSCCV(void);
casiotone401 4:b9f5ae574447 66 inline void NetPoll(void);
casiotone401 20:a44f4a024902 67 void CalibrationCV(void);
casiotone401 15:3e4bc47d6a39 68 inline void SetCV(void);
casiotone401 15:3e4bc47d6a39 69 inline int CheckBPM(void);
casiotone401 29:8b61b87b9676 70 inline float CheckGlide(void);
casiotone401 29:8b61b87b9676 71 inline float CheckDuration(void);
casiotone401 20:a44f4a024902 72 void CheckModeSW(void);
casiotone401 29:8b61b87b9676 73 inline void UpdateLCD();
casiotone401 0:a4d93cd4c30d 74 void WriteCustomChar(unsigned char, unsigned char*);
casiotone401 0:a4d93cd4c30d 75 int SetupEthNetIf(void);
casiotone401 4:b9f5ae574447 76 inline void onUDPSocketEvent(UDPSocketEvent);
casiotone401 20:a44f4a024902 77
casiotone401 0:a4d93cd4c30d 78
casiotone401 0:a4d93cd4c30d 79 //-------------------------------------------------------------
casiotone401 20:a44f4a024902 80 // Global Variables
casiotone401 0:a4d93cd4c30d 81
casiotone401 0:a4d93cd4c30d 82 // CV Meter Custom Character
casiotone401 0:a4d93cd4c30d 83 unsigned char str1[8] = {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x1F};
casiotone401 0:a4d93cd4c30d 84 unsigned char str2[8] = {0x00,0x00,0x00,0x00,0x00,0x00,0x1F,0x1F};
casiotone401 0:a4d93cd4c30d 85 unsigned char str3[8] = {0x00,0x00,0x00,0x00,0x00,0x1F,0x1F,0x1F};
casiotone401 0:a4d93cd4c30d 86 unsigned char str4[8] = {0x00,0x00,0x00,0x00,0x1F,0x1F,0x1F,0x1F};
casiotone401 0:a4d93cd4c30d 87 unsigned char str5[8] = {0x00,0x00,0x00,0x1F,0x1F,0x1F,0x1F,0x1F};
casiotone401 0:a4d93cd4c30d 88 unsigned char str6[8] = {0x00,0x00,0x1F,0x1F,0x1F,0x1F,0x1F,0x1F};
casiotone401 0:a4d93cd4c30d 89 unsigned char str7[8] = {0x00,0x1F,0x1F,0x1F,0x1F,0x1F,0x1F,0x1F};
casiotone401 0:a4d93cd4c30d 90 unsigned char str8[8] = {0x1F,0x1F,0x1F,0x1F,0x1F,0x1F,0x1F,0x1F};
casiotone401 0:a4d93cd4c30d 91
casiotone401 20:a44f4a024902 92 // OSCtoCV Converter Mode
casiotone401 20:a44f4a024902 93 int gMode;
casiotone401 15:3e4bc47d6a39 94
casiotone401 20:a44f4a024902 95 // UDP Socket
casiotone401 20:a44f4a024902 96 UDPSocket gUdp;
casiotone401 15:3e4bc47d6a39 97
casiotone401 0:a4d93cd4c30d 98 //-------------------------------------------------------------
casiotone401 0:a4d93cd4c30d 99 // main
casiotone401 0:a4d93cd4c30d 100
casiotone401 0:a4d93cd4c30d 101 int main()
casiotone401 0:a4d93cd4c30d 102 {
casiotone401 29:8b61b87b9676 103 float duration;
casiotone401 15:3e4bc47d6a39 104 int bpm;
casiotone401 20:a44f4a024902 105
casiotone401 29:8b61b87b9676 106 InitOSCCV();
casiotone401 24:99045b0f7c4a 107
casiotone401 24:99045b0f7c4a 108 // Init LCD
casiotone401 29:8b61b87b9676 109 UpdateLCD();
casiotone401 24:99045b0f7c4a 110
casiotone401 15:3e4bc47d6a39 111 gLCD.locate( 0, 1 );
casiotone401 15:3e4bc47d6a39 112 gLCD.printf("12345678 G>>%3.2f", gGlide);
casiotone401 24:99045b0f7c4a 113
casiotone401 15:3e4bc47d6a39 114 // Main loop
casiotone401 15:3e4bc47d6a39 115 while (1)
casiotone401 24:99045b0f7c4a 116 {
casiotone401 29:8b61b87b9676 117 UpdateLCD(); // Check Text LCD Mode Status
casiotone401 15:3e4bc47d6a39 118
casiotone401 29:8b61b87b9676 119 CheckGlide(); // check glide value
casiotone401 15:3e4bc47d6a39 120
casiotone401 17:55e5136790a6 121 bpm = CheckBPM(); // check current BPM
casiotone401 17:55e5136790a6 122
casiotone401 29:8b61b87b9676 123 duration = CheckDuration(); // check current duration(Gate length)
casiotone401 27:65e873bf8307 124
casiotone401 15:3e4bc47d6a39 125 switch (gMode)
casiotone401 15:3e4bc47d6a39 126 {
casiotone401 15:3e4bc47d6a39 127 case MODE_OSC: // OSCtoCV mode
casiotone401 15:3e4bc47d6a39 128
casiotone401 15:3e4bc47d6a39 129 SetCV();
casiotone401 15:3e4bc47d6a39 130 break;
casiotone401 15:3e4bc47d6a39 131
casiotone401 15:3e4bc47d6a39 132 case MODE_SEQ: // Shift Sequencer mode
casiotone401 15:3e4bc47d6a39 133
casiotone401 15:3e4bc47d6a39 134 GateSeq(bpm, N8TH, GATE2, 3, NON_INVERT, GATESOUT_ON, SYNC_OFF);
casiotone401 15:3e4bc47d6a39 135
casiotone401 15:3e4bc47d6a39 136 if (gCtrlSW[3])
casiotone401 24:99045b0f7c4a 137 { // euclid sequencer auto offset
casiotone401 29:8b61b87b9676 138 ShiftCVSeq(EuclideanSeq(GateSeq(bpm, N16TH, SUBGATE, (duration * 12.0f), NON_INVERT, GATESOUT_OFF, SYNC_ON), gCtrlSW[0], GATESOUT_OFF, true), gCtrlSW[0], CV_CHANNEL8);
casiotone401 24:99045b0f7c4a 139
casiotone401 24:99045b0f7c4a 140 } else {
casiotone401 25:6b29d7e631cb 141
casiotone401 29:8b61b87b9676 142 ShiftCVSeq(BeatsSeq(GateSeq(bpm, N16TH, SUBGATE, (duration * 8.0f), NON_INVERT, GATESOUT_OFF, SYNC_ON), gCtrlSW[0], GATESOUT_OFF), gCtrlSW[0], CV_CHANNEL8);
casiotone401 15:3e4bc47d6a39 143 }
casiotone401 15:3e4bc47d6a39 144 break;
casiotone401 15:3e4bc47d6a39 145
casiotone401 15:3e4bc47d6a39 146 case MODE_185: // M185 Sequencer mode
casiotone401 15:3e4bc47d6a39 147
casiotone401 25:6b29d7e631cb 148
casiotone401 24:99045b0f7c4a 149 GateSeq(bpm, N8TH, GATE2, 3, NON_INVERT, GATESOUT_ON, SYNC_OFF);
casiotone401 24:99045b0f7c4a 150
casiotone401 24:99045b0f7c4a 151 if (gCtrlSW[3])
casiotone401 24:99045b0f7c4a 152 { // euclid sequencer auto offset
casiotone401 29:8b61b87b9676 153 M185Seq(EuclideanSeq(GateSeq(bpm, N16TH, SUBGATE, (duration * 12.0f), NON_INVERT, GATESOUT_OFF, SYNC_ON), gCtrlSW[0], GATESOUT_OFF, true), gCtrlSW[0], CV_CHANNEL8);
casiotone401 25:6b29d7e631cb 154
casiotone401 24:99045b0f7c4a 155 } else {
casiotone401 25:6b29d7e631cb 156
casiotone401 29:8b61b87b9676 157 M185Seq(BeatsSeq(GateSeq(bpm, N16TH, SUBGATE, (duration * 8.0f), NON_INVERT, GATESOUT_OFF, SYNC_ON), gCtrlSW[0], GATESOUT_OFF), gCtrlSW[0], CV_CHANNEL8);
casiotone401 24:99045b0f7c4a 158 }
casiotone401 24:99045b0f7c4a 159 break;
casiotone401 24:99045b0f7c4a 160
casiotone401 24:99045b0f7c4a 161 case MODE_437: // F437 sequencer
casiotone401 25:6b29d7e631cb 162
casiotone401 15:3e4bc47d6a39 163 GateSeq(bpm, N8TH, GATE2, 3, NON_INVERT, GATESOUT_ON, SYNC_OFF);
casiotone401 15:3e4bc47d6a39 164
casiotone401 15:3e4bc47d6a39 165 if (gCtrlSW[3])
casiotone401 24:99045b0f7c4a 166 { // euclid sequencer auto offset
casiotone401 29:8b61b87b9676 167 PolyCVSeq(EuclideanSeq(GateSeq(bpm, N16TH, SUBGATE, (duration * 12.0f), NON_INVERT, GATESOUT_OFF, SYNC_ON), gCtrlSW[0], GATESOUT_OFF, true), gCtrlSW[0]);
casiotone401 25:6b29d7e631cb 168
casiotone401 24:99045b0f7c4a 169 } else {
casiotone401 25:6b29d7e631cb 170
casiotone401 29:8b61b87b9676 171 PolyCVSeq(BeatsSeq(GateSeq(bpm, N16TH, SUBGATE, (duration * 8.0f), NON_INVERT, GATESOUT_OFF, SYNC_ON), gCtrlSW[0], GATESOUT_OFF), gCtrlSW[0]);
casiotone401 15:3e4bc47d6a39 172 }
casiotone401 15:3e4bc47d6a39 173 break;
casiotone401 24:99045b0f7c4a 174
casiotone401 15:3e4bc47d6a39 175 case MODE_EUC: // Euclidean Sequencer mode
casiotone401 15:3e4bc47d6a39 176
casiotone401 29:8b61b87b9676 177 ShiftCVSeq(GateSeq(bpm, N1ST, SUBGATE, (duration * 5.0f), NON_INVERT, GATESOUT_OFF, SYNC_OFF), gCtrlSW[0], CV_CHANNEL8);
casiotone401 24:99045b0f7c4a 178 EuclideanSeq(GateSeq(bpm, N16TH, GATE1, 3, NON_INVERT, GATESOUT_OFF, SYNC_OFF), gCtrlSW[0], GATESOUT_ON, false);
casiotone401 15:3e4bc47d6a39 179 break;
casiotone401 24:99045b0f7c4a 180
casiotone401 21:2273c3676f1b 181 case MODE_RND: // Random CV Generator mode
casiotone401 24:99045b0f7c4a 182
casiotone401 29:8b61b87b9676 183 RandomCVGenerator(GateSeq(bpm, N32TH, GATE1, (duration * 5.0f), NON_INVERT, GATESOUT_OFF, SYNC_ON));
casiotone401 21:2273c3676f1b 184 break;
casiotone401 21:2273c3676f1b 185
casiotone401 21:2273c3676f1b 186 case MODE_LFO: // Stepped LFO mode
casiotone401 24:99045b0f7c4a 187
casiotone401 27:65e873bf8307 188 SteppedLFO(CV_CHANNEL1, false); // LFO out ch1 ~ ch8
casiotone401 21:2273c3676f1b 189 break;
casiotone401 24:99045b0f7c4a 190
casiotone401 15:3e4bc47d6a39 191 default: // CV Calibration mode
casiotone401 15:3e4bc47d6a39 192
casiotone401 15:3e4bc47d6a39 193 CalibrationCV();
casiotone401 15:3e4bc47d6a39 194 break;
casiotone401 15:3e4bc47d6a39 195 }
casiotone401 15:3e4bc47d6a39 196
casiotone401 15:3e4bc47d6a39 197 }
casiotone401 15:3e4bc47d6a39 198 }
casiotone401 15:3e4bc47d6a39 199
casiotone401 15:3e4bc47d6a39 200 //-------------------------------------------------------------
casiotone401 20:a44f4a024902 201 // Ethernet Polling
casiotone401 20:a44f4a024902 202
casiotone401 20:a44f4a024902 203 inline void NetPoll()
casiotone401 20:a44f4a024902 204 {
casiotone401 20:a44f4a024902 205 Net::poll();
casiotone401 20:a44f4a024902 206 }
casiotone401 20:a44f4a024902 207
casiotone401 20:a44f4a024902 208 //-------------------------------------------------------------
casiotone401 15:3e4bc47d6a39 209 // Initialize OSCtoCV
casiotone401 15:3e4bc47d6a39 210
casiotone401 15:3e4bc47d6a39 211 void InitOSCCV()
casiotone401 15:3e4bc47d6a39 212 {
casiotone401 20:a44f4a024902 213
casiotone401 24:99045b0f7c4a 214 // Set System Frequency 120Mhz
casiotone401 24:99045b0f7c4a 215 setSystemFrequency(0x3, 0x1, 15, 1);
casiotone401 20:a44f4a024902 216 wait(0.5);
casiotone401 20:a44f4a024902 217
casiotone401 20:a44f4a024902 218 // Setup Ethernet
casiotone401 20:a44f4a024902 219 SetupEthNetIf();
casiotone401 20:a44f4a024902 220
casiotone401 20:a44f4a024902 221 // Announce mdnsResponder (Bonjour)
casiotone401 20:a44f4a024902 222 HTTPServer svr;
casiotone401 20:a44f4a024902 223 mDNSResponder mdns;
casiotone401 20:a44f4a024902 224
casiotone401 20:a44f4a024902 225 svr.addHandler<SimpleHandler>("/");
casiotone401 20:a44f4a024902 226 svr.bind(INPUT_PORT);
casiotone401 20:a44f4a024902 227 IpAddr ip = gEth.getIp();
casiotone401 20:a44f4a024902 228 mdns.announce(ip, "OSCtoCV", "_osc._udp", INPUT_PORT, "mbed(OSCtoCV)", (char *[]) {"path=/",NULL});
casiotone401 20:a44f4a024902 229
casiotone401 15:3e4bc47d6a39 230 // Write custom char LCD CGRAM
casiotone401 15:3e4bc47d6a39 231 WriteCustomChar(0x00, str1);
casiotone401 15:3e4bc47d6a39 232 WriteCustomChar(0x01, str2);
casiotone401 15:3e4bc47d6a39 233 WriteCustomChar(0x02, str3);
casiotone401 15:3e4bc47d6a39 234 WriteCustomChar(0x03, str4);
casiotone401 15:3e4bc47d6a39 235 WriteCustomChar(0x04, str5);
casiotone401 15:3e4bc47d6a39 236 WriteCustomChar(0x05, str6);
casiotone401 15:3e4bc47d6a39 237 WriteCustomChar(0x06, str7);
casiotone401 15:3e4bc47d6a39 238 WriteCustomChar(0x07, str8);
casiotone401 15:3e4bc47d6a39 239
casiotone401 15:3e4bc47d6a39 240 // Init SPI
casiotone401 15:3e4bc47d6a39 241 gLDAC = _ENABLE;
casiotone401 27:65e873bf8307 242 gSPI.format(8, 1); // Data word length 8bit, Mode=1
casiotone401 15:3e4bc47d6a39 243 gSPI.frequency(SPI_RATE);
casiotone401 15:3e4bc47d6a39 244
casiotone401 15:3e4bc47d6a39 245 UpdateCV(CLR, 0, 0); // Ignore CLR Pin
casiotone401 24:99045b0f7c4a 246
casiotone401 24:99045b0f7c4a 247 // Init Euclidean Sequencer
casiotone401 24:99045b0f7c4a 248 InitEuclideanSeq();
casiotone401 24:99045b0f7c4a 249
casiotone401 24:99045b0f7c4a 250 // Init Glide value
casiotone401 24:99045b0f7c4a 251 gGlide = gAIN.read();
casiotone401 29:8b61b87b9676 252
casiotone401 29:8b61b87b9676 253 // Init Mode
casiotone401 29:8b61b87b9676 254 gMode = MODE_CLB;
casiotone401 29:8b61b87b9676 255
casiotone401 29:8b61b87b9676 256 // Init Sequencer Data
casiotone401 29:8b61b87b9676 257 for (int i = 0; i < 16; ++i)
casiotone401 29:8b61b87b9676 258 {
casiotone401 29:8b61b87b9676 259 if (i < 8)
casiotone401 29:8b61b87b9676 260 {
casiotone401 29:8b61b87b9676 261 g185_cv[i] = (calibMap1[69] * SCALING_N);
casiotone401 29:8b61b87b9676 262 gBeatsLevel[i] = gBeatsDecay[i] = 1;
casiotone401 29:8b61b87b9676 263 }
casiotone401 29:8b61b87b9676 264
casiotone401 29:8b61b87b9676 265 gSeq_cv[i] = (calibMap1[69] * SCALING_N);
casiotone401 29:8b61b87b9676 266 }
casiotone401 29:8b61b87b9676 267
casiotone401 15:3e4bc47d6a39 268 // Set OSC message for sending
casiotone401 15:3e4bc47d6a39 269 sendMes.setIp(touchOSCAddress);
casiotone401 15:3e4bc47d6a39 270 sendMes.setPort(touchOSCPort);
casiotone401 3:ca15241dd6b4 271
casiotone401 29:8b61b87b9676 272 gSW.attach(&CheckModeSW, IRQ_RISE, 20); // InterruptIn rising edge(ModeSW)
casiotone401 17:55e5136790a6 273 wait(0.5);
casiotone401 15:3e4bc47d6a39 274
casiotone401 17:55e5136790a6 275 gPoller.attach_us(&NetPoll, POLLING_INTERVAL); // Ticker Polling
casiotone401 27:65e873bf8307 276 wait(0.2);
casiotone401 0:a4d93cd4c30d 277 }
casiotone401 0:a4d93cd4c30d 278
casiotone401 0:a4d93cd4c30d 279 //-------------------------------------------------------------
casiotone401 15:3e4bc47d6a39 280 // Calibration Mode
casiotone401 15:3e4bc47d6a39 281
casiotone401 20:a44f4a024902 282 void CalibrationCV()
casiotone401 14:977f3c5a4b4e 283 {
casiotone401 14:977f3c5a4b4e 284 static int ch;
casiotone401 14:977f3c5a4b4e 285 unsigned int cv;
casiotone401 14:977f3c5a4b4e 286
casiotone401 29:8b61b87b9676 287 cv = (unsigned int)(calibMap1[69] * SCALING_N); // A880.0Hz
casiotone401 14:977f3c5a4b4e 288
casiotone401 29:8b61b87b9676 289 gSUBGATE = gGATES[0] = gGATES[1] = gGATES[2] = gGATES[3] = true;
casiotone401 29:8b61b87b9676 290
casiotone401 29:8b61b87b9676 291 UpdateCV(WRITE_UPDATE_N, ch, &cv);
casiotone401 27:65e873bf8307 292 UpdateCVMeter(ch, &cv);
casiotone401 27:65e873bf8307 293
casiotone401 27:65e873bf8307 294 ++ch;
casiotone401 27:65e873bf8307 295 ch &= 0x07;
casiotone401 14:977f3c5a4b4e 296 }
casiotone401 14:977f3c5a4b4e 297
casiotone401 14:977f3c5a4b4e 298 //-------------------------------------------------------------
casiotone401 14:977f3c5a4b4e 299 // Calculate CV
casiotone401 14:977f3c5a4b4e 300
casiotone401 15:3e4bc47d6a39 301 inline void SetCV()
casiotone401 14:977f3c5a4b4e 302 {
casiotone401 27:65e873bf8307 303 static int ch, mcount;
casiotone401 14:977f3c5a4b4e 304 static float glidecv[8];
casiotone401 14:977f3c5a4b4e 305 unsigned int cv;
casiotone401 14:977f3c5a4b4e 306 static float qcv;
casiotone401 14:977f3c5a4b4e 307
casiotone401 27:65e873bf8307 308 switch (CheckQuantizeMode())
casiotone401 14:977f3c5a4b4e 309 {
casiotone401 14:977f3c5a4b4e 310 case Lin:
casiotone401 14:977f3c5a4b4e 311
casiotone401 14:977f3c5a4b4e 312 glidecv[ch] = glidecv[ch] * gGlide + gOSC_cv[ch] * (1.0f - gGlide);
casiotone401 14:977f3c5a4b4e 313 break;
casiotone401 14:977f3c5a4b4e 314
casiotone401 14:977f3c5a4b4e 315 case Chr:
casiotone401 15:3e4bc47d6a39 316
casiotone401 15:3e4bc47d6a39 317 qcv = calibMap1[(unsigned int)MapFloat(gOSC_cv[ch], 0, SCALING_N, 0, (QUAN_RES1 - 1))];
casiotone401 14:977f3c5a4b4e 318
casiotone401 14:977f3c5a4b4e 319 glidecv[ch] = glidecv[ch] * gGlide + (qcv * SCALING_N) * (1.0f - gGlide);
casiotone401 15:3e4bc47d6a39 320
casiotone401 14:977f3c5a4b4e 321 break;
casiotone401 14:977f3c5a4b4e 322
casiotone401 15:3e4bc47d6a39 323 case Maj:
casiotone401 15:3e4bc47d6a39 324
casiotone401 15:3e4bc47d6a39 325 qcv = calibMap2[(unsigned int)MapFloat(gOSC_cv[ch], 0, SCALING_N, 0, (QUAN_RES2 - 1))];
casiotone401 15:3e4bc47d6a39 326
casiotone401 14:977f3c5a4b4e 327 glidecv[ch] = glidecv[ch] * gGlide + (qcv * SCALING_N) * (1.0f - gGlide);
casiotone401 15:3e4bc47d6a39 328
casiotone401 14:977f3c5a4b4e 329 break;
casiotone401 15:3e4bc47d6a39 330
casiotone401 15:3e4bc47d6a39 331 case M7:
casiotone401 14:977f3c5a4b4e 332
casiotone401 15:3e4bc47d6a39 333 qcv = calibMap3[(unsigned int)MapFloat(gOSC_cv[ch], 0, SCALING_N, 0, (QUAN_RES3 - 1))];
casiotone401 14:977f3c5a4b4e 334
casiotone401 14:977f3c5a4b4e 335 glidecv[ch] = glidecv[ch] * gGlide + (qcv * SCALING_N) * (1.0f - gGlide);
casiotone401 15:3e4bc47d6a39 336
casiotone401 15:3e4bc47d6a39 337 break;
casiotone401 15:3e4bc47d6a39 338
casiotone401 15:3e4bc47d6a39 339 case Min7:
casiotone401 15:3e4bc47d6a39 340
casiotone401 15:3e4bc47d6a39 341 qcv = calibMap4[(unsigned int)MapFloat(gOSC_cv[ch], 0, SCALING_N, 0, (QUAN_RES4 - 1))];
casiotone401 15:3e4bc47d6a39 342
casiotone401 15:3e4bc47d6a39 343 glidecv[ch] = glidecv[ch] * gGlide + (qcv * SCALING_N) * (1.0f - gGlide);
casiotone401 15:3e4bc47d6a39 344
casiotone401 15:3e4bc47d6a39 345 break;
casiotone401 15:3e4bc47d6a39 346
casiotone401 15:3e4bc47d6a39 347 case Dor:
casiotone401 15:3e4bc47d6a39 348
casiotone401 15:3e4bc47d6a39 349 qcv = calibMap5[(unsigned int)MapFloat(gOSC_cv[ch], 0, SCALING_N, 0, (QUAN_RES5 - 1))];
casiotone401 15:3e4bc47d6a39 350
casiotone401 15:3e4bc47d6a39 351 glidecv[ch] = glidecv[ch] * gGlide + (qcv * SCALING_N) * (1.0f - gGlide);
casiotone401 15:3e4bc47d6a39 352
casiotone401 15:3e4bc47d6a39 353 break;
casiotone401 15:3e4bc47d6a39 354
casiotone401 15:3e4bc47d6a39 355 case Min:
casiotone401 15:3e4bc47d6a39 356
casiotone401 15:3e4bc47d6a39 357 qcv = calibMap6[(unsigned int)MapFloat(gOSC_cv[ch], 0, SCALING_N, 0, (QUAN_RES6 - 1))];
casiotone401 15:3e4bc47d6a39 358
casiotone401 15:3e4bc47d6a39 359 glidecv[ch] = glidecv[ch] * gGlide + (qcv * SCALING_N) * (1.0f - gGlide);
casiotone401 15:3e4bc47d6a39 360
casiotone401 15:3e4bc47d6a39 361 break;
casiotone401 15:3e4bc47d6a39 362
casiotone401 15:3e4bc47d6a39 363 case S5th:
casiotone401 15:3e4bc47d6a39 364
casiotone401 15:3e4bc47d6a39 365 qcv = calibMap7[(unsigned int)MapFloat(gOSC_cv[ch], 0, SCALING_N, 0, (QUAN_RES7 - 1))];
casiotone401 15:3e4bc47d6a39 366
casiotone401 15:3e4bc47d6a39 367 glidecv[ch] = glidecv[ch] * gGlide + (qcv * SCALING_N) * (1.0f - gGlide);
casiotone401 15:3e4bc47d6a39 368
casiotone401 15:3e4bc47d6a39 369 break;
casiotone401 15:3e4bc47d6a39 370
casiotone401 15:3e4bc47d6a39 371 case Wht:
casiotone401 15:3e4bc47d6a39 372
casiotone401 15:3e4bc47d6a39 373 qcv = calibMap8[(unsigned int)MapFloat(gOSC_cv[ch], 0, SCALING_N, 0, (QUAN_RES8 - 1))];
casiotone401 15:3e4bc47d6a39 374
casiotone401 15:3e4bc47d6a39 375 glidecv[ch] = glidecv[ch] * gGlide + (qcv * SCALING_N) * (1.0f - gGlide);
casiotone401 17:55e5136790a6 376
casiotone401 14:977f3c5a4b4e 377 break;
casiotone401 14:977f3c5a4b4e 378 }
casiotone401 17:55e5136790a6 379
casiotone401 17:55e5136790a6 380 cv = (unsigned int)glidecv[ch];
casiotone401 17:55e5136790a6 381
casiotone401 17:55e5136790a6 382 UpdateCV(WRITE_UPDATE_N, ch, &cv);
casiotone401 14:977f3c5a4b4e 383
casiotone401 17:55e5136790a6 384 if (mcount == 0x1F)
casiotone401 17:55e5136790a6 385 {
casiotone401 17:55e5136790a6 386 UpdateCVMeter(ch, &cv);
casiotone401 17:55e5136790a6 387 }
casiotone401 17:55e5136790a6 388
casiotone401 17:55e5136790a6 389 ++ch;
casiotone401 17:55e5136790a6 390
casiotone401 17:55e5136790a6 391 if (ch &= 0x07)
casiotone401 17:55e5136790a6 392 {
casiotone401 17:55e5136790a6 393 ++mcount;
casiotone401 17:55e5136790a6 394 mcount &= 0x3F;
casiotone401 17:55e5136790a6 395 }
casiotone401 14:977f3c5a4b4e 396 }
casiotone401 14:977f3c5a4b4e 397
casiotone401 15:3e4bc47d6a39 398
casiotone401 5:e305509d53f3 399 //-------------------------------------------------------------
casiotone401 15:3e4bc47d6a39 400 // Check BPM
casiotone401 15:3e4bc47d6a39 401
casiotone401 15:3e4bc47d6a39 402 inline int CheckBPM()
casiotone401 15:3e4bc47d6a39 403 {
casiotone401 15:3e4bc47d6a39 404 static int _bpm = -1;
casiotone401 15:3e4bc47d6a39 405 int bpm;
casiotone401 14:977f3c5a4b4e 406
casiotone401 15:3e4bc47d6a39 407 if (gCtrlSW[0])
casiotone401 14:977f3c5a4b4e 408 {
casiotone401 15:3e4bc47d6a39 409 bpm = 0;
casiotone401 15:3e4bc47d6a39 410
casiotone401 15:3e4bc47d6a39 411 return bpm;
casiotone401 0:a4d93cd4c30d 412 }
casiotone401 3:ca15241dd6b4 413
casiotone401 20:a44f4a024902 414 if (gCtrl[0]) {
casiotone401 15:3e4bc47d6a39 415
casiotone401 15:3e4bc47d6a39 416 bpm = (gCtrl[0] * 240 + 5);
casiotone401 15:3e4bc47d6a39 417
casiotone401 29:8b61b87b9676 418 if (bpm != _bpm)
casiotone401 15:3e4bc47d6a39 419 {
casiotone401 15:3e4bc47d6a39 420 _bpm = bpm;
casiotone401 15:3e4bc47d6a39 421
casiotone401 15:3e4bc47d6a39 422 sendMes.setTopAddress("/bpm");
casiotone401 15:3e4bc47d6a39 423 sendMes.setArgs("i", bpm);
casiotone401 15:3e4bc47d6a39 424 osc.sendOsc(&sendMes);
casiotone401 27:65e873bf8307 425
casiotone401 27:65e873bf8307 426 sendMes.setTopAddress("/ctrl1");
casiotone401 27:65e873bf8307 427 sendMes.setArgs("f", gCtrl[0]);
casiotone401 27:65e873bf8307 428 osc.sendOsc(&sendMes);
casiotone401 15:3e4bc47d6a39 429 }
casiotone401 15:3e4bc47d6a39 430 }
casiotone401 15:3e4bc47d6a39 431
casiotone401 15:3e4bc47d6a39 432 return bpm;
casiotone401 15:3e4bc47d6a39 433 }
casiotone401 15:3e4bc47d6a39 434
casiotone401 15:3e4bc47d6a39 435 //-------------------------------------------------------------
casiotone401 29:8b61b87b9676 436 // Check Glide Value
casiotone401 29:8b61b87b9676 437
casiotone401 29:8b61b87b9676 438 inline float CheckGlide()
casiotone401 29:8b61b87b9676 439 {
casiotone401 29:8b61b87b9676 440 static float _pot;
casiotone401 29:8b61b87b9676 441 float pot = 0;
casiotone401 29:8b61b87b9676 442
casiotone401 29:8b61b87b9676 443 pot = gAIN.read(); // Update glide value
casiotone401 29:8b61b87b9676 444
casiotone401 29:8b61b87b9676 445 if (!pot) // when (glide pot value == 0) && MODE_OSC
casiotone401 29:8b61b87b9676 446 { // use gCtrl[3] value
casiotone401 29:8b61b87b9676 447 if (abs(gCtrl[3] - _pot) > 0.01f)
casiotone401 29:8b61b87b9676 448 {
casiotone401 29:8b61b87b9676 449 _pot = gGlide = gCtrl[3];
casiotone401 29:8b61b87b9676 450
casiotone401 29:8b61b87b9676 451 gLCD.locate( 9, 1 );
casiotone401 29:8b61b87b9676 452 gLCD.printf("G>>%3.2f", gGlide);
casiotone401 29:8b61b87b9676 453 }
casiotone401 29:8b61b87b9676 454
casiotone401 29:8b61b87b9676 455 } else if (abs(pot - _pot) > 0.01f) {
casiotone401 29:8b61b87b9676 456
casiotone401 29:8b61b87b9676 457 _pot = gGlide = pot;
casiotone401 29:8b61b87b9676 458
casiotone401 29:8b61b87b9676 459 gLCD.locate( 9, 1 );
casiotone401 29:8b61b87b9676 460 gLCD.printf("G>>%3.2f", gGlide);
casiotone401 29:8b61b87b9676 461 }
casiotone401 29:8b61b87b9676 462
casiotone401 29:8b61b87b9676 463 return pot;
casiotone401 29:8b61b87b9676 464 }
casiotone401 29:8b61b87b9676 465
casiotone401 29:8b61b87b9676 466 //-------------------------------------------------------------
casiotone401 29:8b61b87b9676 467 // Check Duration Value
casiotone401 29:8b61b87b9676 468
casiotone401 29:8b61b87b9676 469 inline float CheckDuration()
casiotone401 29:8b61b87b9676 470 {
casiotone401 29:8b61b87b9676 471 static float _duration = 0.6f;
casiotone401 29:8b61b87b9676 472
casiotone401 29:8b61b87b9676 473 if (_duration != gCtrl[6]) // check current gate duration
casiotone401 29:8b61b87b9676 474 {
casiotone401 29:8b61b87b9676 475 sendMes.setTopAddress("/ctrl7");
casiotone401 29:8b61b87b9676 476 sendMes.setArgs("f", gCtrl[6]);
casiotone401 29:8b61b87b9676 477 osc.sendOsc(&sendMes);
casiotone401 29:8b61b87b9676 478
casiotone401 29:8b61b87b9676 479 _duration = gCtrl[6];
casiotone401 29:8b61b87b9676 480 }
casiotone401 29:8b61b87b9676 481
casiotone401 29:8b61b87b9676 482 return gCtrl[6];
casiotone401 29:8b61b87b9676 483 }
casiotone401 29:8b61b87b9676 484
casiotone401 29:8b61b87b9676 485 //-------------------------------------------------------------
casiotone401 15:3e4bc47d6a39 486 // Check Mode SW
casiotone401 15:3e4bc47d6a39 487
casiotone401 20:a44f4a024902 488 void CheckModeSW()
casiotone401 15:3e4bc47d6a39 489 {
casiotone401 15:3e4bc47d6a39 490 if (gMode < MODE_TOTAL - 1)
casiotone401 15:3e4bc47d6a39 491 {
casiotone401 15:3e4bc47d6a39 492 ++gMode;
casiotone401 15:3e4bc47d6a39 493
casiotone401 15:3e4bc47d6a39 494 } else {
casiotone401 15:3e4bc47d6a39 495
casiotone401 15:3e4bc47d6a39 496 gMode = 0;
casiotone401 15:3e4bc47d6a39 497 }
casiotone401 15:3e4bc47d6a39 498
casiotone401 15:3e4bc47d6a39 499 gCLOCKOUT = gGATES[0] = gGATES[1] = gGATES[2] = gGATES[3] = false;
casiotone401 21:2273c3676f1b 500 gSubModeCount1 = gSubModeCount2 = 0;
casiotone401 15:3e4bc47d6a39 501
casiotone401 24:99045b0f7c4a 502 if (gMode != MODE_CLB || gMode != MODE_OSC)
casiotone401 15:3e4bc47d6a39 503 {
casiotone401 15:3e4bc47d6a39 504 gTimer.start(); // Sequencer Timer Start
casiotone401 15:3e4bc47d6a39 505 midi.begin(1);
casiotone401 5:e305509d53f3 506
casiotone401 15:3e4bc47d6a39 507 } else {
casiotone401 15:3e4bc47d6a39 508
casiotone401 15:3e4bc47d6a39 509 gTimer.stop(); // Sequencer Timer Stop
casiotone401 5:e305509d53f3 510 }
casiotone401 5:e305509d53f3 511
casiotone401 4:b9f5ae574447 512 }
casiotone401 4:b9f5ae574447 513
casiotone401 4:b9f5ae574447 514 //-------------------------------------------------------------
casiotone401 15:3e4bc47d6a39 515 // Print LCD Mode Status
casiotone401 15:3e4bc47d6a39 516
casiotone401 29:8b61b87b9676 517 inline void UpdateLCD()
casiotone401 15:3e4bc47d6a39 518 {
casiotone401 15:3e4bc47d6a39 519 static int _mode = -1;
casiotone401 15:3e4bc47d6a39 520 static int _qmode = -1;
casiotone401 15:3e4bc47d6a39 521 static int qmode;
casiotone401 15:3e4bc47d6a39 522
casiotone401 15:3e4bc47d6a39 523 if (_mode != gMode)
casiotone401 15:3e4bc47d6a39 524 {
casiotone401 15:3e4bc47d6a39 525 sendMes.setTopAddress("/mode");
casiotone401 15:3e4bc47d6a39 526
casiotone401 15:3e4bc47d6a39 527 switch (gMode)
casiotone401 15:3e4bc47d6a39 528 {
casiotone401 24:99045b0f7c4a 529 case MODE_CLB:
casiotone401 15:3e4bc47d6a39 530 gLCD.locate( 9, 0 );
casiotone401 15:3e4bc47d6a39 531 gLCD.printf("CLB|880");
casiotone401 15:3e4bc47d6a39 532
casiotone401 21:2273c3676f1b 533 gLCD.locate( 0, 1 );
casiotone401 21:2273c3676f1b 534 gLCD.printf("12345678 G>>%3.2f", gGlide);
casiotone401 21:2273c3676f1b 535
casiotone401 15:3e4bc47d6a39 536 sendMes.setArgs("s", "Calibration");
casiotone401 15:3e4bc47d6a39 537 osc.sendOsc(&sendMes);
casiotone401 15:3e4bc47d6a39 538
casiotone401 15:3e4bc47d6a39 539 sendMes.setTopAddress("/scale");
casiotone401 15:3e4bc47d6a39 540 sendMes.setArgs("s", "880Hz");
casiotone401 15:3e4bc47d6a39 541
casiotone401 15:3e4bc47d6a39 542 _qmode = -1;
casiotone401 15:3e4bc47d6a39 543
casiotone401 15:3e4bc47d6a39 544 break;
casiotone401 15:3e4bc47d6a39 545
casiotone401 15:3e4bc47d6a39 546 case MODE_OSC:
casiotone401 15:3e4bc47d6a39 547 gLCD.locate( 9, 0 );
casiotone401 15:3e4bc47d6a39 548 gLCD.printf("OSC|");
casiotone401 15:3e4bc47d6a39 549
casiotone401 15:3e4bc47d6a39 550 sendMes.setArgs("s", "OSCtoCV");
casiotone401 15:3e4bc47d6a39 551
casiotone401 15:3e4bc47d6a39 552 break;
casiotone401 15:3e4bc47d6a39 553
casiotone401 15:3e4bc47d6a39 554 case MODE_SEQ:
casiotone401 15:3e4bc47d6a39 555 gLCD.locate( 9, 0 );
casiotone401 15:3e4bc47d6a39 556 gLCD.printf("ASR|");
casiotone401 15:3e4bc47d6a39 557
casiotone401 15:3e4bc47d6a39 558 sendMes.setArgs("s", "ASR SEQ");
casiotone401 15:3e4bc47d6a39 559
casiotone401 15:3e4bc47d6a39 560 break;
casiotone401 15:3e4bc47d6a39 561
casiotone401 15:3e4bc47d6a39 562 case MODE_185:
casiotone401 15:3e4bc47d6a39 563 gLCD.locate( 9, 0 );
casiotone401 15:3e4bc47d6a39 564 gLCD.printf("185|");
casiotone401 15:3e4bc47d6a39 565
casiotone401 15:3e4bc47d6a39 566 sendMes.setArgs("s", "M185 SEQ");
casiotone401 15:3e4bc47d6a39 567
casiotone401 15:3e4bc47d6a39 568 break;
casiotone401 24:99045b0f7c4a 569
casiotone401 24:99045b0f7c4a 570 case MODE_437:
casiotone401 24:99045b0f7c4a 571 gLCD.locate( 9, 0 );
casiotone401 24:99045b0f7c4a 572 gLCD.printf("437|");
casiotone401 24:99045b0f7c4a 573
casiotone401 24:99045b0f7c4a 574 sendMes.setArgs("s", "F437 SEQ");
casiotone401 24:99045b0f7c4a 575
casiotone401 24:99045b0f7c4a 576 break;
casiotone401 15:3e4bc47d6a39 577
casiotone401 15:3e4bc47d6a39 578 case MODE_EUC:
casiotone401 15:3e4bc47d6a39 579 gLCD.locate( 9, 0 );
casiotone401 15:3e4bc47d6a39 580 gLCD.printf("EUC|");
casiotone401 15:3e4bc47d6a39 581
casiotone401 15:3e4bc47d6a39 582 sendMes.setArgs("s", "Euclidean SEQ");
casiotone401 15:3e4bc47d6a39 583
casiotone401 15:3e4bc47d6a39 584 break;
casiotone401 24:99045b0f7c4a 585
casiotone401 24:99045b0f7c4a 586 case MODE_RND:
casiotone401 24:99045b0f7c4a 587 gLCD.locate( 9, 0 );
casiotone401 24:99045b0f7c4a 588 gLCD.printf("RND|");
casiotone401 24:99045b0f7c4a 589
casiotone401 24:99045b0f7c4a 590 sendMes.setArgs("s", "Xorshift Random");
casiotone401 24:99045b0f7c4a 591
casiotone401 24:99045b0f7c4a 592 break;
casiotone401 15:3e4bc47d6a39 593
casiotone401 24:99045b0f7c4a 594 case MODE_LFO:
casiotone401 24:99045b0f7c4a 595 gLCD.locate( 9, 0 );
casiotone401 24:99045b0f7c4a 596 gLCD.printf("LFO|");
casiotone401 24:99045b0f7c4a 597
casiotone401 24:99045b0f7c4a 598 sendMes.setArgs("s", "Stepped LFO");
casiotone401 24:99045b0f7c4a 599
casiotone401 24:99045b0f7c4a 600 break;
casiotone401 24:99045b0f7c4a 601
casiotone401 15:3e4bc47d6a39 602 default:
casiotone401 15:3e4bc47d6a39 603 break;
casiotone401 15:3e4bc47d6a39 604 }
casiotone401 15:3e4bc47d6a39 605
casiotone401 15:3e4bc47d6a39 606 osc.sendOsc(&sendMes);
casiotone401 15:3e4bc47d6a39 607 _mode = gMode;
casiotone401 15:3e4bc47d6a39 608 }
casiotone401 15:3e4bc47d6a39 609
casiotone401 27:65e873bf8307 610 qmode = (gCtrl[1] * (SCALE_TOTAL - 1));
casiotone401 15:3e4bc47d6a39 611
casiotone401 17:55e5136790a6 612 if (_qmode != qmode)
casiotone401 15:3e4bc47d6a39 613 {
casiotone401 15:3e4bc47d6a39 614 sendMes.setTopAddress("/scale");
casiotone401 15:3e4bc47d6a39 615
casiotone401 15:3e4bc47d6a39 616 switch (qmode)
casiotone401 15:3e4bc47d6a39 617 {
casiotone401 15:3e4bc47d6a39 618 case Lin:
casiotone401 15:3e4bc47d6a39 619 gLCD.locate( 13, 0 );
casiotone401 15:3e4bc47d6a39 620 gLCD.printf("lin");
casiotone401 15:3e4bc47d6a39 621
casiotone401 15:3e4bc47d6a39 622 sendMes.setArgs("s", "Linear");
casiotone401 15:3e4bc47d6a39 623
casiotone401 15:3e4bc47d6a39 624 break;
casiotone401 15:3e4bc47d6a39 625
casiotone401 15:3e4bc47d6a39 626 case Chr:
casiotone401 15:3e4bc47d6a39 627 gLCD.locate( 13, 0 );
casiotone401 15:3e4bc47d6a39 628 gLCD.printf("chr");
casiotone401 15:3e4bc47d6a39 629
casiotone401 15:3e4bc47d6a39 630 sendMes.setArgs("s", "Chromatic");
casiotone401 15:3e4bc47d6a39 631
casiotone401 15:3e4bc47d6a39 632 break;
casiotone401 15:3e4bc47d6a39 633
casiotone401 15:3e4bc47d6a39 634 case Maj:
casiotone401 15:3e4bc47d6a39 635 gLCD.locate( 13, 0 );
casiotone401 15:3e4bc47d6a39 636 gLCD.printf("maj");
casiotone401 15:3e4bc47d6a39 637
casiotone401 15:3e4bc47d6a39 638 sendMes.setArgs("s", "Major");
casiotone401 15:3e4bc47d6a39 639
casiotone401 15:3e4bc47d6a39 640 break;
casiotone401 15:3e4bc47d6a39 641
casiotone401 15:3e4bc47d6a39 642 case M7:
casiotone401 15:3e4bc47d6a39 643 gLCD.locate( 13, 0 );
casiotone401 15:3e4bc47d6a39 644 gLCD.printf("ma7");
casiotone401 15:3e4bc47d6a39 645
casiotone401 15:3e4bc47d6a39 646 sendMes.setArgs("s", "Major7");
casiotone401 15:3e4bc47d6a39 647
casiotone401 15:3e4bc47d6a39 648 break;
casiotone401 15:3e4bc47d6a39 649
casiotone401 15:3e4bc47d6a39 650 case Min7:
casiotone401 15:3e4bc47d6a39 651 gLCD.locate( 13, 0 );
casiotone401 15:3e4bc47d6a39 652 gLCD.printf("mi7");
casiotone401 15:3e4bc47d6a39 653
casiotone401 15:3e4bc47d6a39 654 sendMes.setArgs("s", "Minor7");
casiotone401 15:3e4bc47d6a39 655
casiotone401 15:3e4bc47d6a39 656 break;
casiotone401 15:3e4bc47d6a39 657
casiotone401 15:3e4bc47d6a39 658 case Dor:
casiotone401 15:3e4bc47d6a39 659 gLCD.locate( 13, 0 );
casiotone401 15:3e4bc47d6a39 660 gLCD.printf("dor");
casiotone401 15:3e4bc47d6a39 661
casiotone401 15:3e4bc47d6a39 662 sendMes.setArgs("s", "Dorian");
casiotone401 15:3e4bc47d6a39 663
casiotone401 15:3e4bc47d6a39 664 break;
casiotone401 15:3e4bc47d6a39 665
casiotone401 15:3e4bc47d6a39 666 case Min:
casiotone401 15:3e4bc47d6a39 667 gLCD.locate( 13, 0 );
casiotone401 15:3e4bc47d6a39 668 gLCD.printf("min");
casiotone401 15:3e4bc47d6a39 669
casiotone401 15:3e4bc47d6a39 670 sendMes.setTopAddress("/scale");
casiotone401 15:3e4bc47d6a39 671 sendMes.setArgs("s", "Minor");
casiotone401 15:3e4bc47d6a39 672
casiotone401 15:3e4bc47d6a39 673 break;
casiotone401 15:3e4bc47d6a39 674
casiotone401 15:3e4bc47d6a39 675 case S5th:
casiotone401 15:3e4bc47d6a39 676 gLCD.locate( 13, 0 );
casiotone401 15:3e4bc47d6a39 677 gLCD.printf("5th");
casiotone401 15:3e4bc47d6a39 678
casiotone401 15:3e4bc47d6a39 679 sendMes.setArgs("s", "5th");
casiotone401 15:3e4bc47d6a39 680
casiotone401 15:3e4bc47d6a39 681 break;
casiotone401 15:3e4bc47d6a39 682
casiotone401 15:3e4bc47d6a39 683 case Wht:
casiotone401 15:3e4bc47d6a39 684 gLCD.locate( 13, 0 );
casiotone401 15:3e4bc47d6a39 685 gLCD.printf("wht");
casiotone401 15:3e4bc47d6a39 686
casiotone401 15:3e4bc47d6a39 687 sendMes.setArgs("s", "Whole Tone");
casiotone401 15:3e4bc47d6a39 688 break;
casiotone401 15:3e4bc47d6a39 689
casiotone401 15:3e4bc47d6a39 690 default:
casiotone401 15:3e4bc47d6a39 691 break;
casiotone401 15:3e4bc47d6a39 692 }
casiotone401 15:3e4bc47d6a39 693
casiotone401 15:3e4bc47d6a39 694 osc.sendOsc(&sendMes);
casiotone401 15:3e4bc47d6a39 695 _qmode = qmode;
casiotone401 15:3e4bc47d6a39 696 }
casiotone401 15:3e4bc47d6a39 697
casiotone401 4:b9f5ae574447 698 }
casiotone401 4:b9f5ae574447 699
casiotone401 15:3e4bc47d6a39 700
casiotone401 0:a4d93cd4c30d 701 //-------------------------------------------------------------
casiotone401 15:3e4bc47d6a39 702 // Write command Custom Char LCD CGRAM for CV Meter)
casiotone401 0:a4d93cd4c30d 703
casiotone401 0:a4d93cd4c30d 704 void WriteCustomChar(unsigned char addr, unsigned char *c)
casiotone401 0:a4d93cd4c30d 705 {
casiotone401 0:a4d93cd4c30d 706 char cnt = 0;
casiotone401 0:a4d93cd4c30d 707 addr = ((addr << 3) | 0x40);
casiotone401 0:a4d93cd4c30d 708
casiotone401 15:3e4bc47d6a39 709 while (cnt < 0x08)
casiotone401 0:a4d93cd4c30d 710 {
casiotone401 0:a4d93cd4c30d 711 gLCD.writeCommand(addr | cnt);
casiotone401 0:a4d93cd4c30d 712 gLCD.writeData(*c);
casiotone401 4:b9f5ae574447 713
casiotone401 15:3e4bc47d6a39 714 ++cnt;
casiotone401 15:3e4bc47d6a39 715 ++c;
casiotone401 0:a4d93cd4c30d 716 }
casiotone401 0:a4d93cd4c30d 717 }
casiotone401 0:a4d93cd4c30d 718
casiotone401 0:a4d93cd4c30d 719 //-------------------------------------------------------------
casiotone401 0:a4d93cd4c30d 720 // Setup Ethernet port
casiotone401 0:a4d93cd4c30d 721
casiotone401 0:a4d93cd4c30d 722 int SetupEthNetIf()
casiotone401 0:a4d93cd4c30d 723 {
casiotone401 0:a4d93cd4c30d 724 gLCD.locate( 0, 1 );
casiotone401 0:a4d93cd4c30d 725 gLCD.printf("Setting up... ");
casiotone401 0:a4d93cd4c30d 726 // printf("Setting up...\r\n");
casiotone401 0:a4d93cd4c30d 727 EthernetErr ethErr = gEth.setup();
casiotone401 0:a4d93cd4c30d 728
casiotone401 15:3e4bc47d6a39 729 if (ethErr)
casiotone401 0:a4d93cd4c30d 730 {
casiotone401 0:a4d93cd4c30d 731 gLCD.locate( 0, 1 );
casiotone401 0:a4d93cd4c30d 732 gLCD.printf("Error in setup.");
casiotone401 0:a4d93cd4c30d 733 // printf("Error %d in setup.\r\n", ethErr);
casiotone401 0:a4d93cd4c30d 734 return -1;
casiotone401 0:a4d93cd4c30d 735 }
casiotone401 0:a4d93cd4c30d 736 // printf("Setup OK\r\n");
casiotone401 0:a4d93cd4c30d 737
casiotone401 0:a4d93cd4c30d 738 // printf("IP address %d.%d.%d.%d\r\n", gEth.getIp()[0], gEth.getIp()[1], gEth.getIp()[2], gEth.getIp()[3]);
casiotone401 0:a4d93cd4c30d 739 Host broadcast(IpAddr(gEth.getIp()[0], gEth.getIp()[1], gEth.getIp()[2], 255), INPUT_PORT, NULL);
casiotone401 0:a4d93cd4c30d 740 gUdp.setOnEvent(&onUDPSocketEvent);
casiotone401 0:a4d93cd4c30d 741 gUdp.bind(broadcast);
casiotone401 4:b9f5ae574447 742
casiotone401 0:a4d93cd4c30d 743 gLCD.locate( 0, 1 );
casiotone401 0:a4d93cd4c30d 744 gLCD.printf("%03d.%03d.%03d.%03d", gEth.getIp()[0], gEth.getIp()[1], gEth.getIp()[2], gEth.getIp()[3]);
casiotone401 15:3e4bc47d6a39 745
casiotone401 4:b9f5ae574447 746 wait(1.0);
casiotone401 0:a4d93cd4c30d 747
casiotone401 0:a4d93cd4c30d 748 return 0;
casiotone401 0:a4d93cd4c30d 749 }
casiotone401 0:a4d93cd4c30d 750
casiotone401 14:977f3c5a4b4e 751
casiotone401 14:977f3c5a4b4e 752 //-------------------------------------------------------------
casiotone401 15:3e4bc47d6a39 753 // Handller receive OSC UDP Packet
casiotone401 0:a4d93cd4c30d 754
casiotone401 4:b9f5ae574447 755 inline void onUDPSocketEvent(UDPSocketEvent e)
casiotone401 0:a4d93cd4c30d 756 {
casiotone401 15:3e4bc47d6a39 757 static union OSCarg msg[10];
casiotone401 24:99045b0f7c4a 758 static char buf[1024] = {0};
casiotone401 29:8b61b87b9676 759 int recvlen;
casiotone401 29:8b61b87b9676 760 int num, numrow, len, offset;
casiotone401 14:977f3c5a4b4e 761 int messagepos = 0;
casiotone401 14:977f3c5a4b4e 762 bool bundleflag = false;
casiotone401 10:ccfeb687c3f2 763
casiotone401 10:ccfeb687c3f2 764 Host host;
casiotone401 10:ccfeb687c3f2 765
casiotone401 15:3e4bc47d6a39 766 switch (e)
casiotone401 0:a4d93cd4c30d 767 {
casiotone401 4:b9f5ae574447 768 case UDPSOCKET_READABLE: // The only event for now
casiotone401 15:3e4bc47d6a39 769
casiotone401 27:65e873bf8307 770 recvlen = gUdp.recvfrom(buf, 1024, &host); // packet length
casiotone401 27:65e873bf8307 771
casiotone401 27:65e873bf8307 772 if (recvlen <= 0) break;
casiotone401 27:65e873bf8307 773
casiotone401 27:65e873bf8307 774 if (!bundleflag && buf[0] == '#') // #bundle
casiotone401 27:65e873bf8307 775 {
casiotone401 27:65e873bf8307 776 messagepos += 16; // skip #bundle & timetag
casiotone401 27:65e873bf8307 777 recvlen -= 16;
casiotone401 27:65e873bf8307 778
casiotone401 27:65e873bf8307 779 bundleflag = true;
casiotone401 27:65e873bf8307 780 }
casiotone401 27:65e873bf8307 781
casiotone401 27:65e873bf8307 782 do {
casiotone401 27:65e873bf8307 783
casiotone401 15:3e4bc47d6a39 784 if (bundleflag)
casiotone401 10:ccfeb687c3f2 785 {
casiotone401 10:ccfeb687c3f2 786 messagepos += 4;
casiotone401 10:ccfeb687c3f2 787 recvlen -= 4;
casiotone401 27:65e873bf8307 788
casiotone401 15:3e4bc47d6a39 789 if (recvlen <= 8)
casiotone401 10:ccfeb687c3f2 790 {
casiotone401 10:ccfeb687c3f2 791 bundleflag = false;
casiotone401 10:ccfeb687c3f2 792 break;
casiotone401 10:ccfeb687c3f2 793 }
casiotone401 10:ccfeb687c3f2 794 }
casiotone401 27:65e873bf8307 795
casiotone401 15:3e4bc47d6a39 796 if (getOSCmsg(buf + messagepos, msg) == -1) continue;
casiotone401 27:65e873bf8307 797
casiotone401 15:3e4bc47d6a39 798 len = strlength(msg[0].address);
casiotone401 27:65e873bf8307 799
casiotone401 15:3e4bc47d6a39 800 if (isdigit(msg[0].address[len-1]))
casiotone401 10:ccfeb687c3f2 801 {
casiotone401 10:ccfeb687c3f2 802 num = msg[0].address[len-1] - '0' - 1;
casiotone401 27:65e873bf8307 803
casiotone401 15:3e4bc47d6a39 804 offset = 1;
casiotone401 27:65e873bf8307 805
casiotone401 15:3e4bc47d6a39 806 if (isdigit(msg[0].address[len-2]))
casiotone401 15:3e4bc47d6a39 807 {
casiotone401 15:3e4bc47d6a39 808 offset = 2;
casiotone401 15:3e4bc47d6a39 809 num += 10;
casiotone401 15:3e4bc47d6a39 810 }
casiotone401 27:65e873bf8307 811
casiotone401 10:ccfeb687c3f2 812 } else {
casiotone401 27:65e873bf8307 813
casiotone401 10:ccfeb687c3f2 814 num = -1;
casiotone401 10:ccfeb687c3f2 815 }
casiotone401 27:65e873bf8307 816
casiotone401 27:65e873bf8307 817 // address pattern SYNC & GATE (Type Tag int, float)
casiotone401 17:55e5136790a6 818 if (!strncmp(msg[0].address + (len - offset) - 4, "sync", 4))
casiotone401 10:ccfeb687c3f2 819 {
casiotone401 29:8b61b87b9676 820 gCLOCKOUT = (msg[2].i != 0) ? true: false;
casiotone401 10:ccfeb687c3f2 821 continue;
casiotone401 10:ccfeb687c3f2 822
casiotone401 17:55e5136790a6 823 } else if (!strncmp(msg[0].address + (len - offset) - 4, "gate", 4) && (num != -1)) {
casiotone401 15:3e4bc47d6a39 824 if (num > 3) continue;
casiotone401 29:8b61b87b9676 825 gGATES[num] = (msg[2].i != 0) ? true: false;
casiotone401 10:ccfeb687c3f2 826 continue;
casiotone401 27:65e873bf8307 827 // (touchOSC Control push, toggle)
casiotone401 17:55e5136790a6 828 } else if (!strncmp(msg[0].address + (len - offset) - 5, "fader", 5) && (num != -1)) {
casiotone401 15:3e4bc47d6a39 829 if (num > 7) continue;
casiotone401 15:3e4bc47d6a39 830 gOSC_cv[num] = msg[2].f * (SCALING_N);
casiotone401 10:ccfeb687c3f2 831 continue;
casiotone401 15:3e4bc47d6a39 832
casiotone401 17:55e5136790a6 833 } else if (!strncmp(msg[0].address + (len - offset) - 9, "multixy1/", 9) && (num != -1)) {
casiotone401 15:3e4bc47d6a39 834 if (num > 7) continue;
casiotone401 15:3e4bc47d6a39 835 if (msg[1].typeTag[1] == 'f') gOSC_cv[num] = msg[2].f * (SCALING_N);
casiotone401 15:3e4bc47d6a39 836 if (msg[1].typeTag[1] == 'f') gOSC_cv[++num] = msg[3].f * (SCALING_N);
casiotone401 10:ccfeb687c3f2 837 continue;
casiotone401 27:65e873bf8307 838
casiotone401 24:99045b0f7c4a 839 } else if (!strncmp(msg[0].address + (len - offset) - 12, "multifader1/", 12) && (num != -1)) {
casiotone401 15:3e4bc47d6a39 840 if (num > 7) continue;
casiotone401 15:3e4bc47d6a39 841 if (msg[1].typeTag[1] == 'f') gOSC_cv[num] = msg[2].f * (SCALING_N);
casiotone401 10:ccfeb687c3f2 842 continue;
casiotone401 27:65e873bf8307 843
casiotone401 24:99045b0f7c4a 844 } else if (!strncmp(msg[0].address + (len - offset) - 5, "m185/", 5) && (num != -1)) {
casiotone401 24:99045b0f7c4a 845 if (num > 7) continue;
casiotone401 24:99045b0f7c4a 846 if (msg[1].typeTag[1] == 'f') g185_cv[num] = msg[2].f * (SCALING_N);
casiotone401 24:99045b0f7c4a 847 continue;
casiotone401 27:65e873bf8307 848
casiotone401 17:55e5136790a6 849 } else if (!strncmp(msg[0].address + (len - offset) -10, "sequencer/", 10) && (num != -1)) {
casiotone401 15:3e4bc47d6a39 850 if (num > 15) continue;
casiotone401 15:3e4bc47d6a39 851 gSeq_cv[num] = msg[2].f * (SCALING_N);
casiotone401 10:ccfeb687c3f2 852 continue;
casiotone401 27:65e873bf8307 853
casiotone401 17:55e5136790a6 854 } else if (!strncmp(msg[0].address + (len - offset) - 6, "ctrlsw", 6) && (num != -1)) {
casiotone401 15:3e4bc47d6a39 855 if (num > 7) continue;
casiotone401 29:8b61b87b9676 856 gCtrlSW[num] = (msg[2].i != 0) ? true: false;
casiotone401 10:ccfeb687c3f2 857 continue;
casiotone401 27:65e873bf8307 858
casiotone401 17:55e5136790a6 859 } else if (!strncmp(msg[0].address + (len - offset) - 4, "ctrl", 4) && (num != -1)) {
casiotone401 15:3e4bc47d6a39 860 if (num > 7) continue;
casiotone401 15:3e4bc47d6a39 861 gCtrl[num] = msg[2].f;
casiotone401 15:3e4bc47d6a39 862 continue;
casiotone401 27:65e873bf8307 863
casiotone401 17:55e5136790a6 864 } else if (!strncmp(msg[0].address + (len - offset) - 9, "pulsecnt/", 9) && (num != -1)) {
casiotone401 15:3e4bc47d6a39 865 if (num > 7) continue;
casiotone401 15:3e4bc47d6a39 866 gPulseCount[num] = msg[2].f;
casiotone401 15:3e4bc47d6a39 867 continue;
casiotone401 27:65e873bf8307 868
casiotone401 17:55e5136790a6 869 } else if (!strncmp(msg[0].address + (len - offset) - 9, "gatemode/", 9) && (num != -1)) {
casiotone401 15:3e4bc47d6a39 870 if (num > 15) continue;
casiotone401 15:3e4bc47d6a39 871 gGateMode[num] = msg[2].f;
casiotone401 15:3e4bc47d6a39 872 continue;
casiotone401 27:65e873bf8307 873
casiotone401 24:99045b0f7c4a 874 } else if (!strncmp(msg[0].address + (len - offset) - 9, "g185mode/", 9) && (num != -1)) {
casiotone401 24:99045b0f7c4a 875 if (num > 7) continue;
casiotone401 24:99045b0f7c4a 876 gGateMode185[num] = msg[2].f;
casiotone401 24:99045b0f7c4a 877 continue;
casiotone401 27:65e873bf8307 878
casiotone401 17:55e5136790a6 879 } else if (!strncmp(msg[0].address + (len - offset) - 6, "slide/", 6) && (num != -1)) {
casiotone401 15:3e4bc47d6a39 880 if (num > 15) continue;
casiotone401 15:3e4bc47d6a39 881 gSlide[num] = msg[2].f;
casiotone401 15:3e4bc47d6a39 882 continue;
casiotone401 27:65e873bf8307 883
casiotone401 24:99045b0f7c4a 884 } else if (!strncmp(msg[0].address + (len - offset) - 9, "slide185/", 9) && (num != -1)) {
casiotone401 24:99045b0f7c4a 885 if (num > 7) continue;
casiotone401 24:99045b0f7c4a 886 gSlide185[num] = msg[2].f;
casiotone401 24:99045b0f7c4a 887 continue;
casiotone401 27:65e873bf8307 888
casiotone401 24:99045b0f7c4a 889 } else if (!strncmp(msg[0].address + (len - offset - 2) - 7, "accent/", 7) && (num != -1)) {
casiotone401 27:65e873bf8307 890
casiotone401 24:99045b0f7c4a 891 if (isdigit(msg[0].address[len - 3]))
casiotone401 17:55e5136790a6 892 {
casiotone401 24:99045b0f7c4a 893 num = msg[0].address[len - 3] - '0' - 1;
casiotone401 17:55e5136790a6 894 }
casiotone401 27:65e873bf8307 895
casiotone401 17:55e5136790a6 896 gAccent[num] = msg[2].i;
casiotone401 17:55e5136790a6 897 continue;
casiotone401 27:65e873bf8307 898
casiotone401 24:99045b0f7c4a 899 } else if (!strncmp(msg[0].address + (len - offset - 3) - 7, "accent/", 7) && (num != -1)) {
casiotone401 27:65e873bf8307 900
casiotone401 24:99045b0f7c4a 901 if (isdigit(msg[0].address[len - 3]))
casiotone401 17:55e5136790a6 902 {
casiotone401 24:99045b0f7c4a 903 num = msg[0].address[len - 3] - '0' - 1;
casiotone401 27:65e873bf8307 904
casiotone401 24:99045b0f7c4a 905 if (isdigit(msg[0].address[len - 4]))
casiotone401 17:55e5136790a6 906 {
casiotone401 17:55e5136790a6 907 num += 10;
casiotone401 17:55e5136790a6 908 }
casiotone401 17:55e5136790a6 909 }
casiotone401 27:65e873bf8307 910
casiotone401 17:55e5136790a6 911 gAccent[num] = msg[2].i;
casiotone401 17:55e5136790a6 912 continue;
casiotone401 27:65e873bf8307 913
casiotone401 24:99045b0f7c4a 914 } else if (!strncmp(msg[0].address + (len - offset - 3) - 6, "185acc/", 6) && (num != -1)) {
casiotone401 27:65e873bf8307 915
casiotone401 24:99045b0f7c4a 916 if (isdigit(msg[0].address[len-3]))
casiotone401 24:99045b0f7c4a 917 {
casiotone401 24:99045b0f7c4a 918 num = msg[0].address[len-3] - '0' - 1;
casiotone401 27:65e873bf8307 919
casiotone401 24:99045b0f7c4a 920 if (isdigit(msg[0].address[len - 4]))
casiotone401 24:99045b0f7c4a 921 {
casiotone401 24:99045b0f7c4a 922 num += 10;
casiotone401 24:99045b0f7c4a 923 }
casiotone401 24:99045b0f7c4a 924 }
casiotone401 27:65e873bf8307 925
casiotone401 24:99045b0f7c4a 926 gAccent185[num] = msg[2].i;
casiotone401 24:99045b0f7c4a 927 continue;
casiotone401 27:65e873bf8307 928
casiotone401 24:99045b0f7c4a 929 } else if (!strncmp(msg[0].address + (len - offset - 2) - 3, "bm/", 3) && (num != -1)) {
casiotone401 27:65e873bf8307 930
casiotone401 24:99045b0f7c4a 931 if (isdigit(msg[0].address[len - 3]))
casiotone401 24:99045b0f7c4a 932 {
casiotone401 24:99045b0f7c4a 933 num = msg[0].address[len - 3] - '0' - 1;
casiotone401 27:65e873bf8307 934
casiotone401 24:99045b0f7c4a 935 if (isdigit(msg[0].address[len - 4]))
casiotone401 24:99045b0f7c4a 936 {
casiotone401 24:99045b0f7c4a 937 num += 10;
casiotone401 24:99045b0f7c4a 938 }
casiotone401 24:99045b0f7c4a 939 }
casiotone401 27:65e873bf8307 940
casiotone401 24:99045b0f7c4a 941 if (isdigit(msg[0].address[len - 1]))
casiotone401 24:99045b0f7c4a 942 {
casiotone401 24:99045b0f7c4a 943 numrow = msg[0].address[len - 1] - '0' - 1;
casiotone401 24:99045b0f7c4a 944 }
casiotone401 27:65e873bf8307 945
casiotone401 24:99045b0f7c4a 946 gBeatsMatrix[numrow][num] = msg[2].i;
casiotone401 24:99045b0f7c4a 947 continue;
casiotone401 27:65e873bf8307 948
casiotone401 24:99045b0f7c4a 949 } else if (!strncmp(msg[0].address + (len - offset - 3) - 3, "bm/", 3) && (num != -1)) {
casiotone401 27:65e873bf8307 950
casiotone401 24:99045b0f7c4a 951 if (isdigit(msg[0].address[len - 3]))
casiotone401 24:99045b0f7c4a 952 {
casiotone401 24:99045b0f7c4a 953 num = msg[0].address[len - 3] - '0' - 1;
casiotone401 27:65e873bf8307 954
casiotone401 24:99045b0f7c4a 955 if (isdigit(msg[0].address[len - 4]))
casiotone401 24:99045b0f7c4a 956 {
casiotone401 24:99045b0f7c4a 957 num += 10;
casiotone401 24:99045b0f7c4a 958 }
casiotone401 24:99045b0f7c4a 959 }
casiotone401 27:65e873bf8307 960
casiotone401 24:99045b0f7c4a 961 if (isdigit(msg[0].address[len - 1]))
casiotone401 24:99045b0f7c4a 962 {
casiotone401 24:99045b0f7c4a 963 numrow = msg[0].address[len - 1] - '0' - 1;
casiotone401 24:99045b0f7c4a 964 }
casiotone401 27:65e873bf8307 965
casiotone401 24:99045b0f7c4a 966 gBeatsMatrix[numrow][num] = msg[2].i;
casiotone401 24:99045b0f7c4a 967 continue;
casiotone401 27:65e873bf8307 968
casiotone401 24:99045b0f7c4a 969 } else if (!strncmp(msg[0].address + (len - offset) - 4, "bpc/", 4) && (num != -1)) {
casiotone401 24:99045b0f7c4a 970 if (num > 15) continue;
casiotone401 24:99045b0f7c4a 971 gPulseCountBeats[num] = msg[2].f;
casiotone401 24:99045b0f7c4a 972 continue;
casiotone401 27:65e873bf8307 973
casiotone401 24:99045b0f7c4a 974 } else if (!strncmp(msg[0].address + (len - offset) - 4, "blv/", 4) && (num != -1)) {
casiotone401 24:99045b0f7c4a 975 if (num > 7) continue;
casiotone401 24:99045b0f7c4a 976 gBeatsLevel[num] = msg[2].f;
casiotone401 24:99045b0f7c4a 977 continue;
casiotone401 27:65e873bf8307 978
casiotone401 24:99045b0f7c4a 979 } else if (!strncmp(msg[0].address + (len - offset) - 4, "bdc/", 4) && (num != -1)) {
casiotone401 24:99045b0f7c4a 980 if (num > 7) continue;
casiotone401 24:99045b0f7c4a 981 gBeatsDecay[num] = msg[2].f;
casiotone401 24:99045b0f7c4a 982 continue;
casiotone401 27:65e873bf8307 983
casiotone401 24:99045b0f7c4a 984 } else if (!strncmp(msg[0].address + (len - offset) - 4, "euca", 4) && (num != -1)) {
casiotone401 15:3e4bc47d6a39 985 if (num > 5) continue;
casiotone401 15:3e4bc47d6a39 986 gEucA[num] = msg[2].f;
casiotone401 15:3e4bc47d6a39 987 continue;
casiotone401 27:65e873bf8307 988
casiotone401 17:55e5136790a6 989 } else if (!strncmp(msg[0].address + (len - offset) - 4, "eucb", 4) && (num != -1)) {
casiotone401 15:3e4bc47d6a39 990 if (num > 5) continue;
casiotone401 15:3e4bc47d6a39 991 gEucB[num] = msg[2].f;
casiotone401 15:3e4bc47d6a39 992 continue;
casiotone401 27:65e873bf8307 993
casiotone401 27:65e873bf8307 994 } else if (MODE_RND || MODE_LFO) {
casiotone401 20:a44f4a024902 995
casiotone401 27:65e873bf8307 996 if (!strncmp(msg[0].address + (len - offset) - 3, "acv", 3) && (num != -1)) {
casiotone401 27:65e873bf8307 997 if (num > 3) continue;
casiotone401 27:65e873bf8307 998 gArdCV[num] = msg[2].i;
casiotone401 27:65e873bf8307 999 continue;
casiotone401 27:65e873bf8307 1000
casiotone401 27:65e873bf8307 1001 } else if (!strncmp(msg[0].address + (len - offset) - 3, "pot", 3) && (num != -1)) {
casiotone401 27:65e873bf8307 1002 if (num > 1) continue;
casiotone401 27:65e873bf8307 1003 gArdPot[num] = msg[2].f;
casiotone401 27:65e873bf8307 1004 continue;
casiotone401 27:65e873bf8307 1005
casiotone401 27:65e873bf8307 1006 } else if (!strncmp(msg[0].address + (len - offset) - 2, "sw", 2) && (num != -1)) {
casiotone401 27:65e873bf8307 1007 if (num > 1) continue;
casiotone401 29:8b61b87b9676 1008 gArdSW[num] = (msg[2].i != 0) ? true: false;
casiotone401 27:65e873bf8307 1009 continue;
casiotone401 27:65e873bf8307 1010
casiotone401 27:65e873bf8307 1011 }
casiotone401 20:a44f4a024902 1012
casiotone401 15:3e4bc47d6a39 1013 } else {
casiotone401 27:65e873bf8307 1014
casiotone401 10:ccfeb687c3f2 1015 continue;
casiotone401 10:ccfeb687c3f2 1016 }
casiotone401 27:65e873bf8307 1017
casiotone401 15:3e4bc47d6a39 1018 } while (bundleflag);
casiotone401 15:3e4bc47d6a39 1019 }
casiotone401 15:3e4bc47d6a39 1020 }