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

DISCLAIMER

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.

SYNOPSIS
#include <multimedia/libaudio.h>

double audio_bytes_to_secs(hp, cnt)
Audio_hdr *hp;
unsigned cnt;

unsigned audio_secs_to_bytes(hp, secs)
Audio_hdr *hp;
double secs;

double audio_str_to_secs(str)
char *str;

char *audio_secs_to_str(secs, str, precision)
double secs;
char *str;
int precision;

int audio_cmp_hdr(hp1, hp2)
Audio_hdr *hp1;
Audio_hdr *hp2;

int audio_enc_to_str(hp, 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
audio_hdr(3).