Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a second button to inject a MIDI marker #3

Closed
Pomax opened this issue Dec 25, 2020 · 3 comments
Closed

Add a second button to inject a MIDI marker #3

Pomax opened this issue Dec 25, 2020 · 3 comments

Comments

@Pomax
Copy link
Owner

Pomax commented Dec 25, 2020

that way you can go "oh that bit was particularly sweet, click" and then move on again.

@Pomax
Copy link
Owner Author

Pomax commented Dec 25, 2020

This involved injecting a <delta> FF 06 <byte length> <ASCII bytes>, and because folks won't be able to type anything, let's make that a simple number that starts at 1?

@Pomax
Copy link
Owner Author

Pomax commented Dec 26, 2020

Time to update the post.

circuit:

identical to beep button

code

#define PLACE_MARKER_PIN 4
int lastMarkState = 0;
int nextMarker = 1;

...

void loop() {
  checkForMarker();
}

void checkForMarker() {
  int markState = digitalRead(PLACE_MARKER_PIN);
  if (markState  != lastMarkState) {
    lastMarkState = markState;
    if (markState == 1) {
      writeMidiMarker();
    }
  }
}

void writeMidiMarker() {
  if (!file) return;

  // delta + op code
  writeVarLen(file, getDelta());
  file.write(0xFF);
  file.write(0x06);

  // how many bytes are we writing?
  byte len = 1;
  if (nextMarker > 9) len++;
  if (nextMarker > 99) len++;
  if (nextMarker > 999) len++;
  file.write(len);

  // our label:
  byte marker[len];
  String(nextMarker++).getBytes(marker, len);
  file.write(marker, len);
}

screenshot

image

@Pomax
Copy link
Owner Author

Pomax commented Dec 26, 2020

landed

@Pomax Pomax closed this as completed Dec 26, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant