Previous Up Next

5.24.7  Extracting samples from audio clips : channel_data

channel_data takes an audio clip as the first argument and optionally the following arguments (in no particular order) :

By default, the data from all channels is extracted and returned as a sequence of lists. If the option matrix is specified, the lists representing channel data are returned as the rows of a matrix. If channel number is specified (or if there is only one channel), the data is returned in a single list. If a range is specified, only the samples from n-th to m-th (inclusive) are extracted. If a real interval a..b is given, it is assumed that the bounds a and b are in seconds and must be given as floating point values.

The returned sample values are all within the interval [−1.0,1.0], i.e. the amplitude of the returned signal is relative. The maximum possible amplitude is represented by the value 1.0.

For example, assume that the directory sounds contains a WAV file example.wav with 3 seconds of stereo sound. Input :


The output is a list L resp. R containing the data between 1.2 and 1.5 seconds in the left resp. right channel of the original file.

Previous Up Next