Playing sound on Arduino Leonardo

Looks like the ATmega32u4 doesn't have a Timer2, just 0, 1, 3, and 4.

Timer0 is 8-bit
Timer1 and Timer3 are 16-bit timers.
Timer4 is a special 10-bit timer

None of them is a good match for the UNO's Timer2 8-bit timer (I assume Timer0 is till used for Arduino system timing). You can probably use Timer3. Start by changing all references to Timer2 registers so they got to Timer3 instead. That leaves references to ASSR, EXCLK, AS2. You will have to study the ATmeag328P and ATmega32u4 datasheets to translate those references.