-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathMidiUtils.h
More file actions
58 lines (50 loc) · 1.76 KB
/
Copy pathMidiUtils.h
File metadata and controls
58 lines (50 loc) · 1.76 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#pragma once
// MidiUtils Class declaration
//
// Author: Fabien
// License: GPL V3.0 © 2016 Fabien (https://github.com/fab672000)
#include <Arduino.h>
#include <Midi_Defs.h>
#include "Leds.h"
#include "MidiBridge.h"
namespace midi
{
class MidiUtils
{
public:
//! Send to the serial midi out port AllSoundOff and ResetAllControllers midi cc message on all channels
static void SendSerialOutPanic(int delayBetweenChannelsMs=20)
{
digitalWrite(led1, LED_ON);
TXLED1;
for (uint8_t channel = 1; channel <= 16; channel++)
{
midiA.sendControlChange(AllSoundOff, 0, channel);
midiA.sendControlChange(ResetAllControllers, 0, channel);
delay(delayBetweenChannelsMs); // allow enough time old interfaces to handle the resets
}
digitalWrite(led1, LED_OFF);
TXLED0;
}
//! Send to Midi Serial a basic note on then off of velocity 100 on first channel for testing
static void SerialOutNote(byte pitch, int duration=250)
{
const uint8_t channel = 0, velocity = 100;
midiA.sendNoteOn(pitch, velocity, channel);
delay(duration);
midiA.sendNoteOff(pitch, velocity, channel);
}
//! Send to Midi Usb a basic note on then off of velocity 100 on first channel for testing
static void UsbOutNote(byte pitch, int duration=250)
{
const uint8_t channel = 0, velocity = 100;
midiEventPacket_t noteOn = {0x09, 0x90 | channel, pitch, velocity};
midiEventPacket_t noteOff = {0x08, 0x80 | channel, pitch, velocity};
MidiUSB.sendMIDI(noteOn);
MidiUSB.flush();
delay(duration);
MidiUSB.sendMIDI(noteOff);
MidiUSB.flush();
}
};
}