com.softsynth.jmsl.score
Class Score

java.lang.Object
  extended by com.softsynth.jmsl.score.Score
All Implemented Interfaces:
XMLCreatable, XMLWritable

public class Score
extends java.lang.Object
implements XMLWritable, XMLCreatable

Score has a handle to a ScoreCollection.
ScoreCollection is a SequentialCollection of Measure.
Measure is a ParallelCollection of Staff.
Staff is a Parallel Collection of Track.
Track is a MusicList of Note
Note implements InstrumentPlayable, and contains musical data as well as graphic info.
JMSL Notation Project

Author:
Nick Didkovsky , copyright 2000 Nick Didkovsky

Field Summary
static CopyBuffer auxCopyBuffer1
           
static CopyBuffer auxCopyBuffer2
           
static CopyBuffer copyBuffer
           
static java.lang.String COPYRIGHT
           
static int JMSL_SCORE_BUILD
           
static int JSYN_INSTRUMENT
           
static int JSYN_MIDI_ORCHESTRA
           
static int JSYN_ORCHESTRA
           
static boolean LITE
           
static int MAX_LITE_MEASURES
           
static int MIDI_INSTRUMENT
           
static int MIDI_ORCHESTRA
           
static int printIndent
           
static int QUIET_INSTRUMENT
           
 
Constructor Summary
Score()
          no arg constructor used by XMLCreatable
Score(int numStaves)
          Specify number of staves.
Score(int numStaves, int systemsPerPage)
          Specify number of staves.
Score(int numStaves, int layoutWidth, int layoutHeight)
           
Score(int numStaves, int layoutWidth, int layoutHeight, java.lang.String name)
           
Score(int numStaves, int systemsPerPage, java.lang.String title)
          Specify number of staves.
Score(int numStaves, java.lang.String title)
          Specify number of staves and title.
 
Method Summary
 void addDirtyListener(DirtyListener listener)
          Add a listener to be notified when this score has been edited
 Note addInterval(DimensionNameSpace dimensionNameSpace, double[] dar)
          Add an interval to the last added note, specifying dimension name space and data[].
 Measure addMeasure()
           
 Measure addMeasure(int tsNumer, int tsDenom)
           
 java.util.Vector addMeasures(int numMeasures)
           
 java.util.Vector addMeasures(int numMeasures, int tsNumer, int tsDenom)
          add numMeasures of indicated timesignature
 Note addNote(DimensionNameSpace dimensionNameSpace, double[] dar)
          Expects length >= 4, where dar[0] is dur ( qtr = 1.0), dar[1] is pitch (1..127), dar[2] is amp (0..1), dar[3] is hold Rounds data[0] to nearest recognized duration.
 Note addNote(double[] dar)
          Expects length >= 4, where dar[0] is dur ( qtr = 1.0), dar[1] is pitch (1..127), dar[2] is amp (0..1), dar[3] is hold Rounds data[0] to nearest recognized duration.
 Note addNote(double dur, double midipitch, double vel, double hold)
           
 Note addNote(Note note)
           
 Note addNote(Note n, int measureNum, int staffNum, int trackNum)
           
 void addNumTracksPerStaffChangedListener(NumTracksPerStaffChangedListener listener)
          objects interested in being notified when the number of tracks per staff has been changed (like the ScoreEditPanel) should implement NumTracksPerStaffChangedListener and register itself with the score using this method
 void build(int numStaves, int layoutWidth, int layoutHeight, java.lang.String name)
           
 void copy(CopyBuffer buf)
          Copy selected notes into specified copy buffer
 java.lang.Object create()
          XMLCreatable Interface
static void deleteCanvas()
          Set static canvas to null to force new upon next build()
 void deleteStaff(int position)
           
 AccidentalLevelManager getAccidentalLevelManager()
          used to hide/show/change accidentals of notes on a Track
 java.lang.String getComposer()
           
 ScoreControlPanel getControlPanel()
           
 java.lang.String getCopyright()
           
 int getCurrentMeasureNumber()
           
 ScoreSection getCurrentScoreSection()
           
 int getCurrentStaffNumber()
           
 boolean getDirty()
           
 EditManager getEditManager()
           
 int getFirstStaffToRender()
           
 java.lang.String getHierarchy()
           
static boolean getInstrumentNamesVisible()
           
 Note getLastAddedNote()
           
 int getLayoutHeight()
           
 int getLayoutWidth()
           
 Measure getMeasure(int n)
           
 java.lang.String getName()
           
 int getNumStaffs()
          Deprecated. use getNumStaves()
 int getNumStaves()
           
 int getNumTracksPerStaff()
           
 Orchestra getOrchestra()
           
 PlayLurkerPatchManager getPlayLurkerPatchManager()
           
static double getRenderDelay()
           
 ScoreCanvas getScoreCanvas()
           
 ScoreCollection getScoreCollection()
           
 ScoreEditPanel getScoreEditPanel()
           
 ScoreLayoutManager getScoreLayoutManager()
           
 ScorePainter getScorePainter()
           
 ScoreSection[] getScoreSections()
           
 Measure getSelectedMeasure()
          useful for mouse editing
 Staff getSelectedStaff()
          useful for mouse editing
 SelectionBuffer getSelectionBuffer()
           
 StaffSpacing getStaffSpacing(int s)
           
static boolean getTempoVisible()
           
 TieManager getTieManager(int s)
           
 boolean getTurnPages()
           
 void handleAttribute(java.lang.String name, java.lang.String value)
          XMLCreatable Interface
static java.lang.String indent()
           
 void insertMeasure(int measureNumber)
          Inswert a new empty measure before measureNumber.
 void insertMeasure(Measure measure)
          Insert a new empty measure before indicated Measure
 void insertStaff(int position)
           
 void killAllNotes()
          Enumerate through all Notes in a Score and call ins.off(JMSL.realTime(), 1.0, note.getPerformanceData()); on each
static Score load(java.lang.String filename)
          Load a Score from an XML file.
static void main(java.lang.String[] args)
           
 void notifyAddMeasure()
           
 void notifyDeleteMeasure()
           
 void openEditScoreDialog(java.awt.Frame f)
           
static void openNewScoreDialog(java.awt.Frame f, NewScoreListener listener)
           
 void ownCanvas()
           
 void paste()
          paste from copy buffer to current location
 void pasteFreeFlow()
          free flow paste from copy buffer to current location
 void pasteWithMeasureInfo()
          paste from copy buffer to current location, preserve measure info like repeats, time sig, etc
 void patchLurkers()
          Run through Vector of Patches in playLurkerPatchManager.
 void rebuildSectionNames()
           
 void removeAllPlayLurkers()
          remove all playLurkers from all tracks of all staves of all measures
 void removeDirtyListener(DirtyListener listener)
           
 void removeNumTracksPerStaffChangedListener(NumTracksPerStaffChangedListener listener)
          objects no longer interested in being notified when the number of tracks per staff has been changed (like the ScoreEditPanel) should remove itself from the score's listeners using this method
 int render()
           
 int render(int startingMeasure)
           
 int render(int startingMeasure, double playTime, boolean scheduled)
           
 void rewind()
          Set current insertion measure to 0, used by addNote().
 void save(java.lang.String filename)
          Save as XML or as ZIP depending on suffix
 void selectAll()
           
 void setComposer(java.lang.String scoreComposer)
           
 void setCopyright(java.lang.String scoreCopyright)
           
 void setCurrentMeasureNumber(int m)
          set measure number for adding/editing
 void setCurrentStaffNumber(int s)
          set staff number for adding/editing
 void setCurrentTrackNumber(int t)
          set track number for adding/editing
 void setDirty(boolean f)
          set T/F if score has been editted or otherwise changed
 void setFirstStaffToRender(int n)
           
static void setInstrumentNamesVisible(boolean b)
           
 void setInstruments()
          Run through every staff and assign ins# from Orchestra to it
 void setLayoutHeight(int layoutHeight)
          Set the canvas height.
 void setLayoutWidth(int layoutWidth)
          Set the canvas width.
 void setMeasureBar(int measureNumber)
           
 void setName(java.lang.String name)
           
 void setNoteFlash(boolean flash)
           
 void setNumTracksPerStaff(int numTracksPerStaff)
          Set the number of Tracks each new Staff will create in its constructor.
 void setOrchestra(Orchestra orch)
           
static void setRenderDelay(double d)
          Set how far in the future a render() is scheduled.
 void setSelectedMeasure(Measure m)
          useful for mouse editing
 void setSelectedStaff(Staff s)
          useful for mouse editing
 void setStaffSpacing(int index, StaffSpacing ss)
          replace StaffSpacing at index
 void setSystemWrap(boolean flag)
          When true, will layout as many systems vertically as there is space.
static void setTempoVisible(boolean b)
           
 void setTurnPages(boolean f)
           
 int size()
           
 java.lang.String toString()
           
static void useSharedCanvas(boolean f)
          If true, all scores render to the same static canvas.
 void writeXML(java.io.PrintWriter out)
           
static void writeXMLPreamble(java.io.PrintWriter out)
           
static void writeXMLWrapup(java.io.PrintWriter out)
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

JMSL_SCORE_BUILD

public static final int JMSL_SCORE_BUILD
See Also:
Constant Field Values

LITE

public static final boolean LITE
See Also:
Constant Field Values

JSYN_INSTRUMENT

public static final int JSYN_INSTRUMENT
See Also:
Constant Field Values

MIDI_INSTRUMENT

public static final int MIDI_INSTRUMENT
See Also:
Constant Field Values

QUIET_INSTRUMENT

public static final int QUIET_INSTRUMENT
See Also:
Constant Field Values

JSYN_ORCHESTRA

public static final int JSYN_ORCHESTRA
See Also:
Constant Field Values

MIDI_ORCHESTRA

public static final int MIDI_ORCHESTRA
See Also:
Constant Field Values

JSYN_MIDI_ORCHESTRA

public static final int JSYN_MIDI_ORCHESTRA
See Also:
Constant Field Values

printIndent

public static int printIndent

copyBuffer

public static CopyBuffer copyBuffer

auxCopyBuffer1

public static CopyBuffer auxCopyBuffer1

auxCopyBuffer2

public static CopyBuffer auxCopyBuffer2

MAX_LITE_MEASURES

public static final int MAX_LITE_MEASURES
See Also:
Constant Field Values

COPYRIGHT

public static final java.lang.String COPYRIGHT
See Also:
Constant Field Values
Constructor Detail

Score

public Score()
no arg constructor used by XMLCreatable


Score

public Score(int numStaves,
             int layoutWidth,
             int layoutHeight,
             java.lang.String name)

Score

public Score(int numStaves,
             int layoutWidth,
             int layoutHeight)

Score

public Score(int numStaves,
             java.lang.String title)
Specify number of staves and title. Score dimensions are calculated as: width = 80% of your display's width, height = the number of staves multiplied by (Staff.DEFAULT_STAFF_SPACE_ABOVE + Staff.DEFAULT_STAFF_SPACE_BELOW + Staff.getStaffHeight())


Score

public Score(int numStaves)
Specify number of staves. Score dimensions are calculated as: width = 80% of your display's width, height = the number of staves multiplied by (Staff.DEFAULT_STAFF_SPACE_ABOVE + Staff.DEFAULT_STAFF_SPACE_BELOW + Staff.getStaffHeight())


Score

public Score(int numStaves,
             int systemsPerPage,
             java.lang.String title)
Specify number of staves. Calculate page height so it can display specified number of systems per page


Score

public Score(int numStaves,
             int systemsPerPage)
Specify number of staves. Calculate page height so it can display specified number of systems per page

Method Detail

handleAttribute

public void handleAttribute(java.lang.String name,
                            java.lang.String value)
XMLCreatable Interface

Specified by:
handleAttribute in interface XMLCreatable

create

public java.lang.Object create()
XMLCreatable Interface

Specified by:
create in interface XMLCreatable

useSharedCanvas

public static void useSharedCanvas(boolean f)
If true, all scores render to the same static canvas. If false, each Score gets its own canvas (you may quickly run out of memory doing this). Shared = true by default


getSelectionBuffer

public SelectionBuffer getSelectionBuffer()
Returns:
SelectionBuffer containing selected notes

setInstrumentNamesVisible

public static void setInstrumentNamesVisible(boolean b)

getInstrumentNamesVisible

public static boolean getInstrumentNamesVisible()

setTempoVisible

public static void setTempoVisible(boolean b)

getTempoVisible

public static boolean getTempoVisible()

deleteCanvas

public static void deleteCanvas()
Set static canvas to null to force new upon next build()


ownCanvas

public void ownCanvas()

selectAll

public void selectAll()

paste

public void paste()
paste from copy buffer to current location


pasteWithMeasureInfo

public void pasteWithMeasureInfo()
paste from copy buffer to current location, preserve measure info like repeats, time sig, etc


pasteFreeFlow

public void pasteFreeFlow()
free flow paste from copy buffer to current location


copy

public void copy(CopyBuffer buf)
Copy selected notes into specified copy buffer


load

public static Score load(java.lang.String filename)
                  throws java.io.IOException
Load a Score from an XML file. Prints messages to console. This is a convenience method which simply uses ScoreXMLLoader

Returns:
new Score
Throws:
java.io.IOException

setLayoutWidth

public void setLayoutWidth(int layoutWidth)
Set the canvas width. Call myScore.ownCanvas() after changing width and height to resize


setLayoutHeight

public void setLayoutHeight(int layoutHeight)
Set the canvas height. Call myScore.ownCanvas() after changing width and height to resize


getLayoutWidth

public int getLayoutWidth()

getLayoutHeight

public int getLayoutHeight()

build

public void build(int numStaves,
                  int layoutWidth,
                  int layoutHeight,
                  java.lang.String name)

addNumTracksPerStaffChangedListener

public void addNumTracksPerStaffChangedListener(NumTracksPerStaffChangedListener listener)
objects interested in being notified when the number of tracks per staff has been changed (like the ScoreEditPanel) should implement NumTracksPerStaffChangedListener and register itself with the score using this method

Parameters:
listener -

removeNumTracksPerStaffChangedListener

public void removeNumTracksPerStaffChangedListener(NumTracksPerStaffChangedListener listener)
objects no longer interested in being notified when the number of tracks per staff has been changed (like the ScoreEditPanel) should remove itself from the score's listeners using this method

Parameters:
listener -

rebuildSectionNames

public void rebuildSectionNames()

setOrchestra

public void setOrchestra(Orchestra orch)

getOrchestra

public Orchestra getOrchestra()

setInstruments

public void setInstruments()
Run through every staff and assign ins# from Orchestra to it


getPlayLurkerPatchManager

public PlayLurkerPatchManager getPlayLurkerPatchManager()

setTurnPages

public void setTurnPages(boolean f)

getTurnPages

public boolean getTurnPages()

addDirtyListener

public void addDirtyListener(DirtyListener listener)
Add a listener to be notified when this score has been edited


removeDirtyListener

public void removeDirtyListener(DirtyListener listener)

setDirty

public void setDirty(boolean f)
set T/F if score has been editted or otherwise changed


getDirty

public boolean getDirty()
Returns:
T/F if score has been editted or otherwise changed

setNoteFlash

public void setNoteFlash(boolean flash)

patchLurkers

public void patchLurkers()
Run through Vector of Patches in playLurkerPatchManager. Each Patch stores a staff index and an instrument index. For each track of each staff of each measure, add the playlurking instrument. Call removeAllPlayLurkers() first if lurkers need to be removed


removeAllPlayLurkers

public void removeAllPlayLurkers()
remove all playLurkers from all tracks of all staves of all measures


getCurrentScoreSection

public ScoreSection getCurrentScoreSection()

getScoreSections

public ScoreSection[] getScoreSections()

setMeasureBar

public void setMeasureBar(int measureNumber)

getNumStaffs

public int getNumStaffs()
Deprecated. use getNumStaves()


getNumStaves

public int getNumStaves()
Returns:
the number of staves in this Score

setFirstStaffToRender

public void setFirstStaffToRender(int n)

getFirstStaffToRender

public int getFirstStaffToRender()

getName

public java.lang.String getName()

setName

public void setName(java.lang.String name)

getScoreCanvas

public ScoreCanvas getScoreCanvas()

getControlPanel

public ScoreControlPanel getControlPanel()

getScoreEditPanel

public ScoreEditPanel getScoreEditPanel()

getScoreCollection

public ScoreCollection getScoreCollection()
Returns:
the underlying playable structure

getEditManager

public EditManager getEditManager()
Returns:
this Score's editmanager

setSelectedStaff

public void setSelectedStaff(Staff s)
useful for mouse editing


getSelectedStaff

public Staff getSelectedStaff()
useful for mouse editing


getStaffSpacing

public StaffSpacing getStaffSpacing(int s)
Returns:
the spacing information for staff#

setStaffSpacing

public void setStaffSpacing(int index,
                            StaffSpacing ss)
replace StaffSpacing at index


getTieManager

public TieManager getTieManager(int s)
Returns:
the spacing information for staff#

setSelectedMeasure

public void setSelectedMeasure(Measure m)
useful for mouse editing


getSelectedMeasure

public Measure getSelectedMeasure()
useful for mouse editing


getAccidentalLevelManager

public AccidentalLevelManager getAccidentalLevelManager()
used to hide/show/change accidentals of notes on a Track


size

public int size()
Returns:
number of measures in score

indent

public static java.lang.String indent()

getHierarchy

public java.lang.String getHierarchy()

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

insertStaff

public void insertStaff(int position)

deleteStaff

public void deleteStaff(int position)

rewind

public void rewind()
Set current insertion measure to 0, used by addNote(). Same as setCurrentMeasureNumber(0) and sets last added note to null Use setCurrentStaffNumber() to set staff index for input


setCurrentMeasureNumber

public void setCurrentMeasureNumber(int m)
set measure number for adding/editing


getCurrentMeasureNumber

public int getCurrentMeasureNumber()
Returns:
current measure number for adding/editing. May have been set by transcriber, for example

setCurrentStaffNumber

public void setCurrentStaffNumber(int s)
set staff number for adding/editing


getCurrentStaffNumber

public int getCurrentStaffNumber()

setCurrentTrackNumber

public void setCurrentTrackNumber(int t)
set track number for adding/editing


addNote

public Note addNote(Note n,
                    int measureNum,
                    int staffNum,
                    int trackNum)

addNote

public Note addNote(double[] dar)
Expects length >= 4, where dar[0] is dur ( qtr = 1.0), dar[1] is pitch (1..127), dar[2] is amp (0..1), dar[3] is hold Rounds data[0] to nearest recognized duration. Copies all other dimensions straight across


addNote

public Note addNote(DimensionNameSpace dimensionNameSpace,
                    double[] dar)
Expects length >= 4, where dar[0] is dur ( qtr = 1.0), dar[1] is pitch (1..127), dar[2] is amp (0..1), dar[3] is hold Rounds data[0] to nearest recognized duration. Copies all other dimensions straight across


addInterval

public Note addInterval(DimensionNameSpace dimensionNameSpace,
                        double[] dar)
Add an interval to the last added note, specifying dimension name space and data[]. Last added note's duration overwrites whatever value is in dar[0]


addNote

public Note addNote(double dur,
                    double midipitch,
                    double vel,
                    double hold)

addNote

public Note addNote(Note note)

getLastAddedNote

public Note getLastAddedNote()

addMeasure

public Measure addMeasure()

addMeasure

public Measure addMeasure(int tsNumer,
                          int tsDenom)

addMeasures

public java.util.Vector addMeasures(int numMeasures,
                                    int tsNumer,
                                    int tsDenom)
add numMeasures of indicated timesignature

Returns:
vector of measures added

addMeasures

public java.util.Vector addMeasures(int numMeasures)
Returns:
addMeasures(numMeasures, 4, 4);

insertMeasure

public void insertMeasure(Measure measure)
Insert a new empty measure before indicated Measure


insertMeasure

public void insertMeasure(int measureNumber)
Inswert a new empty measure before measureNumber. You are responsible for ensuring measureNumber

notifyAddMeasure

public void notifyAddMeasure()

notifyDeleteMeasure

public void notifyDeleteMeasure()

getMeasure

public Measure getMeasure(int n)

getScoreLayoutManager

public ScoreLayoutManager getScoreLayoutManager()

setSystemWrap

public void setSystemWrap(boolean flag)
When true, will layout as many systems vertically as there is space. When false, lays out only one system at top of canvas


getScorePainter

public ScorePainter getScorePainter()

render

public int render()

render

public int render(int startingMeasure)
Returns:
number of measures laid out
Throws:
JustificationException

render

public int render(int startingMeasure,
                  double playTime,
                  boolean scheduled)
Returns:
number of measures laid out
Throws:
JustificationException

writeXMLPreamble

public static void writeXMLPreamble(java.io.PrintWriter out)
                             throws java.io.IOException
Throws:
java.io.IOException

writeXMLWrapup

public static void writeXMLWrapup(java.io.PrintWriter out)
                           throws java.io.IOException
Throws:
java.io.IOException

writeXML

public final void writeXML(java.io.PrintWriter out)
                    throws java.io.IOException
Specified by:
writeXML in interface XMLWritable
Throws:
java.io.IOException

save

public void save(java.lang.String filename)
          throws java.io.IOException
Save as XML or as ZIP depending on suffix

Throws:
java.io.IOException

openNewScoreDialog

public static void openNewScoreDialog(java.awt.Frame f,
                                      NewScoreListener listener)

openEditScoreDialog

public void openEditScoreDialog(java.awt.Frame f)

main

public static void main(java.lang.String[] args)

getRenderDelay

public static double getRenderDelay()
Returns:
how many seconds in the future render() actually renders. Defaults to 0 (instant) but a little delay, say about 0.2, is needed on OS X, for example, which sometimes does not render a note when the user inserts a new one.

setRenderDelay

public static void setRenderDelay(double d)
Set how far in the future a render() is scheduled. Really only needed under OSX which failed to redraw when notes added by hand. Under windows, keep it 0, for OSX try 0.2 Note that tou will experience this little delay between the time you add a note and the note is drawn.


killAllNotes

public void killAllNotes()
Enumerate through all Notes in a Score and call ins.off(JMSL.realTime(), 1.0, note.getPerformanceData()); on each


getNumTracksPerStaff

public int getNumTracksPerStaff()
Returns:
number of tracks each newly created Staff will generate in its constructor

setNumTracksPerStaff

public void setNumTracksPerStaff(int numTracksPerStaff)
Set the number of Tracks each new Staff will create in its constructor. Will not automatically change the number of tracks in existing Staves. So call this right after the constructor, else manage the addition of tracks for those staves that have a different size() yourself.

Parameters:
numTracksPerStaff -

getComposer

public java.lang.String getComposer()

setComposer

public void setComposer(java.lang.String scoreComposer)

getCopyright

public java.lang.String getCopyright()

setCopyright

public void setCopyright(java.lang.String scoreCopyright)