how to drive a speaker from a r2r ladder

Sorry about that, re-reading I can see I wasn't too clear.
Your midi stuff goes where these lines are.

toggle = 1-toggle; // results in 0 1 0 1 ...

// do stuff on 0.1mS intervals, 1mS intervals, ets.

} // end of time interval

Then your other stuff occurs.

So, loop starts, if 32uS have gone by you write out the next part of the waveform.

After that, or if 32uS have not gone by, your other stuff occurs.

Then, you go back to the top & start again:
} // end of void loop