public class WaveModule
extends net.beadsproject.beads.core.Bead
Buffer type.
WaveModule player = new WaveModule(); player.setFrequency(440); player.setGain(0.1f); player.setBuffer(Buffer.SQUARE); player.connectTo(HB.getAudioOutput());The WaveModule can be killed using the standad
Bead.kill() function. For example, to kill the
player at the end of an envelope, one would add the WaveModule to the KillTrigger
For example:
Envelope gainEnvelope = new Envelope(0); WaveModule player = new WaveModule(); player.setGain(gainEnvelope); // Now plug the object into the audio output player.connectTo(HB.getAudioOutput()); // first add a segment to progress to the higher volume gainEnvelope.addSegment(0.1f, 100); //Now make our gain fade out to 0 and then kill it gainEnvelope.addSegment(0, 10, new KillTrigger(player));
UGen object via setGainObject(UGen) or to a specific value
via setGainValue(double)
UGen object via setFrequency(UGen), a specific value
via setFrequency(double) (double)}, or to a converted Midi value via setMidiFrequency(int)
Buffer is set via setBuffer(Buffer). The waveform can be paused through pause(boolean)| Constructor and Description |
|---|
WaveModule()
Create a
WaveModule with default parameters of 440hz, 0.1 gain with a sine wave buffer |
WaveModule(double frequency,
double gain,
net.beadsproject.beads.data.Buffer waveform_type)
Create a basic
WaveModule for generating simple wave playback |
WaveModule(double frequency,
net.beadsproject.beads.core.UGen gain_control,
net.beadsproject.beads.data.Buffer waveform_type)
Create a basic
WaveModule for generating simple wave playback |
WaveModule(net.beadsproject.beads.core.UGen frequency_control,
double gain,
net.beadsproject.beads.data.Buffer waveform_type)
Create a basic
WaveModule for generating simple wave playback |
WaveModule(net.beadsproject.beads.core.UGen frequency_control,
net.beadsproject.beads.core.UGen gain_control,
net.beadsproject.beads.data.Buffer waveform_type)
Create a basic
WaveModule for generating simple wave playback |
| Modifier and Type | Method and Description |
|---|---|
WaveModule |
connectTo(net.beadsproject.beads.core.UGen input_device)
Connect the output of this instrument to the input of another device
|
protected void |
connectToDevice(net.beadsproject.beads.core.UGen input_device)
Connect the output of this instrument to the input of another device
|
net.beadsproject.beads.core.UGen |
getFrequencyControl()
Get the Frequency Control
UGen |
net.beadsproject.beads.core.UGen |
getGainAmplifier()
Get the final gain Object
|
net.beadsproject.beads.core.UGen |
getGainControl()
Get the gain Control Object
|
net.beadsproject.beads.core.UGen |
getKillTrigger()
Deprecated.
use the class instead. Eg, instead of
new KillTrigger(player.getKillTrigger()use new KillTrigger(waveModule) |
net.beadsproject.beads.ugens.WavePlayer |
getWavePlayer()
Get the UGen
WavePlayer object |
boolean |
isPaused()
Test if waveform generator ia paused.
|
void |
kill()
Kill the current control and release resources
Enables the instrument to be added to a kill trigger
|
void |
pause(boolean pause)
Pause the waveform playback.
|
WaveModule |
setBuffer(net.beadsproject.beads.data.Buffer new_buffer)
set the new Buffer type for waveplayer
|
WaveModule |
setFrequency(double new_frequency)
set the frequency of the
WavePlayer to this frequency. |
WaveModule |
setFrequency(net.beadsproject.beads.core.UGen new_frequency_control)
set a
UGen to control the frequency of the WavePlayer. |
WaveModule |
setGain(double new_gain)
Set the gain to a new value
Eg
|
WaveModule |
setGain(net.beadsproject.beads.core.UGen gain_control)
Set an object to control the gain of this
WaveModule. |
protected void |
setGainObject(net.beadsproject.beads.core.UGen gain_control)
Set an object to control the gain of this instrument
For example, the set the Gain of a
WaveModule so it follows an Envelope we would do as follows |
void |
setGainValue(double new_gain)
Set the gain to a new value
|
WaveModule |
setMidiFrequency(int midi_note_number)
Set the frequency based on Midi Note Number.
|
public WaveModule()
WaveModule with default parameters of 440hz, 0.1 gain with a sine wave bufferpublic WaveModule(double frequency,
double gain,
net.beadsproject.beads.data.Buffer waveform_type)
WaveModule for generating simple wave playbackfrequency - the initial frequencygain - the initial volume. A value of 0.1 is a typical value for playbackwaveform_type - the type of waveform to use, eg, sine, square, etc...public WaveModule(net.beadsproject.beads.core.UGen frequency_control,
double gain,
net.beadsproject.beads.data.Buffer waveform_type)
WaveModule for generating simple wave playbackfrequency_control - the UGen Object that will control the frequencygain - the initial volume. A value of 0.1 is a typical value for playbackwaveform_type - the type of waveform to use, eg, sine, square, etc...public WaveModule(double frequency,
net.beadsproject.beads.core.UGen gain_control,
net.beadsproject.beads.data.Buffer waveform_type)
WaveModule for generating simple wave playbackfrequency - the initial frequencygain_control - the Object that will control the gainwaveform_type - the type of waveform to use, eg, sine, square, etc...public WaveModule(net.beadsproject.beads.core.UGen frequency_control,
net.beadsproject.beads.core.UGen gain_control,
net.beadsproject.beads.data.Buffer waveform_type)
WaveModule for generating simple wave playbackfrequency_control - the UGen Object that will control the frequencygain_control - the UGen Object that will control the gainwaveform_type - the type of Buffer to use, eg, sine, square, etc...public net.beadsproject.beads.core.UGen getFrequencyControl()
UGenpublic void pause(boolean pause)
UGen.pause(boolean)pause in class net.beadsproject.beads.core.Beadpause - set true to pausepublic boolean isPaused()
Bead.isPaused()isPaused in class net.beadsproject.beads.core.Beadpublic WaveModule setGain(double new_gain)
WaveModule waveModule = new WaveModule();
waveModule.setGain(0.3);
new_gain - the new gain to set this player topublic net.beadsproject.beads.ugens.WavePlayer getWavePlayer()
WavePlayer objectWavePlayer objectpublic WaveModule setGain(net.beadsproject.beads.core.UGen gain_control)
WaveModule.
For example, to set the gain to follow and Envelope
you could do the following
Envelope outputEnvelope = new Envelope(0.1f);
// type basicWavePlayer to generate this code
WaveModule waveModule = new WaveModule();
waveModule.setGain(outputEnvelope);
gain_control - the new Object that will control the gainpublic WaveModule setFrequency(net.beadsproject.beads.core.UGen new_frequency_control)
UGen to control the frequency of the WavePlayer.
An example of using an Envelope to control
the frequency is as follows:
final float INITIAL_VOLUME = 0.1f; // Define how loud we want our sound
// define the different frequencies we will be using in our envelope
final float LOW_FREQUENCY = 500; // this is the low frequency of the waveform we will make
final float HIGH_FREQUENCY = 2000; // This is the high frequency of the waveform we will make
// define the times it takes to reach the points in our envelope
final float RAMP_UP_FREQUENCY_TIME = 1000; // 1 second (time is in milliseconds)
final float HOLD_FREQUENCY_TIME = 3000; // 3 seconds
final float RAMP_DOWN_FREQUENCY_TIME = 5000; // 5 seconds
// Create our envelope using LOW_FREQUENCY as the starting value
Envelope frequencyEnvelope = new Envelope(LOW_FREQUENCY);
WaveModule player = new WaveModule(frequencyEnvelope, INITIAL_VOLUME, Buffer.SINE);
player.connectTo(HB.getAudioOutput());
// Now start changing the frequency of frequencyEnvelope
// first add a segment to progress to the higher frequency over 5 seconds
frequencyEnvelope.addSegment(HIGH_FREQUENCY, RAMP_UP_FREQUENCY_TIME);
// now add a segment to make the frequencyEnvelope stay at that frequency
// we do this by setting the start of the segment to the value as our HIGH_FREQUENCY
frequencyEnvelope.addSegment(HIGH_FREQUENCY, HOLD_FREQUENCY_TIME);
//Now make our frequency go back to the lower frequency
frequencyEnvelope.addSegment(LOW_FREQUENCY, RAMP_DOWN_FREQUENCY_TIME);
//Now make our frequency hold to the lower frequency, and after holding, kill our WaveModule
frequencyEnvelope.addSegment(LOW_FREQUENCY, HOLD_FREQUENCY_TIME, new KillTrigger(player));
new_frequency_control - the new object that will control the frequencypublic WaveModule setFrequency(double new_frequency)
WavePlayer to this frequency.
For example, to set the frequency to 1KHz, one could do the following:
WaveModule waveModule = new WaveModule();
waveModule.setFrequency(1000);
new_frequency - the new frequencypublic WaveModule setMidiFrequency(int midi_note_number)
WaveModule waveModule = new WaveModule();
waveModule.setMidiFrequency(60); // 60 is Middle C
midi_note_number - the Midi Note numberpublic WaveModule setBuffer(net.beadsproject.beads.data.Buffer new_buffer)
new_buffer - the new buffer type that will be playedpublic WaveModule connectTo(net.beadsproject.beads.core.UGen input_device)
input_device - the device we want to connect it topublic net.beadsproject.beads.core.UGen getGainControl()
public net.beadsproject.beads.core.UGen getGainAmplifier()
public net.beadsproject.beads.core.UGen getKillTrigger()
new KillTrigger(player.getKillTrigger()use
new KillTrigger(waveModule)
WaveModule instrument and the end of an envelope
we might code the function as follows:
Envelope gainEnvelope = new Envelope(0); WaveModule player = new WaveModule(); player.setGain(gainEnvelope); // Now plug the object into the audio output player.connectTo(HB.getAudioOutput()); // first add a segment to progress to the higher volume gainEnvelope.addSegment(0.1f, 100); // now add a segment to make the gainEnvelope stay at that volume // we do this by setting the start of the segment to the value as our MAX_VOLUME gainEnvelope.addSegment(0.1f, 1000); //Now make our gain fade out to 0 and then kill it gainEnvelope.addSegment(0, 10, new KillTrigger(player));
protected void setGainObject(net.beadsproject.beads.core.UGen gain_control)
WaveModule so it follows an Envelope we would do as follows
Envelope gainEnvelope = new Envelope(0); WaveModule player = new WaveModule(); player.setGain(gainEnvelope);
gain_control - the new Object that will control the gainpublic void setGainValue(double new_gain)
new_gain - the new gain to set this nstrument topublic void kill()
kill in class net.beadsproject.beads.core.Beadprotected void connectToDevice(net.beadsproject.beads.core.UGen input_device)
input_device - the device we want to connect it to