Tuesday, September 21, 2010

Basic4GL Basics Tutorial 4 - Playing a .wav sound

Ok so basically it has been a while. I haven't really done much lately on programming especially with basic4GL, but I'm back with a new tutorial that will get you on your way with programming more applications. This tutorial will go into detail about loading and playing a .wav file. This part will conclude with the basic4GL basics tutorial.

This is a very simple program as the sound we will be using for this example will be the gong.wav file. It is found inside the C:\Program Files\Basic4GL\Programs\Sounds directory. So if you run save this program in the default programs directory you will be able to play the sound. So lets get to the code of this program.

dim sound

sound = LoadSound("sounds/gong.wav"
PlaySound(sound)

lets explain the code. we have to dim the variable which will store the sound file in this program. We then use the LoadSound function which was made for the use of games or other media applications to make it easier for people to have audio in their programs. Part of the LoadSound function we have to include a path to file. Then we use the PlaySound functions which we use the variable that holds our sound. save your program in the programs directory that was installed with the basic4gl installer. on my system it is C:\Program Files\Basic4GL\Programs\. Play the program and you should hear the sound of a gong.

I hope this tutorial helps you in the future.

No comments:

Post a Comment