// paint up to end of buffer or of input, whichever is lower
count = sfx->total_length - ch->pos;
count = bound(0, count, (int)frames - ltime);
// paint up to end of buffer or of input, whichever is lower
count = sfx->total_length - ch->pos;
count = bound(0, count, (int)frames - ltime);