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 24:99045b0f7c4a, committed 2016-01-28
- Comitter:
- casiotone401
- Date:
- Thu Jan 28 11:40:56 2016 +0000
- Parent:
- 23:2cb7fad36ce0
- Child:
- 25:6b29d7e631cb
- Commit message:
- bug fix & added beats seq
Changed in this revision
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/ClockControl.lib Thu Jan 28 11:40:56 2016 +0000 @@ -0,0 +1,1 @@ +http://developer.mbed.org/users/JST2011/code/ClockControl/#a6d100de3aee
--- a/OSCtoCV.lib Sun Jan 17 10:48:23 2016 +0000 +++ b/OSCtoCV.lib Thu Jan 28 11:40:56 2016 +0000 @@ -1,1 +1,1 @@ -https://developer.mbed.org/users/casiotone401/code/OSCtoCV/#cd43a974c54c +https://developer.mbed.org/users/casiotone401/code/OSCtoCV/#981b62bb5c87
--- a/main.cpp Sun Jan 17 10:48:23 2016 +0000
+++ b/main.cpp Thu Jan 28 11:40:56 2016 +0000
@@ -33,6 +33,7 @@
#include "OSCReceiver.h"
#include "mbedOSC.h"
#include "MIDI.h"
+#include "ClockControl.h" // https://developer.mbed.org/users/JST2011/code/ClockControl/
#include "OSCtoCV.h"
#include "OSCtoCV_Sequencer.h"
#include "OSCtoCV_GateSequencer.h"
@@ -40,6 +41,7 @@
#include "OSCtoCV_Random.h"
#include "OSCtoCV_LFO.h"
+
#include <stdlib.h>
#include <ctype.h>
#include <math.h>
@@ -47,15 +49,16 @@
//-------------------------------------------------------------
// Macros
-#define MODE_Calb 0 // Calibration (for VCO Tuning)
+#define MODE_CLB 0 // Calibration (for VCO Tuning)
#define MODE_OSC 1 // Mode OSCtoCV
#define MODE_SEQ 2 // Mode Shift Sequencer
#define MODE_185 3 // Mode M185 Sequencer
-#define MODE_EUC 4 // Mode Euclidean Sequencer
-#define MODE_RND 5 // Mode xshift Random Generator
-#define MODE_LFO 6 // Mode Stepped LFO
+#define MODE_437 4 // Mode 437 Sequencer
+#define MODE_EUC 5 // Mode Euclidean Sequencer
+#define MODE_RND 6 // Mode xshift Random Generator
+#define MODE_LFO 7 // Mode Stepped LFO
-#define MODE_TOTAL 7 // Modes
+#define MODE_TOTAL 8 // Modes
//-------------------------------------------------------------
// Functions
@@ -99,26 +102,26 @@
float pot, _pot;
int bpm;
- InitOSCCV();
-
- InitEuclideanSeq(); // Init Euclidean Sequencer
+ InitOSCCV();
gCtrl[3] = _pot = pot = gMode = 0;
- gGlide = gAIN.read();
-
+
+
+// Init LCD
LCD();
+
gLCD.locate( 0, 1 );
gLCD.printf("12345678 G>>%3.2f", gGlide);
-
+
// Main loop
while (1)
- {
- LCD(); // Check Text LCD
+ {
+ LCD(); // Check Text LCD Mode Status
pot = gAIN.read(); // Update glide value
if (!pot) // when glide pot value == 0
- { // use gCtrl[3] value
+ { // use gCtrl[3] value (MODE_OSC)
if (abs(gCtrl[3] - _pot) > 0.01f)
{
_pot = gGlide = gCtrl[3];
@@ -146,42 +149,65 @@
case MODE_SEQ: // Shift Sequencer mode
- ShiftCVSeq(GateSeq(bpm, N16TH, GATE1, 3, NON_INVERT, GATESOUT_OFF, SYNC_ON), gCtrlSW[0]);
+ ShiftCVSeq(GateSeq(bpm, N16TH, GATE1, (gCtrl[6] * 5), NON_INVERT, GATESOUT_OFF, SYNC_ON), gCtrlSW[0], CV_CHANNEL8);
GateSeq(bpm, N8TH, GATE2, 3, NON_INVERT, GATESOUT_ON, SYNC_OFF);
if (gCtrlSW[3])
- {
- EuclideanSeq(GateSeq(bpm, N16TH, SUBGATE, 1, NON_INVERT, GATESOUT_OFF, SYNC_OFF), gCtrlSW[0], GATESOUT_OFF);
+ { // euclid sequencer auto offset
+ EuclideanSeq(GateSeq(bpm, N16TH, SUBGATE, 3, NON_INVERT, GATESOUT_OFF, SYNC_OFF), gCtrlSW[0], GATESOUT_OFF, true);
+
+ } else {
+ // beats sequencer
+ BeatsSeq(GateSeq(bpm, N16TH, SUBGATE, 3, NON_INVERT, GATESOUT_OFF, SYNC_OFF), gCtrlSW[0], GATESOUT_OFF);
}
break;
case MODE_185: // M185 Sequencer mode
- M185Seq(GateSeq(bpm, N16TH, GATE1, 3, NON_INVERT, GATESOUT_OFF, SYNC_ON), gCtrlSW[0]);
+ M185Seq(GateSeq(bpm, N16TH, GATE1, (gCtrl[6] * 5), NON_INVERT, GATESOUT_OFF, SYNC_ON), gCtrlSW[0], CV_CHANNEL8);
+ GateSeq(bpm, N8TH, GATE2, 3, NON_INVERT, GATESOUT_ON, SYNC_OFF);
+
+ if (gCtrlSW[3])
+ { // euclid sequencer auto offset
+ EuclideanSeq(GateSeq(bpm, N16TH, SUBGATE, 3, NON_INVERT, GATESOUT_OFF, SYNC_OFF), gCtrlSW[0], GATESOUT_OFF, true);
+
+ } else {
+ // beats sequencer
+ BeatsSeq(GateSeq(bpm, N16TH, SUBGATE, 3, NON_INVERT, GATESOUT_OFF, SYNC_OFF), gCtrlSW[0], GATESOUT_OFF);
+ }
+ break;
+
+ case MODE_437: // F437 sequencer
+ // random gated shift sequence ch1 ~ ch6
+ PolyCVSeq(GateSeq(bpm, N16TH, GATE1, (gCtrl[6] * 5), NON_INVERT, GATESOUT_OFF, SYNC_ON), gCtrlSW[0]);
GateSeq(bpm, N8TH, GATE2, 3, NON_INVERT, GATESOUT_ON, SYNC_OFF);
if (gCtrlSW[3])
- {
- EuclideanSeq(GateSeq(bpm, N16TH, SUBGATE, 1, NON_INVERT, GATESOUT_OFF, SYNC_OFF), gCtrlSW[0], GATESOUT_OFF);
+ { // euclid sequencer auto offset
+ EuclideanSeq(GateSeq(bpm, N16TH, SUBGATE, 3, NON_INVERT, GATESOUT_OFF, SYNC_OFF), gCtrlSW[0], GATESOUT_OFF, true);
+
+ } else {
+ // beats sequencer
+ BeatsSeq(GateSeq(bpm, N16TH, SUBGATE, 3, NON_INVERT, GATESOUT_OFF, SYNC_OFF), gCtrlSW[0], GATESOUT_OFF);
}
break;
-
+
case MODE_EUC: // Euclidean Sequencer mode
- 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);
+ ShiftCVSeq(GateSeq(bpm, N1ST, SUBGATE, (gCtrl[6] * 5), NON_INVERT, GATESOUT_OFF, SYNC_OFF), gCtrlSW[0], CV_CHANNEL8);
+ EuclideanSeq(GateSeq(bpm, N16TH, GATE1, 3, NON_INVERT, GATESOUT_OFF, SYNC_OFF), gCtrlSW[0], GATESOUT_ON, false);
break;
-
+
case MODE_RND: // Random CV Generator mode
-
- RandomCVGenerator(GateSeq(bpm, N32TH, GATE1, 3, NON_INVERT, GATESOUT_OFF, SYNC_ON));
+
+ RandomCVGenerator(GateSeq(bpm, N32TH, GATE1, (gCtrl[6] * 5), NON_INVERT, GATESOUT_OFF, SYNC_ON));
break;
case MODE_LFO: // Stepped LFO mode
-
- SteppedLFO();
+
+ SteppedLFO(CV_CHANNEL1, true); // LFO out ch1 ~ ch8
break;
-
+
default: // CV Calibration mode
CalibrationCV();
@@ -206,29 +232,8 @@
{
int i;
-//Clock Up --------------------------------------------------------------------
- LPC_SC->PLL0CON = 0x00; /* PLL0 Disable */
- LPC_SC->PLL0FEED = 0xAA;
- LPC_SC->PLL0FEED = 0x55;
-
- LPC_SC->CCLKCFG = 0x00000003; /* Select Clock Divisor = 4 */
- LPC_SC->PLL0CFG = 0x00020038; /* configure PLL0 */
- LPC_SC->PLL0FEED = 0xAA; /* divide by 3 then multiply by 50 */
- LPC_SC->PLL0FEED = 0x55; /* PLL0 frequency = 400,000,000 */
-
- LPC_SC->PLL0CON = 0x01; /* PLL0 Enable */
- LPC_SC->PLL0FEED = 0xAA;
- LPC_SC->PLL0FEED = 0x55;
- while (!(LPC_SC->PLL0STAT & (1<<26)));/* Wait for PLOCK0 */
-
- LPC_SC->PLL0CON = 0x03; /* PLL0 Enable & Connect */
- LPC_SC->PLL0FEED = 0xAA;
- LPC_SC->PLL0FEED = 0x55;
- while (!(LPC_SC->PLL0STAT & ((1<<25) | (1<<24))));/* Wait for PLLC0_STAT & PLLE0_STAT */
-
- SystemCoreClockUpdate();
-//-----------------------------------------------------------------------------
-
+// Set System Frequency 120Mhz
+ setSystemFrequency(0x3, 0x1, 15, 1);
wait(0.5);
// Setup Ethernet
@@ -266,11 +271,26 @@
// Init Sequence Data
for (i = 0; i < 16; ++i)
{
- gSeq_cv[i] = calibMap1[69] * SCALING_N;
+ gSeq_cv[i] = (calibMap1[69] * SCALING_N);
+ }
+
+ for (i = 0; i < 8; ++i)
+ {
+ g185_cv[i] = (calibMap1[69] * SCALING_N);
+ gBeatsLevel[i] = gBeatsDecay[i] = 1;
}
-// Init M185 Reset Count
- gCtrl[4] = 1;
+// Init Sequencer Reset Count
+ gCtrl[4] = gCtrl[5] = gCtrl[7] = 1;
+
+// Init Sequencer Gate Length
+ gCtrl[6] = 0.6;
+
+// Init Euclidean Sequencer
+ InitEuclideanSeq();
+
+// Init Glide value
+ gGlide = gAIN.read();
// Set OSC message for sending
sendMes.setIp(touchOSCAddress);
@@ -280,7 +300,7 @@
wait(0.5);
gPoller.attach_us(&NetPoll, POLLING_INTERVAL); // Ticker Polling
- wait(1.8);
+ wait(1.7);
}
//-------------------------------------------------------------
@@ -293,7 +313,7 @@
switch (gMode)
{
- case MODE_Calb:
+ case MODE_CLB:
cv = (unsigned int)(calibMap1[69] * SCALING_N); // A880.0Hz
@@ -465,7 +485,7 @@
gCLOCKOUT = gGATES[0] = gGATES[1] = gGATES[2] = gGATES[3] = false;
gSubModeCount1 = gSubModeCount2 = 0;
- if (gMode == MODE_SEQ || gMode == MODE_185 || gMode == MODE_EUC || gMode == MODE_RND || gMode == MODE_LFO)
+ if (gMode != MODE_CLB || gMode != MODE_OSC)
{
gTimer.start(); // Sequencer Timer Start
midi.begin(1);
@@ -492,7 +512,7 @@
switch (gMode)
{
- case MODE_Calb:
+ case MODE_CLB:
gLCD.locate( 9, 0 );
gLCD.printf("CLB|880");
@@ -532,6 +552,14 @@
sendMes.setArgs("s", "M185 SEQ");
break;
+
+ case MODE_437:
+ gLCD.locate( 9, 0 );
+ gLCD.printf("437|");
+
+ sendMes.setArgs("s", "F437 SEQ");
+
+ break;
case MODE_EUC:
gLCD.locate( 9, 0 );
@@ -540,7 +568,23 @@
sendMes.setArgs("s", "Euclidean SEQ");
break;
+
+ case MODE_RND:
+ gLCD.locate( 9, 0 );
+ gLCD.printf("RND|");
+
+ sendMes.setArgs("s", "Xorshift Random");
+
+ break;
+ case MODE_LFO:
+ gLCD.locate( 9, 0 );
+ gLCD.printf("LFO|");
+
+ sendMes.setArgs("s", "Stepped LFO");
+
+ break;
+
default:
break;
}
@@ -697,9 +741,9 @@
inline void onUDPSocketEvent(UDPSocketEvent e)
{
static union OSCarg msg[10];
- static char buf[896] = {0};
+ static char buf[1024] = {0};
static int recvlen;
- static int num, len, offset;
+ static int num, numrow, len, offset;
int messagepos = 0;
bool bundleflag = false;
@@ -709,7 +753,7 @@
{
case UDPSOCKET_READABLE: // The only event for now
- recvlen = gUdp.recvfrom(buf, 896, &host); // packet length
+ recvlen = gUdp.recvfrom(buf, 1024, &host); // packet length
if (recvlen <= 0) break;
@@ -779,11 +823,16 @@
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) - 5, "m185/", 5) && (num != -1)) {
+ if (num > 7) continue;
+ if (msg[1].typeTag[1] == 'f') g185_cv[num] = msg[2].f * (SCALING_N);
+ continue;
+
} 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);
@@ -810,28 +859,38 @@
gGateMode[num] = msg[2].f;
continue;
+ } else if (!strncmp(msg[0].address + (len - offset) - 9, "g185mode/", 9) && (num != -1)) {
+ if (num > 7) continue;
+ gGateMode185[num] = msg[2].f;
+ continue;
+
} 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-2) - 7, "accent/", 7) && (num != -1)) {
+ } else if (!strncmp(msg[0].address + (len - offset) - 9, "slide185/", 9) && (num != -1)) {
+ if (num > 7) continue;
+ gSlide185[num] = msg[2].f;
+ continue;
- if (isdigit(msg[0].address[len-3]))
+ } 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;
+ 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)) {
+ } else if (!strncmp(msg[0].address + (len - offset - 3) - 7, "accent/", 7) && (num != -1)) {
- if (isdigit(msg[0].address[len-3]))
+ if (isdigit(msg[0].address[len - 3]))
{
- num = msg[0].address[len-3] - '0' - 1;
+ num = msg[0].address[len - 3] - '0' - 1;
- if (isdigit(msg[0].address[len-4]))
+ if (isdigit(msg[0].address[len - 4]))
{
num += 10;
}
@@ -840,7 +899,77 @@
gAccent[num] = msg[2].i;
continue;
- } else if (!strncmp(msg[0].address + (len - offset) - 4, "euca", 4) && (num != -1)) {
+ } else if (!strncmp(msg[0].address + (len - offset - 3) - 6, "185acc/", 6) && (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;
+ }
+ }
+
+ gAccent185[num] = msg[2].i;
+ continue;
+
+ } else if (!strncmp(msg[0].address + (len - offset - 2) - 3, "bm/", 3) && (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;
+ }
+ }
+
+ if (isdigit(msg[0].address[len - 1]))
+ {
+ numrow = msg[0].address[len - 1] - '0' - 1;
+ }
+
+ gBeatsMatrix[numrow][num] = msg[2].i;
+ continue;
+
+ } else if (!strncmp(msg[0].address + (len - offset - 3) - 3, "bm/", 3) && (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;
+ }
+ }
+
+ if (isdigit(msg[0].address[len - 1]))
+ {
+ numrow = msg[0].address[len - 1] - '0' - 1;
+ }
+
+ gBeatsMatrix[numrow][num] = msg[2].i;
+ continue;
+
+ } else if (!strncmp(msg[0].address + (len - offset) - 4, "bpc/", 4) && (num != -1)) {
+ if (num > 15) continue;
+ gPulseCountBeats[num] = msg[2].f;
+ continue;
+
+ } else if (!strncmp(msg[0].address + (len - offset) - 4, "blv/", 4) && (num != -1)) {
+ if (num > 7) continue;
+ gBeatsLevel[num] = msg[2].f;
+ continue;
+
+ } else if (!strncmp(msg[0].address + (len - offset) - 4, "bdc/", 4) && (num != -1)) {
+ if (num > 7) continue;
+ gBeatsDecay[num] = msg[2].f;
+ continue;
+
+ } else if (!strncmp(msg[0].address + (len - offset) - 4, "euca", 4) && (num != -1)) {
if (num > 5) continue;
gEucA[num] = msg[2].f;
continue;
@@ -852,7 +981,7 @@
} else if (!strncmp(msg[0].address + (len - offset) - 3, "acv", 3) && (num != -1)) {
if (num > 3) continue;
- gArdCV[num] = msg[2].f * (SCALING_N);
+ gArdCV[num] = msg[2].i;
continue;
} else if (!strncmp(msg[0].address + (len - offset) - 3, "pot", 3) && (num != -1)) {
@@ -873,4 +1002,3 @@
} while (bundleflag);
}
}
-