uk.org.toot.music.performance
Class Performer

java.lang.Object
  extended by uk.org.toot.music.performance.Performer

public class Performer
extends java.lang.Object

A Performer performs on an Instrument. It can swing (eigth note) timing. Currently it can only render to a MIDI file, not perform live.

Author:
st

Constructor Summary
Performer(java.lang.String name, Instrument instrument)
           
 
Method Summary
 Instrument getInstrument()
           
 java.lang.String getName()
           
 float getSwingRatio()
           
 void renderBar(int[] notes, javax.sound.midi.Track track, long startTick, int ppqn)
          Render a bar of notes as MIDI to the specified Track from the specified start tick with the specified ticks per bar.
 void setInstrument(Instrument instrument)
           
 void setSwingRatio(float ratio)
          Set the ratio of the first eigth note to the second eigth note when a quarter note is divied into two with a swing or shuffle rhythm
 float swing(int time)
          Swing the timing of a sixty-fourth note timing such that when a quarter note is divided into two the second eigth note is delayed relative to its nominal position and all other sixty-fourth note timings are smoothly varied accordingly.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Performer

public Performer(java.lang.String name,
                 Instrument instrument)
Method Detail

getName

public java.lang.String getName()

renderBar

public void renderBar(int[] notes,
                      javax.sound.midi.Track track,
                      long startTick,
                      int ppqn)
               throws javax.sound.midi.InvalidMidiDataException
Render a bar of notes as MIDI to the specified Track from the specified start tick with the specified ticks per bar.

Parameters:
notes - the notes to render
track - the MIDI Track to render to
startTick - the tick at the start of the bar
ticksPerBar - the number of ticks per bar
Throws:
javax.sound.midi.InvalidMidiDataException

getSwingRatio

public float getSwingRatio()
Returns:
the ratio of the first eigth note to the second eigth note when a quarter note is divided into two with a swing or shuffle rhythm

setSwingRatio

public void setSwingRatio(float ratio)
Set the ratio of the first eigth note to the second eigth note when a quarter note is divied into two with a swing or shuffle rhythm

Parameters:
ratio - the ratio of the first eigth note to the second eigth note

swing

public float swing(int time)
Swing the timing of a sixty-fourth note timing such that when a quarter note is divided into two the second eigth note is delayed relative to its nominal position and all other sixty-fourth note timings are smoothly varied accordingly.

Parameters:
time - the timing index of a sixty-fourth note in a bar
Returns:
the swung timing

getInstrument

public Instrument getInstrument()
Returns:
the instrument

setInstrument

public void setInstrument(Instrument instrument)
Parameters:
instrument - the instrument to set


Copyright © 2004, 2005, 2006, 2007 Steve Taylor. All Rights Reserved.