Audible pop on exiting a BBC Basic application

Here you can talk about anything related to BBC BASIC, not covered in another category
Pete
Posts: 96
Joined: Wed 10 Apr 2019, 17:36

Audible pop on exiting a BBC Basic application

Post by Pete »

I certainly think BBC Basic for Windows is just brilliant, but I wonder if there is a fix for a minor problem as follows:

Whenever I exit an application originally made in BBC Basic which uses sound, there is an audible pop through the loudspeaker on exiting. I don't know what causes this or whether the pop can be muted? Not a major problem but it would be nice to stop this.
Hated Moron

Re: Audible pop on exiting a BBC Basic application

Post by Hated Moron »

Pete wrote: Wed 09 Nov 2022, 18:18 Whenever I exit an application originally made in BBC Basic which uses sound, there is an audible pop through the loudspeaker on exiting.
That suggests to me that your application is shutting down when the audio output is nowhere near zero, so what you're hearing is the sudden transition between whatever value it's been left at by the program, and zero.

For example if you're playing an audio sample (e.g. a sound-effect) and not allowing it to decay fully, it could happen. Or if you're using the SOUND statement and suddenly stopping a note being played, again the audio output will be left at whatever instantaneous value it had at the time. In the latter case you may want to consider using ENVELOPE to allow the sound to decay gradually.

Another factor to consider is the audio encoding parameters you are using. If it's 16-bit PCM it's usual for the samples to be signed, so zero is in the middle of the range. But with 8-bit samples it's more common for them to be unsigned, in which case the middle value is 128. If that proves to be the cause you could try using the HQSOUND library, which uses 16-bit samples rather than 8.