Library to play WAV files (Alpha test version)


As a token of thanks to TrueBASIC Inc. (who sent me some files), I created a small library that should enable playback of simple WAV files.

It's ALPHA version though. The biggest limit that I know of is that the path can not be longer than 255 characters. This limit is imposed by the Windows API that I use. I think I know a workaround around this which I will implement once I have ported the code to C (see below).

Right now the DLL is written in PowerBASIC for Windows 10, which produce very tiny standalone DLLs. I will port it to C ASAP (PB has a clause in their license that prohibit writing of wrappers around their own statements. AFAIK I do not break this now, because it basically is a wrapper around a Win32 API method. Another reason for porting to C is that it does not feel "right" to use a competitor's product to enhance TB anyway). I only chose PB because I just did not have a modern C-compiler on my TB development machine last night.

The biggest drawback is that a program that uses the library will need to distribute TBPLAYWAV.DLL with them, even BIND-ed ones. I strongly believe there's no workaround for this. AFAIK only the TB core system (most probably only the portions of it which were written in C) can do direct Win32 API calls without using wrapper DLLs.

Right now the lib only supports synchronous playback (program halts until playback has finished), of course I will add support for ASYNC playback soon. I have seen other wish lists for this function too which I will take into consideration. Let's first wait to see if this simple version works on everybody's machine :-)

If anybody is willing to test, you can download it from:

The ZIP file contains the PLAYWAV.TRC library file and the TBPLAYWAV.DLL file. It also contains the PowerBASIC source code of the DLL. Finally it contains the TESTPLAYWAV.TRU file that tests the library by playing the supplied WAV file (that is in the public domain according to where I downloaded the file from).

I tested it on a Windows 7 machine with TB 6 Bronze and Silver, but only did some quick tests. I am curious to "hear" (pun intened!) whether others have any success or problems with it. If the supplied WAV file does not work, please try one of your own WAV files if possible.

To use it in your project, copy the PLAYWAV.TRC and TBPLAYWAV.DLL to your project's directory and in your TB source add a INCLUDE "PLAYWAV.TRC" statement. You should then be able to call the PLAYWAV sub with the path to the WAV file (see "TESTPLAYWAV.TRU").



re: Wav player

Good job! Worked perfectly, using TB Gold Ver 5.5b19 with W7 Home Prem 64 bit.
(But won't do in Silver 5.33)
Now we can sound such things as the Windows "ding.wav", etc.
(One can also play wav. and .mid files with BBC Basic for Windows.)

Mike C.

re:WAV player

It also works fine under Windows 8. I think the 255 character path is a general limit in TrueBasic (actually was 128 until about 5.5--when the .DLL files went away, and is probably still 128 if you use an older version of TB that requires the .dll files.) Thanks a lot for working on this, and I look forward to the ASYNCH version.

Rick Tarara

Worked fine on my windows 7

Worked fine on my windows 7 laptop.