/* ISR to handle the reloading of the PWM timer with the next sample.  */
ISR(TIMER0_COMPA_vect, ISR_BLOCK)
/* ISR to handle the reloading of the PWM timer with the next sample.  */
ISR(TIMER0_COMPA_vect, ISR_BLOCK)
{
	uint16_t MixedSample = 0;
	for (uint8_t i = 0; i < MAX_SIMULTANEOUS_NOTES; i++)
	{
		if (NoteData[i].Pitch)
		{
			uint8_t TableIndex = (NoteData[i].TablePosition >> 24);
			MixedSample += SineTable[TableIndex];
			NoteData[i].TablePosition += NoteData[i].TableIncrement;
		}
	}
	OCR3A = (MixedSample <= 0xFF) ? MixedSample : 0xFF;
}