Nucleo F401REでFM音源を実装するやつ 外部DACとオペアンプを利用 現在はMCP4922とNJM2737

Dependencies:   AOTTrigon I2CEEPROM MCP4922 AQM0802A mbed

Fork of NuMidi401 by Yuu Kobayashi

NuFM401

Nucleo F401用の自作ソフトウェアMIDI音源

概要

だいたいそんなもんです。

特徴

  • ブレッドボードの上で組める程度には簡単な回路構成
  • 外部のDACにMCP4922を採用
  • 念のためのボルテージフォロアとしてNJM2737Dを採用
  • バンク用EEPROMに24FC1025を採用
  • シリアル経由でMIDIデータを受信することで操作

補足

シリアル <=> MIDI のドライバにはHairless-MIDISerialをオススメします。 仮想MIDIケーブルはとりあえずMIDI Yokeで。

Revision:
21:e3014c1bdf9c
Parent:
20:8278e607a687
Child:
23:deb76bdf6f03
--- a/FMOscillator/FMAlgorithm.cpp	Thu Jan 29 11:09:56 2015 +0000
+++ b/FMOscillator/FMAlgorithm.cpp	Thu Jan 29 12:27:21 2015 +0000
@@ -13,6 +13,7 @@
     opcount = opc;
     cncount = cnc;
     operators = new FMOperator*[opcount];
+    for(int i = 0; i < opcount; i++) operators[i] = NULL;
     connections = new FMAlgorithmConnection[cncount];
 }
 
@@ -33,4 +34,31 @@
     if (num >= cncount) return;
     connections[num].target = t;
     connections[num].source = s;
+    connections[num].allocated = true;
 }
+
+void FMAlgorithm::noteOn(float freq, double time) {
+    for(int i = 0; i < opcount; i++) {
+        if (operators[i] != NULL) operators[i]->attackNote(freq, time);
+    }
+}
+
+void FMAlgorithm::noteOff(double time) {
+    for(int i = 0; i < opcount; i++) {
+        if (operators[i] != NULL) operators[i]->releaseNote(time);
+    }
+}
+
+float FMAlgorithm::calculate() {
+    return calculate(0);
+}
+
+float FMAlgorithm::calculate(int opn) {
+    float sum = 0;
+    for(int i = 0; i < cncount; i++) {
+        if (connections[i].allocated && connections[i].target == opn) {
+            sum += calculate(connections[i].source);
+        }
+    }
+    return operators[opn]->calculate(sum);
+}
\ No newline at end of file