arb.soundcipher
Class SCUtilities

java.lang.Object
  extended by arb.soundcipher.SCUtilities
Direct Known Subclasses:
SCScore, SoundCipher

public class SCUtilities
extends java.lang.Object

The SCUtilties class contains a collection of helper methods for users of the SoundCipher package. In particular the utilities provide support for common musical and mathematical functions as a convenience for the algorithmic musician.

The SCUtilities class is not designed to be instantiated directly, but can be accessed via the SoundCipher or SCScore classes which inherit the methods. For example, given the declaration

 SoundCipher sc = new SoundCipher(this);
 
then utilities can be accessed using dot syntax such as,
 float frequency = sc.midiToFreq(60);
 

Author:
Andrew R. Brown

Constructor Summary
SCUtilities()
           
 
Method Summary
 float gaussian(double mean, double stdDeviation)
          Returns a psudorandom number dispersed by a gaussian distribution around the mean specified.
 float midiToFreq(double midiPitch)
          Convert a MIDI pitch into a frequency in hertz.
 float midiToFreq(float midiPitch)
          Convert a MIDI pitch into a frequency in hertz.
 float pcGaussianWalk(float startVal, float stdDeviation, float[] pitchClassSet)
          Select a constrained pitch from a pitch class with the specified range around a specificed value.
 float pcRandom(float lower, float upper, float[] pitchClassSet)
          Select a constrained pitch from a pitch class set with the specified range.
 float pcRandom(int lower, int upper, float[] pitchClassSet)
          Select a constrained pitch from a pitch class set with the specified range.
 float pcRandomWalk(float startVal, float stepMax, float[] pitchClassSet)
          Select a constrained MIDI pitch from a pitch class that is poximate to the starting MIDI pitch value.
 float pcRandomWalk(int startVal, int stepMax, float[] pitchClassSet)
          Select a constrained MIDI pitch from a pitch class that is poximate to the starting MIDI pitch value.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SCUtilities

public SCUtilities()
Method Detail

midiToFreq

public float midiToFreq(float midiPitch)
Convert a MIDI pitch into a frequency in hertz. Assumes pitch 69 (A4) = 440.0 hz and equal tempered tuning.

Parameters:
midiPitch - The MIDI pitch number to convert (e.g., 60 = middle C)
Returns:
The equivalent frequency in hertz (cycles per second).

midiToFreq

public float midiToFreq(double midiPitch)
Convert a MIDI pitch into a frequency in hertz. Assumes pitch 69 (A4) = 440.0 hz and equal tempered tuning.

Parameters:
midiPitch - The MIDI pitch number to convert (e.g., 60 = middle C)
Returns:
The equivalent frequency in hertz (cycles per second).

gaussian

public float gaussian(double mean,
                      double stdDeviation)
Returns a psudorandom number dispersed by a gaussian distribution around the mean specified. About 68% of the pitches returned will be no greater than the mean plus the standard deviation and no less than the mean minus the standard deviation. Around 95% of pitches will be within twice this range.

Parameters:
mean - the centre value that should be most commonly returned by this method.
stdDeviation - the breadth of variation eaither side of the mean.

pcRandom

public float pcRandom(int lower,
                      int upper,
                      float[] pitchClassSet)
Select a constrained pitch from a pitch class set with the specified range. A pitch class set is a float array of scale degree values in the range from 0 to 11. There are some pitch class sets defined in the PitchClassSets interface.

Parameters:
lower - The lowest MIDI pitch that can be selected
upper - The highest MIDI pitch that can be selected
pitchClassSet - The scale or mode that the selected pitch must belong too
Returns:
The randomly chosen pitch that meets all constriants.

pcRandom

public float pcRandom(float lower,
                      float upper,
                      float[] pitchClassSet)
Select a constrained pitch from a pitch class set with the specified range. A pitch class set is a float array of scale degree values in the range from 0 to 11. There are some pitch class sets defined in the PitchClassSets interface.

Parameters:
lower - The lowest MIDI pitch that can be selected
upper - The highest MIDI pitch that can be selected
pitchClassSet - The scale or mode that the selected pitch must belong too
Returns:
The randomly chosen pitch that meets all constriants.

pcRandomWalk

public float pcRandomWalk(int startVal,
                          int stepMax,
                          float[] pitchClassSet)
Select a constrained MIDI pitch from a pitch class that is poximate to the starting MIDI pitch value. A pitch class set is a float array of scale degree values in the range from 0 to 11. There are some pitch class sets for common scales and modes are defined in the PitchClassSets interface.

Parameters:
startVal - The initial MIDI pitch
stepMax - The largest allowable interval away from the initial pitch
pitchClassSet - The scale or mode that the selected pitch must belong too
Returns:
The randomly chosen pitch that meets all constriants.

pcRandomWalk

public float pcRandomWalk(float startVal,
                          float stepMax,
                          float[] pitchClassSet)
Select a constrained MIDI pitch from a pitch class that is poximate to the starting MIDI pitch value. A pitch class set is a float array of scale degree values in the range from 0 to 11. There are some pitch class sets for common scales and modes are defined in the PitchClassSets interface.

Parameters:
startVal - The initial MIDI pitch
stepMax - The largest allowable interval away from the initial pitch
pitchClassSet - The scale or mode that the selected pitch must belong too
Returns:
The randomly chosen pitch that meets all constriants.

pcGaussianWalk

public float pcGaussianWalk(float startVal,
                            float stdDeviation,
                            float[] pitchClassSet)
Select a constrained pitch from a pitch class with the specified range around a specificed value. A pitch class set is a float array of scale degree values in the range from 0 to 11. There are some pitch class sets for common scales and modes are defined in the PitchClassSets interface.

Parameters:
startVal - The median point around which values will centre
stdDeviation - The standard deviation from the centre/median point
pitchClassSet - The scale or mode that the selected pitch must belong too
Returns:
The randomly chosen pitch that meets all constriants.