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で。
FMOscillator/MIDIChannel.cpp@20:8278e607a687, 2015-01-29 (annotated)
- Committer:
- kb10uy
- Date:
- Thu Jan 29 11:09:56 2015 +0000
- Revision:
- 20:8278e607a687
- Parent:
- 19:f0dcf591c5dd
- Child:
- 21:e3014c1bdf9c
??
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
kb10uy | 17:2e577c6000cf | 1 | #include "MIDIChannel.h" |
kb10uy | 17:2e577c6000cf | 2 | |
kb10uy | 17:2e577c6000cf | 3 | MIDIChannel::MIDIChannel() |
kb10uy | 17:2e577c6000cf | 4 | { |
kb10uy | 17:2e577c6000cf | 5 | modulation = 0; |
kb10uy | 17:2e577c6000cf | 6 | portamentoTime = 0; |
kb10uy | 17:2e577c6000cf | 7 | portamento = false; |
kb10uy | 17:2e577c6000cf | 8 | volume = 127; |
kb10uy | 17:2e577c6000cf | 9 | panpot = 64; |
kb10uy | 17:2e577c6000cf | 10 | expression = 127; |
kb10uy | 17:2e577c6000cf | 11 | hold1 = false; |
kb10uy | 19:f0dcf591c5dd | 12 | dataEntryMSB = 0; |
kb10uy | 19:f0dcf591c5dd | 13 | dataEntryLSB = 0; |
kb10uy | 19:f0dcf591c5dd | 14 | nrpnMSB = 0; |
kb10uy | 19:f0dcf591c5dd | 15 | nrpnLSB = 0; |
kb10uy | 19:f0dcf591c5dd | 16 | rpnMSB = 0; |
kb10uy | 19:f0dcf591c5dd | 17 | rpnLSB = 0; |
kb10uy | 19:f0dcf591c5dd | 18 | algo = NULL; |
kb10uy | 19:f0dcf591c5dd | 19 | state = Undefined; |
kb10uy | 19:f0dcf591c5dd | 20 | } |
kb10uy | 19:f0dcf591c5dd | 21 | |
kb10uy | 19:f0dcf591c5dd | 22 | MIDIChannel::~MIDIChannel() |
kb10uy | 19:f0dcf591c5dd | 23 | { |
kb10uy | 19:f0dcf591c5dd | 24 | if (algo != NULL) delete algo; |
kb10uy | 19:f0dcf591c5dd | 25 | } |
kb10uy | 19:f0dcf591c5dd | 26 | |
kb10uy | 19:f0dcf591c5dd | 27 | void MIDIChannel::setDataEntryMSB(char msb) |
kb10uy | 19:f0dcf591c5dd | 28 | { |
kb10uy | 19:f0dcf591c5dd | 29 | dataEntryMSB = msb; |
kb10uy | 19:f0dcf591c5dd | 30 | |
kb10uy | 19:f0dcf591c5dd | 31 | } |
kb10uy | 19:f0dcf591c5dd | 32 | |
kb10uy | 19:f0dcf591c5dd | 33 | void MIDIChannel::setDataEntryLSB(char lsb) |
kb10uy | 19:f0dcf591c5dd | 34 | { |
kb10uy | 19:f0dcf591c5dd | 35 | dataEntryLSB = lsb; |
kb10uy | 19:f0dcf591c5dd | 36 | } |
kb10uy | 19:f0dcf591c5dd | 37 | |
kb10uy | 19:f0dcf591c5dd | 38 | void MIDIChannel::setNRPNMSB(char msb) |
kb10uy | 19:f0dcf591c5dd | 39 | { |
kb10uy | 19:f0dcf591c5dd | 40 | nrpnMSB = msb; |
kb10uy | 19:f0dcf591c5dd | 41 | if (msb >= 0x60) { |
kb10uy | 19:f0dcf591c5dd | 42 | state = NRPNSingleData; |
kb10uy | 19:f0dcf591c5dd | 43 | } else { |
kb10uy | 19:f0dcf591c5dd | 44 | state = NRPNDoubleData; |
kb10uy | 19:f0dcf591c5dd | 45 | } |
kb10uy | 19:f0dcf591c5dd | 46 | } |
kb10uy | 19:f0dcf591c5dd | 47 | |
kb10uy | 19:f0dcf591c5dd | 48 | void MIDIChannel::setNRPNLSB(char lsb) |
kb10uy | 19:f0dcf591c5dd | 49 | { |
kb10uy | 19:f0dcf591c5dd | 50 | nrpnLSB = lsb; |
kb10uy | 19:f0dcf591c5dd | 51 | if (state == NRPNNoData) processNRPNFunction(); |
kb10uy | 19:f0dcf591c5dd | 52 | } |
kb10uy | 19:f0dcf591c5dd | 53 | |
kb10uy | 19:f0dcf591c5dd | 54 | void MIDIChannel::setRPNMSB(char msb) |
kb10uy | 19:f0dcf591c5dd | 55 | { |
kb10uy | 19:f0dcf591c5dd | 56 | rpnMSB = msb; |
kb10uy | 19:f0dcf591c5dd | 57 | if (msb == 0x7f){ |
kb10uy | 19:f0dcf591c5dd | 58 | state = RPNNoData; |
kb10uy | 19:f0dcf591c5dd | 59 | } else { |
kb10uy | 19:f0dcf591c5dd | 60 | state = RPNSingleData; |
kb10uy | 19:f0dcf591c5dd | 61 | } |
kb10uy | 19:f0dcf591c5dd | 62 | } |
kb10uy | 19:f0dcf591c5dd | 63 | |
kb10uy | 19:f0dcf591c5dd | 64 | void MIDIChannel::setRPNLSB(char lsb) |
kb10uy | 19:f0dcf591c5dd | 65 | { |
kb10uy | 19:f0dcf591c5dd | 66 | rpnLSB = lsb; |
kb10uy | 19:f0dcf591c5dd | 67 | if (state == RPNNoData) processRPNFunction(); |
kb10uy | 17:2e577c6000cf | 68 | } |
kb10uy | 17:2e577c6000cf | 69 | |
kb10uy | 17:2e577c6000cf | 70 | void MIDIChannel::allSoundOff() |
kb10uy | 17:2e577c6000cf | 71 | { |
kb10uy | 17:2e577c6000cf | 72 | } |
kb10uy | 17:2e577c6000cf | 73 | |
kb10uy | 17:2e577c6000cf | 74 | void MIDIChannel::allNoteOff() |
kb10uy | 17:2e577c6000cf | 75 | { |
kb10uy | 19:f0dcf591c5dd | 76 | } |
kb10uy | 19:f0dcf591c5dd | 77 | |
kb10uy | 19:f0dcf591c5dd | 78 | void MIDIChannel::processNRPNFunction() { |
kb10uy | 19:f0dcf591c5dd | 79 | switch(nrpnMSB) { |
kb10uy | 19:f0dcf591c5dd | 80 | |
kb10uy | 19:f0dcf591c5dd | 81 | } |
kb10uy | 20:8278e607a687 | 82 | state = Undefined; |
kb10uy | 19:f0dcf591c5dd | 83 | } |
kb10uy | 19:f0dcf591c5dd | 84 | |
kb10uy | 19:f0dcf591c5dd | 85 | void MIDIChannel::processRPNFunction() { |
kb10uy | 19:f0dcf591c5dd | 86 | switch(rpnMSB) { |
kb10uy | 19:f0dcf591c5dd | 87 | case 0x00: |
kb10uy | 19:f0dcf591c5dd | 88 | //LSB 0~2全部実装できないですから |
kb10uy | 19:f0dcf591c5dd | 89 | break; |
kb10uy | 19:f0dcf591c5dd | 90 | case 0x7f: |
kb10uy | 19:f0dcf591c5dd | 91 | if (rpnLSB == 0x7f) { |
kb10uy | 19:f0dcf591c5dd | 92 | rpnMSB = 0; |
kb10uy | 19:f0dcf591c5dd | 93 | rpnLSB = 0; |
kb10uy | 19:f0dcf591c5dd | 94 | nrpnMSB = 0; |
kb10uy | 19:f0dcf591c5dd | 95 | nrpnLSB = 0; |
kb10uy | 19:f0dcf591c5dd | 96 | } |
kb10uy | 19:f0dcf591c5dd | 97 | break; |
kb10uy | 19:f0dcf591c5dd | 98 | } |
kb10uy | 19:f0dcf591c5dd | 99 | state = Undefined; |
kb10uy | 20:8278e607a687 | 100 | } |