You are here

Fun with Sound

posted by Charlie
on Wed, 06/17/2009 - 10:17

Included with the Open GL package for Delphi [http://www.glscene.org GLScene] are various extras such as the ODE package as well as [http://www.un4seen.com/bass.html the BASS sound library]. Recently I took a closer look at the library to see what it can do. I have to say that it is pretty amazing.

The library is a relative small single (100K) DLL with header or unit files for various languages including VB, C, and Delphi. There also extension libraries that allow for specific encoding and special effects. It support playing streaming radio (Shoutcast) in the background as well as many audio files both wave based and music files such as MIDI and MOD music files. Check out the site link above for more details.

There are a number of sample programs, and the one showing how to play a Shoutcast feed was most interesting. My goal was to create an HTTP plugin that would be able to play that stations on the main simulation server box, (so that the music would come out of the main speakers), but allow control from one of the remote machines. Remarkably it worked on the first try, a rare occurance in web server modules, usually due to executing in a separate thread.

With the station playing (SomaFM's GrooveSalad) we then tested other programs using the library to play sound files at the same time. The library actaully support multiple sound channels each with its own volume and other control settings including 3D effects. The FX plugin adds things like, echo, flanger, reverb, as well and pitch and tempo setting.

So for example, we can set up and engine sound as a deep pulsing tone. As the throttle is increased it only takes one function call to raise or lower the pitch by a desired amount.

The tempo is great for something like a sonar ping (sensor sweep), where it can be adjusted to how quickly the sample is played. Adding an echo effect could give feedback to a target, and adjusting the delay could show changes in distance.

With the player located on all five machines we should be able to distrubute sounds around the room in addition to the main speakers for the general background sounds. Overall the potentail is pretty amazing.

Now we just need to come up with a good descriptor for a sound that can include all the necessary parameters to make the sound service flexible.