where the author demos differents ways to get a visual tempo feedback.
It is usefull in live performances, you don't need to listen to the click.
how would you code that, how to subscribe to the clock ?
The only "problems" with using clips that way is launching scenes or using the stop all clips function as you'd have to restart the metronome midi clip. Of course you can copy the clip to all scenes. Using other time signatures might be another issue, you'd need multiple metronome clips depending on the signature. A script always hooked to the transport might be a more desired solution, taking all that into account.Tj Shredder wrote: Sat May 02, 2020 9:30 am I don't think it needs a script for that. Simply create a clip which would send the note or controller information to the external controller to switch on the blink, and include it into your default project. One HW instrument track for visualization - could be abused for extra independent audio input as well...; - )
Code: Select all
var numberOfBeat = 4; // init to a default value, is going to be updated by the real signature.
function init() {
transport = host.createTransport();
transport.timeSignature().numerator().addValueObserver(function(numerator){
numberOfBeat = numerator;
});
transport.getPosition().addValueObserver(function(value)
{
var tick = (Math.round((value*100/10))%10);
var blink = false;
if(tick >=0 && tick <= 3){
blink = true;
}
println(blink); // use it to blink one pad, heartbeat style
var padNumberToLight = Math.round(value)%numberOfBeat;
println(padNumberToLight); // use it to blink pad number, snake style
});
}
Code: Select all
private int numberOfBeat = 4;
public void init()
{
final ControllerHost host = getHost();
final Transport transport = host.createTransport();
transport.timeSignature().numerator().addValueObserver (numerator -> {
this.numberOfBeat = numerator;
});
transport.getPosition().addValueObserver (value -> {
final long tick = (Math.round((value*100/10))%10);
boolean blink = false;
if(tick >=0 && tick <= 3){
blink = true;
}
host.println(String.valueOf(blink)); // use it to blink one pad, heartbeat style
final long padNumberToLight = Math.round(value)%numberOfBeat;
host.println(String.valueOf(padNumberToLight)); // use it to blink pad number, snake style
});
}
Code: Select all
#include <MIDI.h>
using namespace midi;
MIDI_CREATE_DEFAULT_INSTANCE(); // Create an instance of MIDI
byte zaehler = 0;
float bpm = 0;
float zeitAlt = 0;
int isPlaying = 0;
void setup() {
pinMode(13, OUTPUT);
Serial.begin(115200);
MIDI.setHandleClock(beatClock);
MIDI.setHandleStart(beatClock);
MIDI.setHandleContinue(beatClock);
MIDI.setHandleStop(beatClock);
MIDI.begin(MIDI_CHANNEL_OMNI);
}
void loop() {
if (MIDI.read()) {
Serial.println(MIDI.getType(), HEX);
}
}
void beatClock() {
midi::MidiType realtimebyte = MIDI.getType();
if(realtimebyte == midi::Start) {
zaehler = 0;
isPlaying = 1;
zeitAlt = millis();
}
if(realtimebyte == Continue) {
zeitAlt = millis();
}
if(realtimebyte == Stop) {
isPlaying = 0;
digitalWrite(13, LOW);
}
if(realtimebyte == Clock) {
zaehler++;
if (zaehler == 97) {zaehler = 1;}
if(zaehler == 1 || zaehler == 24 || zaehler == 48 || zaehler == 72) {
if(isPlaying){
digitalWrite(13, HIGH);
}
}
if(zaehler == 5 || zaehler == 25 || zaehler == 49 || zaehler == 73) {
digitalWrite(13, LOW);
}
}
if (zaehler == 24 || zaehler == 48 || zaehler == 72 || zaehler == 96 ) {
bpm = round((60000 / (millis() - zeitAlt)));
Serial.print(bpm);
Serial.println(" BPM");
zeitAlt = millis();
}
}
Submit: News, Plugins, Hosts & Apps | Advertise @ KVR | Developer Account | About KVR / Contact Us | Privacy Statement
© KVR Audio, Inc. 2000-2026