audio_misc(3)
NAME
audio_misc, audio_bytes_to_secs, audio_secs_to_bytes, audio_str_to_secs, audio_secs_to_str, audio_cmp_hdr, audio_enc_to_str − miscellaneous audio functions
SYNOPSIS
#include <multimedia/libaudio.h>
double audio_bytes_to_secs(Audio_hdr ∗hp,
unsigned cnt);
unsigned audio_secs_to_bytes(Audio_hdr ∗hp,
double secs);
double audio_str_to_secs(char ∗str);
char ∗audio_secs_to_str(double secs,
char ∗str,
int precision);
int audio_cmp_hdr(Audio_hdr ∗hp1,
Audio_hdr ∗hp2);
int audio_enc_to_str(Audio_hdr ∗hp,
char ∗str);
DESCRIPTION
These functions perform some simple, useful transformations.
audio_bytes_to_secs() converts a byte count into a floating-point time value that is appropriate to the encoding described by the given audio header. The time value returned indicates the number of seconds of data that would correspond to cnt bytes. Note that a byte count is not the same as an offset in an audio file, since the size of the audio file header is not taken into account.
audio_secs_to_bytes() converts a floating-point time value into a byte count that is appropriate to the encoding described by the given audio header. The byte count is rounded down to a sample frame boundary; this guarantees that the returned count will not refer to an offset in the middle of a multi-byte sample frame.
audio_str_to_secs() converts an ASCII string into a floating-point time value, in seconds. The string should take the form:
[hh:][mm:][ss][.dd]
For example, the following strings all convert to to the floating-point value 90.5:
90.5
1:30.5
0:01:30.500
If the given string contains a syntax error, the value HUGE_VAL is returned.
audio_secs_to_str() converts a floating-point time value into an ASCII string of the form hh:mm:ss.dd. As a special case, the value HUGE_VAL is converted to the string The precision argument specifies the maximum number of digits to appear after the decimal point. A precision of −1 guarantees the maximum precision necessary to represent the given time. The str argument is a pointer to a buffer of at least AUDIO_MAX_TIMEVAL bytes. For convenience, the address of the converted string is returned as the function value.
audio_cmp_hdr() compares the encoding information fields of the two specified audio headers, returning 0 if they are identical. If the encoding type and precision match but the sample rates are different, 1 is returned. Otherwise, −1 is returned.
audio_enc_to_str() converts the encoding information in the given audio header to a printable ASCII string, e.g.:
mono 8-bit u-law @ 8kHz
stereo 16-bit linear PCM @ 44.1kHz
The str argument is a pointer to a buffer of at least AUDIO_MAX_ENCODE_INFO bytes. On successful completion, the value AUDIO_SUCCESS is returned. If any fields of the audio header cannot be interpreted, the value AUDIO_ERR_BADHDR is returned, with an appropriate string stored in the buffer.
SEE ALSO
WARNINGS
The manual pages, header files, and object library associated with /usr/demo/SOUND/libaudio.a are furnished on an as is basis as a preliminary interface to several useful audio data-processing capabilities. A future release of the operating system may redefine the syntax or semantics of some of the functions described herein.
SunOS 5.1/SPARC — Last change: 30 Sep 1991