A sound/music routine that accesses sound cards.

It would be nice to be able to play some standard (at very least .wav) files from within TB, ideally as background. Voice and music files could add a lot to programs, but the current SOUND function with only access to the internal speaker (if there is one) is pretty useless. Fundamentally the whole language needs to reflect the capabilities of machines in the second decade of the 21st Century. ;-)



Access to Sound Card in TrueBASIC

Ladies and Gentlemen,
TrueBASIC is one of the computer languages that I use for programming, and the only one of which I am aware that has simple sound generation capabilities. Hence, like the rest of you folks, I would like to drive my EXTERNAL "sound card" from TrueBASIC. Unfortunately, as we all are aware, this is not being provided in the TB programming environment (#$*&%# !). Well, I guess that we have to live with it.

That being the case, I propose another method to address this problem. I think that I may open up my computer and attach two wires to the built-in speaker, perhaps disconnecting the speaker and maybe inserting a resistor in its place. Then, perhaps attach the two wires to a small 1:1 audio transformer (for ground isolation if necessary), run the secondary wires out and attach a plug to these. I could insert the plug into my external "sound card". What do you think?

Wave file player

Actually I have the beginnings of a wave player--in C (dated back in 1999) that I worked (well I tested) with Chris Sweeney on. I would be happy to zip the files and email them to anyone who might be able to do something with these. I will send them to BigJohn, but anyone else? As I recall, what is here didn't work all that well--if at all. Let me know at rtarara@saintmarys.edu.



I certainly know that chaining out is possible--I have programs that chain out to play video segments--but getting TB to use the sound card to play some simple sound files would be very nice. Chris Sweeney and I did play with this a little bit--trying to write a C subroutine--but could not get it to work very well, and the process for adding external (non-TB) routines is beyond my comprehension even though I once accomplished it (in my 'youth' when the brain worked a bit better).



I am reasonably proficient in 'C' so I would be happy to collaborate with others to produce a sound library module that would play .wav files (or similar). Anyone interested?

Big John

Sound modules, etc

Hi BigJohn,

With TB Gold, one is supposed to be able to deal with midi and .wav files, providing one knows enough about C programming to do it. If one knows C or C++ then why bother with TB in the first place. If in fact one can play a .wav file as suggested in Chapt 24 of the Gold manual, using "tbplysnd.c", (which I have not yet figured out how to do), then the routine described below should be a snap.

In my opinion, the main thing in particular which would be really useful to a lot of people, would be a replacement for the old SOUND statement, which is now useless since most all computers no longer have compatible internal speakers. If I knew how to implement it I would have already done it myself. Such might be:

SoundWave([wpfna$],[t]), where [wpfna$] is the path and filename of the .WAV file to be played; and [t], the duration to allow it to play, in seconds, which may be fractional. This would be exactly analogous to the SOUND statement. But the nature of [t] to be interpreted slightly differently:

Since a .wav file will have its own "duration", let t<0 mean to allow the file to run to its natural completion. For t=0, interpret the same as in SOUND, i.e. stop the playing file when this statement is encountered. For t>0, stop the file after t seconds.

Otherwise, as with SOUND, True BASIC continues executing statements while the file is sounding. If a subsequent SoundWave statement with a nonzero duration is encountered before the first sound file is finished, True BASIC waits for the first to complete (for t's<0; or to stop itself for t's>0); then starts the second, and continues executing statements.

With this SoundWav function, it would be possible to add Windows style alarm chirps and beeps (ding.wav, etc.) to one's programs. One could dabble in music, supplying one's own recorded musical notes or sounds. Also do Morse Code. Using recorded words, text-to-speech type routines would be facilitated. Those writing game programs would probably find this sort of thing useful as well.

Also similarly, midi, mp3, or other types of sound files could presumably be used. To me it would be useful if midi files could be handled this simply, but I think midi's might be a bit more complicated. I know this can be implemented for midi files easily in BBC Basic although I do not understand how it does it.

I would love to collaborate but I don't know anything much about C,C++ or how the Windows API works at all. I have seen a lot of C stuff on the 'net about playing midi files but it's all Greek to me. So I can't be of much real help on this, other than to make the suggestion above.

Mike. C.


Hi Rick,

Apart from CHAINing to a media player, the only realistic way to add the sort of music feature you are looking for is for somebody to write a library module for that purpose. The fact that synthesized speech is possible with TB suggests that music should be too. It is very unlikely in the near future that the language system will be updated to include "real" music as a built-in feature.

Big John