at.ofai.music.beatroot

Class GUI

public class GUI extends JFrame

The main window of BeatRoot's graphical user interface.
Field Summary
static StringAUDIO_SCALE_FACTOR
protected AudioPlayeraudioPlayer
The object which handles sound output
protected AudioProcessoraudioProcessor
The object which reads and processes audio
protected EventListbeats
The current list of beat times
static intBAR
Constants defining metrical levels (see at.ofai.music.worm.WormFile)
static intBEAT
Constants defining metrical levels (see at.ofai.music.worm.WormFile)
static StringBEAT_TRACK
protected Chooserchooser
BeatRoot's file chooser object
protected ControlPanelcontrolPanel
The panel containing buttons and text fields, situated at the bottom of the window
static StringCLEAR_BEATS
static StringCLEAR_METRICAL_LEVELS
static StringCLICK_VOLUME
static booleandebug
Flag for enabling printing of debugging information
protected BeatTrackDisplaydisplayPanel
The main data panel, which displays audio and beat data, and is a component of this window
static doubleDEFAULT_CLICK_VOLUME
static doubleDEFAULT_HIGH_THRESHOLD
static doubleDEFAULT_LOW_THRESHOLD
Default values of preferences
static doubleDEFAULT_SCALE_FACTOR
static StringEDIT_PERCUSSION
static StringEDIT_PREFERENCES
static StringEXIT
static StringHIGH_THRESHOLD
protected EventProcessorlistener
The object which processes key, button and menu events
static StringLENGTH
static StringLEVEL
Strings displayed in metrical level window
static StringLOAD_AUDIO
Strings displayed on menus and buttons
static StringLOAD_BEATS
static StringLOW_THRESHOLD
Strings displayed in preferences window
protected JMenuBarmenuBar
BeatRoot's menu bar
protected ParametersmetricalLevels
Dialog for specifying metrical levels
static StringMARK_METRICAL_LEVEL
static intpercussionCount
Constants and default file names for percussion sounds for each metrical levels
protected ParameterspercussionSounds
Dialog for setting the percussion sounds which are played on beats
protected Parameterspreferences
Dialog for setting preferences
static String[][]PERCUSSION_STRINGS
static StringPHASE
static StringPLAY
static StringPLAY_AUDIO
static StringPLAY_BEATS
static StringREDO
protected JScrollBarscroller
The scroller for showing or changing the position of the viewport relative to the whole audio file
protected JPanelscrollPane
An intermediate level panel containing the displayPanel and scroller
static longserialVersionUID
Avoid compiler warning
static StringSAVE_AUDIO
static StringSAVE_BEATS
static intSEG1
Constants defining metrical levels (see at.ofai.music.worm.WormFile)
static intSEG2
Constants defining metrical levels (see at.ofai.music.worm.WormFile)
static intSEG3
Constants defining metrical levels (see at.ofai.music.worm.WormFile)
static intSEG4
Constants defining metrical levels (see at.ofai.music.worm.WormFile)
static StringSHOW_BEATS
static StringSHOW_IBIS
static StringSHOW_SPECTRO
static StringSHOW_WAVE
static StringSTOP
static Stringtitle
Name of program - displayed as part of window title
static intTRACK
Constants defining metrical levels (see at.ofai.music.worm.WormFile)
static StringUNDO
static Stringversion
Version number of program - displayed as part of window title.
Constructor Summary
GUI(AudioPlayer ap, AudioProcessor proc, Chooser ch)
Constructor: creates the GUI for BeatRoot
Method Summary
voidclearBeatData()
Clear all beats.
voidclearMetricalLevels()
Clears any metrical level annotations from the beats
voideditPercussionSounds()
Opens the percussion sound selection dialog and updates the sound buffers accordingly
voideditPreferences()
Opens preferences dialog and updates the display accordingly.
EventListgetBeatData()
Returns the list of beats
StringgetPercussionSound(int level)
Returns the file name of a percussion sound for playing at beat times.
voidloadAudioData()
Loads and processes an audio file chosen with a file open dialog.
voidloadAudioData(String fileName)
Loads and processes a given audio file.
voidloadBeatData()
Loads beat data from a file chosen by a file open dialog.
voidloadBeatData(String fileName)
Loads beat data from a given file.
protected JMenumakeBeatTrackMenu()
Creates the beat tracking menu
protected JMenumakeEditMenu()
Creates the edit menu
protected JMenumakeFileMenu()
Creates the file menu
protected JMenuItemmakeMenuItem(String text, int menuKey, int altKey, boolean isCheckBox)
Creates a menu item with the given text and key codes.
protected JMenumakePlayMenu()
Creates the play menu
protected JMenumakeViewMenu()
Creates the view menu
voidmarkMetricalLevel()
Opens the metrical levels dialog and annotates the beat data correspondingly
voidsaveBeatData()
Saves beat data to a file chosen by a file save dialog.
voidscroll(int dir)
Scroll the display by a given amount.
voidsetAudioData(double[] onsets, double[] envTimes, int[] envMags)
NOT USED: Sets the data for the amplitude envelope and onsets on the display.
voidsetBeatData(EventList b)
Set the list of beats displayed on this window.
voidsetMetricalLevels()
Initialises the metrical levels dialog
voidsetMidiData(double[] onsets, double[] offsets, int[] pitches)
NOT USED: Sets the data for a MIDI piano-roll display.
voidsetMode(int mode, boolean flag)
Changes the display mode (which elements are displayed on the data panel).
voidsetPercussionSounds()
Initialises the percussion sound dialog and sound buffers
voidsetPreferences()
Copies default values into preferences dialog.
voidsetSpectroData(double[][] data, int len, double tInc, double overlap)
NOT USED Sets the data for displaying the spectrogram of the audio signal.
voidskipTo(double time)
Send a request to the audio player to skip to a given time if it is not playing
voidupdateDisplay(boolean resetSelection)
Redraws the data panel when new data is loaded or the mode or preferences are changed.

Field Detail

AUDIO_SCALE_FACTOR

public static final String AUDIO_SCALE_FACTOR

audioPlayer

protected AudioPlayer audioPlayer
The object which handles sound output

audioProcessor

protected AudioProcessor audioProcessor
The object which reads and processes audio

beats

protected EventList beats
The current list of beat times

BAR

public static final int BAR
Constants defining metrical levels (see at.ofai.music.worm.WormFile)

BEAT

public static final int BEAT
Constants defining metrical levels (see at.ofai.music.worm.WormFile)

BEAT_TRACK

public static final String BEAT_TRACK

chooser

protected Chooser chooser
BeatRoot's file chooser object

controlPanel

protected ControlPanel controlPanel
The panel containing buttons and text fields, situated at the bottom of the window

CLEAR_BEATS

public static final String CLEAR_BEATS

CLEAR_METRICAL_LEVELS

public static final String CLEAR_METRICAL_LEVELS

CLICK_VOLUME

public static final String CLICK_VOLUME

debug

public static boolean debug
Flag for enabling printing of debugging information

displayPanel

protected BeatTrackDisplay displayPanel
The main data panel, which displays audio and beat data, and is a component of this window

DEFAULT_CLICK_VOLUME

public static double DEFAULT_CLICK_VOLUME

DEFAULT_HIGH_THRESHOLD

public static double DEFAULT_HIGH_THRESHOLD

DEFAULT_LOW_THRESHOLD

public static double DEFAULT_LOW_THRESHOLD
Default values of preferences

DEFAULT_SCALE_FACTOR

public static double DEFAULT_SCALE_FACTOR

EDIT_PERCUSSION

public static final String EDIT_PERCUSSION

EDIT_PREFERENCES

public static final String EDIT_PREFERENCES

EXIT

public static final String EXIT

HIGH_THRESHOLD

public static final String HIGH_THRESHOLD

listener

protected EventProcessor listener
The object which processes key, button and menu events

LENGTH

public static final String LENGTH

LEVEL

public static final String LEVEL
Strings displayed in metrical level window

LOAD_AUDIO

public static final String LOAD_AUDIO
Strings displayed on menus and buttons

LOAD_BEATS

public static final String LOAD_BEATS

LOW_THRESHOLD

public static final String LOW_THRESHOLD
Strings displayed in preferences window

menuBar

protected JMenuBar menuBar
BeatRoot's menu bar

metricalLevels

protected Parameters metricalLevels
Dialog for specifying metrical levels

MARK_METRICAL_LEVEL

public static final String MARK_METRICAL_LEVEL

percussionCount

public static final int percussionCount
Constants and default file names for percussion sounds for each metrical levels

percussionSounds

protected Parameters percussionSounds
Dialog for setting the percussion sounds which are played on beats

preferences

protected Parameters preferences
Dialog for setting preferences

PERCUSSION_STRINGS

public static final String[][] PERCUSSION_STRINGS

PHASE

public static final String PHASE

PLAY

public static final String PLAY

PLAY_AUDIO

public static final String PLAY_AUDIO

PLAY_BEATS

public static final String PLAY_BEATS

REDO

public static final String REDO

scroller

protected JScrollBar scroller
The scroller for showing or changing the position of the viewport relative to the whole audio file

scrollPane

protected JPanel scrollPane
An intermediate level panel containing the displayPanel and scroller

serialVersionUID

static final long serialVersionUID
Avoid compiler warning

SAVE_AUDIO

public static final String SAVE_AUDIO

SAVE_BEATS

public static final String SAVE_BEATS

SEG1

public static final int SEG1
Constants defining metrical levels (see at.ofai.music.worm.WormFile)

SEG2

public static final int SEG2
Constants defining metrical levels (see at.ofai.music.worm.WormFile)

SEG3

public static final int SEG3
Constants defining metrical levels (see at.ofai.music.worm.WormFile)

SEG4

public static final int SEG4
Constants defining metrical levels (see at.ofai.music.worm.WormFile)

SHOW_BEATS

public static final String SHOW_BEATS

SHOW_IBIS

public static final String SHOW_IBIS

SHOW_SPECTRO

public static final String SHOW_SPECTRO

SHOW_WAVE

public static final String SHOW_WAVE

STOP

public static final String STOP

title

public static final String title
Name of program - displayed as part of window title

TRACK

public static final int TRACK
Constants defining metrical levels (see at.ofai.music.worm.WormFile)

UNDO

public static final String UNDO

version

public static final String version
Version number of program - displayed as part of window title. DO NOT EDIT: This line is also used in creating the file name of the jar file.

Constructor Detail

GUI

public GUI(AudioPlayer ap, AudioProcessor proc, Chooser ch)
Constructor: creates the GUI for BeatRoot

Parameters: ap Handle to the audio player object proc Handle to the audio processor object ch Handle to the file chooser object

Method Detail

clearBeatData

public void clearBeatData()
Clear all beats. Note that this action can't be undone.

clearMetricalLevels

public void clearMetricalLevels()
Clears any metrical level annotations from the beats

editPercussionSounds

public void editPercussionSounds()
Opens the percussion sound selection dialog and updates the sound buffers accordingly

editPreferences

public void editPreferences()
Opens preferences dialog and updates the display accordingly.

getBeatData

public EventList getBeatData()
Returns the list of beats

getPercussionSound

public String getPercussionSound(int level)
Returns the file name of a percussion sound for playing at beat times.

Parameters: level The requested metrical level

Returns: The file name of the percussion sound for the requested metrical level

loadAudioData

public void loadAudioData()
Loads and processes an audio file chosen with a file open dialog.

loadAudioData

public void loadAudioData(String fileName)
Loads and processes a given audio file.

Parameters: fileName The name of the audio file to open

loadBeatData

public void loadBeatData()
Loads beat data from a file chosen by a file open dialog.

loadBeatData

public void loadBeatData(String fileName)
Loads beat data from a given file.

Parameters: fileName The name of the file to open

makeBeatTrackMenu

protected JMenu makeBeatTrackMenu()
Creates the beat tracking menu

makeEditMenu

protected JMenu makeEditMenu()
Creates the edit menu

makeFileMenu

protected JMenu makeFileMenu()
Creates the file menu

makeMenuItem

protected JMenuItem makeMenuItem(String text, int menuKey, int altKey, boolean isCheckBox)
Creates a menu item with the given text and key codes.

Parameters: text The text that appears on the menu menuKey The key to access the menu item when the menu is open altKey The shortcut key to access the menu item using the ALT key isCheckBox Flag indicating whether the menu item is a binary flag

Returns: The menu item

makePlayMenu

protected JMenu makePlayMenu()
Creates the play menu

makeViewMenu

protected JMenu makeViewMenu()
Creates the view menu

markMetricalLevel

public void markMetricalLevel()
Opens the metrical levels dialog and annotates the beat data correspondingly

saveBeatData

public void saveBeatData()
Saves beat data to a file chosen by a file save dialog.

scroll

public void scroll(int dir)
Scroll the display by a given amount. Used in dragging a selection beyond the left or right edge of the display.

Parameters: dir The direction and number of units to scroll

setAudioData

public void setAudioData(double[] onsets, double[] envTimes, int[] envMags)
NOT USED: Sets the data for the amplitude envelope and onsets on the display.

Parameters: onsets The list of onset times envTimes The list of times corresponding to envelope values (envMag) envMags The values of the signal magnitude at each of these times

setBeatData

public void setBeatData(EventList b)
Set the list of beats displayed on this window.

Parameters: b The list of beats

setMetricalLevels

public void setMetricalLevels()
Initialises the metrical levels dialog

setMidiData

public void setMidiData(double[] onsets, double[] offsets, int[] pitches)
NOT USED: Sets the data for a MIDI piano-roll display.

Parameters: onsets The onset times of each note offsets The offset times of each note pitches The MIDI pitches of each note

setMode

public void setMode(int mode, boolean flag)
Changes the display mode (which elements are displayed on the data panel). Constant values (SHOW_BEATS, etc.) are defined in BeatTrackDisplay.java

Parameters: mode A bit string indicating the elements that should be switched on or off flag Indicates whether the elements should be switched on (true) or off (false)

setPercussionSounds

public void setPercussionSounds()
Initialises the percussion sound dialog and sound buffers

setPreferences

public void setPreferences()
Copies default values into preferences dialog.

setSpectroData

public void setSpectroData(double[][] data, int len, double tInc, double overlap)
NOT USED Sets the data for displaying the spectrogram of the audio signal.

Parameters: data The spectrogram data, indexed by time and frequency len The number of frames of spectrogram data tInc The time between successive frames (hop time) overlap The ratio of hop size to frame size; used for centering the frames in the display

skipTo

public void skipTo(double time)
Send a request to the audio player to skip to a given time if it is not playing

updateDisplay

void updateDisplay(boolean resetSelection)
Redraws the data panel when new data is loaded or the mode or preferences are changed.

Parameters: resetSelection Indicates whether the selected region should be reset