public class WesternScaleNote extends Object
Modifier and Type | Field and Description |
---|---|
float |
frequency
The frequency of the note
|
String |
noteName
The note name; e.g.
|
static String[] |
noteNames
The names of the notes in the Western scale
|
int |
noteNumber
The MIDI note number of the note
|
int |
octaveNumber
The octave number.
|
static float |
tuningOfA
The standing tuning is A=440Hz.
|
static double |
twelfthRootOfTwo
The twelfth root of 2
|
Constructor and Description |
---|
WesternScaleNote() |
Modifier and Type | Method and Description |
---|---|
static WesternScaleNote |
createNote(float frequency)
Create a
WesternScaleNote given a frequency. |
static WesternScaleNote |
createNote(int noteNumber)
Given a note number, returns a
WesternScaleNote from which other
information can be garnered. |
static WesternScaleNote |
createNote(String noteString)
Given a note string, returns a new
WesternScaleNote from
which other information can be garnered. |
static WesternScaleNote |
createNote(String noteName,
int octaveNumber)
Given a note name and octave, returns a
WesternScaleNote from
which other information can be garnered. |
static int |
frequencyToNote(float frequency)
Converts a frequency to the nearest note number
|
static float |
noteToFrequency(int noteNumber)
Converts a MIDI note number to a frequency.
|
static int |
nStepsBetween(WesternScaleNote note1,
WesternScaleNote note2)
Returns the number of half-steps between the two given notes.
|
String |
toString() |
public int noteNumber
public int octaveNumber
public float frequency
public static float tuningOfA
public static final double twelfthRootOfTwo
public WesternScaleNote()
public String toString()
toString
in class Object
Object.toString()
public static final int nStepsBetween(WesternScaleNote note1, WesternScaleNote note2)
note1
- The first note of the intervalnote2
- The second note of the intervalpublic static final float noteToFrequency(int noteNumber)
noteNumber
- The note numberpublic static final int frequencyToNote(float frequency)
frequency
- The frequencypublic static final WesternScaleNote createNote(String noteString)
WesternScaleNote
from
which other information can be garnered. A note string is the note name
followed by the octave; e.g. "D3" or "A#5".noteString
- The note stringWesternScaleNote
or null if the note string is invalidpublic static final WesternScaleNote createNote(String noteName, int octaveNumber)
WesternScaleNote
from
which other information can be garnered.noteName
- The name of the noteoctaveNumber
- The octave of the note.public static final WesternScaleNote createNote(float frequency)
WesternScaleNote
given a frequency. It does this by
converting the frequency in to a MIDI note number and using
createNote(int)
which returns the note. For
this reason, the value of the member frequency
in the returned
note may not be the same as the given frequency.frequency
- The frequency to convert to a note.WesternScaleNote
public static final WesternScaleNote createNote(int noteNumber)
WesternScaleNote
from which other
information can be garnered.noteNumber
- A note numberWesternScaleNote