ddf.minim.ugens
Class Oscil

java.lang.Object
  extended by ddf.minim.ugens.UGen
      extended by ddf.minim.ugens.Oscil

public class Oscil
extends UGen

Provides a UGen which generates a Waveform at a specified frequency.

Author:
Damien Di Fede, Anderson Mills

Nested Class Summary
 
Nested classes/interfaces inherited from class ddf.minim.ugens.UGen
UGen.InputType, UGen.UGenInput
 
Field Summary
 UGen.UGenInput amplitude
          Patch to this to control the amplitude of the oscillator with another UGen.
 UGen.UGenInput frequency
          Patch to this to control the frequency of the oscillator with another UGen.
 UGen.UGenInput phase
          Patch to this to control the phase of the oscillator with another UGen.
 
Constructor Summary
Oscil(float frequencyInHertz, float amplitude)
          Constructs an Oscil UGen given frequency in Hz and amplitude.
Oscil(float frequencyInHertz, float amplitude, Waveform waveform)
          Constructs an Oscil UGen given frequency in Hz, amplitude, and a waveform
Oscil(Frequency frequency, float amplitude)
          Constructs an Oscil UGen given a Frequency and amplitude.
Oscil(Frequency freq, float amp, Waveform wave)
          Constructs an Oscil UGen given a Frequency, amplitude, and a waveform
 
Method Summary
 void reset()
          Resets the time-step used by the oscillator to be equal to the current phase value.
protected  void sampleRateChanged()
          This routine will be called any time the sample rate changes.
 void setFrequency(float hz)
          Sets the frequency of this Oscil.
 void setFrequency(Frequency newFreq)
          Sets the frequency of this Oscil.
 void setPhase(float newPhase)
          Set the amount that the phase will be offset by.
protected  void uGenerate(float[] channels)
          Implement this method when you extend UGen.
 
Methods inherited from class ddf.minim.ugens.UGen
addInput, getLastValues, patch, patch, patch, printInputs, removeInput, sampleRate, setSampleRate, tick, unpatch, unpatch
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

amplitude

public UGen.UGenInput amplitude
Patch to this to control the amplitude of the oscillator with another UGen.


frequency

public UGen.UGenInput frequency
Patch to this to control the frequency of the oscillator with another UGen.


phase

public UGen.UGenInput phase
Patch to this to control the phase of the oscillator with another UGen.

Constructor Detail

Oscil

public Oscil(float frequencyInHertz,
             float amplitude,
             Waveform waveform)
Constructs an Oscil UGen given frequency in Hz, amplitude, and a waveform

Parameters:
frequencyInHertz - the frequency this should oscillate at
amplitude - the base amplitude
waveform - the waveform we will oscillate over

Oscil

public Oscil(float frequencyInHertz,
             float amplitude)
Constructs an Oscil UGen given frequency in Hz and amplitude. This oscillator uses a sine wave.

Parameters:
frequencyInHertz - the frequency this should oscillate at
amplitude - the amplitude

Oscil

public Oscil(Frequency frequency,
             float amplitude)
Constructs an Oscil UGen given a Frequency and amplitude. This oscillator uses a sine wave.

Parameters:
frequency - the frequency this should oscillate at
amplitude - the amplitude

Oscil

public Oscil(Frequency freq,
             float amp,
             Waveform wave)
Constructs an Oscil UGen given a Frequency, amplitude, and a waveform

Parameters:
frequency -
amplitude -
waveform -
Method Detail

sampleRateChanged

protected void sampleRateChanged()
This routine will be called any time the sample rate changes.

Overrides:
sampleRateChanged in class UGen

setFrequency

public void setFrequency(float hz)
Sets the frequency of this Oscil. You might want to do this to change the frequency of this Oscil in response to a button press or something. For controlling frequency continuously over time you will usually want to use the frequency input.

Parameters:
hz - the frequency, in Hertz, to set this Oscil to

setFrequency

public void setFrequency(Frequency newFreq)
Sets the frequency of this Oscil. You might want to do this to change the frequency of this Oscil in response to a button press or something. For controlling frequency continuously over time you will usually want to use the frequency input.

Parameters:
freq - the Frequency to set this Oscil to

setPhase

public void setPhase(float newPhase)
Set the amount that the phase will be offset by. Oscil steps its time from 0 to 1, which means that the phase is also normalized. However, it still makes sense to set the phase to greater than 1 or even to a negative number.

Parameters:
newPhase -

reset

public void reset()
Resets the time-step used by the oscillator to be equal to the current phase value. You will typically use this when starting a new note with an Oscil that you have already used so that the waveform will begin sounding at the beginning of its period, which will typically be a zero-crossing. In other words, use this to prevent clicks when starting Oscils that have been used before.


uGenerate

protected void uGenerate(float[] channels)
Description copied from class: UGen
Implement this method when you extend UGen. It will be called when your UGen needs to generate one sample frame of audio. It is expected that you will assign values to the array and not simply modify the existing values. In the case where you write a UGen that takes audio input and modifies it, the pattern to follow is to have the first UGenInput you create be your audio input and then in uGenerate you will use the getLastValues method of your audio UGenInput to retrieve the audio you want to modify, which you will then modify however you need to, assigning the result to the values in channels.

Specified by:
uGenerate in class UGen
Parameters:
channels - an array representing one sample frame.