GLBasic forum

Main forum => GLBasic - en => Topic started by: matchy on 2010-Sep-09

Title: Wav byte
Post by: matchy on 2010-Sep-09
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/
Title: Re: Wav byte
Post by: MrTAToad on 2010-Sep-10
I think Gernot had code to generate a WAV file somewhere - would be worth looking at that...
Title: Re: Wav byte
Post by: matchy on 2010-Sep-10
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:
Title: Re: Wav byte
Post by: backslider on 2010-Sep-10
Do you mean this http://www.glbasic.com/xmlhelp.php?lang=de&id=213&action=view ?
Title: Re: Wav byte
Post by: matchy on 2010-Sep-10
That is from the help file only, which only has the file pos for read not write.
Title: Re: Wav byte
Post by: Bursar on 2010-Sep-10
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.
Title: Re: Wav byte
Post by: matchy on 2010-Sep-10
Oh great...thanks for the link Bursar.  =D