public class Note
extends java.lang.Object
implements java.lang.Cloneable, java.io.Serializable
Phrase phrase = new Phrase(0.0); Note note = new Note(C4, CROTCHET, MF); phrase.addNote(note);The note also has the option to create notes with reasonable default values. This allows a user who is not interested in any performance details to work with notes solely using pitch value and rythmValue like this....
Note note = new Note(C4, CROTCHET);The final option for building a note also includes the dynamic parameter for minimal performace information.
Note note = new Note(C4, CROTCHET, F);Comments about the offset parameter: The intention of offset was to allow for 'feel' in score playback. For example, a snare drum might be played slightly ahead or behind the beat, or a sound with a slow attack might need to be triggered early in order to sound in time with other parts. With this in mind, offset should have no influence on rhythmValue or duration calculations within the jMusic data structure, only when translated to another format (eg MIDI). In your example (offset 0.1, duration 0.8, and rv 1.0) the rendering (MIDI or other that does not support the offset concept) should consider the start time of the note 0.1 bpm later than 'normal' but the duration of the note will be 0.8 bpm from that offset start time. The next note should start 1.0 bpm after the 'normal' startTime (ignoring offset). This allows for offset to be used in cases where performance of music varies from beat to beat, eg., the downbeat is anticipated slightly. In extreme cases this could cause overlapping notes in MIDI translation which need to be 'handled' but we consider this a weakness of the MIDI data specification rather than a problem for jMusic : ) In short, think of offset as "A displacement from the normal start time of a note that allows performance interpretation without distorting the score for compositional or analysis purposes." ---------------
Phrase
,
Serialized FormModifier and Type | Field and Description |
---|---|
static java.lang.String |
A |
static java.lang.String |
A_FLAT |
static java.lang.String |
A_SHARP |
static int |
AMP_ENV
Specified envelope break point value indexes
|
static java.lang.String |
B |
static java.lang.String |
B_FLAT |
static java.lang.String |
C
string constants for keys on the keyboard
|
static java.lang.String |
C_SHARP |
static java.lang.String |
D |
static java.lang.String |
D_SHARP |
static double |
DEFAULT_ARTICULATION
Default articulation.
|
static double |
DEFAULT_DURATION
default duration
|
static double |
DEFAULT_DURATION_MULTIPLIER
default duration multiplier
|
static int |
DEFAULT_DYNAMIC
default dynamic
|
static double |
DEFAULT_OFFSET
default offset value
|
static double |
DEFAULT_PAN
default pan value
|
static int |
DEFAULT_PITCH
default pitch value
|
static double |
DEFAULT_RHYTHM_VALUE
default rhythmValue
|
static double |
DEFAULT_SAMPLE_START_TIME
The number of seconds into a sample to begin reading data
|
static java.lang.String |
E |
static java.lang.String |
E_FLAT |
static java.lang.String |
F |
static java.lang.String |
F_SHARP |
static int |
FILTER_ENV |
static boolean |
FREQUENCY
Pitch type flag - indicates that pitch should be a frequency in hertz.
|
static java.lang.String |
G |
static java.lang.String |
G_SHARP |
static double |
MAX_DURATION
The largest value for a note's duration.
|
static int |
MAX_DYNAMIC
The largest value for a dynamic.
|
static double |
MAX_MIDI_PITCH
The largest value for a pitch.
|
static double |
MAX_PAN
The largest pan value for a note.
|
static int |
MAX_PITCH
The largest value for a pitch.
|
static double |
MAX_RHYTHM_VALUE
The largest value for a rhythValue.
|
static boolean |
MIDI_PITCH
Pitch type flag - indicates that pitch should be MIDI note number.
|
static double |
MIN_DURATION
The smallest value for a note's duration.
|
static int |
MIN_DYNAMIC
The smallest value for a dynamic.
|
static double |
MIN_FREQUENCY
The smallest value for a frequency.
|
static double |
MIN_PAN
The smallest pan value for a note.
|
static int |
MIN_PITCH
The smallest value for a pitch.
|
static double |
MIN_RHYTHM_VALUE
The smallest value for a rhythmValue.
|
static int |
PAN_ENV |
static int |
PITCH_ENV |
static int |
REST
The pitch value which indicates a rest.
|
Constructor and Description |
---|
Note()
Default constructor assigns null values to all note attributes
|
Note(double frequency,
double rhythmValue)
Assigns frequency and rhythmic values to the note object upon creation
|
Note(double frequency,
double rhythmValue,
int dynamic)
Assigns frequency and rhythmic values to the note object upon creation
|
Note(double frequency,
double rhythmValue,
int dynamic,
double pan)
Assigns frequency and rhythmic values to the note object upon creation
|
Note(int pitch,
double rhythmValue)
Assigns pitch and rhythmic values to the note object upon creation
Other values (e.g.
|
Note(int pitch,
double rhythmValue,
int dynamic)
Assigns pitch and rhythmic values to the note object upon creation
Other values (e.g.
|
Note(int pitch,
double rhythmValue,
int dynamic,
double pan)
Assigns pitch and rhythmic values to the note object upon creation
Other values (e.g.
|
Note(java.lang.String note) |
Modifier and Type | Method and Description |
---|---|
Note |
copy()
Returns a copy of this note
|
boolean |
equals(Note note) |
static int |
freqToMidiPitch(double freq)
Convert a frequency into a MIDI note pitch.
|
double[] |
getBreakPoints(int index)
Retrieve the break point envelope values.
|
double |
getDuration()
Return note duration.
|
int |
getDynamic()
Retrieve notes dynamic
|
double |
getFrequency()
Retrieve the note's pitch as a frequency
|
Phrase |
getMyPhrase()
Return a reference to the phrase containing this note
|
java.lang.String |
getNote()
gets the string representation for a note for a given MIDI pitch (0-127)
|
static java.lang.String |
getNote(int pitch)
gets the string representation for a note for a given MIDI pitch (0-127)
|
double |
getOffset()
Return note offset.
|
double |
getPan()
Retrieves note's pan.
|
int |
getPitch()
Retrieve the note's pitch as an integer.
|
boolean |
getPitchType()
Retrieve note's pitch type
|
int |
getPitchValue()
returns the pitches for the middle scale(default) on a keyboard
|
double |
getRhythmValue()
Retrieve note's rhythmValue
|
double |
getSampleStartTime()
Return note sampleStartTime
|
boolean |
isFlat()
tells whether the note is a sharp or not by using its string value
|
boolean |
isNatural()
tells whether the note is natural or not
|
boolean |
isRest()
Check if the note is a rest or a pitched note.
|
boolean |
isScale(int[] scale)
Checks if the note is within a particular scale
There are a number of scale constants specified in the JMC
which can be used with this method,
these include MAJOR_SCALE, MINOR_SCALE, and PENTATONIC_SCALE
|
boolean |
isSharp()
tells whether the note is a sharp or not
|
static double |
midiPitchToFreq(int midiPitch)
Calculate the frequency in hertz of a MIDI note pitch.
|
Note |
nextNote(int[] scale)
gives the next note in the scale
For example, if inputting a D note for a DMinor scale, the next note returned is an E
if inputing a Bb for a C
|
boolean |
sameDuration(Note note) |
boolean |
samePitch(Note note) |
void |
setBreakPoints(int index,
double[] points)
Specify the values for a break point envelope.
|
void |
setDuration(double duration)
Set notes duration.
|
void |
setDynamic(int dynamic)
Assign notes dynamic
|
void |
setFrequency(double freq)
Assign notes pitch as a frequency.
|
void |
setLength(double newLength)
Change both the rhythmValue and duration of a note in the one step.
|
void |
setMyPhrase(Phrase phr)
Sets a reference to the phrase that contains this note
|
void |
setOffset(double offset)
Set notes offset.
|
void |
setPan(double pan)
Assign notes pan.
|
void |
setPitch(int pitch)
Assign notes pitch.
|
void |
setPitchType(boolean newType)
Specifies the note's pitch type.
|
void |
setRhythmValue(double rhythmValue)
Assign notes rhythmValue
|
void |
setRhythmValue(double rv,
boolean factorDuration)
Sets the rhythmValue, and optionally change the duration
at the same time.
|
void |
setSampleStartTime(double sampleStartTime)
Set notes sampleStartTime
|
java.lang.String |
toString()
Collects a string of the notes attributes
|
public static final int DEFAULT_PITCH
public static final double DEFAULT_RHYTHM_VALUE
public static final int DEFAULT_DYNAMIC
public static final double DEFAULT_PAN
public static final double DEFAULT_DURATION_MULTIPLIER
public static final double DEFAULT_ARTICULATION
public static final double DEFAULT_DURATION
public static final double DEFAULT_OFFSET
public static final double DEFAULT_SAMPLE_START_TIME
public static final int MIN_PITCH
public static final double MIN_FREQUENCY
public static final double MAX_MIDI_PITCH
public static final int MAX_PITCH
public static final double MIN_RHYTHM_VALUE
public static final double MAX_RHYTHM_VALUE
public static final int MIN_DYNAMIC
public static final int MAX_DYNAMIC
public static final double MIN_PAN
public static final double MAX_PAN
public static final double MIN_DURATION
public static final double MAX_DURATION
public static final int REST
public static final boolean FREQUENCY
public static final boolean MIDI_PITCH
public static final int AMP_ENV
public static final int PITCH_ENV
public static final int FILTER_ENV
public static final int PAN_ENV
public static final java.lang.String C
public static final java.lang.String G
public static final java.lang.String D
public static final java.lang.String A
public static final java.lang.String E
public static final java.lang.String B
public static final java.lang.String F_SHARP
public static final java.lang.String C_SHARP
public static final java.lang.String G_SHARP
public static final java.lang.String D_SHARP
public static final java.lang.String A_SHARP
public static final java.lang.String A_FLAT
public static final java.lang.String E_FLAT
public static final java.lang.String B_FLAT
public static final java.lang.String F
public Note()
public Note(int pitch, double rhythmValue)
MIDI
- pitch range is 0-127 (middle c = 60): Constant values
representing pitch values can be found in JMCrhythmValue
- 0.5 = quaver: constant values representing most
duration types can be found in JMCpublic Note(int pitch, double rhythmValue, int dynamic)
MIDI
- pitch range is 0-127 (middle c = 60): Constant values
representing pitch values can be found in JMCrhythmValue
- 0.5 = quaver: constant values representing most
duration types can be found in JMCdynamic
- range is 0-127 (0 = off; 127 = loud): Constant values
representing some basic dynamic types can be found in JMCpublic Note(int pitch, double rhythmValue, int dynamic, double pan)
MIDI
- pitch range is 0-127 (middle c = 60): Constant values
representing pitch values can be found in JMCrhythmValue
- 0.5 = quaver: constant values representing most
duration types can be found in JMCdynamic
- range is 0-127 (0 = off; 127 = loud): Constant values
representing some basic dynamic types can be found in JMCpan
- Specifies the balance between output channels;
usually between 0 - left, and 1 - right.public Note(double frequency, double rhythmValue)
frequency
- Pitch in hertz, any double value (A4 = 400)rhythmValue
- 0.5 = quaver: constant values representing most
duration types can be found in JMCpublic Note(double frequency, double rhythmValue, int dynamic)
frequency
- Pitch in hertz, any double value (e.g., A4 = 440.0)rhythmValue
- 0.5 = quaver: constant values representing most
duration types can be found in JMCdynamic
- range is 0-127 (0 = off; 127 = loud): Constant values
representing some basic dynamic types can be found in JMCpublic Note(double frequency, double rhythmValue, int dynamic, double pan)
frequency
- Pitch in hertz, any double value (e.g., A4 = 440.0)rhythmValue
- 0.5 = quaver: constant values representing most
duration types can be found in JMCdynamic
- range is 0-127 (0 = off; 127 = loud): Constant values
representing some basic dynamic types can be found in JMCpan
- Specifies the balance between output channels;
usually between 0 - left, and 1 - right.public Note(java.lang.String note)
public boolean getPitchType()
public void setPitchType(boolean newType)
boolean
- note's pitch typepublic double getFrequency()
public void setFrequency(double freq)
pitch
is less than
MIN_FREQUENCY
then the pitch of this note will be set to MIN_FREQUENCY.double
- note pitch as a frequency in hertzpublic int getPitch()
public void setPitch(int pitch)
pitch
is less than
MIN_PITCH
then the pitch of this note will be set to MIN_PITCH.
Likewise, if pitch
is greater than MAX_MIDI_PITCH
,
pitch will be set to MAX_MIDI_PITCH.int
- notes pitchpublic double getRhythmValue()
public void setRhythmValue(double rhythmValue)
float
- notes rhythmValuepublic int getDynamic()
public void setDynamic(int dynamic)
int
- notes dynamicpublic double getPan()
public void setPan(double pan)
double
- note's panpublic double getDuration()
public void setDuration(double duration)
double
- note's durationpublic double getOffset()
public void setOffset(double offset)
double
- note's offsetpublic double getSampleStartTime()
public void setSampleStartTime(double sampleStartTime)
int
- note's sampleStartTimepublic void setMyPhrase(Phrase phr)
public Phrase getMyPhrase()
public Note copy()
public void setBreakPoints(int index, double[] points)
index
- The specific breakPoint number to set.points
- The values for this break point array.public double[] getBreakPoints(int index)
public java.lang.String toString()
toString
in class java.lang.Object
public boolean isScale(int[] scale)
int[]
- - an array of scale degreespublic void setRhythmValue(double rv, boolean factorDuration)
factorDuration
- wether or not to change the duration
to be a multiple of the rhythm value as wellpublic static int freqToMidiPitch(double freq)
freq
- The frequency value to convert.public static double midiPitchToFreq(int midiPitch)
midiPitch
- The note pitch value to convert.public boolean isRest()
public void setLength(double newLength)
newLength
- The new rhythmValue for the note (Duration is a proportion of this value)public boolean isSharp()
public boolean isFlat()
public boolean isNatural()
public boolean samePitch(Note note)
public boolean sameDuration(Note note)
public boolean equals(Note note)
public Note nextNote(int[] scale)
scale
- a constant from Scales.java goes herepublic int getPitchValue()
public java.lang.String getNote()
public static java.lang.String getNote(int pitch)