Package com.softsynth.jmsl.util
Class Tuning
java.lang.Object
com.softsynth.jmsl.util.Tuning
- Direct Known Subclasses:
TuningET
,TuningTable
public abstract class Tuning
extends java.lang.Object
-
Constructor Summary
Constructors Constructor Description Tuning()
-
Method Summary
Modifier and Type Method Description static double
freqPlusCents(double freq, double cents)
abstract double
getFrequency(double pitchIndex)
abstract double
getFrequency(double pitchIndex, int octaveNumber)
double
getOctaveRatio()
Normally 2.0 so frequency doubles every octave.int
getOctaveStretchCents()
double
getReferenceFrequency()
Reference frequency is locked to the reference pitch.double
getReferencePitch()
Reference pitch is locked to the reference frequency.abstract double
getStepsPerOctave()
static void
main(java.lang.String[] args)
void
setOctaveRatio(double f)
Normally 2.0 so frequency doubles every octave.void
setOctaveStretchCents(int cents)
Set the octave stretch in cents.void
setReferenceFrequency(double d)
Reference frequency is locked to the reference pitch.void
setReferencePitch(double d)
Reference pitch is locked to the reference frequency.double
stretch(double pitch, double frequency)
Distributes octave stretch evenly across n intervals.Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Constructor Details
-
Tuning
public Tuning()
-
-
Method Details
-
getFrequency
public abstract double getFrequency(double pitchIndex, int octaveNumber)- Returns:
- frequency associated with pitchIndex and octaveNumber
-
getFrequency
public abstract double getFrequency(double pitchIndex)- Returns:
- frequency of pitch associated with pitchIndex
-
freqPlusCents
public static double freqPlusCents(double freq, double cents)- Returns:
- frequency plus or minus cents
-
setOctaveStretchCents
public void setOctaveStretchCents(int cents)Set the octave stretch in cents. Only stores this value here, implemented in subclasses -
getOctaveStretchCents
public int getOctaveStretchCents()- Returns:
- the octave stretch in cents.
-
getStepsPerOctave
public abstract double getStepsPerOctave()- Returns:
- number of steps in an octave (12 for western 12tet for example)
-
setOctaveRatio
public void setOctaveRatio(double f)Normally 2.0 so frequency doubles every octave. This is used in the formula 2.0^(i/numintervals). Set to a value other than 2.0 to redefine the distance of an "octave" -
getOctaveRatio
public double getOctaveRatio()Normally 2.0 so frequency doubles every octave. Set to a value other than 2.0 to redefine the distance of an "octave" -
getReferencePitch
public double getReferencePitch()Reference pitch is locked to the reference frequency. For example, to anchor an ET tuning on middle C use reference frequency MIDDLE_C_FREQ and reference pitch 60 or to anchor a TuningTable's lowest frequency to a pitch.- Returns:
- referencePitch
-
setReferencePitch
public void setReferencePitch(double d)Reference pitch is locked to the reference frequency. For example, to anchor an ET tuning on middle C use reference frequency MIDDLE_C_FREQ and reference pitch 60 or to anchor a TuningTable's lowest frequency to a pitch.- Parameters:
reference
- pitch
-
getReferenceFrequency
public double getReferenceFrequency()Reference frequency is locked to the reference pitch. For example, to anchor a tuning on middle C use reference frequency 261.6 and reference pitch 60- Returns:
- reference frequency
-
setReferenceFrequency
public void setReferenceFrequency(double d)Reference frequency is locked to the reference pitch. For example, to anchor a tuning on middle C use reference frequency MIDDLE_C_FREQ and reference pitch 60- Parameters:
reference
- frequency
-
stretch
public double stretch(double pitch, double frequency)Distributes octave stretch evenly across n intervals. Override to change this . Body of method follows:
double pitchDiff = pitch - getReferencePitch(); double stretchedFreq = freqPlusCents(frequency, pitchDiff * getOctaveStretchCents() / getStepsPerOctave()); return stretchedFreq;
- Returns:
- frequency stretched according to distance pitch is from reference pitch
-
main
public static void main(java.lang.String[] args)
-