net.beadsproject.beads.data
Class Pitch

java.lang.Object
  extended by net.beadsproject.beads.data.Pitch

public abstract class Pitch
extends java.lang.Object

A set of static fields and utility methods associated with pitch.

Author:
ollie

Field Summary
static int[] circleOfFifths
          The circle of fifths relative to root.
static int[] dorian
          The dorian scale relative to root.
static float LOG2
          The constant log(2) = 0.6931472.
static int[] major
          The major scale relative to root.
static int[] minor
          The minor scale relative to root.
static java.lang.String[] pitchNames
          Pitch names for scale starting at C.
 
Constructor Summary
Pitch()
           
 
Method Summary
static float forceFrequencyToScale(float freq, int[] scale)
           
static int forceToScale(int pitch, int[] scale)
          Takes a pitch and returns that pitch adjusted downwards to the nearest pitch in the given scale.
static int forceToScale(int pitch, int[] scale, int notesPerOctave)
          Takes a pitch and returns that pitch adjusted downwards to the nearest pitch in the given scale.
static float ftom(float frequency)
          Convert frequency to MIDI note number.
static float mtof(float midi)
          Convert MIDI note number to frequency.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LOG2

public static final float LOG2
The constant log(2) = 0.6931472.

See Also:
Constant Field Values

pitchNames

public static final java.lang.String[] pitchNames
Pitch names for scale starting at C.


dorian

public static final int[] dorian
The dorian scale relative to root.


major

public static final int[] major
The major scale relative to root.


minor

public static final int[] minor
The minor scale relative to root.


circleOfFifths

public static final int[] circleOfFifths
The circle of fifths relative to root.

Constructor Detail

Pitch

public Pitch()
Method Detail

ftom

public static final float ftom(float frequency)
Convert frequency to MIDI note number.

Parameters:
frequency - the required frequency.
Returns:
the resulting MIDI note number.

mtof

public static final float mtof(float midi)
Convert MIDI note number to frequency.

Parameters:
midi - the required MIDI note number.
Returns:
the resulting frequency.

forceToScale

public static final int forceToScale(int pitch,
                                     int[] scale,
                                     int notesPerOctave)
Takes a pitch and returns that pitch adjusted downwards to the nearest pitch in the given scale.

Parameters:
pitch - the pitch to modify.
scale - the scale to use.
notesPerOctave - how many notes in your octave (12 if you're not sure).
Returns:
adjusted pitch.

forceToScale

public static final int forceToScale(int pitch,
                                     int[] scale)
Takes a pitch and returns that pitch adjusted downwards to the nearest pitch in the given scale. Assumes 12 pitches per octave.

Parameters:
pitch - the pitch to modify.
scale - the scale to use.
Returns:
adjusted pitch.

forceFrequencyToScale

public static final float forceFrequencyToScale(float freq,
                                                int[] scale)