at.ofai.music.beatroot
public class BeatTrackDisplay extends JPanel implements MouseListener, MouseMotionListener
Field Summary | |
---|---|
static Color | AUDIO_COLOUR the colour of the amplitude envelope |
static double | adjustment for synchronising audio and graphics, a constant related to the size of the audio buffer in seconds |
static double | allowedError For evaluation of beat tracking results, the largest difference allowed between
the computed and annotated beat times. |
double | audioScale Scaling factor for displaying the amplitude envelope |
protected ListIterator<Event> | beatPtr location of selected beat (previous()) in the EventList beats |
protected EventList | beats beat data encoded as a list of Events |
static Color | BEAT_COLOUR the colour of the lines marking the beats |
static boolean | centred mode for scrolling the display:
if true the cursor remains centred on the screen and the data scrolls;
if false the cursor moves and the data is changed just before
the cursor reaches the edge of the screen. |
protected Rectangle | clipRect the clip rectangle for painting only those areas which have changed |
static Color[] | colour colour map used in the spectrogram |
double | currentTime the current time of audio output (for cursor position) |
static boolean | debug Flag for enabling debugging output |
static int | DEFAULT_MODE the default display mode |
protected double | endSelection end of selected data region (may be < start) |
protected double[] | env the times corresponding to each point in the magnitudes array |
Font | font font used for displaying text |
protected int | fontSize size of font for inter-beat intervals and axis labels |
protected Graphics | gImage the Graphics object for drawing on img |
protected GUI | gui handle to the GUI (parent) object |
double | hiThreshold the threshold above which the maximum colour is used in the spectrogram |
protected BufferedImage | img background image showing audio data but not beats |
double | loThreshold the threshold below which the minimum colour is used in the spectrogram |
protected int[] | magnitudes smoothed amplitude envelope of audio signal |
double | maximumTime the maximum time that might need to be displayed for this input file (seconds) |
FontMetrics | metrics metrics for calculating the size of printed strings |
int | midiMax largest displayed midi pitch |
int | midiMin smallest displayed midi pitch |
double | minimumTime the minimum time that might need to be displayed for this input file (seconds) |
int | mode a bit string indicating what items are displayed on the main data panel |
static Color | MIDI_COLOUR the colour of the MIDI piano roll |
protected double[] | offsets the times of offsets (in seconds) for MIDI data |
protected EventList | onsetList a list of onset events for passing to the tempo induction and beat tracking methods |
protected double[] | onsets the times of onsets (in seconds) |
double | overlap the ratio of hop size to frame size (for aligning the spectrogram with the audio) |
static Color | ONSET_COLOUR the colour of the onset markers on the amplitude envelope |
protected int[] | pitches the pitches of MIDI notes |
protected boolean | regionSelected flag indicating whether a region is selected |
protected int | scrollDirection the direction of scrolling when dragging outside the displayed bounds |
protected Event | selectedBeat the current beat (in editing and annotation operations) |
protected double | selectedBeatTime time of selected beat (for undo) |
static long | serialVersionUID avoid compiler warning |
protected double[][] | spectro spectrogram data |
protected int | spectroLength number of frames of valid spectrogram data |
protected double | startSelection beginning of selected data region |
static Color | SELECTION_COLOUR the background colour of a selected region |
static int | SHOW_AUDIO |
static int | SHOW_BEATS Constants defining the various elements that can be displayed on the main data panel |
static int | SHOW_DATA |
static int | SHOW_IBI |
static int | SHOW_MIDI |
static int | SHOW_ONSETS |
static int | SHOW_SPECTRO |
protected double | tInc time interval between frames of spectrogram data (hop time) |
static Color | TEXT_COLOUR the colour of the text (for IBIs and axes) |
static boolean | usePScore For evaluation, select whether to use the P-score or T-score |
static boolean | useRelativeError For evaluation of beat tracking results, indicates whether allowedError
is interpreted as absolute (in seconds) or relative (0-1). |
protected static double | UNKNOWN Constant representing an unknown relationship between metrical levels |
double | visibleTimeLength the duration of the visible audio data (seconds) |
double | visibleTimeStart the time corresponding to the leftmost point on the panel (seconds) |
protected int | x0 x-coordinate corresponding to time t = 0 (could be off-screen) |
protected int | xSize width in pixels of this panel |
protected int | yBottom y-coordinate of bottom of data area (position of x-axis) |
protected int | yMid y-coordinate of the bottom of the spectrogram and top of the amplitude envelope area |
protected int | ySize height in pixels of this panel |
protected int | yTop y-coordinate of top of data area |
Constructor Summary | |
---|---|
BeatTrackDisplay(GUI g, EventList b) Constructor: |
Method Summary | |
---|---|
void | addAfterSelectedBeat() Interpolates a new beat between the currently selected and the following beat |
void | addBeat(double time) Adds a beat at the given time. |
void | addBeatNow() Adds a beat at the current playback time, with an adjustment for audio latency.
|
static EventList | beatTrack(EventList events) Perform beat tracking where the GUI is not active;
there is no selected region. |
static EventList | beatTrack(EventList events, EventList beats) Perform beat tracking where the GUI is not active;
there is no selected region. |
void | beatTrack() Performs automatic beat tracking and updates the GUI accordingly.
|
void | clearBeats() Clears all beats in the selected area and sets beatPtr
to point between the beats surrounding the deleted area. |
protected void | clearImage() Clears the background image to white |
void | ensureShowing(double time, boolean isRunning) Ensures that the given time is visible on the screen, by requesting a scroll if it is off the screen. |
void | evaluate(String beatsFile) Evaluates a beat tracking solution against an annotation of the data. |
static void | evaluate(String beatsFile, EventList beats) Evaluates a beat tracking solution against an annotation of the data. |
static void | evaluate(String annotationFile, String testFile) Evaluates a beat tracking solution against an annotation of the data. |
static void | evaluate(String beatsFile, double[] beatsArr) Evaluates a beat tracking solution against an annotation of the data. |
void | findClosestBeat(int x, boolean nextHighest) Finds the closest beat to a given time.
|
static double | getAverageIBI(double[] d) Finds the mean tempo (as inter-beat interval) from an array of beat times |
EventList | getBeats() |
Color | getColour(double c) Maps a double to a colour for displaying the spectrogram |
int | getMaximum() |
static double | getMedianIBI(double[] d) Finds the median tempo (as inter-beat interval) from an array of beat times |
int | getMinimum() |
double[] | getOffsets() |
double[] | getOnsets() |
int[] | getPitches() |
static double | getRhythmicLevel(double[] beats, double[] correct) Estimates the metrical relationship between two beat sequences. |
String | getSelectedRegion(String prefix) Gets the start ( selectedStart ) and length
(selectedLength ) of the region of audio which has been
selected (if any). |
int | getValue() Returns the time corresponding to the left edge of the display; used in scrolling |
int | getVisibleAmount() Gets the length of audio that is visible at any one time (i.e. zoom factor). |
void | init(boolean resetSelection) Initialises the panel after new data is loaded or preferences are changed. |
double | locationToTime(int loc) Finds the time corresponding to a given x-coordinate. |
void | markMetricalLevel(int level, int len, int phase) Marks (only) the selected metrical level as specified. |
void | mouseClicked(MouseEvent e) Ignore composite events (already processed as press/drag/release events) |
void | mouseDragged(MouseEvent e) Called when the mouse is moved with a button down; if a beat is selected, it is moved under
the cursor, and if a region is selected it is expanded or shrunk under the cursor. |
void | mouseEntered(MouseEvent e) Request focus for key events whenever the mouse enters the window. |
void | mouseExited(MouseEvent e) Ignore mouse exit events |
void | mouseMoved(MouseEvent e) Ignore mouse movement with no button pressed |
void | mousePressed(MouseEvent e) A mouse button press can be used to move (left button), add (middle button),
or delete (right button) a beat, or to select or deselect a region, by clicking
on the axis. |
void | mouseReleased(MouseEvent e) Called when the mouse button is released, to finalise move/add/delete operations. |
void | moveBeat(double t1, double t2) Changes the time of a beat, and re-sorts the list. |
static Event | newBeat(double time, int beatNum) Creates a new Event object representing a beat. |
void | paint(Graphics g) Renders the panel. |
protected void | paintAudioData(Graphics g) Paints the audio amplitude envelope and onset markers. |
protected void | paintAxes(Graphics g) Paints the time axis and labels |
protected void | paintBackground(Graphics g) Paints the background of the spectrogram and selected area (if any). |
protected void | paintBeats(Graphics g) Paints the beats and inter-baet intervals |
protected void | paintMidiData(Graphics g) Paints MIDI data in piano-roll notation. |
protected void | paintSpectroData(Graphics g) Paints the spectrogram data. |
void | removeBeat(double time) Deletes a beat. |
void | removeSelectedBeat() Deletes the currently selected beat |
void | reorderBeats() The current beat (pointed to by beatPtr ) is moved
to its correct place in the otherwise sorted list of beats. |
protected void | repaintImage() Updates the background image, after creating it if necessary |
void | scrollTo(double time, boolean isRunning) Updates the screen to show data for the current time, by scrolling and/or moving the cursor. |
void | selectBeat(int x, int err) Selects the nearest beat to a given x-coordinate. |
void | selectFirstBeat() Selects the first beat |
void | selectLastBeat() Selects the last beat |
void | selectNextBeat() Selects the beat after the currently selected beat |
void | selectPreviousBeat() Selects the beat before the currently selected beat |
void | setBeats(EventList b) Sets the list of beats. |
void | setEnvTimes(double[] envTimes) Sets the array of times of amplitude envelope points, for displaying. |
void | setMagnitudes(int[] mag) Sets the array of magnitude values, for displaying. |
void | setMetricalLevel(int x) Marks the selected beat with all metrical levels up to and including x. |
void | setMode(int on, int off) Changes the display mode (which elements are displayed on the panel).
|
void | setOffsets(double[] off) Sets the array of offset times, for displaying MIDI input data. |
void | setOnsetList(EventList on) Sets the onset times as a list of Events, for use by the beat tracking methods. |
void | setOnsets(double[] on) Sets the array of onset times, for displaying MIDI or audio input data. |
void | setPitches(int[] p) Sets the array of pitch values, for displaying MIDI input data. |
void | setSpectro(double[][] spec, int len, double inc, double lap) Sets the data for the spectrogram. |
void | setValue(int value) Scrolls the data so that the left edge of the panel corresponds to the given time. |
void | setVisibleAmount(int msec) Sets the length of audio that is visible at any one time (i.e. zoom factor). |
int | timeToLocation(double time) Finds the x-coordinate corresponding to the given time. |
void | toggleAnnotateMode() Turns keyboard annotation of metrical levels on and off |
void | update(Graphics g) Don't clear before repainting |
beats
magnitudes
arrayimg
allowedError
is interpreted as absolute (in seconds) or relative (0-1).Parameters: g A handle to the parent GUI object b The list of beats
Parameters: time Time in seconds of the new beat
Parameters: events The onsets or peaks in a feature list
Returns: The list of beats, or an empty list if beat tracking fails
Parameters: events The onsets or peaks in a feature list beats The initial beats which are given, if any
Returns: The list of beats, or an empty list if beat tracking fails
Parameters: time The current time of audio output in seconds isRunning Flag indicating whether audio output is active
Parameters: beatsFile The file name of the annotation data
Parameters: beatsFile The file name of the annotation data beats The list of beats to be evaluated
Parameters: annotationFile The file name of the annotation data testFile The file name containing the beat times (as text) to be evaluated
Parameters: beatsFile The file name of the annotation data beatsArr The array of beat times to be evaluated
Parameters: x The horizontal location on the panel representing the time to search around nextHighest If true, the returned beat must occur after the given time
Parameters: d An array of beat times
Returns: The average inter-beat interval
Returns: the list of beats
Parameters: c The energy value
Returns: The corresponding colour for this energy value
Returns: The maximum time that might need to be displayed for this data
Parameters: d An array of beat times
Returns: The median inter-beat interval
Returns: The minimum time that might need to be displayed for this data
Returns: the array of offset times
Returns: the array of onset times
Returns: the array of MIDI pitches
Parameters: beats The system's beat times correct The annotated beat times
Returns: A double encoding the metrical relationship between the sequences, which ideally should be an integer or reciprocal of an integer.
selectedStart
) and length
(selectedLength
) of the region of audio which has been
selected (if any). The result is returned as a String containing
a list of attribute-value pairs, where the attribute and value
are separated by '=' and the pairs are separated by a space.Parameters: prefix Other attribute-value pairs
Returns: The prefix followed by the start and length pairs if set
Returns: The time in milliseconds of the left edge of the display
Returns: Length in milliseconds
Parameters: resetSelection Indicates whether the selected region should be cleared
Parameters: loc The given x-coordinate
Returns: The corresponding time in seconds
Parameters: level The given metrical level len The number of lowest-level beats in one unit of this metrical level phase The position of the first lowest-level beat relative to the boundaries of this metrical level, where 0 means it is aligned
Parameters: e The object describing the event that occurred
Parameters: t1 The original time of the beat t2 The new time of the beat
Parameters: time The time of the beat in seconds beatNum The index of the beat
Returns: The Event object representing the beat
Parameters: g The Graphics object for painting on this panel.
Parameters: g The Graphics object to paint to (i.e. img
)
Parameters: g The Graphics object to paint to
Parameters: g The Graphics object to paint to (i.e. img
)
Parameters: g The Graphics object to paint to
Parameters: g The Graphics object to paint to (i.e. img
)
Parameters: g The Graphics object to paint to (i.e. img
)
Parameters: time The time of the beat (in seconds)
beatPtr
) is moved
to its correct place in the otherwise sorted list of beats.Parameters: time The current time of audio output in seconds isRunning Flag indicating whether audio output is active
Parameters: x The x-coordinate (e.g. of a mouse-click) near which a beat is sought err The allowed error in the beat location: if negative, no limit is
imposed on the beat, otherwise the beat must be within err
pixels
of x
. If no suitable beat is found, there is no selected beat.
Parameters: b The list of beats
Parameters: envTimes The array of times in seconds corresponding to the values in magnitudes
Parameters: mag The array of amplitude envelope values
Parameters: x The given highest metrical level
Parameters: on A bit string indicating the elements that should be switched on off A bit string indicating the elements that should be switched off
Parameters: off The array of MIDI offset times
Parameters: on The times of onsets in seconds
Parameters: on The times of onsets in seconds
Parameters: p The array of MIDI pitch values
Parameters: spec The spectrogram data, indexed by time and frequency len The number of frames of spectrogram data inc The time interval between frames of spectrogram data lap The ratio between hop size and frame size
Parameters: value The given time in milliseconds
Parameters: msec Length in milliseconds
Parameters: time Time in seconds
Returns: The corresponding x-coordinate