Nucleo F401REでFM音源を実装するやつ 外部DACとオペアンプを利用 現在はMCP4922とNJM2737
Dependencies: AOTTrigon I2CEEPROM MCP4922 AQM0802A mbed
Fork of NuMidi401 by
NuFM401
Nucleo F401用の自作ソフトウェアMIDI音源
概要
だいたいそんなもんです。
特徴
- ブレッドボードの上で組める程度には簡単な回路構成
- 外部のDACにMCP4922を採用
- 念のためのボルテージフォロアとしてNJM2737Dを採用
- バンク用EEPROMに24FC1025を採用
- シリアル経由でMIDIデータを受信することで操作
補足
シリアル <=> MIDI のドライバにはHairless-MIDISerialをオススメします。 仮想MIDIケーブルはとりあえずMIDI Yokeで。
Diff: MIDI.cpp
- Revision:
- 11:62da91a1eaf1
diff -r 0ffdefe75566 -r 62da91a1eaf1 MIDI.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/MIDI.cpp Mon Dec 29 12:48:44 2014 +0000 @@ -0,0 +1,138 @@ +#include "MIDI.h" + +char sysexData[128]; + +void getMIDIMessage() +{ + unsigned char st = midis.getc(); + switch(st >> 4) { + case 0x8: + midiNoteOff(st & 0xf, midis.getc(), midis.getc()); + break; + case 0x9: + midiNoteOn(st & 0xf, midis.getc(), midis.getc()); + break; + case 0xa: + midiPolyphonicKeyPressure(st & 0xf, midis.getc(), midis.getc()); + break; + case 0xb: + char b2 = midis.getc(); + if (b2 >= 120) { + midiChannelMode(st & 0xf, b2, midis.getc()); + } else { + midiControlChange(st & 0xf, b2, midis.getc()); + } + break; + case 0xc: + midiProgramChange(st & 0xf, midis.getc()); + break; + case 0xd: + midiChannelPressure(st & 0xf, midis.getc()); + break; + case 0xe: + char LSB = midis.getc(); + char MSB = midis.getc(); + midiPitchBend(st & 0xf, ((LSB << 7) | (MSB << 7)) + 8192); + break; + case 0xf: + int t2 = st & 0xf; + if (t2 <= 7) { + getMIDISystemCommonMessage(t2); + } else { + midiSystemRealtimeMessage(st); + } + break; + } +} + +void getMIDISystemCommonMessage(char t2) +{ + switch(t2) { + case 0: + //もう面倒臭いから128byteのバッファに適当に放り込んでおこう + sysexData[0] = 0xf0; + int i = 1; + char d = 0; + do { + d = midis.getc(); + sysexData[i]=d; + i++; + } while(d != 0xf7); + + break; + case 1: + midis.getc(); + break; + case 2: + midis.getc(); + midis.getc(); + break; + case 3: + midis.getc(); + break; + case 4: + break; + case 5: + break; + case 6: + break; + case 7: + //どうしろと + break; + } +} + +void midiSystemRealtimeMessage(char mes) +{ + +} + + +void midiNoteOn(char ch, char note, char vel) +{ + if (vel==0) { + globalrelease((ch<<8)|note); + } else { + globalattack((ch<<8)|note,vel); + } +} + +void midiNoteOff(char ch, char note, char vel) +{ + globalrelease((ch<<8)|note); +} + +void midiPolyphonicKeyPressure(char ch, char note, char vel) +{ + +} + +void midiControlChange(char ch, char ctrl, char data) +{ + +} + +void midiChannelMode(char ch, char ctrl, char data) +{ + +} + +void midiProgramChange(char ch, char prg) +{ + +} + +void midiChannelPressure(char ch, char pres) +{ + +} + +void midiPitchBend(char ch, short pb) +{ + +} + +void midiSystemExclusiveMessage() +{ + +} \ No newline at end of file