Wav byte

Previous topic - Next topic

matchy

Is this right or how can the write spot be set regarding WAV header file creation?!   :blink:

Code (glbasic) Select

WRITESTR  iWavefile,"RIFF"                    // 04
WRITEBYTE iWavefile,INTEGER(iRIFFLength)     // 08
WRITESTR  iWavefile,"WAVE"                    // 12  Format
WRITESTR  iWavefile,"fmt "                    // 16  Subchunk1ID
WRITEBYTE iWavefile,INTEGER(16)               // 20  Subchunk1Size (16 FOR PCM)
WRITEBYTE iWavefile,INTEGER(1)                // 22  AudioFormat   (1 FOR PCM)
WRITEBYTE iWavefile,INTEGER(iChannels)        // 24  NumChannels Mono/Stereo
WRITEBYTE iWavefile,INTEGER(iSampleRate)      // 28  SamplesPerSecond
WRITEBYTE iWavefile,INTEGER(iBytesPerSecond)
WRITEBYTE iWavefile,INTEGER(iBlockAlign)
WRITEBYTE iWavefile,INTEGER(iBitsPerSample)   // 36
WRITESTR  iWavefile,"data"                    // 40  Subchunk2ID
WRITEBYTE iWavefile,INTEGER(iDataLength)      // 44  Subchunk2Size


WAV file format:
https://ccrma.stanford.edu/courses/422/projects/WaveFormat/

MrTAToad

I think Gernot had code to generate a WAV file somewhere - would be worth looking at that...

matchy

Oh cool and I suppose I'll wait for G's code if it's not on the forum.  :bed:

I can generate the wave data but just generally wanted to know how to write in a file to a certain spot, like with the PUT statement in VB.  :whistle:


matchy

#4
That is from the help file only, which only has the file pos for read not write.

Bursar

Take a look here: http://www.glbasic.com/forum/index.php?topic=4897.0

The SFXR wrapper outputs the sound as a .wav file, and the wav writing code is in its own little function.

matchy

Oh great...thanks for the link Bursar.  =D