public class SampleModule
extends net.beadsproject.beads.core.Bead
setSample(String), define looping through setLoopStart(UGen), setLoopStart(double), setLoopEnd(UGen), setLoopEnd(UGen), setLoopStart(UGen) and setLoopType(SamplePlayer.LoopType).
setRate(UGen) and setRate(double).
setPosition(double) and setToEnd().
pause(boolean)
UGen object via setGainObject(UGen) or to a specific value
* via setGainValue(double).
SampleModule might be as follows
// define our start and end loop points
final float LOOP_START = 0;
final float LOOP_END = 2000;
final String sample_name = "data/audio/Roje/i-write.wav";
SampleModule samplePlayer = new SampleModule();
if (samplePlayer.setSample(sample_name)) {
samplePlayer.connectTo(HB.getAudioOutput());
// define our loop type. we will loop forwards
samplePlayer.setLoopType(SamplePlayer.LoopType.LOOP_FORWARDS);
// now set the loop start and end in the actual sample player
samplePlayer.setLoopStart(LOOP_START);
samplePlayer.setLoopEnd(LOOP_END);
} else {
HB.sendStatus("Failed sample " + sample_name);
}
| Modifier and Type | Field and Description |
|---|---|
java.lang.String |
EXAMPLE_SAMPLE_NAME |
| Constructor and Description |
|---|
SampleModule()
Creates basic
SampleModule for playing wave files |
| Modifier and Type | Method and Description |
|---|---|
SampleModule |
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 |
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.SamplePlayer |
getSamplePlayer()
Get the Beads
SamplePlayer Object of this object |
boolean |
isRestartSample()
FLag indicating we will restart when a new sample name is added
|
void |
kill()
Kill the current control and release resources
Enables the instrument to be added to a kill trigger
|
void |
pause(boolean pause_playing)
Pause the Sample Playback
|
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
|
SampleModule |
setLoopEnd(double loop_end)
Set the End Loop position
See
setLoopStart(double) for example code |
SampleModule |
setLoopEnd(net.beadsproject.beads.core.UGen loop_end)
Set the End Loop using a
UGen. |
SampleModule |
setLoopStart(double loop_start)
|
SampleModule |
setLoopStart(net.beadsproject.beads.core.UGen loop_start)
Set the start Loop Control using a
UGen. |
SampleModule |
setLoopType(net.beadsproject.beads.ugens.SamplePlayer.LoopType loop_type)
Sets the
SamplePlayer.LoopType Type for this Sampler |
SampleModule |
setPosition(double new_position)
Set SamplePlayer to new position
|
SampleModule |
setRate(double new_rate)
set the playback rate to this value.
|
SampleModule |
setRate(net.beadsproject.beads.core.UGen new_rate_control)
set an object to control the playback rate of the samplePlayer.
|
SampleModule |
setRestartSample(boolean restart_on_new_sample)
Cause the sample player to start playing new samples at the start
|
boolean |
setSample(java.lang.String filename)
Set the sample.
|
SampleModule |
setToEnd()
Set SamplePlayer to end
|
public final java.lang.String EXAMPLE_SAMPLE_NAME
public SampleModule()
SampleModule for playing wave filespublic boolean setSample(java.lang.String filename)
final String s = "data/audio/Roje/i-write.wav";
SampleModule sampleModule = new SampleModule();
if (sampleModule.setSample(s))
{
}
filename - the filename of the samplepublic void pause(boolean pause_playing)
pause in class net.beadsproject.beads.core.Beadpause_playing - true if we want to pause. Set to false to start playingpublic SampleModule setPosition(double new_position)
new_position - new position in millisecondspublic SampleModule setToEnd()
public SampleModule setRate(net.beadsproject.beads.core.UGen new_rate_control)
Envelope sampleRateEnvelope = new Envelope(0);
final String s = "data/audio/Roje/i-write.wav";
SampleModule sampleModule = new SampleModule();
if (sampleModule.setSample(s)) {// Write your code below this line
sampleModule.setRate(sampleRateEnvelope);
sampleModule.connectTo(HB.getAudioOutput());
sampleRateEnvelope.addSegment(2, 3000); // Set Rate to 2X over 3 seconds
sampleRateEnvelope.addSegment(1, 2000); // Set Rate to 1X over 2 seconds
// Write your code above this line
} else {
HB.HBInstance.setStatus("Failed sample " + s);
}// End samplePlayer code
new_rate_control - the new object that will control the playback ratepublic SampleModule setRate(double new_rate)
new_rate - the new frequencypublic boolean isRestartSample()
public SampleModule setRestartSample(boolean restart_on_new_sample)
restart_on_new_sample - true if we want to play new samples at the startpublic SampleModule setLoopStart(double loop_start)
SampleModule loops might be as follows
// define our start and end loop points
final float LOOP_START = 0;
final float LOOP_END = 2000;
final String sample_name = "data/audio/Roje/i-write.wav";
SampleModule samplePlayer = new SampleModule();
if (samplePlayer.setSample(sample_name)) {
samplePlayer.connectTo(HB.getAudioOutput());
// define our loop type. we will loop forwards
samplePlayer.setLoopType(SamplePlayer.LoopType.LOOP_FORWARDS);
// now set the loop start and end in the actual sample player
samplePlayer.setLoopStart(LOOP_START);
samplePlayer.setLoopEnd(LOOP_END);
} else {
HB.sendStatus("Failed sample " + sample_name);
}
loop_start - loopPointpublic SampleModule setLoopStart(net.beadsproject.beads.core.UGen loop_start)
UGen. EG
Glide loopStart = new Glide(0);
Glide loopEnd = new Glide(2000);
final String sample_name = "data/audio/Roje/i-write.wav";
SampleModule samplePlayer = new SampleModule();
if (samplePlayer.setSample(sample_name)) {
samplePlayer.connectTo(HB.getAudioOutput());
// define our loop type. we will loop forwards
samplePlayer.setLoopType(SamplePlayer.LoopType.LOOP_FORWARDS);
// now set the loop start and end in the actual sample player
samplePlayer.setLoopStart(loopStart);
samplePlayer.setLoopEnd(loopEnd);
} else {
HB.sendStatus("Failed sample " + sample_name);
}
loop_start - the Object that will control loopStartpublic SampleModule setLoopEnd(double loop_end)
setLoopStart(double) for example codeloop_end - loopPointpublic SampleModule setLoopEnd(net.beadsproject.beads.core.UGen loop_end)
UGen. EG
For an example see setLoopStart(UGen)loop_end - the Object that will control loopEndpublic SampleModule connectTo(net.beadsproject.beads.core.UGen input_device)
SampleModule output to a Reverb,
you could do the following:
Reverb reverb = new Reverb();
final String sample_name = "data/audio/Roje/i-write.wav";
SampleModule samplePlayer = new SampleModule();
if (samplePlayer.setSample(sample_name)) {
samplePlayer.connectTo(reverb);
input_device - the device we want to connect it topublic SampleModule setLoopType(net.beadsproject.beads.ugens.SamplePlayer.LoopType loop_type)
SamplePlayer.LoopType Type for this Samplerloop_type - the type of looppublic net.beadsproject.beads.ugens.SamplePlayer getSamplePlayer()
SamplePlayer Object of this objectpublic 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