com.perisic.sound
Class Voice

java.lang.Object
  extended by com.perisic.sound.Voice

public class Voice
extends java.lang.Object

This class represents a voice that consists of a set of three functions [0..1] -> [0..1] that determine the pitch, velocity and instrument at time t where 0 <= t <= 1.

Copyright:(c) Marc Conrad, Tim French 2006; Usage of the works is permitted provided that this instrument is retained with the works, so that any entity that uses the works is notified of this instrument. DISCLAIMER: THE WORKS ARE WITHOUT WARRANTY.

Version:
0.1
Author:
Marc Conrad

Constructor Summary
Voice(java.util.Random rG, int[] myInstruments, int lowestPitch, int highestPitch, java.lang.String name)
          These parameters determine fully this voice.
 
Method Summary
 NiceFunction[] getFunctions()
          Gives an array of the three functions { pitch, velocity, instrument }.
 java.awt.image.BufferedImage getImage(int width, int height)
          Displays a visualization of the voice.
 int getInstrument(double t)
          The instrument (klangfarbe) is determined according to the defining function for instruments.
 java.lang.String getInstrumentNames()
          This returns the names of all instruments that are used by this voice separated by newlines.
 java.lang.String getName()
          When used in conjunction with the class VoiceAssignment
 int getNumberOfInstruments()
           
 int getPitch(double t)
          The pitch is determined according to the defining function for the pitch.
 int getVelocity(double t)
          The velocity is determined according to the defining function for the velocity.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Voice

public Voice(java.util.Random rG,
             int[] myInstruments,
             int lowestPitch,
             int highestPitch,
             java.lang.String name)
These parameters determine fully this voice. The voice produces pitches in the range lowestPitch to highestPitch.

Parameters:
rG - a random number generator that is used for producing the generating functions.
myInstruments - The array of instruments that is used by this voice. In Midi context the number refers to the number of the program in bank zero. Note that the method Util.getInstrumentName(int) returns a text description of the instrument.
lowestPitch - The lowest possible pitch of the voice.
highestPitch - The highest possible pitch of the voice.
name - The name of the voice.
Method Detail

getNumberOfInstruments

public int getNumberOfInstruments()
Returns:
The number of instruments that are used by this voice.

getInstrumentNames

public java.lang.String getInstrumentNames()
This returns the names of all instruments that are used by this voice separated by newlines. This is used for the visualization of the composition.

Returns:
all instrument names.

getName

public java.lang.String getName()
When used in conjunction with the class VoiceAssignment

Returns:
The name of this voice.

getPitch

public int getPitch(double t)
The pitch is determined according to the defining function for the pitch. The return value is between lowestPitch and highestPitch, as specified in the constructor.

Parameters:
t - A value with 0 <= t <= 1
Returns:
the pitch at time t

getVelocity

public int getVelocity(double t)
The velocity is determined according to the defining function for the velocity. The return value is between 80 and 127 (maximum velocity).

Parameters:
t - A value with 0 <= t <= 1
Returns:
the velocity at time t

getInstrument

public int getInstrument(double t)
The instrument (klangfarbe) is determined according to the defining function for instruments.

Parameters:
t - A value with 0 <= t <= 1
Returns:
the instrument (midi program number) at time t

getFunctions

public NiceFunction[] getFunctions()
Gives an array of the three functions { pitch, velocity, instrument }.

Returns:
an array of the three defining functions.

getImage

public java.awt.image.BufferedImage getImage(int width,
                                             int height)
Displays a visualization of the voice. The instrument is shown as green, the velocity is shown as blue and the pitch is shown as a red line.

Parameters:
width - The width of the image.
height - The height of the image.
Returns:
a visualization of the voice.