mp3 files

Here you can talk about anything related to BBC BASIC, not covered in another category
Ric
Posts: 221
Joined: Tue 17 Apr 2018, 21:03

mp3 files

Post by Ric »

Afternoon all,
I am trying to add sound to a simple game i have written for bbcsdl (specifically for my phone). The game now is playable but in a very basic form and i would like to add sound effects.
I have used the audiolib to download the sound of a gun shot, but when using PROC_playsound the effect happens about 2 seconds after i initiate it. In the scenario of firing bullets, this is obviously way to long. Can someone help/point in the right direction as to how i make the effects instant.
Kind Regards Ric.

6502 back in the day, BB4W 2017 onwards, BBCSDL from 2023
Richard Russell
Posts: 457
Joined: Tue 18 Jun 2024, 09:32

Re: mp3 files

Post by Richard Russell »

Ric wrote: Sun 24 Aug 2025, 15:33 when using PROC_playsound the effect happens about 2 seconds after i initiate it
There's no way the latency should be that long, at 44,100 16-bit stereo samples per second that would imply about 350 Kbytes of audio data being buffered somewhere before being fed to the hardware DAC!

What happens when you run cowboy.bbc (in the examples/games/ folder)? Is the latency significantly less? If so you must be doing something wrong: compare your code with what's in cowboy.bbc.

But if cowboy.bbc also suffers from a huge latency I'm afraid the fault lies in your PC, and has nothing to do with BBC BASIC. In that case you could try updating the audio drivers, but you might have to conclude that your PC isn't suitable for that kind of application.

(P.S. This really belongs in Multimedia rather than in Miscellaneous).
Ric
Posts: 221
Joined: Tue 17 Apr 2018, 21:03

Re: mp3 files

Post by Ric »

My apologies Richard
cowboy.bbc works perfectly.
I had put the playsound statement in a loop instead of outside and it was permanently trying to replay itself.
Kind Regards Ric.

6502 back in the day, BB4W 2017 onwards, BBCSDL from 2023