Go Down

Topic: How to get ableton live to sync to arduino MIDI? (Read 1 time) previous topic - next topic

DrSpeed

Hi All,

Can anyone give me advice on how to generate the appropriate MIDI sync or timecode to get an external application to sync to the Arduino?

I know I can setup Ableton Live to sync a different source.

I already have MIDI working (sending notes) via a conventional MIDI cable, but I have no experience with sync'ing. My Arduino program has a tempo (BPM) so I know the duration of a quarternote etc.

Thanks,
  Dr. Speed

WilliamK Govinda

Well, in our Beat707 project, I searched on how to send MIDI Clock Sync, which is 24 PPQ. So, at every 24 PPQ I send a clock signal via MIDI.

Code: [Select]
MSerial.write(0xF8); // Midi Clock Sync Tick

You can also send Start/Stop to Live's Transport:

Code: [Select]
MSerial.write(0xFA); // MIDI Start
MSerial.write(0xFC); // MIDI Stop


Hope that helps, otherwise, tell us more on what you need exactly.

Wk

WilliamK Govinda

Ah, I forgot, you will need a good timer to send Midi Sync Clock to the host, here's what I use:

Code: [Select]
void timerStart()
{
  TCCR1A = TCCR1B = 0;
  bitWrite(TCCR1B, CS11, 1);
  bitWrite(TCCR1B, WGM12, 1);
  timerSetFrequency();
  bitWrite(TIMSK1, OCIE1A, 1);
}

void timerSetFrequency()
{
  // Calculates the Frequency for the Timer, used by the PPQ clock (Pulses Per Quarter Note) //
  // This uses the 16-bit Timer1, unused by the Arduino, unless you use the analogWrite or Tone functions //
  #define frequency (((midiClockBPM)*(PPQ))/60)
  OCR1A = (F_CPU/ 8) / frequency - 1;
}

void timerStop(void)
{
  bitWrite(TIMSK1, OCIE1A, 0);
  TCCR1A = TCCR1B = OCR1A = 0;
}

ISR(TIMER1_COMPA_vect)
{
   MSerial.write(0xF8); // Midi Clock Sync Tick
}


For PPQ use 24, as its the standard clock format. Unless Live let you chose 96.

Wk

DrSpeed

Great! Thanks. I'll give that a go.

-Dr Speed

DrSpeed

I was having a hard time getting my head around the way interrupts work and I looked in the 'Arduino Cookbook' and found a reference to a library called MsTimer2 (http://www.arduino.cc/playground/Main/MsTimer2). This is much simpler. I just need two functions, one to set the tempo (beats per minute) and one to send the sync.

This works with Ableton Live.

Thanks,
    Dr Speed



#include <MsTimer2.h>

define PPQ 24

// when the sequencer starts, set the timer with the new tempo, something like 75 or 125, a normal bpm.

void setTimer(int beatsPerMinute){
 
  // sync period in milliSeconds
  period = ((1000L * 60)/beatsPerMinute)/PPQ;


  MsTimer2::set(period, syncMIDI);
  MsTimer2::start();                                                                                               
}

// Called by timer
void syncMIDI()
{
   Serial.write(0xF8); // Midi Clock Sync Tick                                                                                                                               
}



Go Up