Most newer models of SPARCstations have a telephone-quality audio chip and an internal speaker. The ``native'' encoding for the audio chip is 8-bit μ-law sampled at 8000/second.
Audio data can be manipulated in two formats: ``raw'' and ``self-describing:''
A file containing raw audio data can be played by sending it directly to the audio device, /dev/audio, as with this command:
% cat audio.raw > /dev/audio
The header must be stripped from self-describing audio data when specifying an audio/basic message part. The header must be present when specifying an audio/x-next part.
In support of the audio/basic and audio/x-next types, it is possible to convert between the raw format and the self-describing format by using a patched version of the raw2audio program. The patches are described a little later on.
The record program delivers self-describing data. The play
program plays self-describing data. These programs are found in the /usr/demo/SOUND/ directory when the demo program package is
installed.
However, the record program is not suitable for running from mhn,
because the control-C that terminates a recording session raises havoc.
The audiotool program, if available, is more suitable.
In the absence of the audiotool program, you can use a little
wrapper program for record that prompts for the beginning and
end of the recording session.
An example wrapper, rec.sparc, can be obtained as described in
appendix .
The audio/x-next type may be used with any self-describing audio data recognized by the SunOS audio programs, such as ADPCM format. The ADPCM format is compressed μ-law encoding based on the CCITT G.721 Adaptive Delta Pulse Code Modulation algorithm. Sun introduced support for this type of audio data with OpenWindows 3.0.
ADPCM format data cannot be directly played to or recorded from the audio chip; it must first be converted back to the native 8-bit μ-law format. Conversions to and from the two encodings can be done with the adpcm_enc and adpcm_dec programs found in the $OPENWINHOME/bin/ directory.
Suggested profile entries for mhn relevant to recording and playing back audio data in ADPCM format are these:
mhn-compose-audio/x-next: audiotool '%f' && adpcm_enc < '%f' mhn-show-audio/x-next: %paudiotool -p '%f'
Suggested profile entries for mhn relevant to recording and playing back audio data in native μ-law format are these:
mhn-compose-audio/basic: audiotool '%f' && raw2audio -F < '%f' mhn-show-audio/basic: %praw2audio 2>/dev/null | play
Because the raw2audio, play, and record programs are provided in source form with SunOS 4.1, it is possible to compile them for systems running earlier versios of SunOS. The sources can be found in the SunOS 4.1 Demos installation.
If these programs are unavailable, then you will be able to manipulate only the raw, native audio data formats by reading and writing directly to the /dev/audio device via cat.
If you do have the raw2audio, play, and record programs (regardless of which version of SunOS you're running), then you need to apply some source changes by using the publicly available patch program. The source patches are part of the MH 6.8 source tree:
% (cd /usr/demo/SOUND; patch) < miscellany/multi-media/SPARC/SOUND.diff % cd /usr/demo/SOUND % make raw2audioThese patches add a -F option to the raw2audio program, and add recognition of types for several different audio data formats.
The raw2audio -F option strips the header from self-describing audio data. This enables you to compose message drafts with #audio/basic.
Be sure to put the audio programs from /usr/demo/SOUND into a directory named in your $PATH environment variable so that the audio programs can be found if absolute paths aren't used in the invocations.
Other useful audio programs supplied with later versions of SunOS 4.1
include these:
The directory /usr/demo/SOUND/sounds/ contains various pre-recorded sound files. The audio files have the extension .au.