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: FMOscillator/FMOscillator.cpp
- Revision:
- 13:e11380ceb460
- Parent:
- 11:62da91a1eaf1
- Child:
- 14:06785925915e
diff -r 7408b85fba39 -r e11380ceb460 FMOscillator/FMOscillator.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/FMOscillator/FMOscillator.cpp Sat Jan 17 03:57:58 2015 +0000 @@ -0,0 +1,146 @@ +#include "FMOscillator.h" + +char sysexData[128]; + +FMOscillator::FMOscillator() { + +} + +FMOscillator::FMOscillator(Timer *timer, Serial *serial, AOTTrigon *trigon) { + +} + +void FMOscillator::getMIDIMessage() +{ + unsigned char st = serial->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 FMOscillator::getMIDISystemCommonMessage(char t2) +{ + switch(t2) { + case 0: + //もう面倒臭いから128byteのバッファに適当に放り込んでおこう + sysexData[0] = 0xf0; + int i = 1; + char d = 0; + do { + d = serial->getc(); + sysexData[i]=d; + i++; + } while(d != 0xf7); + + break; + case 1: + serial->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 FMOscillator::midiSystemRealtimeMessage(char mes) +{ + +} + + +void FMOscillator::midiNoteOn(char ch, char note, char vel) +{ + if (vel==0) { + //globalrelease((ch<<8)|note); + } else { + //globalattack((ch<<8)|note,vel); + } +} + +void FMOscillator::midiNoteOff(char ch, char note, char vel) +{ + //globalrelease((ch<<8)|note); +} + +void FMOscillator::midiPolyphonicKeyPressure(char ch, char note, char vel) +{ + +} + +void FMOscillator::midiControlChange(char ch, char ctrl, char data) +{ + +} + +void FMOscillator::midiChannelMode(char ch, char ctrl, char data) +{ + +} + +void FMOscillator::midiProgramChange(char ch, char prg) +{ + +} + +void FMOscillator::midiChannelPressure(char ch, char pres) +{ + +} + +void FMOscillator::midiPitchBend(char ch, short pb) +{ + +} + +void FMOscillator::midiSystemExclusiveMessage() +{ + +} \ No newline at end of file