Music key reference. From C to B, major and minor
Dependencies: EFM32_SegmentLCD IOFuncLib mbed
Diff: midiFunctions.h
- Revision:
- 0:45c4e9ef5b03
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/midiFunctions.h Sun Jun 28 12:57:01 2015 +0000
@@ -0,0 +1,48 @@
+#include <string>
+#include "IOFuncLib.h"
+genFunctions fnz;
+
+
+int getScala(char notaf, bool tiposcala)
+{
+ //idx= nota da calcolare NB 0-6
+ //tiposcala true=maggiore, flase=minore
+ int idx = kcount;
+ int scalamaggiore[] = {0,2,2,1,2,2,2 };
+ int scalaminore[] = {0,2,1,2,2,1,2 };
+ notaf = fnz.constrain(notaf, 0, 6);
+ for (int i = 0; i < notaf + 1; i++) {
+ if (tiposcala) idx = idx + scalamaggiore[i];
+ else idx = idx + scalaminore[i];
+ }
+ return idx;
+}
+
+
+void printKey(int valk)
+{
+ char score[] = {'C', 'c', 'D', 'd',
+ 'E', 'F', 'f', 'G',
+ 'g', 'A', 'a', 'B'
+ };
+ char posidxs = 0;
+ string strnota;
+
+ for (int i = 0; i < 7; i++) {
+ //scala anglosassone
+ if ((valk%2) == 0) strnota = strnota+score[getScala(i, true) % 12]; //se maggiore
+ else strnota = strnota+score[getScala(i, false) % 12]; //se minore
+ posidxs = posidxs + 8 + 3;
+ }
+ segmentDisplay.Number(valk);
+ segmentDisplay.Write(fnz.string2char(strnota));
+ if ((valk%2)==0) segmentDisplay.Symbol(LCD_SYMBOL_MINUS, false);
+ else segmentDisplay.Symbol(LCD_SYMBOL_MINUS, true);
+
+
+}
+
+
+
+
+