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 17 03:57:58 2015 +0000
Revision:
13:e11380ceb460
Parent:
11:62da91a1eaf1
Child:
15:b03677948732
MIDI.cpp??Operator.cpp????FMOscillator???????????????

Who changed what in which revision?

UserRevisionLine numberNew contents of line
kb10uy 1:cde592d8076e 1 #include "Main.h"
kb10uy 1:cde592d8076e 2
kb10uy 10:0ffdefe75566 3 MCP4922 output(PA_7, PA_5, PA_8);
kb10uy 10:0ffdefe75566 4
kb10uy 10:0ffdefe75566 5 AOTTrigon t;
kb10uy 4:e300f6fd7f96 6 Timer master;
kb10uy 10:0ffdefe75566 7 Serial midis(USBTX,USBRX);
kb10uy 13:e11380ceb460 8 FMOscillator fm;
kb10uy 3:e98f2da2d3c5 9
kb10uy 3:e98f2da2d3c5 10 const double smpps = 40000.0;
kb10uy 3:e98f2da2d3c5 11 const double smpus = 1000000.0 / smpps;
kb10uy 3:e98f2da2d3c5 12
kb10uy 3:e98f2da2d3c5 13 double ntime = 0.0;
kb10uy 11:62da91a1eaf1 14 volatile double freq = 0;
kb10uy 2:658699249a81 15
kb10uy 10:0ffdefe75566 16 float out = 0.0f;
kb10uy 3:e98f2da2d3c5 17
kb10uy 10:0ffdefe75566 18 void tick_sampling();
kb10uy 10:0ffdefe75566 19 void midiReceived();
kb10uy 10:0ffdefe75566 20
kb10uy 11:62da91a1eaf1 21 int state[operators];
kb10uy 11:62da91a1eaf1 22
kb10uy 10:0ffdefe75566 23 int main()
kb10uy 10:0ffdefe75566 24 {
kb10uy 10:0ffdefe75566 25 //DAC setting
kb10uy 5:6f060709aa23 26 output.referenceMode(MCP4922::DAC_A, MCP4922::REF_UNBUFFERED);
kb10uy 5:6f060709aa23 27 output.gainMode(MCP4922::DAC_A, MCP4922::GAIN_1X);
kb10uy 5:6f060709aa23 28 output.powerMode(MCP4922::DAC_A, MCP4922::POWER_NORMAL);
kb10uy 5:6f060709aa23 29 output.referenceMode(MCP4922::DAC_B, MCP4922::REF_UNBUFFERED);
kb10uy 5:6f060709aa23 30 output.gainMode(MCP4922::DAC_B, MCP4922::GAIN_1X);
kb10uy 5:6f060709aa23 31 output.powerMode(MCP4922::DAC_B, MCP4922::POWER_NORMAL);
kb10uy 11:62da91a1eaf1 32
kb10uy 10:0ffdefe75566 33 //MIDI Serial setting
kb10uy 10:0ffdefe75566 34 midis.baud(256000);
kb10uy 10:0ffdefe75566 35 midis.format();
kb10uy 13:e11380ceb460 36
kb10uy 10:0ffdefe75566 37 //for(int i = 0; i < operators; i++) new(op + i) FMOperator(&master, &t);
kb10uy 10:0ffdefe75566 38 midis.attach(&midiReceived);
kb10uy 11:62da91a1eaf1 39
kb10uy 4:e300f6fd7f96 40 master.start();
kb10uy 11:62da91a1eaf1 41 while(true) {
kb10uy 11:62da91a1eaf1 42 ntime = master.read_us()/1000000.0;
kb10uy 13:e11380ceb460 43 //output.write(MCP4922::DAC_A,out/oc+0.5);
kb10uy 11:62da91a1eaf1 44 }
kb10uy 10:0ffdefe75566 45 }
kb10uy 10:0ffdefe75566 46
kb10uy 10:0ffdefe75566 47 void midiReceived()
kb10uy 10:0ffdefe75566 48 {
kb10uy 11:62da91a1eaf1 49 getMIDIMessage();
kb10uy 11:62da91a1eaf1 50 while(midis.readable()) midis.getc();
kb10uy 11:62da91a1eaf1 51 }