[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: II.Sound and .wav files



On Wed, 30 Jun 2004 13:48:45 GMT, Simon Williams <email@luddite.ca> wrote:
> Some time ago I built a quick and dirty Applesoft program that
> stripped the headers and reduced stereo to mono, though I had some
> problems going from 16-bit to 8-bit, so I never quite finished it.

How far did you go with it?

8-bit WAVs are unsigned (0..255); while 16-bit ones are signed
(32768..65535 represent -32768..-1), in 'Little-Endian'
(least-significant byte first) order, thus:

0020000: 2d0d 8413 a504 c0f0 33e4 f6ea 99fc ad04  -.......3.......
0020010: 4a04 06ff d0f4 50ed 16e9 98e0 60e0 7aef  J.....P.....`.z.
0020020: ab02 fd23 fe45 914f c451 dd4a d72f ee12  ...#.E.O.Q.J./..
0020030: a3f7 9dde 24d8 6ae0 dbea 52f1 7eec dce8  ....$.j...R.~...

So a quick-'n'-dirty way to convert from 16- down to 8-bit samples would
be to ignore the LSB, while taking the MSB and flipping the high bit
(e.g., EOR #$80):

           8d   93   84   70   64   6a   7c   84
           84   7f   74   6d   69   60   60   6f
           82   a3   c5   cf   d1   ca   af   92
           77   5e   58   60   6a   71   6c   68
-- 
Matthew W. Miller <mwmiller@columbus.rr.com>      MPlayer does not suck.