Skip to content

Incoming Clock to BPM #295

Answered by ghost
ghost asked this question in Q&A
Aug 16, 2022 · 4 comments · 23 replies
Discussion options

You must be logged in to vote

this prints bpm to serial monitor
thanks for the suggestions, solved.
`#include <MIDI.h>

byte midi_clock = 0xf8;
unsigned long int startTime;
int beatCount;
bool counting = false;
long int bpm;
long int noteTime;

MIDI_CREATE_INSTANCE(HardwareSerial, Serial1, MIDI);

void setup() {
MIDI.begin(MIDI_CHANNEL_OMNI);
Serial.begin(57600);
Serial.println("MIDI Input Test");
}

void loop() {

if (MIDI.read()) { // Is there a MIDI message incoming ?
byte type = MIDI.getType();
if (type == midi_clock) {
if ( not counting) { // first time you have seen a clock message in this batch
startTime = millis();
counting = true;
beatCount = 1;
}
else {
beatCount += 1;
if (beatCount >= 96) {
noteTime = millis() -…

Replies: 4 comments 23 replies

Comment options

You must be logged in to vote
1 reply
@franky47
Comment options

Comment options

You must be logged in to vote
22 replies
@franky47
Comment options

@m-r-m-s
Comment options

@franky47
Comment options

@franky47
Comment options

@m-r-m-s
Comment options

Answer selected
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants