ReadAiffData

Synopsis

Reads in an AIFF file and outputs the data as a short array.


  module ReadAiffData <src_file="readaiff.cxx",
                       cxx_src_files="libaiff.cxx"> {
    ReadAiffParams+IPort2 &parameters;
    cxxmethod+notify_inst+req update;
    string+read+notify+req file_name    => parameters.file_name;
    int+write              Num_channels => parameters.Num_channels;
    int+write              Sample_size  => parameters.Sample_size;
    int+write              Num_samples  => parameters.Num_samples;
    double+write           Sample_rate  => parameters.Sample_rate;
    short+write+OPort2     out_data[Num_samples];
  };

Description

ReadAiffData reads in an uncompressed AIFF file and outputs an array of short values representing the samples that make up the waveform. The amplitude of the samples is represented by a single short value, where 0 is silence, and 32767 and -32768 represent the extensions of the speaker toward and away from the listener. It also sets a number of parameters within the parameter block it references. These describe the format of the sample that it has loaded. This module is not able to read compressed AIFF audio files and will give an error message if this is tried.

Inputs

&ReadAiffParams

Reference to the parameter block, which contains real instances of the parameters for the ReadAiffData function.

file_name

Name of the AIFF file to be loaded. The parameter is of type string. This is the only input parameter to the ReadAiffData function, all the other parameter are set by the ReadAiffData function. Normally the value of this parameter is found by referring to the parameter block, which is referenced by the &ReadAiffParams input.

Outputs

out_data

The output array containing the waveform contained in the AIFF file. The array is of type short and uses two bytes to store the amplitude of each sample, where 0 is quiet, and 32767 and -32768 represent the extensions of the speaker toward and away from the listener. If the input audio has a sample size of 8 bits then each byte is expanded so that it fills the full range of values.

Num_Channels

Number of Channels present in AIFF file. The parameter is of type int, and is set by the ReadAiffData module. Setting this value has no affect upon the ReadAiffData module. Normally the value of this parameter is found by referring to the parameter block, which is referenced by the &ReadAiffParams input.

Sample_Size

Size of each individual sample in bits. The ReadAiffData module can only cope with sample sizes of either 8 or 16 bits. The parameter is of type int, and is set by the ReadAiffData module. Setting this value has no affect upon the ReadAiffData module. Normally the value of this parameter is found by referring to the parameter block, which is referenced by the &ReadAiffParams input.

Num_Samples

Number of individual samples in the AIFF file. The parameter is of type int, and is set by the ReadAiffData module. Setting this value has no affect upon the ReadAiffData module. Normally the value of this parameter is found by referring to the parameter block, which is referenced by the &ReadAiffParams input.

Sample_Rate

Number of samples per second. The parameter is of type double, and is set by the ReadAiffData module. Setting this value has no affect upon the ReadAiffData module. Normally the value of this parameter is found by referring to the parameter block, which is referenced by the &ReadAiffParams input.

Utility Macros

The low-level ReadAiffData module is used in the Functional Macro ReadAiff and the User Macro readAiff. Additionally, this macro also uses the ReadAiffParams parameter block group object, as does the ReadAiffUI UI Macro.

Example

An example application ReadAiffEg is provided, which displays AIFF files on screen using the AGGraph set of graphing components.

Files

iac_proj/rd_aiff/aiffmods.v contains the ReadAiffParams group and the ReadAiffData module V definitions.

Other Notes

The low-level ReadAiffMods library containing the module ReadAiffData does not specify a process. By default the express process will be used.

Authors

Paul G. Lever
Andrew Dodd

Contact

International AVS Centre
Manchester Visualization Centre
Manchester Computing
University of Manchester
Oxford Road
Manchester
United Kingdom
M13 9PL

See Also

ReadAiffParams, ReadAiffUI, ReadAiff, readAiff