Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: Bonjour OSCReceiver TextLCD mbed mbed-rpc BurstSPI DebouncedInterrupt FastIO MIDI OSC OSCtoCV ClockControl
Revision 17:55e5136790a6, committed 2016-01-02
- Comitter:
- casiotone401
- Date:
- Sat Jan 02 23:45:04 2016 +0000
- Parent:
- 16:1196b8c87bb7
- Child:
- 18:396d16bef1d4
- Commit message:
- improved performance & minor change
Changed in this revision
--- a/OSC.lib Fri Aug 07 12:47:35 2015 +0000 +++ b/OSC.lib Sat Jan 02 23:45:04 2016 +0000 @@ -1,1 +1,1 @@ -https://developer.mbed.org/users/casiotone401/code/OSC/#507dea4cc97a +http://developer.mbed.org/users/tobyspark/code/OSC/#498df61ee77e
--- a/main.cpp Fri Aug 07 12:47:35 2015 +0000
+++ b/main.cpp Sat Jan 02 23:45:04 2016 +0000
@@ -1,7 +1,6 @@
//-------------------------------------------------------------
-// OSCtoCV Converter
-// Schematic, touchOSC template & VST Plug-in
-// http://gtbts.tumblr.com/post/125663817741/osc-to-cv-converter-ver2-mbed-osctocv
+// TI DAC8568 OSCtoCV Converter ver.2
+// http://gtbts.tumblr.com/post/125663817741/osc-to-cv-converter-ver2-mbed-osctocv
//
// DAC8568 16bit Octal DAC http://www.ti.com/product/dac8568
//
@@ -16,9 +15,6 @@
// http://www.eleclabo.com/denshi/device/lcd1602/gcram.html
// Dirk-Willem van Gulik's BonjourLib
// http://mbed.org/users/dirkx/code/BonjourLib/file/bb6472f455e8/services/mDNS
-// ADDAC System & sneak-thief's Euclidean Polyrhythm generator
-// https://github.com/addacsystem/ADDAC-Library
-// https://www.muffwiggler.com/forum/viewtopic.php?p=1451228#1451228
//
// Released under the MIT License: http://mbed.org/license/mit
//-------------------------------------------------------------
@@ -28,8 +24,10 @@
#include "mbed.h"
#include "FastIO.h"
+//#include "FastAnalogIn.h"
#include "DebouncedInterrupt.h"
#include "BurstSPI.h"
+//#include "BufferedSoftSerial.h"
#include "TextLCD.h" //edit "writeCommand" "writeData" protected -> public
#include "EthernetNetIf.h"
#include "HTTPServer.h"
@@ -79,7 +77,7 @@
#define SCALING_N 32256.0f
#define INPUT_PORT 12345 // Input Port Number
-#define POLLING_INTERVAL 20 // Polling Interval (us)
+#define POLLING_INTERVAL 21 // Polling Interval (us)
//-------------------------------------------------------------
// DAC8568 Control Bits (See datasheet)
@@ -189,6 +187,7 @@
int SetupEthNetIf(void);
inline size_t strlength(const char *);
inline void onUDPSocketEvent(UDPSocketEvent);
+inline void ReceiveArduinoOSC(void);
void EuclideanSeq(int, bool, bool);
unsigned int Euclid(int, int, int);
inline int BitRead(uint16_t, int);
@@ -367,6 +366,7 @@
gCtrlSW[1] /ctrlsw2 Euclidean Sequencer reset
gCtrlSW[2] /ctrlsw3 Sequencer Loop
gCtrlSW[3] /ctrlsw4 Euclid Seq ON
+gCtrlSW[4] /ctrlsw5 ASR Analog Mode
float gPulseCount[8] = {0}; M185 Pulse Count
float gGateMode[8] = {0}; M185 Gate Mode
@@ -386,6 +386,7 @@
float gPulseCount[8] = {0};
float gGateMode[16] = {0};
float gSlide[16];
+float gAccent[16] = {0};
// Euclidean SEQ Variables
float gEucA[6], gEucB[6];
@@ -428,6 +429,7 @@
DebouncedInterrupt gSW(p30); // Mode SW
// Serial for Arduino
+//BufferedSoftSerial ardSerial(p25, p26);
MIDI midi(p28, p27);
Timer gTimer; // Timer
@@ -443,7 +445,7 @@
IpAddr(192,168,1,1)
);
*/
-
+
UDPSocket gUdp;
// touchOSC Address
@@ -529,6 +531,8 @@
gLCD.printf("G>>%3.2f", gGlide);
}
+ bpm = CheckBPM(); // check current BPM
+
switch (gMode)
{
case MODE_OSC: // OSCtoCV mode
@@ -538,8 +542,7 @@
case MODE_SEQ: // Shift Sequencer mode
- bpm = CheckBPM();
-
+ //ReceiveArduinoOSC();
ShiftCVSeq(GateSeq(bpm, N16TH, GATE1, 3, NON_INVERT, GATESOUT_OFF, SYNC_ON), gCtrlSW[0]);
GateSeq(bpm, N8TH, GATE2, 3, NON_INVERT, GATESOUT_ON, SYNC_OFF);
@@ -551,8 +554,6 @@
case MODE_185: // M185 Sequencer mode
- bpm = CheckBPM();
-
M185Seq(GateSeq(bpm, N16TH, GATE1, 3, NON_INVERT, GATESOUT_OFF, SYNC_ON), gCtrlSW[0]);
GateSeq(bpm, N8TH, GATE2, 3, NON_INVERT, GATESOUT_ON, SYNC_OFF);
@@ -564,8 +565,6 @@
case MODE_EUC: // Euclidean Sequencer mode
- bpm = CheckBPM();
-
ShiftCVSeq(GateSeq(bpm, N1ST, SUBGATE, 3, NON_INVERT, GATESOUT_OFF, SYNC_OFF), gCtrlSW[0]);
EuclideanSeq(GateSeq(bpm, N16TH, GATE1, 1, NON_INVERT, GATESOUT_OFF, SYNC_OFF), gCtrlSW[0], GATESOUT_ON);
break;
@@ -654,9 +653,10 @@
sendMes.setPort(touchOSCPort);
gSW.attach(&CheckModeSW,IRQ_RISE, 30); // InterruptIn rising edge(ModeSW)
- gPoller.attach_us(&NetPoll, POLLING_INTERVAL); // Ticker Polling
+ wait(0.5);
- wait(0.4);
+ gPoller.attach_us(&NetPoll, POLLING_INTERVAL); // Ticker Polling
+ wait(1.5);
// Begin Serial for Arduino
//ardSerial.baud(115200);
@@ -771,10 +771,6 @@
case Lin:
glidecv[ch] = glidecv[ch] * gGlide + gOSC_cv[ch] * (1.0f - gGlide);
- cv = (unsigned int)glidecv[ch];
-
- UpdateCV(WRITE_UPDATE_N, ch, &cv);
-
break;
case Chr:
@@ -782,9 +778,6 @@
qcv = calibMap1[(unsigned int)MapFloat(gOSC_cv[ch], 0, SCALING_N, 0, (QUAN_RES1 - 1))];
glidecv[ch] = glidecv[ch] * gGlide + (qcv * SCALING_N) * (1.0f - gGlide);
- cv = (unsigned int)glidecv[ch];
-
- UpdateCV(WRITE_UPDATE_N, ch, &cv);
break;
@@ -793,9 +786,6 @@
qcv = calibMap2[(unsigned int)MapFloat(gOSC_cv[ch], 0, SCALING_N, 0, (QUAN_RES2 - 1))];
glidecv[ch] = glidecv[ch] * gGlide + (qcv * SCALING_N) * (1.0f - gGlide);
- cv = (unsigned int)glidecv[ch];
-
- UpdateCV(WRITE_UPDATE_N, ch, &cv);
break;
@@ -804,9 +794,6 @@
qcv = calibMap3[(unsigned int)MapFloat(gOSC_cv[ch], 0, SCALING_N, 0, (QUAN_RES3 - 1))];
glidecv[ch] = glidecv[ch] * gGlide + (qcv * SCALING_N) * (1.0f - gGlide);
- cv = (unsigned int)glidecv[ch];
-
- UpdateCV(WRITE_UPDATE_N, ch, &cv);
break;
@@ -815,9 +802,6 @@
qcv = calibMap4[(unsigned int)MapFloat(gOSC_cv[ch], 0, SCALING_N, 0, (QUAN_RES4 - 1))];
glidecv[ch] = glidecv[ch] * gGlide + (qcv * SCALING_N) * (1.0f - gGlide);
- cv = (unsigned int)glidecv[ch];
-
- UpdateCV(WRITE_UPDATE_N, ch, &cv);
break;
@@ -826,9 +810,6 @@
qcv = calibMap5[(unsigned int)MapFloat(gOSC_cv[ch], 0, SCALING_N, 0, (QUAN_RES5 - 1))];
glidecv[ch] = glidecv[ch] * gGlide + (qcv * SCALING_N) * (1.0f - gGlide);
- cv = (unsigned int)glidecv[ch];
-
- UpdateCV(WRITE_UPDATE_N, ch, &cv);
break;
@@ -837,9 +818,6 @@
qcv = calibMap6[(unsigned int)MapFloat(gOSC_cv[ch], 0, SCALING_N, 0, (QUAN_RES6 - 1))];
glidecv[ch] = glidecv[ch] * gGlide + (qcv * SCALING_N) * (1.0f - gGlide);
- cv = (unsigned int)glidecv[ch];
-
- UpdateCV(WRITE_UPDATE_N, ch, &cv);
break;
@@ -848,9 +826,6 @@
qcv = calibMap7[(unsigned int)MapFloat(gOSC_cv[ch], 0, SCALING_N, 0, (QUAN_RES7 - 1))];
glidecv[ch] = glidecv[ch] * gGlide + (qcv * SCALING_N) * (1.0f - gGlide);
- cv = (unsigned int)glidecv[ch];
-
- UpdateCV(WRITE_UPDATE_N, ch, &cv);
break;
@@ -859,25 +834,26 @@
qcv = calibMap8[(unsigned int)MapFloat(gOSC_cv[ch], 0, SCALING_N, 0, (QUAN_RES8 - 1))];
glidecv[ch] = glidecv[ch] * gGlide + (qcv * SCALING_N) * (1.0f - gGlide);
- cv = (unsigned int)glidecv[ch];
-
- UpdateCV(WRITE_UPDATE_N, ch, &cv);
-
+
break;
}
-
- if (mcount == 0x1F)
- {
- UpdateCVMeter(ch, &cv);
- }
+
+ cv = (unsigned int)glidecv[ch];
+
+ UpdateCV(WRITE_UPDATE_N, ch, &cv);
- ++ch;
-
- if (ch &= 0x07)
- {
- ++mcount;
- mcount &= 0x3F;
- }
+ if (mcount == 0x1F)
+ {
+ UpdateCVMeter(ch, &cv);
+ }
+
+ ++ch;
+
+ if (ch &= 0x07)
+ {
+ ++mcount;
+ mcount &= 0x3F;
+ }
}
//-------------------------------------------------------------
@@ -897,6 +873,8 @@
static float glidecv[8], shiftcv[8];
unsigned int cv;
static float qcv;
+ static int jitterCount;
+ static int jitter;
qmode = (gCtrl[1] * (SCALE_NUM - 1.0f)); // Sequencer Quantize Mode (gCtrl[1])
amode = SCALE_AOUT * qmode;
@@ -908,11 +886,7 @@
case Lin:
glidecv[0] = glidecv[0] * gSlide[currentStep] + gSeq_cv[currentStep] * (1.0f - gSlide[currentStep]);
-
- cv = (unsigned int)glidecv[0];
-
- UpdateCV(WRITE_UPDATE_N, 0, &cv);
-
+
break;
case Chr:
@@ -920,10 +894,7 @@
qcv = calibMap1[(unsigned int)MapFloat(gSeq_cv[currentStep], 0, SCALING_N, 0, (QUAN_RES1 - 1))];
glidecv[0] = glidecv[0] * gSlide[currentStep] + (qcv * SCALING_N) * (1.0f - gSlide[currentStep]);
- cv = (unsigned int)glidecv[0];
-
- UpdateCV(WRITE_UPDATE_N, 0, &cv);
-
+
break;
case Maj:
@@ -931,9 +902,6 @@
qcv = calibMap2[(unsigned int)MapFloat(gSeq_cv[currentStep], 0, SCALING_N, 0, (QUAN_RES2 - 1))];
glidecv[0] = glidecv[0] * gSlide[currentStep] + (qcv * SCALING_N) * (1.0f - gSlide[currentStep]);
- cv = (unsigned int)glidecv[0];
-
- UpdateCV(WRITE_UPDATE_N, 0, &cv);
break;
@@ -942,9 +910,6 @@
qcv = calibMap3[(unsigned int)MapFloat(gSeq_cv[currentStep], 0, SCALING_N, 0, (QUAN_RES3 - 1))];
glidecv[0] = glidecv[0] * gSlide[currentStep] + (qcv * SCALING_N) * (1.0f - gSlide[currentStep]);
- cv = (unsigned int)glidecv[0];
-
- UpdateCV(WRITE_UPDATE_N, 0, &cv);
break;
@@ -953,9 +918,6 @@
qcv = calibMap4[(unsigned int)MapFloat(gSeq_cv[currentStep], 0, SCALING_N, 0, (QUAN_RES4 - 1))];
glidecv[0] = glidecv[0] * gSlide[currentStep] + (qcv * SCALING_N) * (1.0f - gSlide[currentStep]);
- cv = (unsigned int)glidecv[0];
-
- UpdateCV(WRITE_UPDATE_N, 0, &cv);
break;
@@ -964,9 +926,6 @@
qcv = calibMap5[(unsigned int)MapFloat(gSeq_cv[currentStep], 0, SCALING_N, 0, (QUAN_RES5 - 1))];
glidecv[0] = glidecv[0] * gSlide[currentStep] + (qcv * SCALING_N) * (1.0f - gSlide[currentStep]);
- cv = (unsigned int)glidecv[0];
-
- UpdateCV(WRITE_UPDATE_N, 0, &cv);
break;
@@ -975,10 +934,7 @@
qcv = calibMap6[(unsigned int)MapFloat(gSeq_cv[currentStep], 0, SCALING_N, 0, (QUAN_RES6 - 1))];
glidecv[0] = glidecv[0] * gSlide[currentStep] + (qcv * SCALING_N) * (1.0f - gSlide[currentStep]);
- cv = (unsigned int)glidecv[0];
-
- UpdateCV(WRITE_UPDATE_N, 0, &cv);
-
+
break;
case S5th:
@@ -986,10 +942,7 @@
qcv = calibMap7[(unsigned int)MapFloat(gSeq_cv[currentStep], 0, SCALING_N, 0, (QUAN_RES7 - 1))];
glidecv[0] = glidecv[0] * gSlide[currentStep] + (qcv * SCALING_N) * (1.0f - gSlide[currentStep]);
- cv = (unsigned int)glidecv[0];
-
- UpdateCV(WRITE_UPDATE_N, 0, &cv);
-
+
break;
case Wht:
@@ -997,17 +950,27 @@
qcv = calibMap8[(unsigned int)MapFloat(gSeq_cv[currentStep], 0, SCALING_N, 0, (QUAN_RES8 - 1))];
glidecv[0] = glidecv[0] * gSlide[currentStep] + (qcv * SCALING_N) * (1.0f - gSlide[currentStep]);
- cv = (unsigned int)glidecv[0];
-
- UpdateCV(WRITE_UPDATE_N, 0, &cv);
break;
}
+ if (!gCtrlSW[4])
+ {
+ jitter = 0;
+
+ } else if (gCtrlSW[4] && jitterCount % 64 == 0) { // ASR Analog Mode
+
+ jitter = (rand() % 100 - 50);
+ }
+
+ cv = (unsigned int)(glidecv[0] + jitter);
+
+ UpdateCV(WRITE_UPDATE_N, 0, &cv);
+
for (i = 1; i < 8; ++i)
{
glidecv[i] = glidecv[i] * gSlide[currentStep] + shiftcv[i] * (1.0f - gSlide[currentStep]);
- cv = (unsigned int)glidecv[i];
+ cv = (unsigned int)(glidecv[i] + jitter);
UpdateCV(WRITE_UPDATE_N, i, &cv);
}
@@ -1120,11 +1083,23 @@
gGATES[0] = true;
}
+ if (gAccent[currentStep]) // accent
+ {
+ gGATES[2] = gGATES[3] = true;
+
+ } else {
+
+ gGATES[2] = gGATES[3] = false;
+ }
+
stepFoward = false;
}
++ch;
ch &= 0x0F;
+
+ ++jitterCount;
+ jitterCount &= 0x1FF;
}
//-------------------------------------------------------------
@@ -1157,11 +1132,7 @@
case Lin:
glidecv[0] = glidecv[0] * gSlide[currentStep] + gSeq_cv[currentStep] * (1.0f - gSlide[currentStep]);
-
- cv = (unsigned int)glidecv[0];
-
- UpdateCV(WRITE_UPDATE_N, 0, &cv);
-
+
break;
case Chr:
@@ -1169,9 +1140,6 @@
qcv = calibMap1[(unsigned int)MapFloat(gSeq_cv[currentStep], 0, SCALING_N, 0, (QUAN_RES1 - 1))];
glidecv[0] = glidecv[0] * gSlide[currentStep] + (qcv * SCALING_N) * (1.0f - gSlide[currentStep]);
- cv = (unsigned int)glidecv[0];
-
- UpdateCV(WRITE_UPDATE_N, 0, &cv);
break;
@@ -1180,10 +1148,7 @@
qcv = calibMap2[(unsigned int)MapFloat(gSeq_cv[currentStep], 0, SCALING_N, 0, (QUAN_RES2 - 1))];
glidecv[0] = glidecv[0] * gSlide[currentStep] + (qcv * SCALING_N) * (1.0f - gSlide[currentStep]);
- cv = (unsigned int)glidecv[0];
-
- UpdateCV(WRITE_UPDATE_N, 0, &cv);
-
+
break;
case M7:
@@ -1191,10 +1156,7 @@
qcv = calibMap3[(unsigned int)MapFloat(gSeq_cv[currentStep], 0, SCALING_N, 0, (QUAN_RES3 - 1))];
glidecv[0] = glidecv[0] * gSlide[currentStep] + (qcv * SCALING_N) * (1.0f - gSlide[currentStep]);
- cv = (unsigned int)glidecv[0];
-
- UpdateCV(WRITE_UPDATE_N, 0, &cv);
-
+
break;
case Min7:
@@ -1202,10 +1164,7 @@
qcv = calibMap4[(unsigned int)MapFloat(gSeq_cv[currentStep], 0, SCALING_N, 0, (QUAN_RES4 - 1))];
glidecv[0] = glidecv[0] * gSlide[currentStep] + (qcv * SCALING_N) * (1.0f - gSlide[currentStep]);
- cv = (unsigned int)glidecv[0];
-
- UpdateCV(WRITE_UPDATE_N, 0, &cv);
-
+
break;
case Dor:
@@ -1213,9 +1172,6 @@
qcv = calibMap5[(unsigned int)MapFloat(gSeq_cv[currentStep], 0, SCALING_N, 0, (QUAN_RES5 - 1))];
glidecv[0] = glidecv[0] * gSlide[currentStep] + (qcv * SCALING_N) * (1.0f - gSlide[currentStep]);
- cv = (unsigned int)glidecv[0];
-
- UpdateCV(WRITE_UPDATE_N, 0, &cv);
break;
@@ -1224,10 +1180,7 @@
qcv = calibMap6[(unsigned int)MapFloat(gSeq_cv[currentStep], 0, SCALING_N, 0, (QUAN_RES6 - 1))];
glidecv[0] = glidecv[0] * gSlide[currentStep] + (qcv * SCALING_N) * (1.0f - gSlide[currentStep]);
- cv = (unsigned int)glidecv[0];
-
- UpdateCV(WRITE_UPDATE_N, 0, &cv);
-
+
break;
case S5th:
@@ -1235,9 +1188,6 @@
qcv = calibMap7[(unsigned int)MapFloat(gSeq_cv[currentStep], 0, SCALING_N, 0, (QUAN_RES7 - 1))];
glidecv[0] = glidecv[0] * gSlide[currentStep] + (qcv * SCALING_N) * (1.0f - gSlide[currentStep]);
- cv = (unsigned int)glidecv[0];
-
- UpdateCV(WRITE_UPDATE_N, 0, &cv);
break;
@@ -1246,13 +1196,14 @@
qcv = calibMap8[(unsigned int)MapFloat(gSeq_cv[currentStep], 0, SCALING_N, 0, (QUAN_RES8 - 1))];
glidecv[0] = glidecv[0] * gSlide[currentStep] + (qcv * SCALING_N) * (1.0f - gSlide[currentStep]);
- cv = (unsigned int)glidecv[0];
-
- UpdateCV(WRITE_UPDATE_N, 0, &cv);
break;
}
-
+
+ cv = (unsigned int)glidecv[0];
+
+ UpdateCV(WRITE_UPDATE_N, 0, &cv);
+
for (i = 1; i < 8; ++i)
{
glidecv[i] = glidecv[i] * gSlide[currentStep] + shiftcv[i] * (1.0f - gSlide[currentStep]);
@@ -1435,7 +1386,7 @@
break;
}
- osc.sendOsc(&sendMes);
+ osc.sendOsc(&sendMes);
}
//-------------------------------------------------------------
@@ -1738,7 +1689,7 @@
qmode = (gCtrl[1] * (SCALE_NUM - 1));
- if ((_qmode != qmode) && gMode)
+ if (_qmode != qmode)
{
sendMes.setTopAddress("/scale");
@@ -1969,72 +1920,96 @@
}
// address pattern SYNC & GATE (Type Tag int, float)
- if (!strncmp(msg[0].address+(len-offset)-4, "sync", 4))
+ if (!strncmp(msg[0].address + (len - offset) - 4, "sync", 4))
{
if (msg[2].i != 0) gCLOCKOUT = true;
else gCLOCKOUT = false;
continue;
- } else if (!strncmp(msg[0].address+(len-offset)-4, "gate", 4) && (num != -1)) {
+ } else if (!strncmp(msg[0].address + (len - offset) - 4, "gate", 4) && (num != -1)) {
if (num > 3) continue;
if (msg[2].i != 0) gGATES[num] = true;
else gGATES[num] = false;
continue;
// (touchOSC Control push, toggle)
- } else if (!strncmp(msg[0].address+(len-offset)-5, "fader", 5) && (num != -1)) {
+ } else if (!strncmp(msg[0].address + (len - offset) - 5, "fader", 5) && (num != -1)) {
if (num > 7) continue;
gOSC_cv[num] = msg[2].f * (SCALING_N);
continue;
- } else if (!strncmp(msg[0].address+(len-offset)-9, "multixy1/", 9) && (num != -1)) {
+ } else if (!strncmp(msg[0].address + (len - offset) - 9, "multixy1/", 9) && (num != -1)) {
if (num > 7) continue;
if (msg[1].typeTag[1] == 'f') gOSC_cv[num] = msg[2].f * (SCALING_N);
if (msg[1].typeTag[1] == 'f') gOSC_cv[++num] = msg[3].f * (SCALING_N);
continue;
- } else if (!strncmp(msg[0].address+(len-offset)-12, "multifader1/", 12) && (num != -1)) {
+ } else if (!strncmp(msg[0].address + (len - offset) -12, "multifader1/", 12) && (num != -1)) {
if (num > 7) continue;
if (msg[1].typeTag[1] == 'f') gOSC_cv[num] = msg[2].f * (SCALING_N);
continue;
- } else if (!strncmp(msg[0].address+(len-offset)-10, "sequencer/", 10) && (num != -1)) {
-
+ } else if (!strncmp(msg[0].address + (len - offset) -10, "sequencer/", 10) && (num != -1)) {
if (num > 15) continue;
gSeq_cv[num] = msg[2].f * (SCALING_N);
continue;
- } else if (!strncmp(msg[0].address+(len-offset)-6, "ctrlsw", 6) && (num != -1)) {
+ } else if (!strncmp(msg[0].address + (len - offset) - 6, "ctrlsw", 6) && (num != -1)) {
if (num > 7) continue;
if (msg[2].i != 0) gCtrlSW[num] = true;
else gCtrlSW[num] = false;
continue;
- } else if (!strncmp(msg[0].address+(len-offset)-4, "ctrl", 4) && (num != -1)) {
+ } else if (!strncmp(msg[0].address + (len - offset) - 4, "ctrl", 4) && (num != -1)) {
if (num > 7) continue;
gCtrl[num] = msg[2].f;
continue;
- } else if (!strncmp(msg[0].address+(len-offset)-9, "pulsecnt/", 9) && (num != -1)) {
+ } else if (!strncmp(msg[0].address + (len - offset) - 9, "pulsecnt/", 9) && (num != -1)) {
if (num > 7) continue;
gPulseCount[num] = msg[2].f;
continue;
- } else if (!strncmp(msg[0].address+(len-offset)-9, "gatemode/", 9) && (num != -1)) {
+ } else if (!strncmp(msg[0].address + (len - offset) - 9, "gatemode/", 9) && (num != -1)) {
if (num > 15) continue;
gGateMode[num] = msg[2].f;
continue;
- } else if (!strncmp(msg[0].address+(len-offset)-6, "slide/", 6) && (num != -1)) {
+ } else if (!strncmp(msg[0].address + (len - offset) - 6, "slide/", 6) && (num != -1)) {
if (num > 15) continue;
gSlide[num] = msg[2].f;
continue;
- } else if (!strncmp(msg[0].address+(len-offset)-4, "euca", 4) && (num != -1)) {
+ } else if (!strncmp(msg[0].address + (len - offset-2) - 7, "accent/", 7) && (num != -1)) {
+
+ if (isdigit(msg[0].address[len-3]))
+ {
+ num = msg[0].address[len-3] - '0' - 1;
+ }
+
+ gAccent[num] = msg[2].i;
+ continue;
+
+ } else if (!strncmp(msg[0].address + (len - offset-3) - 7, "accent/", 7) && (num != -1)) {
+
+ if (isdigit(msg[0].address[len-3]))
+ {
+ num = msg[0].address[len-3] - '0' - 1;
+
+ if (isdigit(msg[0].address[len-4]))
+ {
+ num += 10;
+ }
+ }
+
+ gAccent[num] = msg[2].i;
+ continue;
+
+ } else if (!strncmp(msg[0].address + (len - offset) - 4, "euca", 4) && (num != -1)) {
if (num > 5) continue;
gEucA[num] = msg[2].f;
continue;
- } else if (!strncmp(msg[0].address+(len-offset)-4, "eucb", 4) && (num != -1)) {
+ } else if (!strncmp(msg[0].address + (len - offset) - 4, "eucb", 4) && (num != -1)) {
if (num > 5) continue;
gEucB[num] = msg[2].f;
continue;
@@ -2048,6 +2023,88 @@
}
//-------------------------------------------------------------
+// Handller receive Arduino OSC Serial Packet
+
+inline void ReceiveArduinoOSC()
+{
+ static union OSCarg msg[10];
+ static char buf[512] = {0};
+ static int recvlen = 0;
+ static int num, len;
+ //int i = 0;
+ int messagepos = 0;
+ bool bundleflag = false;
+
+ //pc.printf("%s", buf);
+/*
+ while (ardSerial.readable())
+ {
+ buf[i] = ardSerial.getc();
+
+ ++i;
+ ++recvlen;
+
+ if (!bundleflag && buf[i] == '#') // #bundle
+ {
+ messagepos += (16 + i); // skip #bundle & timetag
+ recvlen -= (16 + i);
+
+ bundleflag = true;
+ }
+ }
+*/
+ do {
+ if (bundleflag)
+ {
+ messagepos += 4;
+ recvlen -= 4;
+
+ if (recvlen <= 2)
+ {
+ bundleflag = false;
+ break;
+ }
+ }
+
+ if (getOSCmsg(buf + messagepos, msg) == -1) continue;
+
+ len = strlength(msg[0].address);
+
+
+ if (isdigit(msg[0].address[len-1]))
+ {
+ num = msg[0].address[len-1] - '0' - 1;
+
+ } else {
+
+ num = -1;
+ }
+
+ if (!strncmp(msg[0].address+(len-1)-2, "sw", 2))
+ {
+ if (num > 3) continue;
+ if (msg[2].i != 0) gArdSW[num] = true;
+ else gArdSW[num] = false;
+ continue;
+
+ } else if (!strncmp(msg[0].address+(len-1)-3, "pot", 3) && (num != -1)) {
+ if (num > 3 && (msg[2].i < 1024)) continue;
+ gArdCtrl[num] = msg[2].i;
+ continue;
+
+ } else if (!strncmp(msg[0].address+(len-1)-2, "ch", 2) && (num != -1)) {
+ if (num > 3 && (msg[2].i < 4096)) continue;
+ gArdCV[num] = msg[2].i;
+ continue;
+
+ } else {
+ continue;
+ }
+
+ } while (bundleflag);
+}
+
+//-------------------------------------------------------------
// Euclidean Sequencer
void EuclideanSeq(int trigger, bool reset, bool gatesoff) {
@@ -2865,7 +2922,7 @@
char col[2];
char ch[2];
- if(euclid)
+ if (euclid)
{
strcpy(address, MATRIX_ADDRESS);
@@ -2877,7 +2934,7 @@
sprintf(col, "%d", column + 1);
strcat(address, col);
- if(euclid)
+ if (euclid)
{
strcat(address, "/");
--- a/mbed-rpc.lib Fri Aug 07 12:47:35 2015 +0000 +++ b/mbed-rpc.lib Sat Jan 02 23:45:04 2016 +0000 @@ -1,1 +1,1 @@ -http://mbed.org/teams/mbed-official/code/mbed-rpc/#d3e03663a6f4 +http://mbed.org/teams/mbed-official/code/mbed-rpc/#325e3da833e1
--- a/mbed.bld Fri Aug 07 12:47:35 2015 +0000 +++ b/mbed.bld Sat Jan 02 23:45:04 2016 +0000 @@ -1,1 +1,1 @@ -http://mbed.org/users/mbed_official/code/mbed/builds/b9ad9a133dc7 \ No newline at end of file +http://mbed.org/users/mbed_official/code/mbed/builds/4336505e4b1c \ No newline at end of file