Wav file tone generation library.

agraham

Expert
Licensed User
Longtime User
Unlike some versions of Basic Basic4PPC does not implement a Beep statement that can specify the frequency and duration of a tone. These libraries, one each for desktop and device, let you write a wav file of the required frequency and duration. They also provide playback of any wav file with some additional options not available to the Basic4PPC Sound facility.

I knocked these libraries up for a specific use in another thread but thought that I would post them here complete with demo app and help file in case they are of use to anyone else.
 

Attachments

  • WavFileGen1.0.zip
    13.9 KB · Views: 308

Zenerdiode

Active Member
Licensed User
I've been using the Wav library in one of my apps for calibrating our mechanical timers - if the user is too slow it gives five low tones, too fast five high tones and within range, a continuous mid tone. Very useful. :)

Then fiddling a bit with the demo application, agraham's note about having the sampling 2.5 times the desired frequency is quite important. For example, if you keep the default rate of 11025samp.s-1; play a tone of 6kHz and 8kHz. The 8kHz tone sounds appreciably lower than the 6kHz tone. A good example of Quantization. That's probably why CD audio is sampled at 44.1kHz.

Using 44100 with the library produces the correct tone.
 

Zenerdiode

Active Member
Licensed User
You're correct (as usual :)) - I always got those mixed up.

I struggle with where the time goes, but that was getting on for four years ago (Gulp)

I'm re-visiting the program that I use your Wav file generator; I'm porting it to the Desktop. Is the (desktop) library able to be packaged for merging? If so I'd be very grateful if you would do that for me.
 
Top