|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object at.ofai.music.beatroot.AudioProcessor
public class AudioProcessor
Audio processing class (adapted from PerformanceMatcher).
Field Summary | |
---|---|
protected java.lang.String |
audioFileName
Source of input data. |
protected javax.sound.sampled.AudioFormat |
audioFormat
Format of the audio data in pcmInputStream |
protected javax.sound.sampled.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 at.ofai.music.util.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 javax.sound.sampled.AudioInputStream |
pcmInputStream
Uncompressed version of rawInputStream . |
protected double[] |
phaseDeviation
Phase deviation onset detection function, indexed by frame. |
(package private) at.ofai.music.worm.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 javax.sound.sampled.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. |
(package private) java.io.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(java.lang.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(java.lang.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. |
java.lang.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(java.lang.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. |
java.lang.String |
toString()
Gives some basic information about the audio being processed. |
protected void |
weightedPhaseDeviation()
Calculates the weighted phase deviation onset detection function. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
protected javax.sound.sampled.AudioInputStream rawInputStream
protected javax.sound.sampled.AudioInputStream pcmInputStream
rawInputStream
.
In the (normal) case where the input is already PCM data,
rawInputStream == pcmInputStream
protected javax.sound.sampled.SourceDataLine audioOut
protected javax.sound.sampled.AudioFormat audioFormat
pcmInputStream
protected int channels
audioFormat
protected float sampleRate
audioFormat
protected java.lang.String audioFileName
protected double hopTime
protected double fftTime
fftSize
is always power of 2.
protected int hopSize
hopTime
)
protected int fftSize
fftTime
)
protected int frameCount
protected double frameRMS
protected double ltAverage
protected byte[] inputBuffer
protected double[] circBuffer
protected int cbIndex
protected double[] window
protected double[] reBuffer
protected double[] imBuffer
protected double[] prevPhase
protected double[] prevPrevPhase
protected double[] phaseDeviation
protected double[] spectralFlux
protected int[] freqMap
protected int freqMapSize
freqMap
. Note that the length of
the array is greater, because its size is not known at creation time.
protected double[] prevFrame
protected double[] newFrame
protected double[][] frames
protected double[] energy
protected double[] onsets
protected at.ofai.music.util.EventList onsetList
protected ProgressIndicator progressCallback
protected int totalFrames
java.io.BufferedReader stdIn
at.ofai.music.worm.Plot plot
public static boolean debug
public static boolean doOnsetPlot
protected static boolean silent
public static boolean batchMode
public static double silenceThreshold
public static double rangeThreshold
public static int normaliseMode
public static int energyOversampleFactor
public static final int liveInputBufferSize
public static final int MAX_LENGTH
Constructor Detail |
---|
public AudioProcessor()
setInputFile()
).
Method Detail |
---|
public void print()
public java.lang.String readLine()
public java.lang.String toString()
toString
in class java.lang.Object
public void setProgressCallback(ProgressIndicator c)
c
- the AudioProcessor representing the other performancepublic void setLiveInput()
pcmInputStream
is set to
null
, indicating that the method did not complete
successfully.
public void setInputFile(java.lang.String fileName)
pcmInputStream
is set to
null
, indicating that the method did not complete
successfully.
fileName
- The path name of the input audio file.protected void init()
public void closeStreams()
protected void makeFreqMap(int fftSize, float sampleRate)
protected void weightedPhaseDeviation()
public boolean getFrame()
protected void processFrame()
public void processFile()
public static double[] getFeatures(java.lang.String fileName)
fileName
- File containing the data
public void processFeatures(java.lang.String fileName, double hopTime)
onsetList
and onsets
.
fileName
- The file of feature valueshopTime
- The spacing of feature values in timepublic void setDisplay(BeatTrackDisplay btd)
|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |