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で。

Committer:
kb10uy
Date:
Mon Dec 29 02:34:12 2014 +0000
Revision:
7:439c57c20593
Child:
9:12a54d2ea8fc
Operator?????

Who changed what in which revision?

UserRevisionLine numberNew contents of line
kb10uy 7:439c57c20593 1 #include "Operator.h"
kb10uy 7:439c57c20593 2
kb10uy 7:439c57c20593 3 static const float pi2 = 6.283185307179586476925286766559f;
kb10uy 7:439c57c20593 4
kb10uy 7:439c57c20593 5 FMOperator::FMOperator(Timer tm, AOTTrigon t)
kb10uy 7:439c57c20593 6 {
kb10uy 7:439c57c20593 7 attack = 0.0f;
kb10uy 7:439c57c20593 8 delay = 0.0f;
kb10uy 7:439c57c20593 9 sustain = 0.0f;
kb10uy 7:439c57c20593 10 sustainRate = 1.0f;
kb10uy 7:439c57c20593 11 release = 0.0f;
kb10uy 7:439c57c20593 12
kb10uy 7:439c57c20593 13 frequencyMultiple = 1.0f;
kb10uy 7:439c57c20593 14 totalLevel = 1.0f;
kb10uy 7:439c57c20593 15
kb10uy 7:439c57c20593 16 tri=t;
kb10uy 7:439c57c20593 17 master = tm;
kb10uy 7:439c57c20593 18 startTime = 0.0;
kb10uy 7:439c57c20593 19 releaseTime = 0.0;
kb10uy 7:439c57c20593 20 baseFrequency = 1.0f;
kb10uy 7:439c57c20593 21 }
kb10uy 7:439c57c20593 22
kb10uy 7:439c57c20593 23 float FMOperator::calculate(float fmIn) {
kb10uy 7:439c57c20593 24 if (startTime == 0.0) return 0.0f;
kb10uy 7:439c57c20593 25 float pos = (pi2 * baseFrequency * frequencyMultiple);
kb10uy 7:439c57c20593 26 double nt = (master.read_us() / 1000000.0) - startTime;
kb10uy 7:439c57c20593 27 return tri.sin(fmIn + (float)(pos * nt));
kb10uy 7:439c57c20593 28 }
kb10uy 7:439c57c20593 29
kb10uy 7:439c57c20593 30 void FMOperator::attackNote(float freq) {
kb10uy 7:439c57c20593 31 baseFrequency = freq;
kb10uy 7:439c57c20593 32 startTime = master.read_us() / 1000000.0;
kb10uy 7:439c57c20593 33 }
kb10uy 7:439c57c20593 34
kb10uy 7:439c57c20593 35 void FMOperator::releaseNote() {
kb10uy 7:439c57c20593 36 startTime = 0.0;
kb10uy 7:439c57c20593 37 releaseTime = master.read_us() / 1000000.0;
kb10uy 7:439c57c20593 38 }