Go Down

Topic: Arduino as Midi Master Clock (Read 9195 times) previous topic - next topic

Koolzuurhoudend

Hi,

i´m working on a project that lets me syncronize my synthesizer
to live played music by tapping in the speed with a pushbutton.

my question now is: is it possible to make the arduino act like a midi master and send a midi clock signal?

do i have to look for the midi specifics and use some normal pins for the interface or is there an midi interface already developed.
(like a driver ic)

thanks.
koolzuurhoudend

MikMo

Try to check this cool project :

http://gieskes.nl/master-clock-generator/build.php

Koolzuurhoudend

thats what i´m looking for...
thaks a lot.

but i want to calculate the clock speed by taping it in with a pushbuttn
and not regulating it with a potentiometer.
like this little thing does (i don't need the 3.4....and 1 function)

http://www.ploytec.com/34oneII/

but maybe this is not too hard to programm.


MikMo

#3
Nov 18, 2008, 02:16 pm Last Edit: Nov 18, 2008, 02:17 pm by MikMo Reason: 1
it shouldn't be too hard to program.

reading a button pres, checking the time, reading the button again checking the time again, calculate the time difference converting the time difference to BPM  - now code that :-)

EDIT: I think someone on the forum made something similar, try searching the forum.

RonaldB

Hi,
I made a tap tempo clock a couple of weaks ago
Here's the code:
Code: [Select]
/*
   Tap Tempo clock
   Ronald B
   */


void setup()
{
 pinMode( 2, INPUT );   /* tap button - press it to set the tempo */
 pinMode( 3, OUTPUT );  /* tempo display light - shows the current tempo */
}


int           lastTapState = LOW;  /* the last tap button state */
unsigned long currentTimer[2] = { 500, 500 };  /* array of most recent tap counts */
unsigned long timeoutTime = 0;  /* this is when the timer will trigger next */

unsigned long indicatorTimeout; /* for our fancy "blink" tempo indicator */


void loop()
{
 /* read the button on pin 12, and only pay attention to the
    HIGH-LOW transition so that we only register when the
    button is first pressed down */
 int tapState = digitalRead( 2 );
 Serial.println(tapState);
 if( tapState == LOW && tapState != lastTapState )
 {
   tap(); /* we got a HIGH-LOW transition, call our tap() function */
 }
 lastTapState = tapState; /* keep track of the state */
 
 /* check for timer timeout */
 if( millis() >= timeoutTime )
 {
   /* timeout happened.  clock tick! */
   indicatorTimeout = millis() + timeoutTime;  /* this sets the time when LED 13 goes off */
   /* and reschedule the timer to keep the pace */
   rescheduleTimer();
 }
 

 if( millis() < indicatorTimeout )
   {
     digitalWrite( 3, HIGH );
     }
 else
  {
     digitalWrite( 3, LOW);
  }
}


unsigned long lastTap = 0; /* when the last tap happened */
void tap()
{
 /* we keep two of these around to average together later */
 currentTimer[1] = currentTimer[0];
 currentTimer[0] = millis() - lastTap;
 lastTap = millis();
 timeoutTime = 0; /* force the trigger to happen immediately - sync and blink! */
 Serial.println(lastTap);
}

void rescheduleTimer()
{
   /* set the timer to go off again when the time reaches the
      timeout.  The timeout is all of the "currentTimer" values averaged
      together, then added onto the current time.  When that time has been
      reached, the next tick will happen...
   */
     timeoutTime = millis() + ((currentTimer[0] + currentTimer[1])/2);
}


I would love to make this a master Midi clock. SO please use it and maybe we can make this work. Let's keep in thouch

RonaldB

RonaldB

and I would love to add 2 buttons one form BPM going up and one for BPM going down. ;) with display of course

maverick

This wouldn't be too difficult to build and code.

I have an idea of taking it a bit further, with an accelerometer.  How cool would it be to have an electronic conductor's baton, which would generate the tempo?  You could then conduct your music live, complete with changes in tempo!

RonaldB

Could you share your idee a bit further, maybe it sounds silly but what's a "baton" (i'm dutch ;D)?
My ulitimate goal is a tempo controller that tracks my playing speed al the time. I think this could be done with an analog input. any idea's on that?

Koolzuurhoudend

to get the tap button working i want to use ext int 0 on pin 8 of the arduino board.

i read through the atmega168 datasheet and found the registers that i have to set to enable the interrupt.

i tried to set the registers directly (should work?)
Code: [Select]
int REG = SREG;
REG=REG | B10000000;
SREG=REG;
EIMSK=B01;
EICRA=B0010;


but i can't find any information how to use the interrupt with the arduino language.

after including io.h and interrupt.h
i tried to test the interrupt with
Code: [Select]

ISR(INT0_vect)
{
 Serial.println("i am in the ISR");
}

but i get an error while compiling.


could anybody tell me how to work with the interrupts?

Koolzuurhoudend

any interrupt programmers here.....

Koolzuurhoudend


robotman777

Try to check this cool project :

http://gieskes.nl/master-clock-generator/build.php


This site does not show any code or maybe I am not finding it?

Go Up