A WAV file is a header specifying format information, followed by a sequence of bytes, representing the state of some audio signal over a length of time.
A WAV file may have any number of channels. Typically, they have 1 (mono) or 2 (for stereo). The data of a WAV file is given as a sequence of frames. A frame consists of samples. There is one sample per channel, per frame. Every wav file has a sample width, or, the number of bytes per sample. Typically this is either 1 or 2 bytes.
The wav module supplies more convenient access to this data. In particular, see the docstring for Wave.channel_data().
The header contains information necessary for playing the WAV file, including the number of frames per second, the number of bytes per sample, and the number of channels in the file.
AUTHORS:
Bases: sage.structure.sage_object.SageObject
A class wrapping a wave audio file.
INPUT:
You must call Wave() with either data = filename, where filename is the name of a wave file, or with each of the following options:
Slicing:
Slicing a Wave object returns a new wave object that has been trimmed to the bytes that you have given it.
Indexing:
Getting the $n$th item in a Wave object will give you the value of the $n$th frame.
Get the data from a given channel.
NOT DONE!
Convolution of self and other, i.e., add their fft’s, then inverse fft back.
Used internally for plotting. Get the x-values for the various points to plot.
Returns the number of frames per second in this wave object.
Returns the length of this file (in seconds).
Returns the number of channels in this wave object.
The total number of frames in this wave object.
Returns the number of bytes per sample in this wave object.
Listen to (or download) this wave file.
Creates a link to this wave file in the notebook.
Plots the audio data.
INPUT:
OUTPUT:
a plot object that can be shown.
Reads out the raw data for the first \(n\) frames of this wave object.
Save this wave file to disk, either as a Sage sobj or as a .wav file.
If no input is given, save the file as ‘sage.wav’.
Used internally for plotting. Get the y-values for the various points to plot.
Slices the wave from start to stop.
Used internally for plotting. Get the y-values for the various points to plot.