at.ofai.music.beatroot
public class AudioProcessor extends Object
Field Summary | |
---|---|
protected String | audioFileName Source of input data.
|
protected AudioFormat | audioFormat Format of the audio data in pcmInputStream |
protected SourceDataLine | audioOut Line for audio output (not used, since output is done by AudioPlayer) |
static boolean | batchMode Flag for batch mode. |
protected int | cbIndex The index of the next position to write in the circular buffer. |
protected int | channels Number of channels of audio in audioFormat |
protected double[] | circBuffer Audio data is scaled to the range [0,1] and averaged to one channel and
stored in a circular buffer for reuse (if hopTime < fftTime). |
static boolean | debug Flag for enabling or disabling debugging output |
static boolean | doOnsetPlot Flag for plotting onset detection function. |
protected double[] | energy The RMS energy of all frames. |
static int | energyOversampleFactor Ratio between rate of sampling the signal energy (for the amplitude envelope) and the hop size |
protected int | fftSize The size of an FFT frame in samples (see fftTime ) |
protected double | fftTime The approximate size of an FFT frame in seconds, as set by the command
line option -f FFTTime. |
protected int | frameCount The number of overlapping frames of audio data which have been read. |
protected double | frameRMS RMS amplitude of the current frame. |
protected double[][] | frames The magnitude spectra of all frames, used for plotting the spectrogram. |
protected int[] | freqMap A mapping function for mapping FFT bins to final frequency bins.
|
protected int | freqMapSize The number of entries in freqMap . |
protected int | hopSize Spacing of audio frames in samples (see hopTime ) |
protected double | hopTime Spacing of audio frames (determines the amount of overlap or skip
between frames). |
protected double[] | imBuffer The imaginary part of the data for the in-place FFT computation.
|
protected byte[] | inputBuffer Audio data is initially read in PCM format into this buffer. |
static int | liveInputBufferSize Audio buffer for live input. |
protected double | ltAverage Long term average frame energy (in frequency domain representation). |
static int | MAX_LENGTH Maximum file length in seconds. |
protected double[] | newFrame The magnitude spectrum of the current frame. |
static int | normaliseMode Determines method of normalisation. |
protected EventList | onsetList The estimated onset times and their saliences. |
protected double[] | onsets The estimated onset times from peak-picking the onset detection function(s). |
protected AudioInputStream | pcmInputStream Uncompressed version of rawInputStream .
|
protected double[] | phaseDeviation Phase deviation onset detection function, indexed by frame. |
Plot | plot Object for plotting output (for debugging / development) . |
protected double[] | prevFrame The magnitude spectrum of the most recent frame.
|
protected double[] | prevPhase Phase of the previous frame, for calculating an onset function
based on spectral phase deviation. |
protected double[] | prevPrevPhase Phase of the frame before the previous frame, for calculating an
onset function based on spectral phase deviation. |
protected ProgressIndicator | progressCallback GUI component which shows progress of audio processing. |
static double | rangeThreshold For dynamic range compression, this value is added to the log magnitude
in each frequency bin and any remaining negative values are then set to zero. |
protected AudioInputStream | rawInputStream Input data stream for this performance (possibly in compressed format) |
protected double[] | reBuffer The real part of the data for the in-place FFT computation.
|
protected float | sampleRate Sample rate of audio in audioFormat |
static double | silenceThreshold RMS frame energy below this value results in the frame being set to zero,
so that normalisation does not have undesired side-effects. |
protected static boolean | silent Flag for suppressing all standard output messages except results. |
protected double[] | spectralFlux Spectral flux onset detection function, indexed by frame. |
BufferedReader | stdIn Standard input for interactive prompts (for debugging). |
protected int | totalFrames Total number of audio frames if known, or -1 for live or compressed input. |
protected double[] | window The window function for the STFT, currently a Hamming window. |
Constructor Summary | |
---|---|
AudioProcessor() Constructor: note that streams are not opened until the input file is set
(see setInputFile() ). |
Method Summary | |
---|---|
void | closeStreams() Closes the input stream(s) associated with this object. |
static double[] | getFeatures(String fileName) Reads a text file containing a list of whitespace-separated feature values.
|
boolean | getFrame() Reads a frame of input data, averages the channels to mono, scales
to a maximum possible absolute value of 1, and stores the audio data
in a circular input buffer. |
protected void | init() Allocates memory for arrays, based on parameter settings |
protected void | makeFreqMap(int fftSize, float sampleRate) Creates a map of FFT frequency bins to comparison bins.
|
void | print() For debugging, outputs information about the AudioProcessor to
standard error. |
void | processFeatures(String fileName, double hopTime) Reads a file of feature values, treated as an onset detection function,
and finds peaks, which are stored in onsetList and onsets . |
void | processFile() Processes a complete file of audio data. |
protected void | processFrame() Processes a frame of audio data by first computing the STFT with a
Hamming window, then mapping the frequency bins into a part-linear
part-logarithmic array, then computing the spectral flux
then (optionally) normalising and calculating onsets. |
String | readLine() For interactive pause - wait for user to hit Enter |
void | setDisplay(BeatTrackDisplay btd) Copies output of audio processing to the display panel. |
void | setInputFile(String fileName) Sets up the streams and buffers for audio file input.
|
void | setLiveInput() Sets up the streams and buffers for live audio input (CD quality).
|
void | setProgressCallback(ProgressIndicator c) Adds a link to the GUI component which shows the progress of matching. |
String | toString() Gives some basic information about the audio being processed. |
protected void | weightedPhaseDeviation() Calculates the weighted phase deviation onset detection function.
|
pcmInputStream
audioFormat
fftTime
)fftSize
is always power of 2.freqMap
. Note that the length of
the array is greater, because its size is not known at creation time.hopTime
)rawInputStream
.
In the (normal) case where the input is already PCM data,
rawInputStream == pcmInputStream
audioFormat
setInputFile()
).Parameters: fileName File containing the data
Returns: An array containing the feature values
Returns: true if a frame (or part of a frame, if it is the final frame) is read. If a complete frame cannot be read, the InputStream is set to null.
onsetList
and onsets
.Parameters: fileName The file of feature values hopTime The spacing of feature values in time
pcmInputStream
is set to
null
, indicating that the method did not complete
successfully.Parameters: fileName The path name of the input audio file.
pcmInputStream
is set to
null
, indicating that the method did not complete
successfully.Parameters: c the AudioProcessor representing the other performance