My guess is that the part that figures out the size of the artwork is in a loop rather than outside of it. The initial calculations takes the album art size and multiplies it by some calculated factor. Then when it's through one iteration of the loop, it uses the same factor to calculate a new size. So instead of looking like this:
$factor = CALCULATEsize($albumArtRef, $song); # Here the factor gets set at the beginning and doesn't change.
while($play = "on") {
PLAYandDISPLAY($songListRef{ $song }, $albumArtRef, $factor);
}
It's:
while($play = "on") {
$factor = CALCULATEsize($albumArtRef, $song); # Here the factor gets changed each time through the loop.
PLAYandDISPLAY($songListRef{ $song }, $albumArtRef, $factor);
}
Of course, the real code is much more complex, but the idea is there.