Looking for a Special Delay Library

I think the best way to implement a background melody player is to set the timer interrupt for the minimal duration being used by a melody.

The interrupt routine can play a table with frequency and duration of each note (don't forget the pause).

Using this method the normal code of your application can execute without any care about the player.

JLB

PS : You have to enable interrupts at the start of your interrupt routine to avoid disfunctionnement on other interrupts routines.