TL;DR
Add the following to the programmable speaker:- Toggle option to stop sound as soon after the control signal stops as possible. (Ideally within a tick or two)
- Control signal option for volume.
- Volume control signal changing effects the currently playing sound, not just future sounds from the speaker.
What ?
I think the extra options for the Programmable Speaker are reasonably straightforward to understand, but the loop point probably needs a bit of explination.The wikipedia page on envelopes probably explains the fundamentals of Attack, Decay, Sustain, Release best. (Decay can be treated as part of the Attack in almost every situation, I think?) A lot of sounds have a noticable difference in more than volume in the different stages, especially noticable between Attack/Decay and Sustain. It would make long, continuous sounds (sirens and musical notes are the obvious ones) sound much better if they played taking those parts into account instead of just starting over at the windup again.
So a programmable speaker that recieves an activation signal would play the Attack/Decay once, then continue repeating the Sustain while the control signal is being sent, then when the control signal stops it finishes its current Sustain then plays the Release (this will always sound better than switching to the Release mid-Sustain due to how sound files are set up). (Unless the "stop sound instantly" toggle is active, in which case it would stop instantly regardless of what part it's in) Imagine how that would improve the sound of a classic Air Raid siren.
Unless the "stop sound instantly" toggle is active, a speaker set to "use signal value as tone" that switches directly from one tone to another without any ticks of "off" shouldn't play the Attack/Descent of the new tone and should go straight to the Sustain. (This will let things like guitar fret slides sound right)
Why ?
Because I want to make a better music box than MIDItorio and I want it to be as vanilla as possible.I can add new sounds (A complete MIDI soundpack is too big for a single mod, but it's not unreasonably large for a modpack, especially with factorio's inbuilt dependency handling) but there are limitations to sound playback that cannot currently be worked around cleanly due to the lack of sound queues. The Musical Speaker mod makes a good attempt, but still has issues.
Edit: I just noticed that Sound is also used for ambient and other sounds. Which means that this addition could also make long-duration locational sounds sound better.