HunterZ wrote:The song at the end is still much quieter than the preceding music, although it's understandable (and still sounds amazing).
Yes, it's just a result of the signal that is produced. The PC speaker has no volume control, it either on or off.
With the regular music, you just let the PC speaker turn itself on and off at a given frequency for each note you play, creating a square wave signal. So on average it is always enabled for 50% of the time, which is perceived as 'loud'.
For the sample playback, a pulse-width-modulation technique is used, which works in a different way.
For a given 'carrier frequency' (sample rate), in our case ~16 KHz, you vary the volume of each sample by its duty cycle. So softer samples are played by enabling the speaker for a shorter time.
This means that the speaker is not enabled 50% of the time on average, but it depends on the music. In theory you could have PWM-based 'music' (well, at least sound, it may not necessarily sound musical) that sounds as loud as regular PC music, but in practice, such music tends to have more dynamic range, so it turns out softer, especially this rather mellow end-tune. Which is somewhat ironic... Early sound chips tend not to be very subtle in the way of dynamics and such, so people tend to perceive music from SID, POKEY etc as 'loud' and 'busy'.
In theory we could put some kind of 'loudness mapping' on it, by remapping the samples to an exponential curve rather than a linear one. But it would take some extra CPU cycles, which means the carrier frequency will be lower, which means it will be more audible (16 KHz is just about at the limit of the hearing of an adult person).
So yes, loudness wars on 1981 hardware 😀