[bb] Sound Card Test by semar [ 1+ years ago ]

Started by BlitzBot, June 29, 2017, 00:28:40

Previous topic - Next topic

BlitzBot

Title : Sound Card Test
Author : semar
Posted : 1+ years ago

Description : This simple test, that uses the return code of loadsound against a .WAV file, can check if there's a working sound card on the pc where your Blitz program is running on.

This is useful on system with low specs, because if your Blitz program attempts to play a sound on a system with no sound card, the program will crash badly..

Note that the test works only with a WAV file; if you try LoadSound against another kind of sound file, the test itself will crash !

Hope you find this snippet useful,
Sergio.


Code :
Code (blitzbasic) Select
First, provide a valid and small .WAV file on the same dir of your program (for example "test.wav");
then, try this test:

If LoadSound("test.wav") = 0 then
    ;NO SOUND CARD or SOUND PROBLEMS
    ;take the necessary action
    ;e.g., set a global sound flag to false and test it before loading/playing any sound/music
Endif


Comments : none...