public class Note
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
private static float |
A0
Frequency for A0
|
private float |
duration
Duration of note in milliseconds.
|
private float |
frequency
Frequency of note in cycles per second.
|
private java.lang.String |
name
Name of note in scientific pitch notation.
|
Constructor and Description |
---|
Note(float frequency,
float duration)
Constructs a new Note object with the specified frequency and duration.
|
Note(java.lang.String name,
float duration)
Constructs a new Note object with the specified pitch and duration.
|
Modifier and Type | Method and Description |
---|---|
float |
getDuration()
Returns the duration of this note.
|
float |
getFrequency()
Returns the frequency (in Hz) of this note.
|
private float |
getFrequency(java.lang.String scientificPitch)
Returns the frequency of the specified note and octave.
|
java.lang.String |
toString()
Returns a string representation of the note.
|
private final java.lang.String name
private final float frequency
private final float duration
private static final float A0
public Note(java.lang.String name, float duration)
name
- Scientific pitch notation for the noteduration
- Duration of the note in millisecondspublic Note(float frequency, float duration)
frequency
- Frequency in hertzduration
- Duration in millisecondsprivate float getFrequency(java.lang.String scientificPitch)
note
- Note from A-G, including sharps (#) specified as "A", "A#", "B", ...octave
- Octave of notepublic float getFrequency()
public float getDuration()
public java.lang.String toString()
toString
in class java.lang.Object