public class Sampler extends UGen
Sampler provides several inputs that allow you to control the properties
of a triggered sample. When you call the trigger method, the values of these
inputs are "snapshotted" and used to configure the new voice that will play
the sample. So, changing the values does not effect already playing voices,
except for amplitude
, which controls the volume of the Sampler
as a whole.
UGen.InputType, UGen.UGenInput
Modifier and Type | Field and Description |
---|---|
UGen.UGenInput |
amplitude
The amplitude of this Sampler.
|
UGen.UGenInput |
attack
The attack time, in seconds, when triggering
this Sampler.
|
UGen.UGenInput |
begin
The sample number in the source sample
the voice will start at when triggering this Sampler.
|
UGen.UGenInput |
end
The sample number in the source sample
the voice will end at when triggering this Sampler.
|
boolean |
looping
Whether triggered voices should loop or not.
|
UGen.UGenInput |
rate
The playback rate used when triggering this Sampler.
|
Constructor and Description |
---|
Sampler(MultiChannelBuffer sampleData,
float sampleRate,
int maxVoices)
Create a Sampler that will use the audio in the provided MultiChannelBuffer
for its sample.
|
Sampler(java.lang.String filename,
int maxVoices,
Minim system)
Create a new Sampler for triggering the provided file.
|
Modifier and Type | Method and Description |
---|---|
protected void |
sampleRateChanged()
Override this method in your derived class to receive a notification when
the sample rate of your UGen has changed.
|
void |
setSample(MultiChannelBuffer newSampleData,
float sampleRate)
Sets the sample data used by this Sampler by copying the
contents of the provided MultiChannelBuffer into the internal buffer.
|
void |
stop()
Stop all active voices.
|
void |
trigger()
Trigger this Sampler.
|
protected void |
uGenerate(float[] channels)
Implement this method when you extend UGen.
|
addAudio, addControl, addControl, addInput, channelCount, channelCountChanged, getLastValues, patch, patch, patch, printInputs, removeInput, sampleRate, setChannelCount, setSampleRate, tick, unpatch, unpatch
public UGen.UGenInput begin
public UGen.UGenInput end
public UGen.UGenInput attack
public UGen.UGenInput amplitude
public UGen.UGenInput rate
public boolean looping
public Sampler(java.lang.String filename, int maxVoices, Minim system)
filename
- String: the file to loadmaxVoices
- int: the maximum number of voices for this Samplersystem
- Minim: the instance of Minim to use for loading the filepublic Sampler(MultiChannelBuffer sampleData, float sampleRate, int maxVoices)
sampleData
- MultiChannelBuffer: the sample data this Sampler will use to generate soundsampleRate
- float: the sample rate of the sampleDatamaxVoices
- int: the maximum number of voices for this Samplerpublic void trigger()
public void stop()
public void setSample(MultiChannelBuffer newSampleData, float sampleRate)
newSampleData
- MultiChannelBuffer: the new sample data for this SamplersampleRate
- float: the sample rate of the sample dataprotected void sampleRateChanged()
UGen
sampleRateChanged
in class UGen
protected void uGenerate(float[] channels)
UGen
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
.