[ Previous | Next | Contents | Glossary | Home | Search ]
Ultimedia Services Version 2 for AIX: Programmer's Guide and Reference

Audio File Access

The UMSAudioFile is a base class used by both the UMSAudioPlayer object and the audio_editor application. For example, the UMSSndFile is an implementation of the base class for a SND file, and a UMSWavFile is an implementation of the base class for a WAVE file. The UMSAudioFile base class provides an abstraction to an audio file that can be mapped onto various audio file formats. This permits other implementations of the base class for new file formats which can be used as UMSAudioFile objects. The UMSAudioFileMClass metaclass has the following method:

make_by_pathname

This method detects the file type of a given file and instantiates the corresponding UMSAudioFile object as specified for that file type in the UMS_config configuration file. This permits the UMSAudioPlayer object to inherit support for new file formats without being modified or recompiled.

To learn more about UMSAudioFile, see:

For introductory information, see Programming with Formatted File Access Objects.

UMSAudioFile Object Method Calls

UMSAudioFile object method calls include:

open Opens an audio file.
close Closes an audio file.
status_ok Checks the return status of the last file operation.
seek Seeks to the location specified by the position parameter.
get_position Returns the current file position.
get_length Returns the the length of the file.
read Reads the audio data from the current file position.
write Writes the audio data to the current file position.
get_file_type Returns the file type alias.
has_attributes Returns whether the file has audio attributes stored in the file.
set_byte_order Sets the byte order audio attribute.
get_byte_order Returns the current byte-order setting.
set_number_format Sets the number format audio attribute.
get_number_format Returns the current number format setting.
set_audio_format_type Sets the audio format audio attribute.
get_audio_format_type Returns the current audio format setting.
set_samples_per_second Sets the sample rate audio attribute.
get_samples_per_second Returns the current sample rate setting.
set_bits_per_sample Sets the bits-per-sample audio attribute.
get_bits_per_sample Returns the current bits-per-sample setting.
set_number_of_channels Set the number of channels audio attribute.
get_number_of_channels Returns the current number of channels setting.

Accessing Audio File Data

The UMSAudioFile provides an abstraction to a file containing audio data. The underlying file is associated with the UMSAudioFile object through the open method and disassociated through the close method. The data in the file is accessed through the read method. File can be created or modified through the write method.

All six audio attributes (audio format, number of channels, number format, samples per second, bits-per-sample, byte_order) can be set through the corresponding set methods before reading or writing to the file.

get_ methods can get the current settings of the audio attributes. The current file location is set through the seek method or queried with the get_position method, which returns the location in the time units specified by the TimeFormat parameter.

There are two types of audio files: formatted and raw. Formatted files have audio attributes stored with the audio data; raw files have no audio attributes in the file. To determine whether the file has audio attributes, use has_attributes. Audio attributes are read and initialized when a file is opened and written when a file is closed.

For introductory information, see Programming with Formatted File Access Objects.


[ Previous | Next | Contents | Glossary | Home | Search ]