Brent Brown wrote: > > > I need to know how the sound information is stored in a WAV file and how I > > can programmatically raise the volume of the sound in a WAV file. > > > > Any hint welcome > > > > Thank you > > > > Duilio Foschi > > > > Not so [OT] because you can do this on a PIC. Here's some ideas. > > Assuming a simple mono 8 bit per sample recording, there is a > about 20 bytes or so of header information at the start of the file > and then the audio samples are stored as 8 bit values. The data is > "biased" with a 7Fh DC offset so that silence is recorded as 7Fh. > Kind of like a single rail audio amplifier would be biased at half the > supply voltage. For simple play back from a micro with a PWM > output just send each byte to the PWM register sequentially at the > original sample rate. Put an RC filter on the output and > capacitively couple it to an audio amp. A little rough by hey - it > works! Even play back the header bytes, they go by so fast you > hardly hear a scratch. > > Back to the subject, to digitally amplify a .wav file you would need > to do something like this for each 8 bit sample: > - Remove the offset by subtracting 7Fh for data above 7Fh or > subtracting from 7Fh for data below 7Fh > - Multiply by your amplification factor > - Put the offset back in by adding 7Fh or subtracting from 7Fh as > necessary > - Store it or play it > > You are limited to what you can do in an 8 bit file before clipping. > Using 16 bit intermediate maths helps by letting you do stuff like > this: for 10% increase in volume, multiply by 11 then divide by 10. > > Brent Brown > Electronic Design Solutions > 16 English Street > Hamilton, New Zealand > Ph/fax: +64 7 849 0069 > Mobile: 025 334 069 > eMail: brent.brown@clear.net.nz tHE LAST CIRCUIT CELLAR HAS INFORMATION ABOUT SOUND REPRODUCED BY PWM...