next up previous contents
Next: 4.3 Using ADPCM compression Up: 4 Advanced topics Previous: 4.1 Optimizing MIDAS performance

Using µ-law compression

In MIDAS Digital Audio System, µ-law samples and streams can be used as an effective compromise between CPU and space usage and sound quality, as they provide sound quality almost equivalent to 16-bit samples while using only as much CPU time and space as 8-bit samples. This section describes how µ-law samples are encoded and used with MIDAS.

Encoding µ-law samples

Encoding µ-law samples is simple. The tools/ directory in the MIDAS distribution contains directories for each supported platform, and these directories contain a program called ulaw. This program can be used to encode 16-bit samples into µ-law samples, and decode µ-law samples back to 16-bit ones. The syntax is simple. To encode a 16-bit sample file to µ-law, use:

        ulaw e input-file-name output-file-name

And to decode a µ-law file to a 16-bit one, use:

        ulaw d input-file-name output-file-name

The files should contain just raw sample data, with no headers. Stereo and mono samples and streams are processed exactly the same way.

Using µ-law samples

µ-law samples and streams are used just like any other samples and streams in MIDAS Digital Audio System. Simply pass the playback function MIDAS_SAMPLE_ULAW_MONO or MIDAS_SAMPLE_ULAW_STEREO as the sample type, and everything will work normally. µ-law sample data can be used for both samples and streams.



Petteri Kangaslampi
Sun Mar 1 22:25:31 EET 1998