at.ofai.music.beatroot
Class BeatTrackDisplay

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by javax.swing.JComponent
              extended by javax.swing.JPanel
                  extended by at.ofai.music.beatroot.BeatTrackDisplay
All Implemented Interfaces:
java.awt.event.MouseListener, java.awt.event.MouseMotionListener, java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable, java.util.EventListener, javax.accessibility.Accessible

public class BeatTrackDisplay
extends javax.swing.JPanel
implements java.awt.event.MouseListener, java.awt.event.MouseMotionListener

Main panel of BeatRoot's GUI, which displays the audio and beat data and allows editing, scrolling, selecting, etc

See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class javax.swing.JPanel
javax.swing.JPanel.AccessibleJPanel
 
Nested classes/interfaces inherited from class javax.swing.JComponent
javax.swing.JComponent.AccessibleJComponent
 
Nested classes/interfaces inherited from class java.awt.Container
java.awt.Container.AccessibleAWTContainer
 
Nested classes/interfaces inherited from class java.awt.Component
java.awt.Component.AccessibleAWTComponent, java.awt.Component.BaselineResizeBehavior, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy
 
Field Summary
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.
(package private) static java.awt.Color AUDIO_COLOUR
          the colour of the amplitude envelope
(package private)  double audioScale
          Scaling factor for displaying the amplitude envelope
(package private) static java.awt.Color BEAT_COLOUR
          the colour of the lines marking the beats
protected  java.util.ListIterator<at.ofai.music.util.Event> beatPtr
          location of selected beat (previous()) in the EventList beats
protected  at.ofai.music.util.EventList beats
          beat data encoded as a list of Events
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  java.awt.Rectangle clipRect
          the clip rectangle for painting only those areas which have changed
static java.awt.Color[] colour
          colour map used in the spectrogram
(package private)  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
(package private)  java.awt.Font font
          font used for displaying text
protected  int fontSize
          size of font for inter-beat intervals and axis labels
protected  java.awt.Graphics gImage
          the Graphics object for drawing on img
protected  GUI gui
          handle to the GUI (parent) object
(package private)  double hiThreshold
          the threshold above which the maximum colour is used in the spectrogram
protected  java.awt.image.BufferedImage img
          background image showing audio data but not beats
(package private)  double loThreshold
          the threshold below which the minimum colour is used in the spectrogram
protected  int[] magnitudes
          smoothed amplitude envelope of audio signal
(package private)  double maximumTime
          the maximum time that might need to be displayed for this input file (seconds)
(package private)  java.awt.FontMetrics metrics
          metrics for calculating the size of printed strings
(package private) static java.awt.Color MIDI_COLOUR
          the colour of the MIDI piano roll
(package private)  int midiMax
          largest displayed midi pitch
(package private)  int midiMin
          smallest displayed midi pitch
(package private)  double minimumTime
          the minimum time that might need to be displayed for this input file (seconds)
(package private)  int mode
          a bit string indicating what items are displayed on the main data panel
protected  double[] offsets
          the times of offsets (in seconds) for MIDI data
(package private) static java.awt.Color ONSET_COLOUR
          the colour of the onset markers on the amplitude envelope
protected  at.ofai.music.util.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)
(package private)  double overlap
          the ratio of hop size to frame size (for aligning the spectrogram with the audio)
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  at.ofai.music.util.Event selectedBeat
          the current beat (in editing and annotation operations)
protected  double selectedBeatTime
          time of selected beat (for undo)
(package private) static java.awt.Color SELECTION_COLOUR
          the background colour of a selected region
static long serialVersionUID
          avoid compiler warning
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[][] spectro
          spectrogram data
protected  int spectroLength
          number of frames of valid spectrogram data
protected  double startSelection
          beginning of selected data region
(package private) static java.awt.Color TEXT_COLOUR
          the colour of the text (for IBIs and axes)
protected  double tInc
          time interval between frames of spectrogram data (hop time)
protected static double UNKNOWN
          Constant representing an unknown relationship between metrical levels
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).
(package private)  double visibleTimeLength
          the duration of the visible audio data (seconds)
(package private)  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
 
Fields inherited from class javax.swing.JComponent
accessibleContext, listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
 
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
BeatTrackDisplay(GUI g, at.ofai.music.util.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.
 void beatTrack()
          Performs automatic beat tracking and updates the GUI accordingly.
static at.ofai.music.util.EventList beatTrack(at.ofai.music.util.EventList events)
          Perform beat tracking where the GUI is not active; there is no selected region.
static at.ofai.music.util.EventList beatTrack(at.ofai.music.util.EventList events, at.ofai.music.util.EventList beats)
          Perform beat tracking where the GUI is not active; there is no selected region.
 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(java.lang.String beatsFile)
          Evaluates a beat tracking solution against an annotation of the data.
static void evaluate(java.lang.String beatsFile, double[] beatsArr)
          Evaluates a beat tracking solution against an annotation of the data.
static void evaluate(java.lang.String beatsFile, at.ofai.music.util.EventList beats)
          Evaluates a beat tracking solution against an annotation of the data.
static void evaluate(java.lang.String annotationFile, java.lang.String testFile)
          Evaluates a beat tracking solution against an annotation of the data.
(package private)  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
 at.ofai.music.util.EventList getBeats()
           
(package private)  java.awt.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.
 java.lang.String getSelectedRegion(java.lang.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.
 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(java.awt.event.MouseEvent e)
          Ignore composite events (already processed as press/drag/release events)
 void mouseDragged(java.awt.event.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(java.awt.event.MouseEvent e)
          Request focus for key events whenever the mouse enters the window.
 void mouseExited(java.awt.event.MouseEvent e)
          Ignore mouse exit events
 void mouseMoved(java.awt.event.MouseEvent e)
          Ignore mouse movement with no button pressed
 void mousePressed(java.awt.event.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(java.awt.event.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 at.ofai.music.util.Event newBeat(double time, int beatNum)
          Creates a new Event object representing a beat.
 void paint(java.awt.Graphics g)
          Renders the panel.
protected  void paintAudioData(java.awt.Graphics g)
          Paints the audio amplitude envelope and onset markers.
protected  void paintAxes(java.awt.Graphics g)
          Paints the time axis and labels
protected  void paintBackground(java.awt.Graphics g)
          Paints the background of the spectrogram and selected area (if any).
protected  void paintBeats(java.awt.Graphics g)
          Paints the beats and inter-baet intervals
protected  void paintMidiData(java.awt.Graphics g)
          Paints MIDI data in piano-roll notation.
protected  void paintSpectroData(java.awt.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(at.ofai.music.util.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(at.ofai.music.util.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.
 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(java.awt.Graphics g)
          Don't clear before repainting
 
Methods inherited from class javax.swing.JPanel
getAccessibleContext, getUI, getUIClassID, paramString, setUI, updateUI
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBaseline, getBaselineResizeBehavior, getBorder, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPopupLocation, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, transferFocusBackward, transferFocusDownCycle, validate, validateTree
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

serialVersionUID

public static final long serialVersionUID
avoid compiler warning

See Also:
Constant Field Values

gui

protected GUI gui
handle to the GUI (parent) object


xSize

protected int xSize
width in pixels of this panel


ySize

protected int ySize
height in pixels of this panel


img

protected java.awt.image.BufferedImage img
background image showing audio data but not beats


gImage

protected java.awt.Graphics gImage
the Graphics object for drawing on img


clipRect

protected java.awt.Rectangle clipRect
the clip rectangle for painting only those areas which have changed


x0

protected int x0
x-coordinate corresponding to time t = 0 (could be off-screen)


yTop

protected int yTop
y-coordinate of top of data area


yMid

protected int yMid
y-coordinate of the bottom of the spectrogram and top of the amplitude envelope area


yBottom

protected int yBottom
y-coordinate of bottom of data area (position of x-axis)


fontSize

protected int fontSize
size of font for inter-beat intervals and axis labels


beats

protected at.ofai.music.util.EventList beats
beat data encoded as a list of Events


selectedBeat

protected at.ofai.music.util.Event selectedBeat
the current beat (in editing and annotation operations)


beatPtr

protected java.util.ListIterator<at.ofai.music.util.Event> beatPtr
location of selected beat (previous()) in the EventList beats


selectedBeatTime

protected double selectedBeatTime
time of selected beat (for undo)


startSelection

protected double startSelection
beginning of selected data region


endSelection

protected double endSelection
end of selected data region (may be < start)


regionSelected

protected boolean regionSelected
flag indicating whether a region is selected


scrollDirection

protected int scrollDirection
the direction of scrolling when dragging outside the displayed bounds


onsetList

protected at.ofai.music.util.EventList onsetList
a list of onset events for passing to the tempo induction and beat tracking methods


onsets

protected double[] onsets
the times of onsets (in seconds)


offsets

protected double[] offsets
the times of offsets (in seconds) for MIDI data


pitches

protected int[] pitches
the pitches of MIDI notes


env

protected double[] env
the times corresponding to each point in the magnitudes array


magnitudes

protected int[] magnitudes
smoothed amplitude envelope of audio signal


tInc

protected double tInc
time interval between frames of spectrogram data (hop time)


spectro

protected double[][] spectro
spectrogram data


spectroLength

protected int spectroLength
number of frames of valid spectrogram data


colour

public static final java.awt.Color[] colour
colour map used in the spectrogram


AUDIO_COLOUR

static java.awt.Color AUDIO_COLOUR
the colour of the amplitude envelope


MIDI_COLOUR

static java.awt.Color MIDI_COLOUR
the colour of the MIDI piano roll


ONSET_COLOUR

static java.awt.Color ONSET_COLOUR
the colour of the onset markers on the amplitude envelope


BEAT_COLOUR

static java.awt.Color BEAT_COLOUR
the colour of the lines marking the beats


TEXT_COLOUR

static java.awt.Color TEXT_COLOUR
the colour of the text (for IBIs and axes)


SELECTION_COLOUR

static java.awt.Color SELECTION_COLOUR
the background colour of a selected region


loThreshold

double loThreshold
the threshold below which the minimum colour is used in the spectrogram


hiThreshold

double hiThreshold
the threshold above which the maximum colour is used in the spectrogram


overlap

double overlap
the ratio of hop size to frame size (for aligning the spectrogram with the audio)


audioScale

double audioScale
Scaling factor for displaying the amplitude envelope


minimumTime

double minimumTime
the minimum time that might need to be displayed for this input file (seconds)


maximumTime

double maximumTime
the maximum time that might need to be displayed for this input file (seconds)


visibleTimeStart

double visibleTimeStart
the time corresponding to the leftmost point on the panel (seconds)


visibleTimeLength

double visibleTimeLength
the duration of the visible audio data (seconds)


currentTime

double currentTime
the current time of audio output (for cursor position)


midiMin

int midiMin
smallest displayed midi pitch


midiMax

int midiMax
largest displayed midi pitch


font

java.awt.Font font
font used for displaying text


metrics

java.awt.FontMetrics metrics
metrics for calculating the size of printed strings


SHOW_BEATS

public static final int SHOW_BEATS
Constants defining the various elements that can be displayed on the main data panel

See Also:
Constant Field Values

SHOW_IBI

public static final int SHOW_IBI
See Also:
Constant Field Values

SHOW_DATA

public static final int SHOW_DATA
See Also:
Constant Field Values

SHOW_ONSETS

public static final int SHOW_ONSETS
See Also:
Constant Field Values

SHOW_AUDIO

public static final int SHOW_AUDIO
See Also:
Constant Field Values

SHOW_SPECTRO

public static final int SHOW_SPECTRO
See Also:
Constant Field Values

SHOW_MIDI

public static final int SHOW_MIDI
See Also:
Constant Field Values

DEFAULT_MODE

public static final int DEFAULT_MODE
the default display mode

See Also:
Constant Field Values

mode

int mode
a bit string indicating what items are displayed on the main data panel


adjustment

public static double adjustment
for synchronising audio and graphics, a constant related to the size of the audio buffer in seconds


allowedError

public static double allowedError
For evaluation of beat tracking results, the largest difference allowed between the computed and annotated beat times.


useRelativeError

public static boolean useRelativeError
For evaluation of beat tracking results, indicates whether allowedError is interpreted as absolute (in seconds) or relative (0-1).


usePScore

public static boolean usePScore
For evaluation, select whether to use the P-score or T-score


centred

public 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.


debug

public static boolean debug
Flag for enabling debugging output


UNKNOWN

protected static final double UNKNOWN
Constant representing an unknown relationship between metrical levels

See Also:
Constant Field Values
Constructor Detail

BeatTrackDisplay

public BeatTrackDisplay(GUI g,
                        at.ofai.music.util.EventList b)
Constructor:

Parameters:
g - A handle to the parent GUI object
b - The list of beats
Method Detail

getColour

java.awt.Color getColour(double c)
Maps a double to a colour for displaying the spectrogram

Parameters:
c - The energy value
Returns:
The corresponding colour for this energy value

init

public void init(boolean resetSelection)
Initialises the panel after new data is loaded or preferences are changed.

Parameters:
resetSelection - Indicates whether the selected region should be cleared

setMode

public void setMode(int on,
                    int off)
Changes the display mode (which elements are displayed on the panel). Constant values (SHOW_BEATS, etc.) are defined above.

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

getMinimum

public int getMinimum()
Returns:
The minimum time that might need to be displayed for this data

getMaximum

public int getMaximum()
Returns:
The maximum time that might need to be displayed for this data

getValue

public int getValue()
Returns the time corresponding to the left edge of the display; used in scrolling

Returns:
The time in milliseconds of the left edge of the display

setValue

public void setValue(int value)
Scrolls the data so that the left edge of the panel corresponds to the given time.

Parameters:
value - The given time in milliseconds

ensureShowing

public 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.

Parameters:
time - The current time of audio output in seconds
isRunning - Flag indicating whether audio output is active

scrollTo

public void scrollTo(double time,
                     boolean isRunning)
Updates the screen to show data for the current time, by scrolling and/or moving the cursor.

Parameters:
time - The current time of audio output in seconds
isRunning - Flag indicating whether audio output is active

getSelectedRegion

public java.lang.String getSelectedRegion(java.lang.String prefix)
Gets the start (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

getVisibleAmount

public int getVisibleAmount()
Gets the length of audio that is visible at any one time (i.e. zoom factor).

Returns:
Length in milliseconds

setVisibleAmount

public void setVisibleAmount(int msec)
Sets the length of audio that is visible at any one time (i.e. zoom factor).

Parameters:
msec - Length in milliseconds

update

public void update(java.awt.Graphics g)
Don't clear before repainting

Overrides:
update in class javax.swing.JComponent

paint

public void paint(java.awt.Graphics g)
Renders the panel.

Overrides:
paint in class javax.swing.JComponent
Parameters:
g - The Graphics object for painting on this panel.

clearImage

protected void clearImage()
Clears the background image to white


repaintImage

protected void repaintImage()
Updates the background image, after creating it if necessary


paintBackground

protected void paintBackground(java.awt.Graphics g)
Paints the background of the spectrogram and selected area (if any).

Parameters:
g - The Graphics object to paint to (i.e. img)

paintAxes

protected void paintAxes(java.awt.Graphics g)
Paints the time axis and labels

Parameters:
g - The Graphics object to paint to

paintBeats

protected void paintBeats(java.awt.Graphics g)
Paints the beats and inter-baet intervals

Parameters:
g - The Graphics object to paint to

paintMidiData

protected void paintMidiData(java.awt.Graphics g)
Paints MIDI data in piano-roll notation.

Parameters:
g - The Graphics object to paint to (i.e. img)

paintAudioData

protected void paintAudioData(java.awt.Graphics g)
Paints the audio amplitude envelope and onset markers.

Parameters:
g - The Graphics object to paint to (i.e. img)

paintSpectroData

protected void paintSpectroData(java.awt.Graphics g)
Paints the spectrogram data.

Parameters:
g - The Graphics object to paint to (i.e. img)

timeToLocation

public int timeToLocation(double time)
Finds the x-coordinate corresponding to the given time.

Parameters:
time - Time in seconds
Returns:
The corresponding x-coordinate

locationToTime

public double locationToTime(int loc)
Finds the time corresponding to a given x-coordinate.

Parameters:
loc - The given x-coordinate
Returns:
The corresponding time in seconds

findClosestBeat

void findClosestBeat(int x,
                     boolean nextHighest)
Finds the closest beat to a given time. Returns with beatPtr pointing to the beat (as next()), unless the list is empty

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

toggleAnnotateMode

public void toggleAnnotateMode()
Turns keyboard annotation of metrical levels on and off


selectFirstBeat

public void selectFirstBeat()
Selects the first beat


selectLastBeat

public void selectLastBeat()
Selects the last beat


selectNextBeat

public void selectNextBeat()
Selects the beat after the currently selected beat


selectPreviousBeat

public void selectPreviousBeat()
Selects the beat before the currently selected beat


removeSelectedBeat

public void removeSelectedBeat()
Deletes the currently selected beat


addAfterSelectedBeat

public void addAfterSelectedBeat()
Interpolates a new beat between the currently selected and the following beat


setMetricalLevel

public void setMetricalLevel(int x)
Marks the selected beat with all metrical levels up to and including x.

Parameters:
x - The given highest metrical level

markMetricalLevel

public void markMetricalLevel(int level,
                              int len,
                              int phase)
Marks (only) the selected metrical level as specified.

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

selectBeat

public void selectBeat(int x,
                       int err)
Selects the nearest beat to a given x-coordinate.

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.

newBeat

public static at.ofai.music.util.Event newBeat(double time,
                                               int beatNum)
Creates a new Event object representing a beat.

Parameters:
time - The time of the beat in seconds
beatNum - The index of the beat
Returns:
The Event object representing the beat

addBeatNow

public void addBeatNow()
Adds a beat at the current playback time, with an adjustment for audio latency. This was a failed attempt at a tapping interface to BeatRoot, as the timing doesn't appear to be at all stable on my platform.


addBeat

public void addBeat(double time)
Adds a beat at the given time.

Parameters:
time - Time in seconds of the new beat

moveBeat

public void moveBeat(double t1,
                     double t2)
Changes the time of a beat, and re-sorts the list. If no beat is found at the given time, an error message is printed and nothing further occurs.

Parameters:
t1 - The original time of the beat
t2 - The new time of the beat

removeBeat

public void removeBeat(double time)
Deletes a beat.

Parameters:
time - The time of the beat (in seconds)

clearBeats

public void clearBeats()
Clears all beats in the selected area and sets beatPtr to point between the beats surrounding the deleted area.


reorderBeats

public void reorderBeats()
The current beat (pointed to by beatPtr) is moved to its correct place in the otherwise sorted list of beats.


beatTrack

public static at.ofai.music.util.EventList beatTrack(at.ofai.music.util.EventList events)
Perform beat tracking where the GUI is not active; there is no selected region.

Parameters:
events - The onsets or peaks in a feature list
Returns:
The list of beats, or an empty list if beat tracking fails

beatTrack

public static at.ofai.music.util.EventList beatTrack(at.ofai.music.util.EventList events,
                                                     at.ofai.music.util.EventList beats)
Perform beat tracking where the GUI is not active; there is no selected region.

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

beatTrack

public void beatTrack()
Performs automatic beat tracking and updates the GUI accordingly. If a region is selected, the beats outside the region are kept intact and the tempo preserved across the region boundaries.


getAverageIBI

public static double getAverageIBI(double[] d)
Finds the mean tempo (as inter-beat interval) from an array of beat times

Parameters:
d - An array of beat times
Returns:
The average inter-beat interval

getMedianIBI

public static double getMedianIBI(double[] d)
Finds the median tempo (as inter-beat interval) from an array of beat times

Parameters:
d - An array of beat times
Returns:
The median inter-beat interval

getRhythmicLevel

public static double getRhythmicLevel(double[] beats,
                                      double[] correct)
Estimates the metrical relationship between two beat sequences.

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.

evaluate

public void evaluate(java.lang.String beatsFile)
Evaluates a beat tracking solution against an annotation of the data.

Parameters:
beatsFile - The file name of the annotation data

evaluate

public static void evaluate(java.lang.String beatsFile,
                            at.ofai.music.util.EventList beats)
Evaluates a beat tracking solution against an annotation of the data.

Parameters:
beatsFile - The file name of the annotation data
beats - The list of beats to be evaluated

evaluate

public static void evaluate(java.lang.String annotationFile,
                            java.lang.String testFile)
Evaluates a beat tracking solution against an annotation of the data.

Parameters:
annotationFile - The file name of the annotation data
testFile - The file name containing the beat times (as text) to be evaluated

evaluate

public static void evaluate(java.lang.String beatsFile,
                            double[] beatsArr)
Evaluates a beat tracking solution against an annotation of the data.

Parameters:
beatsFile - The file name of the annotation data
beatsArr - The array of beat times to be evaluated

mouseClicked

public void mouseClicked(java.awt.event.MouseEvent e)
Ignore composite events (already processed as press/drag/release events)

Specified by:
mouseClicked in interface java.awt.event.MouseListener

mouseExited

public void mouseExited(java.awt.event.MouseEvent e)
Ignore mouse exit events

Specified by:
mouseExited in interface java.awt.event.MouseListener

mouseMoved

public void mouseMoved(java.awt.event.MouseEvent e)
Ignore mouse movement with no button pressed

Specified by:
mouseMoved in interface java.awt.event.MouseMotionListener

mouseEntered

public void mouseEntered(java.awt.event.MouseEvent e)
Request focus for key events whenever the mouse enters the window.

Specified by:
mouseEntered in interface java.awt.event.MouseListener

mousePressed

public void mousePressed(java.awt.event.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.

Specified by:
mousePressed in interface java.awt.event.MouseListener
Parameters:
e - The object describing the event that occurred

mouseDragged

public void mouseDragged(java.awt.event.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.

Specified by:
mouseDragged in interface java.awt.event.MouseMotionListener

mouseReleased

public void mouseReleased(java.awt.event.MouseEvent e)
Called when the mouse button is released, to finalise move/add/delete operations.

Specified by:
mouseReleased in interface java.awt.event.MouseListener

getBeats

public at.ofai.music.util.EventList getBeats()
Returns:
the list of beats

getOnsets

public double[] getOnsets()
Returns:
the array of onset times

getOffsets

public double[] getOffsets()
Returns:
the array of offset times

getPitches

public int[] getPitches()
Returns:
the array of MIDI pitches

setOnsetList

public void setOnsetList(at.ofai.music.util.EventList on)
Sets the onset times as a list of Events, for use by the beat tracking methods.

Parameters:
on - The times of onsets in seconds

setOnsets

public void setOnsets(double[] on)
Sets the array of onset times, for displaying MIDI or audio input data.

Parameters:
on - The times of onsets in seconds

setOffsets

public void setOffsets(double[] off)
Sets the array of offset times, for displaying MIDI input data.

Parameters:
off - The array of MIDI offset times

setEnvTimes

public void setEnvTimes(double[] envTimes)
Sets the array of times of amplitude envelope points, for displaying.

Parameters:
envTimes - The array of times in seconds corresponding to the values in magnitudes

setMagnitudes

public void setMagnitudes(int[] mag)
Sets the array of magnitude values, for displaying.

Parameters:
mag - The array of amplitude envelope values

setPitches

public void setPitches(int[] p)
Sets the array of pitch values, for displaying MIDI input data.

Parameters:
p - The array of MIDI pitch values

setBeats

public void setBeats(at.ofai.music.util.EventList b)
Sets the list of beats.

Parameters:
b - The list of beats

setSpectro

public void setSpectro(double[][] spec,
                       int len,
                       double inc,
                       double lap)
Sets the data for the spectrogram.

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