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 9:1ac3d135d965, committed 2013-03-02
- Comitter:
- casiotone401
- Date:
- Sat Mar 02 00:14:57 2013 +0000
- Parent:
- 8:fe50078d6b80
- Child:
- 10:ccfeb687c3f2
- Commit message:
- bug fix & change quantize data
Changed in this revision
| main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/main.cpp Sun Feb 17 08:47:25 2013 +0000
+++ b/main.cpp Sat Mar 02 00:14:57 2013 +0000
@@ -46,11 +46,11 @@
#define MODE_NUM 8 // Modes
-#define QUAN_RES1 116 // Quantize voltage Steps
-#define QUAN_RES2 69
-#define QUAN_RES3 68
+#define QUAN_RES1 115 // Quantize voltage Steps
+#define QUAN_RES2 67
+#define QUAN_RES3 67
#define QUAN_RES4 17
-#define QUAN_RES5 58
+#define QUAN_RES5 57
#define SPI_RATE 40000000 // 40Mbps SPI Clock
#define SCALING_N 38400.0
@@ -114,7 +114,7 @@
void SetCV(void);
void SeqCV(int);
void CheckModeSW(void);
-void CVMeter(int, const unsigned int*);
+inline void CVMeter(int, const unsigned int*);
void LCD();
void WriteCustomChar(unsigned char, unsigned char*);
int SetupEthNetIf(void);
@@ -126,92 +126,89 @@
// Chromatic Scale
const float calibMap1[QUAN_RES1] = {
-0.00663080, 0.01433030, 0.02202980, 0.02972930, 0.03742880,
-0.04512830, 0.05282781, 0.06052731, 0.06822681, 0.07592630,
-0.08362581, 0.09132531, 0.09902481, 0.10672431, 0.11442380,
-0.12212331, 0.12951356, 0.13671936, 0.14392516, 0.15113096,
-0.15833676, 0.16554256, 0.17274836, 0.17995416, 0.18715996,
-0.19436575, 0.20157155, 0.20877735, 0.21598317, 0.22318897,
-0.23039477, 0.23760056, 0.24480636, 0.25202271, 0.25926629,
-0.26650983, 0.27375340, 0.28099698, 0.28824055, 0.29548413,
-0.30272770, 0.30997124, 0.31721482, 0.32445839, 0.33170196,
-0.33894554, 0.34618911, 0.35343266, 0.36067623, 0.36791980,
-0.37516347, 0.38241133, 0.38965923, 0.39690709, 0.40415496,
-0.41140282, 0.41865072, 0.42589858, 0.43314645, 0.44039431,
-0.44764221, 0.45489007, 0.46213794, 0.46938580, 0.47663370,
-0.48388156, 0.49112943, 0.49837729, 0.50566339, 0.51296055,
-0.52025765, 0.52755481, 0.53485191, 0.54214907, 0.54944617,
-0.55674326, 0.56404042, 0.57133752, 0.57863468, 0.58593178,
-0.59322894, 0.60052603, 0.60782319, 0.61512029, 0.62241745,
-0.62976688, 0.63714498, 0.64452308, 0.65190119, 0.65927929,
-0.66665739, 0.67403549, 0.68141359, 0.68879169, 0.69616979,
-0.70354789, 0.71092600, 0.71830410, 0.72568226, 0.73306036,
-0.74043846, 0.74781656, 0.75820577, 0.76986063, 0.78151548,
-0.79317033, 0.80482519, 0.81648004, 0.82813489, 0.83978975,
-0.85144460, 0.86309946, 0.87475431, 0.90686423, 0.93941462,
-0.97196496
+0.00559238, 0.01324014, 0.02088790, 0.02853566, 0.03618342,
+0.04383118, 0.05147894, 0.05912671, 0.06677447, 0.07442223,
+0.08206999, 0.08971775, 0.09736551, 0.10501327, 0.11266103,
+0.12030879, 0.12775089, 0.13486665, 0.14198242, 0.14909819,
+0.15621395, 0.16332972, 0.17044549, 0.17756125, 0.18467702,
+0.19179279, 0.19890857, 0.20602433, 0.21314010, 0.22025587,
+0.22737163, 0.23448740, 0.24160317, 0.24871893, 0.25587305,
+0.26303557, 0.27019811, 0.27736065, 0.28452319, 0.29168573,
+0.29884824, 0.30601078, 0.31317332, 0.32033587, 0.32749838,
+0.33466092, 0.34182346, 0.34898600, 0.35614854, 0.36331105,
+0.37047359, 0.37764084, 0.38481620, 0.39199156, 0.39916691,
+0.40634227, 0.41351759, 0.42069295, 0.42786831, 0.43504366,
+0.44221902, 0.44939438, 0.45656973, 0.46374506, 0.47092041,
+0.47809577, 0.48527113, 0.49244648, 0.49962184, 0.50685716,
+0.51409578, 0.52133441, 0.52857304, 0.53581166, 0.54305035,
+0.55028898, 0.55752760, 0.56476623, 0.57200485, 0.57924354,
+0.58648217, 0.59372079, 0.60095942, 0.60819805, 0.61543667,
+0.62267536, 0.62996829, 0.63728690, 0.64460552, 0.65192413,
+0.65924275, 0.66656137, 0.67387998, 0.68119860, 0.68851727,
+0.69583589, 0.70315450, 0.71047312, 0.71779174, 0.72511035,
+0.73242897, 0.73974758, 0.74706620, 0.75810421, 0.77163076,
+0.78515732, 0.79868382, 0.81221038, 0.82573694, 0.83926344,
+0.85279000, 0.86631656, 0.88188213, 0.90110368, 0.92032516
};
// Major Scale
const float calibMap2[QUAN_RES2] = {
-0.00663080, 0.01433030, 0.02972930, 0.04512830, 0.05282781,
-0.06822681, 0.08362581, 0.09902481, 0.10672431, 0.12212331,
-0.13671936, 0.14392516, 0.15833676, 0.17274836, 0.18715996,
-0.19436575, 0.20877735, 0.22318897, 0.23039477, 0.24480636,
-0.25926629, 0.27375340, 0.28099698, 0.29548413, 0.30997124,
-0.31721482, 0.33170196, 0.34618911, 0.36067623, 0.36791980,
-0.38241133, 0.39690709, 0.40415496, 0.41865072, 0.43314645,
-0.44764221, 0.45489007, 0.46938580, 0.48388156, 0.49112943,
-0.50566339, 0.52025765, 0.53485191, 0.54214907, 0.55674326,
-0.57133752, 0.57863468, 0.59322894, 0.60782319, 0.62241745,
-0.62976688, 0.64452308, 0.65927929, 0.66665739, 0.68141359,
-0.69616979, 0.71092600, 0.71830410, 0.73306036, 0.74781656,
-0.75820577, 0.78151548, 0.80482519, 0.82813489, 0.83978975,
-0.86309946, 0.90686423, 0.93941462
+0.01324014, 0.02853566, 0.03618342, 0.05147894, 0.06677447,
+0.08206999, 0.08971775, 0.10501327, 0.12030879, 0.12775089,
+0.14198242, 0.15621395, 0.17044549, 0.17756125, 0.19179279,
+0.20602433, 0.21314010, 0.22737163, 0.24160317, 0.25587305,
+0.26303557, 0.27736065, 0.29168573, 0.29884824, 0.31317332,
+0.32749838, 0.34182346, 0.34898600, 0.36331105, 0.37764084,
+0.38481620, 0.39916691, 0.41351759, 0.42786831, 0.43504366,
+0.44939438, 0.46374506, 0.47092041, 0.48527113, 0.49962184,
+0.51409578, 0.52133441, 0.53581166, 0.55028898, 0.55752760,
+0.57200485, 0.58648217, 0.60095942, 0.60819805, 0.62267536,
+0.63728690, 0.64460552, 0.65924275, 0.67387998, 0.68851727,
+0.69583589, 0.71047312, 0.72511035, 0.73242897, 0.74706620,
+0.77163076, 0.79868382, 0.81221038, 0.83926344, 0.86631656,
+0.88188213, 0.92032516
};
// Dorian Scale
const float calibMap3[QUAN_RES3] = {
-0.00663080, 0.01433030, 0.02972930, 0.04512830, 0.06052731,
-0.06822681, 0.08362581, 0.09902481, 0.10672431, 0.12212331,
-0.13671936, 0.15113096, 0.15833676, 0.17274836, 0.18715996,
-0.19436575, 0.20877735, 0.22318897, 0.23760056, 0.24480636,
-0.25926629, 0.27375340, 0.28099698, 0.29548413, 0.30997124,
-0.32445839, 0.33170196, 0.34618911, 0.36067623, 0.36791980,
-0.38241133, 0.39690709, 0.41140282, 0.41865072, 0.43314645,
-0.44764221, 0.45489007, 0.46938580, 0.48388156, 0.49837729,
-0.50566339, 0.52025765, 0.53485191, 0.54214907, 0.55674326,
-0.57133752, 0.58593178, 0.59322894, 0.60782319, 0.62241745,
-0.62976688, 0.64452308, 0.65927929, 0.67403549, 0.68141359,
-0.69616979, 0.71092600, 0.71830410, 0.73306036, 0.74781656,
-0.76986063, 0.78151548, 0.80482519, 0.82813489, 0.83978975,
-0.86309946, 0.90686423, 0.97196496
+0.01324014, 0.02853566, 0.04383118, 0.05147894, 0.06677447,
+0.08206999, 0.08971775, 0.10501327, 0.12030879, 0.13486665,
+0.14198242, 0.15621395, 0.17044549, 0.17756125, 0.19179279,
+0.20602433, 0.22025587, 0.22737163, 0.24160317, 0.25587305,
+0.26303557, 0.27736065, 0.29168573, 0.30601078, 0.31317332,
+0.32749838, 0.34182346, 0.34898600, 0.36331105, 0.37764084,
+0.39199156, 0.39916691, 0.41351759, 0.42786831, 0.43504366,
+0.44939438, 0.46374506, 0.47809577, 0.48527113, 0.49962184,
+0.51409578, 0.52133441, 0.53581166, 0.55028898, 0.56476623,
+0.57200485, 0.58648217, 0.60095942, 0.60819805, 0.62267536,
+0.63728690, 0.65192413, 0.65924275, 0.67387998, 0.68851727,
+0.69583589, 0.71047312, 0.72511035, 0.73974758, 0.74706620,
+0.77163076, 0.79868382, 0.81221038, 0.83926344, 0.86631656,
+0.90110368, 0.92032516
};
// 5th
const float calibMap4[QUAN_RES4] = {
-0.00663080, 0.06052731, 0.11442380, 0.16554256, 0.21598317,
-0.26650983, 0.31721482, 0.36791980, 0.41865072, 0.46938580,
-0.52025765, 0.57133752, 0.62241745, 0.67403549, 0.72568226,
-0.79317033, 0.87475431
-
+0.01324014, 0.06677447, 0.12030879, 0.17044549, 0.22025587,
+0.27019811, 0.32033587, 0.37047359, 0.42069295, 0.47092041,
+0.52133441, 0.57200485, 0.62267536, 0.67387998, 0.72511035,
+0.79868382, 0.90110368
};
// Whole tone
const float calibMap5[QUAN_RES5] = {
-0.00663080, 0.02202980, 0.03742880, 0.05282781, 0.06822681,
-0.08362581, 0.09902481, 0.11442380, 0.12951356, 0.14392516,
-0.15833676, 0.17274836, 0.18715996, 0.20157155, 0.21598317,
-0.23039477, 0.24480636, 0.25926629, 0.27375340, 0.28824055,
-0.30272770, 0.31721482, 0.33170196, 0.34618911, 0.36067623,
-0.37516347, 0.38965923, 0.40415496, 0.41865072, 0.43314645,
-0.44764221, 0.46213794, 0.47663370, 0.49112943, 0.50566339,
-0.52025765, 0.53485191, 0.54944617, 0.56404042, 0.57863468,
-0.59322894, 0.60782319, 0.62241745, 0.63714498, 0.65190119,
-0.66665739, 0.68141359, 0.69616979, 0.71092600, 0.72568226,
-0.74043846, 0.75820577, 0.78151548, 0.80482519, 0.82813489,
-0.85144460, 0.87475431, 0.93941462
-
+0.01324014, 0.02853566, 0.04383118, 0.05912671, 0.07442223,
+0.08971775, 0.10501327, 0.12030879, 0.13486665, 0.14909819,
+0.16332972, 0.17756125, 0.19179279, 0.20602433, 0.22025587,
+0.23448740, 0.24871893, 0.26303557, 0.27736065, 0.29168573,
+0.30601078, 0.32033587, 0.33466092, 0.34898600, 0.36331105,
+0.37764084, 0.39199156, 0.40634227, 0.42069295, 0.43504366,
+0.44939438, 0.46374506, 0.47809577, 0.49244648, 0.50685716,
+0.52133441, 0.53581166, 0.55028898, 0.56476623, 0.57924354,
+0.59372079, 0.60819805, 0.62267536, 0.63728690, 0.65192413,
+0.66656137, 0.68119860, 0.69583589, 0.71047312, 0.72511035,
+0.73974758, 0.75810421, 0.78515732, 0.81221038, 0.83926344,
+0.86631656, 0.90110368
};
//-------------------------------------------------------------
@@ -232,13 +229,13 @@
float gOSC_cv[8];
float gSeq_cv1[8];
float gSeq_cv2[8];
-volatile float gGlide;
+float gGlide;
volatile int gMode;
// Variables for Control
-float gCtrl[2];
-volatile int gCtrlSW[4];
+float gCtrl[2];
+volatile int gCtrlSW[4];
//-------------------------------------------------------------
// mbed Functions
@@ -249,7 +246,7 @@
DigitalOut gSYNCMODE(p15); // SYNC DAC8568
DigitalOut gLDAC(p16); // LDAC DAC8568
-DigitalOut gGATES[4] = {p22, p23, p24, p25}; // GateOut
+DigitalOut gGATES[4] = {p23, p24, p24, p25}; // GateOut
DigitalOut gLEDS[4] = {p18, p19, p20, p21}; // LED
DigitalOut gCLOCKOUT(p26); // ClockOut
@@ -337,7 +334,7 @@
UpdateGate(bpm, NDOT8, GATE3, 3, 0);
UpdateGate(bpm, TRIP4, GATE4, 3, 0);
- continue;
+ break;
} else if (gCtrlSW[2] == 1 && gCtrlSW[3] == 0) { // Sequencer Mode2 (if gCtrlSW[2] ON)
@@ -346,7 +343,7 @@
SeqCV((UpdateGate(bpm, NDOT4, GATE3, 3, 0))); // Do shift ch 7
SeqCV((UpdateGate(bpm, TRIP8, GATE4, 3, 0))); // Do shift ch 8
- continue;
+ break;
} else if (gCtrlSW[3] == 1) { // Sequencer Mode3 (if gCtrlSW[3] ON)
// (ch6,7,8, short loop)
@@ -355,13 +352,13 @@
SeqCV((UpdateGate(bpm, NDOT8, GATE3, 3, 0))); // Do shift ch 7
SeqCV((UpdateGate(bpm, TRIP4, GATE4, 3, 0))); // Do shift ch 8
- continue;
+ break;
}
default:
SetCV();
- continue;
+ break;
}
}
}
@@ -664,7 +661,7 @@
case MODE_Calb:
- cv[ch] = 19212; // A440.0Hz
+ cv[ch] = 19212; // A880.0Hz
gGATES[0] = gGATES[1] = gGATES[2] = gGATES[3] = 1;
gLEDS[0] = gLEDS[1] = gLEDS[2] = gLEDS[3] = 1;
@@ -997,11 +994,11 @@
//-------------------------------------------------------------
// CV meter
-void CVMeter(int ch, const unsigned int *level)
+inline void CVMeter(int ch, const unsigned int *level)
{
unsigned int cvmeter;
- cvmeter = *level / (SCALING_N / 7.9);
+ cvmeter = *level / (SCALING_N / 7.9f);
gLCD.locate ( ch, 0 );
gLCD.putc(cvmeter); // put custom char