Package com.softsynth.jmsl.score
Class Note
java.lang.Object
com.softsynth.jmsl.score.Note
- All Implemented Interfaces:
DimensionNameSpaceEditable
,InstrumentPlayable
,XMLWritable
,java.lang.Cloneable
public class Note extends java.lang.Object implements InstrumentPlayable, java.lang.Cloneable, XMLWritable, DimensionNameSpaceEditable
Note
A Note is a Playable object with dur/note/amp/hold info as well as graphic info.
JMSL Notation Project
A Note is a Playable object with dur/note/amp/hold info as well as graphic info.
JMSL Notation Project
- Author:
- Nick Didkovsky , copyright 2000 Nick Didkovsky
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and Type Method Description static java.lang.String
accToString(int acc)
Note
addGraceNote(double duration, double pitch, double amp, double hold, boolean accPreferSharp, boolean beamedOut, boolean slurredOut, boolean tiedOut, boolean slashed, int mark)
Note
addGraceNote(Note graceNote)
Note
addInterval(double pitch)
Add an interval to this Note.Note
addInterval(Note newInterval)
add newNote as interval to this Note.void
addMark(int mark)
add a mark to this note.void
addUserBean(java.lang.Object bean)
Add a bean to a note.double
calcGraceNoteRollbackTime()
void
clearIntervals()
void
clearStemInfoOverride()
static Note
cloneNote(Note n)
Make an exact copy of a Note.static void
copyProperties(Note fromNote, Note toNote)
Copy properties from one Note to another.static java.lang.String
dynamicToString(int dynamic)
boolean
endOf8va()
boolean
endOf8vb()
boolean
endOfCresc()
boolean
endOfDecresc()
static boolean
firstNoteOfLine(Note note)
boolean
get8vaIn()
boolean
get8vaOut()
Deprecated.Misnomer.boolean
get8vbIn()
boolean
get8vbOut()
Deprecated.Misnomer.int
getAcc()
boolean
getAccHidden()
int
getAccidentalOffset()
byte
getAccidentalVisibilityPolicy()
One of: ACCIDENTAL_SHOW_NORMAL, ACCIDENTAL_SHOW_NEVER, ACCIDENTAL_SHOW_ALWAYSint
getAccPref()
Indicates Note's spelling preferences if it requires an accidentalboolean
getAltEnharmonicSpelling()
Flag determines if note uses alternate enharmonic spelling (ex E#, F##, Cb, Fbb, etc).boolean
getBeamedOut()
int[]
getCompleteIndexArray()
int
getCoreDuration()
Synonynmous with getNoteDur()boolean
getCrescIn()
boolean
getCrescOut()
double[]
getData()
double
getData(int dimension)
double[]
getDataCopy()
Convenience method, shorthand for getData() and System.arraycopy()boolean
getDecrescIn()
boolean
getDecrescOut()
DimensionNameSpace
getDimensionNameSpace()
double[]
getDoubleArray()
synonym with getData()java.awt.geom.Point2D
getDrawingAnchor()
anchor is the horizontal note locationdouble
getDurationData()
int
getDynamic()
boolean
getGlissOut()
Note
getGraceNoteHandle()
A grace note has a pointer to the note which it is attached to.java.util.Vector
getGraceNotes()
double
getGraceNoteSeparationScaler()
Note
getHandle()
If this Note is an interval, get the root of the chord (called the handle)static Note
getHighest(Note n)
Assuming this Note is a chord, find the Note with the highest pitch.double
getHoldData()
static int
getIndexOfCoreDuration(double duration)
input: duration like 0.25java.util.Vector
getIntervals()
double
getLayoutShiftX()
you can nudge a note left or rightint
getLevel()
static Note
getLowest(Note n)
Assuming this Note is a chord, find the Note with the lowest pitch.int
getMark()
Just returns first of marks.java.util.Vector
getMarks()
int
getMeasureIndex()
int
getNoteDur()
double
getNoteDurationAsPerformanceTime()
static double
getNoteDurationAsPerformanceTime(int durConst)
java.awt.Color
getNoteheadColor()
double
getNoteheadScale()
int
getNoteHeadType()
int
getNoteIndex()
int
getNumDots()
int
getNumGraceNotes()
int
getNumTails()
boolean
getOverflow()
int
getOverrideLevel()
double[]
getPerformanceData()
translate internal performance data based on expressive properties.double[]
getPerformanceDataCopy()
translate internal performance data based on expressive properties.double
getPitchData()
static Note
getRoot(Note n)
Assuming this Note is a chord, find the Note with the lowest pitch.Score
getScore()
boolean
getSelected()
boolean
getSlurredIn()
boolean
getSlurredOut()
static Note[]
getSortedChord(Note n)
Get an array containing this Note's intervals and handle in sorted orderint
getStaffIndex()
int
getStemInfo()
Get stem info 0=no stem, 1=stem up, 2= stem downboolean
getStemInfoOverride()
java.lang.String
getText()
int
getTextOffsetX()
horizontal text displacementint
getTextOffsetY()
vertical text displacementboolean
getTiedIn()
boolean
getTiedOut()
Track
getTrack()
int
getTuplet()
java.util.Vector
getUserBeans()
A Note can have a vector of custom user-defined beans attached to it.double
getVelData()
boolean
is8va()
boolean
is8vb()
boolean
isBeamable()
boolean
isChord()
boolean
isFirstGraceNote()
boolean
isGraceNote()
boolean
isInterval()
boolean
isLedgerLinesVisible()
boolean
isMonoNote()
boolean
isNoteheadVisible()
boolean
isOverrideLevel()
boolean
isRest()
boolean
isStemVisible()
Get visibility flag of this note's stem.boolean
isVisible()
static boolean
lastNoteOfLine(Note note)
static void
main(java.lang.String[] args)
static java.lang.String
markToString(int mark)
Note
nextNote()
static boolean
performExpressionMarks()
double
play(double playTime, Composable parent, Instrument ins)
play() is called by MusicList.Note
prevNote()
void
removeAllGraceNotes()
void
removeGraceNote(Note graceNote)
void
removeInterval(Note n)
void
removeUserBean(java.lang.Object bean)
void
render(java.awt.Graphics g, double zoom)
void
replaceDrawingAnchor(java.awt.geom.Point2D p)
anchor is the horizontal note locationstatic void
resortChord(Note n)
make root == handle == lowest pitched note, sort the vector of intervals low to highvoid
set8va(boolean flag)
Set 8va property on Note.void
set8vaOut(boolean flag)
Deprecated.Misnomer.void
set8vb(boolean flag)
Set 8vb property on Note.void
set8vbOut(boolean flag)
Deprecated.Misnomer.void
setAcc(int acc)
Set accidental info 0=none, 1=sharp, 2=flat, 3=natural, 4= DOUBLE FLAT, 5= DOUBLE SHARPvoid
setAccHidden(boolean flag)
Set accidental hidden flag 0,1void
setAccidentalOffset(int accidentalOffset)
void
setAccidentalVisibilityPolicy(byte accidentalVisibilityPolicy)
One of: ACCIDENTAL_SHOW_NORMAL, ACCIDENTAL_SHOW_NEVER, ACCIDENTAL_SHOW_ALWAYSvoid
setAccPref(int pref)
Set preferred accidental spelling: Note.ACC_PREFER_SHARP or Note.ACC_PREFER_FLAT.void
setAltEnharmonicSpelling(boolean flag)
Set flag determines if note uses alternate enharmonic spelling (ex E#, F##, Cb, Fbb, etc).void
setBeamedOut(boolean f)
set the beamed out flag for this note and all intervals and handlevoid
setCrescOut(boolean flag)
Set crescendo out flag on Note.void
setData(double[] data)
void
setData(double dur, double midinote, double vel, double hold)
set four dimensional double[] datavoid
setData(int dimension, double value)
Set the value of one element of the double[] array held by this Note.void
setDecrescOut(boolean flag)
Set decrescendo out flag on Note.void
setDimensionNameSpace(DimensionNameSpace d)
void
setDimensionNameSpaceDefaults()
void
setDoubleArray(double[] dar)
Hand Note an entirely new array of data.void
setDrawingAnchor(java.awt.geom.Point2D p)
anchor is the horizontal note locationvoid
setDurationData(double dur)
set performable duration, where 1.0=quarter notevoid
setDynamic(int dynamic)
set dynamic marking for this notevoid
setGlissOut(boolean f)
void
setGraceNoteHandle(Note graceNoteHandle)
void
setGraceNotes(java.util.Vector graceNotes)
void
setGraceNoteSeparationScaler(double graceNoteSeparationScaler)
static void
setGraceNotesToTrackOfParent(Note note)
void
setHandle(Note p)
void
setHoldData(double hold)
set performable duration of hold, where 1.0 = quarter notestatic void
setIntervalsToTrackOfHandle(Note note)
void
setIsGraceNote(boolean flag)
Set flag determines if note is a grace notevoid
setLayoutShiftX(double layoutShiftX)
you can nudge a note left or rightvoid
setLedgerLinesVisible(boolean showLedgerLines)
void
setLevel(int l)
set the vertical placement of note on staffvoid
setMark(int mark)
Deprecated.use addMark() insteadvoid
setMeasureIndex(int m)
Use with caution! Only retrievable with getMeasureIndex() if this note has no track or staffvoid
setNoteDur(int d)
Set note duration to constants 0..8 standing for WHOLE, HALF, QUARTER,...void
setNoteheadColor(java.awt.Color noteheadColor)
void
setNoteheadScale(double noteheadScale)
void
setNoteHeadType(int noteheadType)
Set to Note.NOTEHEAD_BLACK or Note.NOTEHEAD_WHITE, or new constants for X, diamond, etcvoid
setNoteheadVisible(boolean flag)
void
setNumDots(int n)
Set number of dots following this note, 0, 1, or 2void
setNumTails(int n)
Deprecated.does nothing.void
setOverflow(boolean f)
true if this note is at the end of a track whose total durations exceeds the measure's timesig's duration.void
setOverrideLevel(boolean isOverrideLevel)
void
setOverrideLevel(int overrideLevel)
overrideLevel is the level the user can set to force a note to be rendered at specified level This value is stored and expressed in rendering if isOverrideLevel() is truestatic void
setPerformExpressionMarks(boolean flag)
if true, staccato, accent staccato, and tenuto marks will affect hold time on a Notevoid
setPitchData(double pitch)
set performable pitch 1..127.void
setSelected(boolean flag)
Set selected flag on Note (if user drew a rectangle that included this Note, for ex.)void
setSlurredOut(boolean flag)
Set slur out flag on Notevoid
setStaffIndex(int s)
Use with caution! Only retrievable with getStaffIndex() if this note has no track or staffvoid
setStemInfo(int stem)
Set stem info 0=no stem, 1=stem up, 2= stem downvoid
setStemInfoOverride(int stem)
override stem direction.void
setStemVisible(boolean visible)
Set visibility of this note's stem.void
setText(java.lang.String s)
Set text to display by this notevoid
setTextOffsetX(int xoffset)
horizontal text displacementvoid
setTextOffsetY(int yoffset)
vertical text displacementvoid
setTiedOut(boolean flag)
Set tied out flag on Notevoid
setTrack(Track track)
void
setTuplet(int n)
Set the tuplet value (3 for triplet, 5 for quintuplet, etc, up to 31void
setVelData(double vel)
set performable amplitude data (0..1)void
setVisible(boolean flag)
Set visible flag on Note.void
setXPositionsOfGraceNotes()
boolean
startOf8va()
boolean
startOf8vb()
boolean
startOfCresc()
boolean
startOfDecresc()
static java.lang.String
stemDirection(int x)
java.lang.String
toString()
static double
tupletDur(int n, double dur)
Calculate duration of n-tuplet, given n and its non-tuplet duration.void
writeXML(java.io.PrintWriter out)
void
writeXML(java.io.PrintWriter out, boolean includeIntervals)
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Field Details
-
ACCIDENTAL_SHOW_NORMAL
public static byte ACCIDENTAL_SHOW_NORMAL -
ACCIDENTAL_SHOW_NEVER
public static byte ACCIDENTAL_SHOW_NEVER -
ACCIDENTAL_SHOW_ALWAYS
public static byte ACCIDENTAL_SHOW_ALWAYS -
GRACE_NOTE_SIZE_SCALER
public static double GRACE_NOTE_SIZE_SCALER -
GRACE_NOTE_TIME_SCALER
public static double GRACE_NOTE_TIME_SCALER -
DBUG
public static boolean DBUG -
MARK_NONE
public static final int MARK_NONE- See Also:
- Constant Field Values
-
MARK_ACCENT
public static final int MARK_ACCENT- See Also:
- Constant Field Values
-
MARK_STACCATO
public static final int MARK_STACCATO- See Also:
- Constant Field Values
-
MARK_TENUTO
public static final int MARK_TENUTO- See Also:
- Constant Field Values
-
MARK_WEDGE
public static final int MARK_WEDGE- See Also:
- Constant Field Values
-
MARK_ACCENT_STACCATO
public static final int MARK_ACCENT_STACCATO- See Also:
- Constant Field Values
-
MARK_ACCENT_TENUTO
public static final int MARK_ACCENT_TENUTO- See Also:
- Constant Field Values
-
MARK_WEDGE_STACCATO
public static final int MARK_WEDGE_STACCATO- See Also:
- Constant Field Values
-
MARK_FERMATA
public static final int MARK_FERMATA- See Also:
- Constant Field Values
-
MARK_HARMONIC
public static final int MARK_HARMONIC- See Also:
- Constant Field Values
-
MARK_TRILL
public static final int MARK_TRILL- See Also:
- Constant Field Values
-
MARK_TRILL_FLAT
public static final int MARK_TRILL_FLAT- See Also:
- Constant Field Values
-
MARK_TRILL_SHARP
public static final int MARK_TRILL_SHARP- See Also:
- Constant Field Values
-
MARK_TRILL_NATURAL
public static final int MARK_TRILL_NATURAL- See Also:
- Constant Field Values
-
MARK_MORDANT
public static final int MARK_MORDANT- See Also:
- Constant Field Values
-
MARK_INVERTED_MORDANT
public static final int MARK_INVERTED_MORDANT- See Also:
- Constant Field Values
-
MARK_BOWED_TREMOLO_1
public static final int MARK_BOWED_TREMOLO_1- See Also:
- Constant Field Values
-
MARK_BOWED_TREMOLO_2
public static final int MARK_BOWED_TREMOLO_2- See Also:
- Constant Field Values
-
MARK_BOWED_TREMOLO_3
public static final int MARK_BOWED_TREMOLO_3- See Also:
- Constant Field Values
-
MARK_ACCIACCATURA
public static final int MARK_ACCIACCATURA- See Also:
- Constant Field Values
-
MARK_BREATH_MARK_COMMA
public static final int MARK_BREATH_MARK_COMMA- See Also:
- Constant Field Values
-
MARK_INVERTED_FERMATA
public static final int MARK_INVERTED_FERMATA- See Also:
- Constant Field Values
-
MARK_COUNT
public static final int MARK_COUNT- See Also:
- Constant Field Values
-
STEM_NONE
public static final int STEM_NONE- See Also:
- Constant Field Values
-
STEM_UP
public static final int STEM_UP- See Also:
- Constant Field Values
-
STEM_DOWN
public static final int STEM_DOWN- See Also:
- Constant Field Values
-
ACC_FORCE_REDECLARATION
public static final int ACC_FORCE_REDECLARATION- See Also:
- Constant Field Values
-
ACC_NONE
public static final int ACC_NONE- See Also:
- Constant Field Values
-
ACC_SHARP
public static final int ACC_SHARP- See Also:
- Constant Field Values
-
ACC_FLAT
public static final int ACC_FLAT- See Also:
- Constant Field Values
-
ACC_NATURAL
public static final int ACC_NATURAL- See Also:
- Constant Field Values
-
ACC_DOUBLE_FLAT
public static final int ACC_DOUBLE_FLAT- See Also:
- Constant Field Values
-
ACC_DOUBLE_SHARP
public static final int ACC_DOUBLE_SHARP- See Also:
- Constant Field Values
-
ACC_QUARTERTONE_FLAT
public static final int ACC_QUARTERTONE_FLAT- See Also:
- Constant Field Values
-
ACC_THREEQUARTERTONE_FLAT
public static final int ACC_THREEQUARTERTONE_FLAT- See Also:
- Constant Field Values
-
ACC_QUARTERTONE_SHARP
public static final int ACC_QUARTERTONE_SHARP- See Also:
- Constant Field Values
-
ACC_THREEQUARTERTONE_SHARP
public static final int ACC_THREEQUARTERTONE_SHARP- See Also:
- Constant Field Values
-
ACC_PREFER_SHARP
public static final int ACC_PREFER_SHARP- See Also:
- Constant Field Values
-
ACC_PREFER_FLAT
public static final int ACC_PREFER_FLAT- See Also:
- Constant Field Values
-
ACC_NO_PREFERENCE
public static final int ACC_NO_PREFERENCEonly used by EditManager, not by Note. If EditManager pref is ACC_NO_PREFERENCE, then accidental preference of newly inserted note will be determined by key signature- See Also:
- Constant Field Values
-
WHOLE
public static final int WHOLE- See Also:
- Constant Field Values
-
HALF
public static final int HALF- See Also:
- Constant Field Values
-
QUARTER
public static final int QUARTER- See Also:
- Constant Field Values
-
EIGHTH
public static final int EIGHTH- See Also:
- Constant Field Values
-
SIXTEENTH
public static final int SIXTEENTH- See Also:
- Constant Field Values
-
THIRTYSECOND
public static final int THIRTYSECOND- See Also:
- Constant Field Values
-
SIXTYFOURTH
public static final int SIXTYFOURTH- See Also:
- Constant Field Values
-
ONEHUNDREDTWENTYEIGHTH
public static final int ONEHUNDREDTWENTYEIGHTH- See Also:
- Constant Field Values
-
TWOHUNDREDFIFTYSIXTH
public static final int TWOHUNDREDFIFTYSIXTH- See Also:
- Constant Field Values
-
coreDurations
public static final double[] coreDurations -
coreDurationNames
public static final java.lang.String[] coreDurationNames -
NOTEHEAD_BLACK
public static final int NOTEHEAD_BLACK- See Also:
- Constant Field Values
-
NOTEHEAD_WHITE
public static final int NOTEHEAD_WHITE- See Also:
- Constant Field Values
-
NOTEHEAD_X
public static final int NOTEHEAD_X- See Also:
- Constant Field Values
-
NOTEHEAD_X_OVAL
public static final int NOTEHEAD_X_OVAL- See Also:
- Constant Field Values
-
NOTEHEAD_X_DIAMOND
public static final int NOTEHEAD_X_DIAMOND- See Also:
- Constant Field Values
-
NOTEHEAD_WHITE_DIAMOND
public static final int NOTEHEAD_WHITE_DIAMOND- See Also:
- Constant Field Values
-
NOTEHEAD_BLACK_DIAMOND
public static final int NOTEHEAD_BLACK_DIAMOND- See Also:
- Constant Field Values
-
NOTEHEAD_WHITE_TRIANGLE
public static final int NOTEHEAD_WHITE_TRIANGLE- See Also:
- Constant Field Values
-
NOTEHEAD_BLACK_TRIANGLE
public static final int NOTEHEAD_BLACK_TRIANGLE- See Also:
- Constant Field Values
-
NOTEHEAD_WHITE_INVERTEDTRIANGLE
public static final int NOTEHEAD_WHITE_INVERTEDTRIANGLE- See Also:
- Constant Field Values
-
NOTEHEAD_BLACK_INVERTEDTRIANGLE
public static final int NOTEHEAD_BLACK_INVERTEDTRIANGLE- See Also:
- Constant Field Values
-
NOTEHEAD_BREVE
public static final int NOTEHEAD_BREVEnot implemented- See Also:
- Constant Field Values
-
NOTEHEAD_SLASH
public static final int NOTEHEAD_SLASH- See Also:
- Constant Field Values
-
NOTEHEAD_RESERVED_1
public static final int NOTEHEAD_RESERVED_1not implemented- See Also:
- Constant Field Values
-
NOTEHEAD_RESERVED_2
public static final int NOTEHEAD_RESERVED_2not implemented- See Also:
- Constant Field Values
-
noteheadNames
public static final java.lang.String[] noteheadNames -
DYNAMIC_NONE
public static final int DYNAMIC_NONE- See Also:
- Constant Field Values
-
DYNAMIC_PPP
public static final int DYNAMIC_PPP- See Also:
- Constant Field Values
-
DYNAMIC_PP
public static final int DYNAMIC_PP- See Also:
- Constant Field Values
-
DYNAMIC_P
public static final int DYNAMIC_P- See Also:
- Constant Field Values
-
DYNAMIC_MP
public static final int DYNAMIC_MP- See Also:
- Constant Field Values
-
DYNAMIC_MF
public static final int DYNAMIC_MF- See Also:
- Constant Field Values
-
DYNAMIC_F
public static final int DYNAMIC_F- See Also:
- Constant Field Values
-
DYNAMIC_FF
public static final int DYNAMIC_FF- See Also:
- Constant Field Values
-
DYNAMIC_FFF
public static final int DYNAMIC_FFF- See Also:
- Constant Field Values
-
copyright
public static final java.lang.String copyright- See Also:
- Constant Field Values
-
-
Constructor Details
-
Note
Constructor specifies playable info. Later will calculate this from notated attributes -
Note
public Note(int coreDur, int tuplet, int dots, int accInfo)
-
-
Method Details
-
cloneNote
Make an exact copy of a Note. Calls clone and then copyProperties() -
getAccidentalVisibilityPolicy
public byte getAccidentalVisibilityPolicy()One of: ACCIDENTAL_SHOW_NORMAL, ACCIDENTAL_SHOW_NEVER, ACCIDENTAL_SHOW_ALWAYS- Returns:
- the accidentalVisibilityPolicy
-
setAccidentalVisibilityPolicy
public void setAccidentalVisibilityPolicy(byte accidentalVisibilityPolicy)One of: ACCIDENTAL_SHOW_NORMAL, ACCIDENTAL_SHOW_NEVER, ACCIDENTAL_SHOW_ALWAYS- Parameters:
accidentalVisibilityPolicy
- the accidentalVisibilityPolicy to set
-
isLedgerLinesVisible
public boolean isLedgerLinesVisible()- Returns:
- the ledger line visibility flag
-
setLedgerLinesVisible
public void setLedgerLinesVisible(boolean showLedgerLines)- Parameters:
turn
- ledger line visibility on or off
-
copyProperties
Copy properties from one Note to another.
Properties include: getData() array, drawing anchor, track, intervals, dimension name space, dynamic, slur, beam, (de)cresc,8ba/b, core duration- Parameters:
fromNote
-toNote
-
-
setIntervalsToTrackOfHandle
-
setGraceNotesToTrackOfParent
-
getLayoutShiftX
public double getLayoutShiftX()you can nudge a note left or right- Returns:
- the layoutShiftX
-
setLayoutShiftX
public void setLayoutShiftX(double layoutShiftX)you can nudge a note left or right- Parameters:
layoutShiftX
- the layoutShiftX to set
-
isChord
public boolean isChord()- Returns:
- true if intervals Vector is non-empty, false otherwise
-
isInterval
public boolean isInterval()- Returns:
- true if this Note has a handle (handle is a handle to chord)
-
isMonoNote
public boolean isMonoNote()- Returns:
- true if this is monophonic note, ie, not the handle of a chord and not an interval in a chord
-
setGraceNotes
public void setGraceNotes(java.util.Vector graceNotes) -
isFirstGraceNote
public boolean isFirstGraceNote() -
addGraceNote
-
addGraceNote
public Note addGraceNote(double duration, double pitch, double amp, double hold, boolean accPreferSharp, boolean beamedOut, boolean slurredOut, boolean tiedOut, boolean slashed, int mark) -
removeGraceNote
-
getGraceNoteHandle
A grace note has a pointer to the note which it is attached to.- Returns:
- Returns the graceNoteHandle.
-
setGraceNoteHandle
- Parameters:
graceNoteHandle
- The graceNoteHandle to set.
-
removeAllGraceNotes
public void removeAllGraceNotes() -
addInterval
Add an interval to this Note. Makes "this" a chord. "This" may not necessarily be the lowest pitch of the chord as it's implemented now, but provides the anchor, and so is called the root.- Returns:
- Note of new interval or null. Reasons for null include trying to add an interval to a rest, or if interval with pitch already exists
-
addInterval
add newNote as interval to this Note.- Returns:
- newNote if successful, else null . Reasons for null include trying to add an interval to a rest, or if interval with same pitch as newNote already exists
-
removeInterval
-
clearIntervals
public void clearIntervals() -
setHandle
-
getHandle
If this Note is an interval, get the root of the chord (called the handle)- Returns:
- handle of chord
-
getIntervals
public java.util.Vector getIntervals() -
getNoteheadScale
public double getNoteheadScale()- Returns:
- the noteheadScale (default is 1.0)
-
setNoteheadScale
public void setNoteheadScale(double noteheadScale)- Parameters:
noteheadScale
- the noteheadScale to set (where 1.0 is default)
-
getNoteIndex
public int getNoteIndex()- Returns:
- the position index of this Note in its Track
-
nextNote
- Returns:
- the next Note in this Track, or first Note of next Track, or null if Track empty
-
prevNote
- Returns:
- the next Note in this Track, or first Note of next Track, or null if Track empty
-
isRest
public boolean isRest()- Returns:
- true if note is a rest (same as getPitchData() == 0.0)
-
isBeamable
public boolean isBeamable()- Returns:
- true of this note is capable of carrying a beam (false if a rest)
-
getDurationData
public double getDurationData()- Returns:
- duration where qtr = 1.0, eighth = 0.5, 16th = 0.25, etc
-
getPitchData
public double getPitchData()- Returns:
- performable pitch
-
getVelData
public double getVelData()- Returns:
- amplitude 0..1
-
getHoldData
public double getHoldData()- Returns:
- hold time
-
setDurationData
public void setDurationData(double dur)set performable duration, where 1.0=quarter note -
setPitchData
public void setPitchData(double pitch)set performable pitch 1..127. A Note is made into a rest by setting its pitch data to 0, followed by NoteFactory.updateFromPitch(note); -
setVelData
public void setVelData(double vel)set performable amplitude data (0..1) -
setHoldData
public void setHoldData(double hold)set performable duration of hold, where 1.0 = quarter note -
setData
public void setData(double dur, double midinote, double vel, double hold)set four dimensional double[] data -
isNoteheadVisible
public boolean isNoteheadVisible() -
setNoteheadVisible
public void setNoteheadVisible(boolean flag) -
isStemVisible
public boolean isStemVisible()Get visibility flag of this note's stem. Not the same as a whole note not having a stem versus a half note having a stem. This flag hides stem rendering on a note, whether or not is has a stem. So this would return true for a unaltered (default) whole note.- Returns:
- true is stem is visible, false otherwise.
-
setStemVisible
public void setStemVisible(boolean visible)Set visibility of this note's stem. Not the same as a whole note not having a stem versus a half note having a stem. This hides stem rendering on a note, whether or not is has a stem. -
setSelected
public void setSelected(boolean flag)Set selected flag on Note (if user drew a rectangle that included this Note, for ex.) -
getSelected
public boolean getSelected()- Returns:
- true if this note is selected
-
getStemInfo
public int getStemInfo()Get stem info 0=no stem, 1=stem up, 2= stem down -
setStemInfo
public void setStemInfo(int stem)Set stem info 0=no stem, 1=stem up, 2= stem down -
getStemInfoOverride
public boolean getStemInfoOverride() -
setStemInfoOverride
public void setStemInfoOverride(int stem)override stem direction. Use wisely. NoteFactory will use this value instead of setting it itself. stem info 0=no stem, 1=stem up, 2= stem down -
clearStemInfoOverride
public void clearStemInfoOverride() -
setOverflow
public void setOverflow(boolean f)true if this note is at the end of a track whose total durations exceeds the measure's timesig's duration. Used only for rendering -
getOverflow
public boolean getOverflow()- Returns:
- flag indicating whether or not this note overfills the measure it is in. Painted differently is true.
-
getNoteDurationAsPerformanceTime
public static double getNoteDurationAsPerformanceTime(int durConst)- Returns:
- double value equal to time taken by Note.WHOLE, Note.HALF, Note.QUARTER, etc... This is the "core", or reference duration of the note, which remains constant despite dots, tuplets, etc If you add a dot or a double dot, or a triplet to a note, it is this duration which is consulted to calculate the performed duration of the note.
-
getNoteDurationAsPerformanceTime
public double getNoteDurationAsPerformanceTime() -
getIndexOfCoreDuration
public static int getIndexOfCoreDuration(double duration)input: duration like 0.25- Returns:
- index in core durations where this duration was found, or -1 if not found
-
getNoteDur
public int getNoteDur()- Returns:
- core duration 0..8 standing for WHOLE, HALF, QUARTER, ... 256th
-
getCoreDuration
public int getCoreDuration()Synonynmous with getNoteDur()- Returns:
- core duration 0..8 standing for WHOLE, HALF, QUARTER, ... 256th
-
setNoteDur
public void setNoteDur(int d)Set note duration to constants 0..8 standing for WHOLE, HALF, QUARTER,... 256th -
setNoteHeadType
public void setNoteHeadType(int noteheadType)Set to Note.NOTEHEAD_BLACK or Note.NOTEHEAD_WHITE, or new constants for X, diamond, etc -
getNoteHeadType
public int getNoteHeadType()- Returns:
- Note.NOTEHEAD_BLACK or Note.NOTEHEAD_WHITE, or other constants for X, diamond, etc
-
getAcc
public int getAcc()- Returns:
- accidental info for this Note, 0=none, 1=sharp, 2=flat, 3=natural
-
setAcc
public void setAcc(int acc)Set accidental info 0=none, 1=sharp, 2=flat, 3=natural, 4= DOUBLE FLAT, 5= DOUBLE SHARP -
getAccPref
public int getAccPref()Indicates Note's spelling preferences if it requires an accidental- Returns:
- Note.ACC_PREFER_SHARP or Note.ACC_PREFER_FLAT.
-
setAccPref
public void setAccPref(int pref)Set preferred accidental spelling: Note.ACC_PREFER_SHARP or Note.ACC_PREFER_FLAT. Indicates Note's spelling preferences if it requires an accidental -
getAccHidden
public boolean getAccHidden() -
setAccHidden
public void setAccHidden(boolean flag)Set accidental hidden flag 0,1 -
getAltEnharmonicSpelling
public boolean getAltEnharmonicSpelling()Flag determines if note uses alternate enharmonic spelling (ex E#, F##, Cb, Fbb, etc). NoteFactory tests Note.getAccPref() ( returning Note.ACC_PREFER_SHARP or Note.ACC_PREFER_FLAT) to determine whether to be spelled with sharp or flat- Returns:
- true if note is spelled with alternate enharmonic spelling
-
setAltEnharmonicSpelling
public void setAltEnharmonicSpelling(boolean flag)Set flag determines if note uses alternate enharmonic spelling (ex E#, F##, Cb, Fbb, etc). -
accToString
public static java.lang.String accToString(int acc) -
getNumDots
public int getNumDots() -
setNumDots
public void setNumDots(int n)Set number of dots following this note, 0, 1, or 2 -
getBeamedOut
public boolean getBeamedOut()- Returns:
- flag if this note is beamed to next note
-
getGlissOut
public boolean getGlissOut() -
getDynamic
public int getDynamic()- Returns:
- dynamic marking for this note
DYNAMICS: DYNAMIC_NONE ; DYNAMIC_PPP ; DYNAMIC_PP ; DYNAMIC_P ; DYNAMIC_MP ; DYNAMIC_MF ; DYNAMIC_F ; DYNAMIC_FF ; DYNAMIC_FFF ;
-
setDynamic
public void setDynamic(int dynamic)set dynamic marking for this noteDYNAMICS: DYNAMIC_NONE ; DYNAMIC_PPP ; DYNAMIC_PP ; DYNAMIC_P ; DYNAMIC_MP ; DYNAMIC_MF ; DYNAMIC_F ; DYNAMIC_FF ; DYNAMIC_FFF ;
-
setMark
public void setMark(int mark)Deprecated.use addMark() instead -
addMark
public void addMark(int mark)add a mark to this note. If mark == MARK_NONE that clears all marks -
getMark
public int getMark()Just returns first of marks. Use getMarks() instead to return Vector of Integer marks -
getMarks
public java.util.Vector getMarks()- Returns:
- Vector of Integer whose intValue is a mark
-
dynamicToString
public static java.lang.String dynamicToString(int dynamic) -
markToString
public static java.lang.String markToString(int mark) -
setBeamedOut
public void setBeamedOut(boolean f)set the beamed out flag for this note and all intervals and handle -
setGlissOut
public void setGlissOut(boolean f) -
setTiedOut
public void setTiedOut(boolean flag)Set tied out flag on Note -
getTiedOut
public boolean getTiedOut()- Returns:
- true if this note is tied out
-
setSlurredOut
public void setSlurredOut(boolean flag)Set slur out flag on Note -
getSlurredOut
public boolean getSlurredOut()- Returns:
- true if this note is slurred to next
-
setVisible
public void setVisible(boolean flag)Set visible flag on Note. If false, NoteRenderer will not render it. -
isVisible
public boolean isVisible()- Returns:
- true if this note is visible
-
isGraceNote
public boolean isGraceNote() -
setIsGraceNote
public void setIsGraceNote(boolean flag)Set flag determines if note is a grace note -
getGraceNotes
public java.util.Vector getGraceNotes() -
getNumGraceNotes
public int getNumGraceNotes() -
getCompleteIndexArray
public int[] getCompleteIndexArray() -
setCrescOut
public void setCrescOut(boolean flag)Set crescendo out flag on Note. Cresc and decresc share the same bit which flags the note as being cresced or decresced to the next note. So you do not have to call setCrescOut(false) before calling setDecrescOut(true), for example. Do *not* call setCrescOut(false) *after* calling setDecrescOut(true) or their common flag will be set by the first call and unset by the second call.
-
setDecrescOut
public void setDecrescOut(boolean flag)Set decrescendo out flag on Note. Cresc and decresc share the same bit which flags the note as being cresced or decresced to the next note. So you do not have to call setCrescOut(false) before calling setDecrescOut(true), for example. Do *not* call setCrescOut(false) *after* calling setDecrescOut(true) or their common flag will be set by the first call and unset by the second call.
-
getCrescOut
public boolean getCrescOut()- Returns:
- true if this is a crescendo which continues to next note, false if it does not continue or if it is a decrescendo
-
getDecrescOut
public boolean getDecrescOut()- Returns:
- true if this is a decrescendo which continues to next note, false if it does not continue or if it is a crescendo
-
set8vaOut
public void set8vaOut(boolean flag)Deprecated.Misnomer. No longer flags 8va to next note. Only indicates that 8va applied to this note. Now a single note can have 8va over it -
set8vbOut
public void set8vbOut(boolean flag)Deprecated.Misnomer. No longer flags 8vb to next note. Only indicates that 8vb applied to this note. Now a single note can have 8vb over it -
set8va
public void set8va(boolean flag)Set 8va property on Note. Since build 20070707 this property can be set on a single note, and no longer flags 8va extended to next note. -
set8vb
public void set8vb(boolean flag)Set 8vb property on Note. Since build 20070707 this propperty can be set on a single note, and no longer flags 8vb extended to next note. -
get8vaOut
public boolean get8vaOut()Deprecated.Misnomer. No longer flags whether 8va to next note. Only indicates that 8va applied to this note.- Returns:
- is8va()
-
get8vbOut
public boolean get8vbOut()Deprecated.Misnomer. No longer flags whether 8vb to next note. Only indicates that 8vb applied to this note.- Returns:
- is8vb()
-
is8va
public boolean is8va()- Returns:
- true if this note has ottava alta property
-
is8vb
public boolean is8vb()- Returns:
- true if this note has ottava bassa property
-
startOf8va
public boolean startOf8va()- Returns:
- true if this note is the first of an 8va
-
endOf8va
public boolean endOf8va()- Returns:
- true if this note is the end of an 8va
-
startOf8vb
public boolean startOf8vb()- Returns:
- true if this note is the first of an 8vb
-
endOf8vb
public boolean endOf8vb()- Returns:
- true if this note is the last of an 8vb
-
getTiedIn
public boolean getTiedIn()- Returns:
- true if this note is tied in from previous note
-
getCrescIn
public boolean getCrescIn()- Returns:
- true if this note is cresc'ed in from previous note
-
getDecrescIn
public boolean getDecrescIn()- Returns:
- true if this note is decresc'ed in from previous note
-
startOfCresc
public boolean startOfCresc()- Returns:
- true of this note is first note of a cresc
-
endOfCresc
public boolean endOfCresc()- Returns:
- true of this note is last note of a cresc
-
startOfDecresc
public boolean startOfDecresc()- Returns:
- true of this note is first note of a decresc
-
endOfDecresc
public boolean endOfDecresc()- Returns:
- true of this note is last note of a decresc
-
getSlurredIn
public boolean getSlurredIn()- Returns:
- true if this note is slurred in from previous note
-
get8vaIn
public boolean get8vaIn()- Returns:
- true if this note is 8va'ed in from previous note
-
get8vbIn
public boolean get8vbIn()- Returns:
- true if this note is 8vb'ed in from previous note
-
setLevel
public void setLevel(int l)set the vertical placement of note on staff -
getLevel
public int getLevel()- Returns:
- the vertical placement of note on staff
-
isOverrideLevel
public boolean isOverrideLevel()- Returns:
- the isOverrideLevel
-
setOverrideLevel
public void setOverrideLevel(boolean isOverrideLevel)- Parameters:
isOverrideLevel
- the isOverrideLevel to set
-
setOverrideLevel
public void setOverrideLevel(int overrideLevel)overrideLevel is the level the user can set to force a note to be rendered at specified level This value is stored and expressed in rendering if isOverrideLevel() is true- Parameters:
overrideLevel
-
-
getOverrideLevel
public int getOverrideLevel()- Returns:
- the overrideLevel
-
setDrawingAnchor
public void setDrawingAnchor(java.awt.geom.Point2D p)anchor is the horizontal note location -
replaceDrawingAnchor
public void replaceDrawingAnchor(java.awt.geom.Point2D p)anchor is the horizontal note location -
getDrawingAnchor
public java.awt.geom.Point2D getDrawingAnchor()anchor is the horizontal note location -
setNumTails
public void setNumTails(int n)Deprecated.does nothing. getNumTails() is now calculated from core durationSet the number of tails on this note (1 for eighth, 2 for 16th, etc) -
getNumTails
public int getNumTails()- Returns:
- the number of tails on this note, calculated from core duration as Math.max(0, getNoteDur()-2)
-
setStaffIndex
public void setStaffIndex(int s)Use with caution! Only retrievable with getStaffIndex() if this note has no track or staff -
getStaffIndex
public int getStaffIndex()- Returns:
- staff index if track and staff != null, else return numeric staff index
-
setMeasureIndex
public void setMeasureIndex(int m)Use with caution! Only retrievable with getMeasureIndex() if this note has no track or staff -
getMeasureIndex
public int getMeasureIndex()- Returns:
- measure index if track and staff != null, else return numeric measure index
-
getTuplet
public int getTuplet()- Returns:
- the the tuplet value for this note. 0 if not a tuplet, else 3, 5, 7, 9, 11, etc
-
setTuplet
public void setTuplet(int n)Set the tuplet value (3 for triplet, 5 for quintuplet, etc, up to 31 -
getTrack
- Returns:
- Track to which this note belongs
-
getScore
- Returns:
- Score to which this note belongs
-
setTrack
-
getData
public double[] getData()- Returns:
- internal performance data: {dur, pitch, vel, hold, .. higher dimensions}
-
getDataCopy
public double[] getDataCopy()Convenience method, shorthand for getData() and System.arraycopy()- Returns:
- copy of internal performance data: {dur, pitch, vel, hold, .. higher dimensions} This can be altered without affecting the Note from where it came
-
setData
public void setData(double[] data) -
setData
public void setData(int dimension, double value)Set the value of one element of the double[] array held by this Note. You must make sure dimensions < getData().length -
getData
public double getData(int dimension)- Returns:
- the value at data[dimension]. You must do your own bounds checking
-
performExpressionMarks
public static boolean performExpressionMarks()- Returns:
- flag whether or not staccato, accent staccato, and tenuto marks will affect hold time on a Note
-
setPerformExpressionMarks
public static void setPerformExpressionMarks(boolean flag)if true, staccato, accent staccato, and tenuto marks will affect hold time on a Note -
getPerformanceData
public double[] getPerformanceData()translate internal performance data based on expressive properties.- Returns:
- { dur, pitch, vel, hold }
-
getPerformanceDataCopy
public double[] getPerformanceDataCopy()translate internal performance data based on expressive properties.- Returns:
- copy of { dur, pitch, vel, hold }
-
calcGraceNoteRollbackTime
public double calcGraceNoteRollbackTime() -
play
Description copied from interface:InstrumentPlayable
play() is called by MusicList. It should return an updated playTime such as playTime + duration * parent.getTimeStretch()- Specified by:
play
in interfaceInstrumentPlayable
-
toString
public java.lang.String toString()- Overrides:
toString
in classjava.lang.Object
-
getGraceNoteSeparationScaler
public double getGraceNoteSeparationScaler()- Returns:
- the graceNoteSeparationScaler
-
setGraceNoteSeparationScaler
public void setGraceNoteSeparationScaler(double graceNoteSeparationScaler)- Parameters:
graceNoteSeparationScaler
- the graceNoteSeparationScaler to set
-
setXPositionsOfGraceNotes
public void setXPositionsOfGraceNotes() -
render
public void render(java.awt.Graphics g, double zoom) -
tupletDur
public static double tupletDur(int n, double dur)Calculate duration of n-tuplet, given n and its non-tuplet duration.
Algorithm: for n-tuplet, multiply the duration of the non-tuplet'ed note by the highest power of 2 that is less than n. That gives the total duration the tuplet is to occupy. Finally, divide that total duration by n.
Example: to calculate the duration of an eighth note triplet (n=3, dur=0.5):
the highest power of 2 less than 3 is 2. 2*0.5 = 1.0 which is the total duration to occupy. 1.0/3 = final duration of 0.3333- Returns:
- tuplet duration applied to dur
-
resortChord
make root == handle == lowest pitched note, sort the vector of intervals low to high -
getSortedChord
Get an array containing this Note's intervals and handle in sorted order -
getRoot
Assuming this Note is a chord, find the Note with the lowest pitch. This is NOT the same as the handle of the chord, (handle which provides the handle to a chord, and may or may not have the lowest Note of the chord.- Returns:
- the Note with the lowest pitch.
-
getHighest
Assuming this Note is a chord, find the Note with the highest pitch.- Returns:
- the Note with the highest pitch, or the note itself if not a chord.
-
getLowest
Assuming this Note is a chord, find the Note with the lowest pitch.- Returns:
- the Note with the lowest pitch, or the note itself if not a chord.
-
writeXML
public void writeXML(java.io.PrintWriter out) throws java.io.IOException- Specified by:
writeXML
in interfaceXMLWritable
- Throws:
java.io.IOException
-
writeXML
public void writeXML(java.io.PrintWriter out, boolean includeIntervals) throws java.io.IOException- Throws:
java.io.IOException
-
setDimensionNameSpace
- Specified by:
setDimensionNameSpace
in interfaceDimensionNameSpaceEditable
-
getDimensionNameSpace
- Specified by:
getDimensionNameSpace
in interfaceDimensionNameSpaceEditable
-
getDoubleArray
public double[] getDoubleArray()synonym with getData()- Specified by:
getDoubleArray
in interfaceDimensionNameSpaceEditable
-
setDoubleArray
public void setDoubleArray(double[] dar)Hand Note an entirely new array of data. Note makes a copy of array, allocates new performance data. Typically used when data dimension exceeds standard 4- Specified by:
setDoubleArray
in interfaceDimensionNameSpaceEditable
-
firstNoteOfLine
-
lastNoteOfLine
-
setText
public void setText(java.lang.String s)Set text to display by this note -
getText
public java.lang.String getText()- Returns:
- text to be displayed by this note
-
setTextOffsetX
public void setTextOffsetX(int xoffset)horizontal text displacement -
getTextOffsetX
public int getTextOffsetX()horizontal text displacement -
setTextOffsetY
public void setTextOffsetY(int yoffset)vertical text displacement -
getTextOffsetY
public int getTextOffsetY()vertical text displacement -
main
public static void main(java.lang.String[] args) -
getUserBeans
public java.util.Vector getUserBeans()A Note can have a vector of custom user-defined beans attached to it. These will be saved to a file with a Score and reloaded as well. The objects must be beans (ie have private simple data types with matching getters and setters.- Returns:
- Returns vector of beans.
-
addUserBean
public void addUserBean(java.lang.Object bean)Add a bean to a note. A bean is an object with primitive fields and matching getters and setters. These will be restored when loaded.- Parameters:
bean
- The bean to add.
-
removeUserBean
public void removeUserBean(java.lang.Object bean) -
getAccidentalOffset
public int getAccidentalOffset()- Returns:
- Returns the accidentalOffset.
-
setAccidentalOffset
public void setAccidentalOffset(int accidentalOffset)- Parameters:
accidentalOffset
- The accidentalOffset to set.
-
getNoteheadColor
public java.awt.Color getNoteheadColor()- Returns:
- Returns the noteheadColor.
-
setNoteheadColor
public void setNoteheadColor(java.awt.Color noteheadColor)- Parameters:
noteheadColor
- The noteheadColor to set.
-
stemDirection
public static java.lang.String stemDirection(int x) -
setDimensionNameSpaceDefaults
public void setDimensionNameSpaceDefaults()
-