uk.org.toot.music.tonality
Class Pitch

java.lang.Object
  extended by uk.org.toot.music.tonality.Pitch

public class Pitch
extends java.lang.Object

This class provides static methods to support pitches and pitch classes, which are just ints. A pitch is a note in a particular register, where note is used as shorthand for pitch class. i.e. C is a note (and pitch class), C4 is a pitch. Pitch classes are represented as the lowest octave of pitches. Hence pitch classes may usually be used in place of pitches. C-1 = 0 C0 = 12 C1 = 24 C2 = 36 C4 (middle-C) = 60 (arbitrary MMA definition)


Method Summary
static int classCount(int[] pitches)
          Count the number of distinct pitch classes in the specified pitches.
static java.lang.String className(int pitch)
          Return the name of the pitch class of the specified pitch.
static java.lang.String classNames(int[] pitches)
          Return the names of the pitch classes of the specified pitches, seperated by spaces.
static int classValue(int pitch)
          Return the int value of the pitch class of the specified pitch.
static int classValue(java.lang.String pitch)
          Returns the int value of the pitch class of the specified pitch.
static int[] classValues(java.lang.String pitches)
          Returns the int values of the pitch classes of the specified pitches.
static int[] distinctClasses(int[] pitches)
          Return the distinct pitch classes of the specified pitches.
static boolean isBlack(int pitch)
          Return whether a keyboard key is black for the specified pitch.
static boolean isWhite(int pitch)
          Return whether a keyboard key is white for the specified pitch.
static java.lang.String name(int pitch)
          Return the name of the specified pitch
static int value(int pitchClass, int register)
           
static int value(java.lang.String name, int register)
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

name

public static java.lang.String name(int pitch)
Return the name of the specified pitch

Parameters:
pitch - the int value of the pitch
Returns:
the name of the pitch

value

public static int value(java.lang.String name,
                        int register)

value

public static int value(int pitchClass,
                        int register)

isWhite

public static boolean isWhite(int pitch)
Return whether a keyboard key is white for the specified pitch.

Parameters:
pitch - the int value of a pitch
Returns:
true if the pitch represents a white key, false otherwise

isBlack

public static boolean isBlack(int pitch)
Return whether a keyboard key is black for the specified pitch.

Parameters:
pitch - the int value of a pitch
Returns:
true if the pitch represents a black key, false otherwise

className

public static java.lang.String className(int pitch)
Return the name of the pitch class of the specified pitch.

Parameters:
pitch - the int value of a pitch
Returns:
the name of the pitch class for the pitch

classNames

public static java.lang.String classNames(int[] pitches)
Return the names of the pitch classes of the specified pitches, seperated by spaces. May result in duplicate pitch class names.

Parameters:
pitches - the array of int values of pitches
Returns:
the names of the pitch classes for the pitches

classValue

public static int classValue(int pitch)
Return the int value of the pitch class of the specified pitch.

Parameters:
pitch - the int value of the pitch
Returns:
the int value of the pitch class for the pitch

classValue

public static int classValue(java.lang.String pitch)
Returns the int value of the pitch class of the specified pitch.

Parameters:
pitch - the string representation of a pitch
Returns:
the int value of the pitch class for the pitch

classValues

public static int[] classValues(java.lang.String pitches)
Returns the int values of the pitch classes of the specified pitches. May result in duplicate pitch classes.

Parameters:
pitches - the string representation of the pitches
Returns:
the aarray of int values of the pitch classes for the pitches

classCount

public static int classCount(int[] pitches)
Count the number of distinct pitch classes in the specified pitches. i.e. C3, C4 etc. are counted as the single pitch class C

Parameters:
pitches - the array of int values of the pitches
Returns:
the count of distinct pitch classes for the pitches

distinctClasses

public static int[] distinctClasses(int[] pitches)
Return the distinct pitch classes of the specified pitches. i.e. remove duplicate pitch classes

Parameters:
pitches - the array of int values of the pitches
Returns:
the array of int values of the distinct pitch classes of the pitches


Copyright © 2004, 2005, 2006, 2007 Steve Taylor. All Rights Reserved.