mexus:
Shouldn't unsigned int duration be unsinged long duration?
I replaced it in your lib. So that it can work even TCCR0B = TCCR0B & B11111000 | B00000001.
Setting clock 0 to this makes one second last 64000 instead of 1000 millis. This causes your function to overflow. If you are working with millis() than you should use unsigned long not unsigned int.
Duration is set to unsigned int because a note duration of up to 65.5 seconds seemed acceptable, reduces the while loop execution time, and it saves a few bytes of programming space. It's only looking at duration for the comparison of millis()-startTime, so it should never roll over in real-world situations.
If you're messing with clock 0, all kinds of wacky stuff could happen. unsigned int is plenty long (65.5 seconds). If you're changing how long a second is, you should probably not use any libraries as all will assume certain standards exist (like a second is 1000 millis).
I see no reason to change it to unsigned long as it would slow down the while loop. Also, no one should ever be messing with timer 0 anyway and 65.5 seconds is plenty long for a note to play.
Tim