Skip to main content
2 of 2
added 13 characters in body
StarCat
  • 1.7k
  • 1
  • 7
  • 15

Your code falls through (skips over) the first “if” statement in the output code because its time period has not yet passed.

It then starts to use startMillis_2, which is not yet initialized (and may be any value), in the next “if”.

Initialization of startMillis_2 only happens inside the first “if” statement but that code has not yet been executed.

The same goes for startMillis_3 and 4.

But I think there’s something more fundamentally wrong with your code. You execute all “if” statements inside of a loop that is continuously repeated. There is no sequence. You have to make sure that tone 2 can only be started after tone 1, etcetera.

StarCat
  • 1.7k
  • 1
  • 7
  • 15