Package com.softsynth.jmsl.util
Class TuningTable
java.lang.Object
com.softsynth.jmsl.util.Tuning
com.softsynth.jmsl.util.TuningTable
- Direct Known Subclasses:
PtolemyTuning
public class TuningTable extends Tuning
-
Constructor Summary
Constructors Constructor Description TuningTable()No-args constructor uses Gamelan Son of Lion tuning with 5 cents octave stretchTuningTable(double[] freqs)Constructor initializes pitches with double[], sets reference frequency to pitches[0], reference pitch defaults to 50TuningTable(double[] frequencies, double referencePitch)supply an octave of frequencies and a reference pitch to associate with lowest frequency -
Method Summary
Modifier and Type Method Description double[]getFrequencies()doublegetFrequency(double pitch)doublegetFrequency(double pc, int octaveNumber)intgetPitchClass(int pitch)doublegetStepsPerOctave()static voidmain(java.lang.String[] args)voidsetFrequencies(double[] pitches)Set array of pitch frequencies, sets referenceFrequency to pitches[0]voidsetPitch(int index, double frequency)Set frequency of index'th entry in tuning table.doublestretch(double pitch, double frequency)Overridden Tuning method.java.lang.StringtoString()Methods inherited from class com.softsynth.jmsl.util.Tuning
freqPlusCents, getOctaveRatio, getOctaveStretchCents, getReferenceFrequency, getReferencePitch, setOctaveRatio, setOctaveStretchCents, setReferenceFrequency, setReferencePitchMethods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Constructor Details
-
TuningTable
public TuningTable()No-args constructor uses Gamelan Son of Lion tuning with 5 cents octave stretch -
TuningTable
public TuningTable(double[] freqs)Constructor initializes pitches with double[], sets reference frequency to pitches[0], reference pitch defaults to 50 -
TuningTable
public TuningTable(double[] frequencies, double referencePitch)supply an octave of frequencies and a reference pitch to associate with lowest frequency
-
-
Method Details
-
getStepsPerOctave
public double getStepsPerOctave()- Specified by:
getStepsPerOctavein classTuning- Returns:
- number of steps in an octave. Equal to number of entries in tuning table
-
getFrequencies
public double[] getFrequencies()- Returns:
- array of pitches
-
setFrequencies
public void setFrequencies(double[] pitches)Set array of pitch frequencies, sets referenceFrequency to pitches[0] -
setPitch
public void setPitch(int index, double frequency)Set frequency of index'th entry in tuning table. 0 < index < tuningTable.length -
getPitchClass
public int getPitchClass(int pitch)- Returns:
- pitch class 0..(frequencies.length-1) of pitch arg
-
getFrequency
public double getFrequency(double pc, int octaveNumber)- Specified by:
getFrequencyin classTuning- Returns:
- frequency of pitch at pitches[pc] transposed up octaveNumber octaves, octaveNumber=0 is base
-
stretch
public double stretch(double pitch, double frequency)Overridden Tuning method. Here octave stetch in cents is not distributed evenly over the pitches, but takes jumps at octave boundaries (each pitch in an octave is offset by the same amount as all other pitches in that octave, by an amount equal to (numberOfOctavesAwayFromReferencePitch * octaveStretchInCents). -
getFrequency
public double getFrequency(double pitch)- Specified by:
getFrequencyin classTuning- Returns:
- frequency of pitch at pitches[getPitchClass(pitch)] transposed to octave. Calls Tuning.stretch() as a last step, which you can override
-
toString
public java.lang.String toString()- Overrides:
toStringin classjava.lang.Object
-
main
public static void main(java.lang.String[] args)
-