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 09:01:10 2014 +0000
Revision:
10:0ffdefe75566
Parent:
7:439c57c20593
Child:
11:62da91a1eaf1
MIDI?????USBMIDI????Serial????????

Who changed what in which revision?

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