Question On Wav Files

I started programming within QuickBasic Then I could create pictures, by just drawing lines and figures and manipulate the pixel colors in the screen. I could also generate all kind of random music in QuickBasic.

Now (in VB6) I can still create pictures all by myself but I cannot code sounds.


  You can still use the QBasic style to generate (random) music with the Api Call Beep 

Declare Function Beep Lib "kernel32.dll" (ByVal dwFreq As Long, ByVal dwDuration As Long) As Long

copied this from an VbApi guide: Beep plays a sound, but its exact behavior varies between platforms. Windows 95/98: The function always plays the SystemDefault system sound, regardless of the values passed to the function. Windows NT/2000: The function plays a tone through the computer's internal speaker at the desired frequency for a specified duration. www.vbapi.com/ref/b/beep.html (original source is extinct)

Actually, when you try this out to generate random music, the QBasic-way, the result just isn't that good at all.


So I want to learn how to edit a .wav, so the sounds are changed, and I also like to learn how to create a .wav from scratch, with nothing but VB6 code to create this Wav file. E.G. Create a .wav file that plays note "dee" for one tenth of a second, etcetera.

I do not look for a program to modify sounds, but I want to learn how to modify sounds myself.

Hope this all is clear and I hope someone can point me the way.

.WAV files are just binary-encoded sound. First, you need to understand the format of .WAV files. There are probably some resources on the web. Note that they record sound and not "notes". Thus, they are at a lower level than QuickBasic sound generation, which does most of the work for you as far as generating wave-forms, etc.

BTW, Wiki may not be the proper place for this kind of question.

Pet peeve alert: It irks me when people say "it's available on the web" or "That's off-topic for this forum", and they fail to give a URI to a better place. If this is not the "proper place", what is ? -- DavidCary


[Content moved to SoundFileFormats.]


If you don't mind working under the GPL, you might want to take a look at the sr-convert source code (http://sr-convert.sourceforge.net/). It reads and writes WAV files, and the WAV file code is clearly separated from the sample-rate conversion code (which is most of the SSE stuff).

If you want to do synthesis you will be doing sine waves and the like. For example if your sampling rate is 48 kHz and you want to produce a 500 Hz tone for one second, then you need 48000 samples, and sample[x] = sin(x*2*pi*500/48000). -- EdwardKiser


I also did find some code to generate a wav file, all you do have to add is a sinoide, or any data, the header of the wav is next generated within the code. I figure this is the best way to handle all and everything. A link soon later. gb


EditText of this page (last edited September 14, 2004) or FindPage with title or text search