midiClock / BPM

Status
Not open for further replies.

AdmiralCrunch

Well-known member
Hi,

so now the point has come at which I have to deal with coding a sequencer for my project.

this has nothing to do with the thread-question but as I want the sequencer to be very feature rich, I ask myself if it will not be too much for the teensy.
I mean I use a T_3.6. but beside a ton of digital/analog-readings, the teensy needs to send the state permanenty to the Raspi (which acts as a display).
When I now add a sequencer for 16 tracks, each track with extensive functions, also this updates needs to be send to the Raspi.

Can one T_3.6. handle that all, or should I suggest to split it? .. maybe another teensy just for the sequencer?


so first things first, I thought I start with the midi-clock.
I searched and tried around, but I can't figure out how the midi-clock is working on teensy. Is there a good explanation, maybe with a working example out there?
I need to have:
- midi-clock-generator so my sequencer can run at some BPM-rate
- send the midiClock through MIDI-OUT, so other hardware or DAWs can sync
- teensy recieving midi-clock through MIDI-IN (teensy as clock-slave) and move through the pattern on each tick
 
There a discussion on generating a BPM clock signal for midi here: https://forum.pjrc.com/threads/50559-How-to-generate-USB-MIDI-clock-with-Teensy-2-0
Might be a useful start

Thanks I tried around a little bit, and now it works. Adapred the last example from the thread:

Code:
#include <Arduino.h>
/*
Repeating Timer
Code Alternative to ElapsedMillis

(c)2015 Forward Computing and Control Pty. Ltd.
This code may be freely used for both private and commerical use.
Provide this copyright is maintained. 
*/
unsigned long timer; 
int tim;

void setup() {

timer = millis(); 
}

void loop() {
 // int tim = 100; // 25 bpm
 //int tim = 10; // 250 bpm
  
  int tim = 19;
  unsigned long INTERVAL = tim; 
  if ((millis()-timer) > INTERVAL) {

    timer += INTERVAL;
    usbMIDI.sendRealTime(usbMIDI.Clock);
  }
}

now.. tim=19 is 132 BPM
and.. tim= 20 is 125 BPM

but how would i get more precisely? .. I would like to be able to send as precisely as possible.. lets say like 128,34 BPM

how would I do that?
 
Use micros instead of millis which allows a 1000 times finer resolution

Converting bpm in a period duration and vice versa is a simple 6th grade exercise, man!
 
great you got working. With one more variable calculation you could have it so that your input variable was the exact bpm that you want, int tim would then be calculated and give you your INTERVAL.
 
great you got working. With one more variable calculation you could have it so that your input variable was the exact bpm that you want, int tim would then be calculated and give you your INTERVAL.

that is a great idea!! .. I am now working on a other problem of the project, but I will make this for sure. thanks bro :)
 
thanks :)

.. it is not the converting, it was the timer-resolution :) with micros() everything works like a charm :)

Hello AdmiralChurch, i am working on a project with a clockGenrator, it would be helpfull to see how yout working code looled like in the end. Could you please post it?
thank you!
 
Status
Not open for further replies.
Back
Top