OSC-CV Converter
Dependencies: Bonjour OSCReceiver TextLCD mbed mbed-rpc BurstSPI DebouncedInterrupt FastIO MIDI OSC OSCtoCV ClockControl
OSC to CV Converter
http://gtbts.tumblr.com/post/125663817741/osc-to-cv-converter-ver2-mbed-osctocv
Diff: main.cpp
- Revision:
- 19:467f98c51e2d
- Parent:
- 17:55e5136790a6
- Child:
- 20:a44f4a024902
--- a/main.cpp Sun Jan 03 00:15:44 2016 +0000 +++ b/main.cpp Mon Jan 04 12:45:30 2016 +0000 @@ -24,10 +24,8 @@ #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" @@ -187,7 +185,6 @@ 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); @@ -542,7 +539,6 @@ case MODE_SEQ: // Shift Sequencer mode - //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); @@ -2023,88 +2019,6 @@ } //------------------------------------------------------------- -// 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) { @@ -2918,32 +2832,16 @@ } inline char * SetMatrixAddress(int row, int column, bool euclid) { + static char address[32]; - char col[2]; - char ch[2]; if (euclid) { - strcpy(address, MATRIX_ADDRESS); + sprintf(address, "%s%d/%d", MATRIX_ADDRESS, column + 1, row + 1); } else { - strcpy(address, STEP_INDICATOR_ADDRESS); - } - - sprintf(col, "%d", column + 1); - strcat(address, col); - - if (euclid) - { - strcat(address, "/"); - - sprintf(ch, "%d", row + 1); - strcat(address, ch); - - } else { - - strcat(address, "/1"); + sprintf(address, "%s%d/1", STEP_INDICATOR_ADDRESS, column + 1); } return address;