0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

Teensy <-> ESP32間のMIDI通信

Posted at

ESP32でBLE-MIDIを使い、Teensyに丸投げ、丸受けすることでTeensyをBLE-MIDIデバイスのように扱う。双方のデバイスでSerialをMIDIとして使えるように設定 (MIDI.begin()) した後で通信速度を上げている。

ESP32側

BLEMIDI_CREATE_INSTANCE("TWV2000M", MIDI);
MIDI_CREATE_INSTANCE(HardwareSerial, Serial2, midiB);

void setup()
{
    midiB.begin();
    Serial2.begin (1500000, SERIAL_8N1, RXD2, TXD2);

    MIDI.begin();

    MIDI.setHandleNoteOn([](byte channel, byte note, byte velocity) {
        midiB.sendNoteOn (note, velocity, channel);
    });

    MIDI.setHandleNoteOff([](byte channel, byte note, byte velocity) {
        midiB.sendNoteOff (note, velocity, channel);
    });

    MIDI.setHandleControlChange ([](byte channel, byte number, byte value) {
        midiB.sendControlChange (number, value, channel);
    });

    MIDI.setHandleProgramChange ([](byte channel, byte number){
        midiB.sendProgramChange (number, channel);

    });

    MIDI.setHandleAfterTouchChannel ([](byte value, byte channel){
        midiB.sendAfterTouch(value, channel);
    });
}

void loop() {
  MIDI.read();
}

Teensy側

MIDI_CREATE_INSTANCE(HardwareSerial, Serial4, midiB);

void setup()
{
    midiB.begin (MIDI_CHANNEL_OMNI);
    Serial4.begin (1500000);

    midiB.setHandleNoteOn (onNoteOn);
    midiB.setHandleNoteOff (onNoteOff);
    midiB.setHandleControlChange (onControlChange);
    midiB.setHandlePitchBend (onPitchBend);
    midiB.setHandleSystemExclusive (onSysex);
    midiB.setHandleProgramChange (onProgramChange);
}
0
0
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?