I was just about to post
There is nothing fundamentally different between the first start and a stop/start
So now, your very first start will be 1 tick too soon. You could also change it to this
if ((data == midi_clock) && (play_flag == 1)) {
if (clk == 0) digitalWrite(tempoled, HIGH);
if (clk == 7) digitalWrite(tempoled, LOW); // this should light it up for 25% of the time
clk = (clk+1) % 24;
Serial.write(midi_clock); // send midi clock to out... Provides tempo!
}
which reduces the amount of times digitalWrite() is actually called and then leave all your clk=0 statements