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:
Sat Jan 31 10:54:13 2015 +0000
Revision:
24:f93b49b4cd66
Parent:
21:e3014c1bdf9c
NRPN 20h xxh???

Who changed what in which revision?

UserRevisionLine numberNew contents of line
kb10uy 7:439c57c20593 1 #pragma once
kb10uy 7:439c57c20593 2 #include "mbed.h"
kb10uy 7:439c57c20593 3 #include "AOTTrigon.h"
kb10uy 7:439c57c20593 4
kb10uy 7:439c57c20593 5
kb10uy 7:439c57c20593 6 class FMOperator {
kb10uy 7:439c57c20593 7
kb10uy 7:439c57c20593 8 public:
kb10uy 10:0ffdefe75566 9 FMOperator();
kb10uy 9:12a54d2ea8fc 10 FMOperator(Timer *tm, AOTTrigon *t);
kb10uy 21:e3014c1bdf9c 11 float calculate(float fmIn);
kb10uy 12:7408b85fba39 12 void attackNote(float freq, double time);
kb10uy 12:7408b85fba39 13 void releaseNote(double time);
kb10uy 12:7408b85fba39 14
kb10uy 12:7408b85fba39 15 inline void setAttack(char x) {
kb10uy 12:7408b85fba39 16 attack = 0.0078125f * x;
kb10uy 12:7408b85fba39 17 }
kb10uy 12:7408b85fba39 18 inline void setDecay(char x) {
kb10uy 12:7408b85fba39 19 decay = 0.0078125f * x;
kb10uy 12:7408b85fba39 20 }
kb10uy 12:7408b85fba39 21 inline void setSustain(char x) {
kb10uy 12:7408b85fba39 22 sustain = 0.0078125f * (x + 1);
kb10uy 12:7408b85fba39 23 }
kb10uy 12:7408b85fba39 24 inline void setSustainRate(char x) {
kb10uy 12:7408b85fba39 25 sustainRate = 0.0078125f * x;
kb10uy 12:7408b85fba39 26 }
kb10uy 12:7408b85fba39 27 inline void setRelease(char x) {
kb10uy 12:7408b85fba39 28 release = 0.0078125f * x;
kb10uy 12:7408b85fba39 29 }
kb10uy 12:7408b85fba39 30
kb10uy 12:7408b85fba39 31 inline void setFrequencyMultiple(char x) {
kb10uy 12:7408b85fba39 32 frequencyMultiple = x;
kb10uy 12:7408b85fba39 33 }
kb10uy 12:7408b85fba39 34
kb10uy 12:7408b85fba39 35 inline void setFrequencyMultipleFloating(char x) {
kb10uy 12:7408b85fba39 36 frequencyMultiple *= 0.0078125f * (x + 1);
kb10uy 12:7408b85fba39 37 }
kb10uy 12:7408b85fba39 38
kb10uy 12:7408b85fba39 39 inline void setTotalLevel(char x) {
kb10uy 12:7408b85fba39 40 totalLevel = 0.0078125f * (x + 1);
kb10uy 12:7408b85fba39 41 }
kb10uy 12:7408b85fba39 42
kb10uy 12:7408b85fba39 43 inline void setFeedback(char x) {
kb10uy 12:7408b85fba39 44 feedback = 0.0078125f * x;
kb10uy 12:7408b85fba39 45 }
kb10uy 7:439c57c20593 46
kb10uy 7:439c57c20593 47 private:
kb10uy 9:12a54d2ea8fc 48 Timer *master;
kb10uy 9:12a54d2ea8fc 49 AOTTrigon *tri;
kb10uy 7:439c57c20593 50 //時間だけdouble確保
kb10uy 7:439c57c20593 51 double startTime;
kb10uy 7:439c57c20593 52 double releaseTime;
kb10uy 12:7408b85fba39 53 bool released;
kb10uy 7:439c57c20593 54 double baseFrequency;
kb10uy 12:7408b85fba39 55
kb10uy 12:7408b85fba39 56 float attack;
kb10uy 12:7408b85fba39 57 float decay;
kb10uy 12:7408b85fba39 58 float sustain;
kb10uy 12:7408b85fba39 59 float sustainRate;
kb10uy 12:7408b85fba39 60 float release;
kb10uy 12:7408b85fba39 61 float frequencyMultiple;
kb10uy 12:7408b85fba39 62 float totalLevel;
kb10uy 12:7408b85fba39 63 float modulation;
kb10uy 12:7408b85fba39 64 float feedback;
kb10uy 12:7408b85fba39 65 float prev;
kb10uy 12:7408b85fba39 66
kb10uy 12:7408b85fba39 67 float getEnvelopeRate(double t);
kb10uy 12:7408b85fba39 68 float getEnvelopeReleaseRate(double rlst, float orate);
kb10uy 12:7408b85fba39 69
kb10uy 12:7408b85fba39 70 inline float getCeilingFloatRate(char cr) {
kb10uy 12:7408b85fba39 71 return 0.0078125f * (cr + 1);
kb10uy 12:7408b85fba39 72 }
kb10uy 7:439c57c20593 73 };