openpiano.control
Class Controller

java.lang.Object
  extended by openpiano.control.Controller

public class Controller
extends Object

A class managing the main application

Version:
1.0, 07/30/08
Author:
Sascha Westermann

Constructor Summary
Controller(OpenPiano openPiano)
          Constructs a new controller class which constructs all other parts of the application
 
Method Summary
 void createSettingsDialog(Boolean refresh)
          Creates and shows the settings dialog
 Camera getCamera()
          Returns the camera
 MidiSettings getCurrentMidiSettings()
          Returns the settings of the current MIDI file
 javax.media.opengl.GL getGL()
          Returns the current GL context
 GLCore getGLCore()
          Returns the GL core
 MidiLoader getMidiLoader()
          Returns the file loader for MIDI files
 LinkedList<MidiTrack> getMidiTracks()
          Returns the list of MIDI tracks
 Notes getNotes()
          Returns the notes
 OpenPiano getOpenPiano()
          Returns the main application
 Piano getPiano()
          Returns the piano
 Settings getSettings()
          Returns the settings
 JDialog getSettingsDialog()
          Returns the settings dialog
 int glToSlider(float glPos)
          Calculates a GL position to a slider position
 long glToTick(float glPos)
          Calculates a GL position to a MIDI tick
 void handleMidiLoader()
          Handles the appearance of the MidiLoader dialog
 void handleSettings()
          Handles the appearance of the settings dialog
 void initPiano(javax.media.opengl.GL gl)
          Creates the piano
 Boolean isAudioOn(int track)
          Returns true if the audio function is selected for a specified track
 Boolean isBpmStopped()
          Returns true if the clock is stopped
 Boolean isMidiLoaderOn()
          Returns true if the MidiLoader dialog is visible
 Boolean isPlayModeSet()
          Returns true if the play button is activated
 Boolean isRepeatOn()
          Returns true if the repeat button is activated
 Boolean isSettingsOn()
          Returns true if the settings dialog is visible
 Boolean isSliding()
          Returns true if the slider is currently in use
 Boolean isVisualOn(int track)
          Returns true if the visual function is selected for a specified track
 void loadNotes(MidiLoader newMidiLoader)
          Loads new notes according to a MidiLoader object
 void pauseNotes()
          Stops or advances notes
 void playNotes()
          Plays notes, starts from the beginning if end reached
 void registerControlPanel(ControlPanel controlPanel)
          Sets the control panel
 void registerSlidePanel(SlidePanel slidePanel)
          Registers the slider panel
 void resetControlMessages()
          Resets the control messages of a MIDI file to the current tick
 void resetMidiLoaderDialog()
          Resets the MidiLoader Dialog to rearrange items
 void resetMidiMessages()
          Resets the all relevant MIDI messages of a MIDI file to the current tick
 void resumePlaying()
          Resumes playing if the play button is active
 void send(ShortMessage midiMessage)
          Handles and interprets a MIDI command
 void setAudio(int track, Boolean audio)
          Sets the status of the audio function for specified track
 void setAwaitNote(Boolean awaitNotes)
          Sets the status of the await notes function
 void setFastForward(Boolean fastForward)
          Sets the status of fast forward
 void setInstrument(int track)
          Sets a previously selected instrument for a specified track
 void setInstrument(int track, int channel, int instrument)
          Sets an instrument for a specified track and its channel
 void setInstruments()
          Sets all previously selected instruments
 void setMarkKey(Boolean markKey)
          Sets the status of the mark keys function
 void setMidiKeyboard(int channel)
          Sets the channel the MIDI keyboard will play on
 void setRepeatOn(Boolean repeat)
          Sets the status of the repeat button
 void setRewind(Boolean rewind)
          Sets the status of rewind
 void setRewind(Boolean rewind, Boolean oldPlayMode)
          Sets the status of rewind
 void setTempo(int value)
          Sets the tempo of a MIDI file
 void setVisual(int track, Boolean visual)
          Sets the status of the visual function for specified track
 void setVisual(int track, Boolean visual, int color)
          Sets the status of the visual function for specified track
 void setVolume()
          Sets the previously set volume of all tracks
 void setVolume(int track)
          Sets a previously set volume to a track
 void setVolume(int track, int volume)
          Sets the volume of a track
 float sliderToGL(int sliderPos)
          Calculates a slider position to a GL position
 long sliderToTick(int sliderPos)
          Calculates a slider position to a MIDI tick
 void slideTo(int sliderPos)
          Slide to a position in the MIDI file
 void slideTo(JSlider slider)
          Slide to a position in the MIDI file
 void startBpm()
          Starts the clock with the current beats per minute settings
 void stopBpm()
          Stops the clock
 void stopNotes()
          Stops the notes
 float tickToGL(long tick)
          Calculates a MIDI tick to a GL position
 int tickToSlider(long tick)
          Calculates a MIDI tick to a slider position
 void updateControlMessages(long tick)
          Updates MIDI control messages to a specified tick
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Controller

public Controller(OpenPiano openPiano)
Constructs a new controller class which constructs all other parts of the application

Parameters:
openPiano - the reference to the main application
Method Detail

createSettingsDialog

public void createSettingsDialog(Boolean refresh)
Creates and shows the settings dialog

Parameters:
refresh - true if settings dialog should only be refreshed

getCamera

public Camera getCamera()
Returns the camera

Returns:
the camera

getCurrentMidiSettings

public MidiSettings getCurrentMidiSettings()
Returns the settings of the current MIDI file

Returns:
the settings of the current MIDI file

getGL

public javax.media.opengl.GL getGL()
Returns the current GL context

Returns:
the current GL context

getGLCore

public GLCore getGLCore()
Returns the GL core

Returns:
the GL core

getMidiLoader

public MidiLoader getMidiLoader()
Returns the file loader for MIDI files

Returns:
the file loader for MIDI files

getMidiTracks

public LinkedList<MidiTrack> getMidiTracks()
Returns the list of MIDI tracks

Returns:
the list of MIDI tracks

getNotes

public Notes getNotes()
Returns the notes

Returns:
the notes

getPiano

public Piano getPiano()
Returns the piano

Returns:
the piano

getOpenPiano

public OpenPiano getOpenPiano()
Returns the main application

Returns:
the main application

getSettings

public Settings getSettings()
Returns the settings

Returns:
the settings

getSettingsDialog

public JDialog getSettingsDialog()
Returns the settings dialog

Returns:
the settings dialog

glToSlider

public int glToSlider(float glPos)
Calculates a GL position to a slider position

Parameters:
glPos - the GL position to calculate
Returns:
the slider position of the GL position

glToTick

public long glToTick(float glPos)
Calculates a GL position to a MIDI tick

Parameters:
glPos - the GL position to calculate
Returns:
the tick of the GL position

handleMidiLoader

public void handleMidiLoader()
Handles the appearance of the MidiLoader dialog


handleSettings

public void handleSettings()
Handles the appearance of the settings dialog


initPiano

public void initPiano(javax.media.opengl.GL gl)
Creates the piano

Parameters:
gl - the relevant GL context

isAudioOn

public Boolean isAudioOn(int track)
Returns true if the audio function is selected for a specified track

Parameters:
track - the relevant track
Returns:
true if the audio function is selected

isBpmStopped

public Boolean isBpmStopped()
Returns true if the clock is stopped

Returns:
true if the clock is stopped

isMidiLoaderOn

public Boolean isMidiLoaderOn()
Returns true if the MidiLoader dialog is visible

Returns:
true if the MidiLoader dialog is visible

isPlayModeSet

public Boolean isPlayModeSet()
Returns true if the play button is activated

Returns:
true if the play button is activated

isRepeatOn

public Boolean isRepeatOn()
Returns true if the repeat button is activated

Returns:
true if the repeat button is activated

isSettingsOn

public Boolean isSettingsOn()
Returns true if the settings dialog is visible

Returns:
true if the settings dialog is visible

isSliding

public Boolean isSliding()
Returns true if the slider is currently in use

Returns:
true if the slider is currently in use

isVisualOn

public Boolean isVisualOn(int track)
Returns true if the visual function is selected for a specified track

Parameters:
track - the relevant track
Returns:
true if the visual function is selected

loadNotes

public void loadNotes(MidiLoader newMidiLoader)
Loads new notes according to a MidiLoader object

Parameters:
newMidiLoader - the MidiLoader object

pauseNotes

public void pauseNotes()
Stops or advances notes


playNotes

public void playNotes()
Plays notes, starts from the beginning if end reached


resetControlMessages

public void resetControlMessages()
Resets the control messages of a MIDI file to the current tick


resetMidiLoaderDialog

public void resetMidiLoaderDialog()
Resets the MidiLoader Dialog to rearrange items


resetMidiMessages

public void resetMidiMessages()
Resets the all relevant MIDI messages of a MIDI file to the current tick


resumePlaying

public void resumePlaying()
Resumes playing if the play button is active


send

public void send(ShortMessage midiMessage)
Handles and interprets a MIDI command

Parameters:
midiMessage - the MIDI command to handle

setAudio

public void setAudio(int track,
                     Boolean audio)
Sets the status of the audio function for specified track

Parameters:
track - the relevant track
audio - true if the audio function should be enabled

setAwaitNote

public void setAwaitNote(Boolean awaitNotes)
Sets the status of the await notes function

Parameters:
awaitNotes - true if the await notes function should be enabled

registerControlPanel

public void registerControlPanel(ControlPanel controlPanel)
Sets the control panel

Parameters:
controlPanel - the control panel

registerSlidePanel

public void registerSlidePanel(SlidePanel slidePanel)
Registers the slider panel

Parameters:
slidePanel - the slider panel

setFastForward

public void setFastForward(Boolean fastForward)
Sets the status of fast forward

Parameters:
fastForward - true if fast forward should be enabled

setInstrument

public void setInstrument(int track)
Sets a previously selected instrument for a specified track

Parameters:
track - the relevant track

setInstrument

public void setInstrument(int track,
                          int channel,
                          int instrument)
Sets an instrument for a specified track and its channel

Parameters:
track - the relevant track
channel - the corresponding channel
instrument - the instrument to set

setInstruments

public void setInstruments()
Sets all previously selected instruments


setMarkKey

public void setMarkKey(Boolean markKey)
Sets the status of the mark keys function

Parameters:
markKey - true if the mark keys function should be enabled

setMidiKeyboard

public void setMidiKeyboard(int channel)
Sets the channel the MIDI keyboard will play on

Parameters:
channel - the channel to play on

setRepeatOn

public void setRepeatOn(Boolean repeat)
Sets the status of the repeat button

Parameters:
repeat - true if repeat button is active

setRewind

public void setRewind(Boolean rewind)
Sets the status of rewind

Parameters:
rewind - true if rewind should be enabled

setRewind

public void setRewind(Boolean rewind,
                      Boolean oldPlayMode)
Sets the status of rewind

Parameters:
rewind - true if rewind should be enabled
oldPlayMode - true if the play button had been activated previously

setTempo

public void setTempo(int value)
Sets the tempo of a MIDI file

Parameters:
value - the tempo to set

setVisual

public void setVisual(int track,
                      Boolean visual)
Sets the status of the visual function for specified track

Parameters:
track - the relevant track
visual - true if the visual function should be enabled

setVisual

public void setVisual(int track,
                      Boolean visual,
                      int color)
Sets the status of the visual function for specified track

Parameters:
track - the relevant track
visual - true if the visual function should be enabled
color - the color of the notes

setVolume

public void setVolume()
Sets the previously set volume of all tracks


setVolume

public void setVolume(int track)
Sets a previously set volume to a track

Parameters:
track - the corresponding track

setVolume

public void setVolume(int track,
                      int volume)
Sets the volume of a track

Parameters:
track - the corresponding track
volume - the volume to set

sliderToGL

public float sliderToGL(int sliderPos)
Calculates a slider position to a GL position

Parameters:
sliderPos - the slider position to calculate
Returns:
the GL position of the slider position

sliderToTick

public long sliderToTick(int sliderPos)
Calculates a slider position to a MIDI tick

Parameters:
sliderPos - the slider position to calculate
Returns:
the MIDI tick of the slider position

slideTo

public void slideTo(int sliderPos)
Slide to a position in the MIDI file

Parameters:
sliderPos - the position on the slider to slide to

slideTo

public void slideTo(JSlider slider)
Slide to a position in the MIDI file

Parameters:
slider - the slider that holds the value to slide to

startBpm

public void startBpm()
Starts the clock with the current beats per minute settings


stopBpm

public void stopBpm()
Stops the clock


stopNotes

public void stopNotes()
Stops the notes


tickToGL

public float tickToGL(long tick)
Calculates a MIDI tick to a GL position

Parameters:
tick - the tick to calculate
Returns:
the GL position of the MIDI tick

tickToSlider

public int tickToSlider(long tick)
Calculates a MIDI tick to a slider position

Parameters:
tick - the tick to calculate
Returns:
the slider position of the MIDI tick

updateControlMessages

public void updateControlMessages(long tick)
Updates MIDI control messages to a specified tick

Parameters:
tick - the tick to update control messages to