Constructor
new GranularEngine(options)
Parameters:
Name | Type | Default | Description | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
Object | {} | Parameters Properties
|
- Source:
Example
import * as audio from 'waves-audio';
const scheduler = audio.getScheduler();
const granularEngine = new audio.GranularEngine();
scheduler.add(granularEngine);
Extends
Members
attackAbs :Number
Absolute attack time in sec
Type:
- Number
- Default Value:
- 0
- Source:
attackRel :Number
Attack time relative to grain duration
Type:
- Number
- Default Value:
- 0.5
- Source:
attackShape :String
Shape of attack ('lin' for linear ramp, 'exp' for exponential ramp)
Type:
- String
- Default Value:
- 'lin'
- Source:
buffer :AudioBuffer
Audio buffer
Type:
- AudioBuffer
- Default Value:
- null
- Source:
(readonly) bufferDuration :Number
Get buffer duration (excluding wrapAroundExtension)
Type:
- Number
- Source:
centered :Boolean
Whether the grain position refers to the center of the grain (or the beginning)
Type:
- Boolean
- Default Value:
- true
- Source:
(readonly) currentPosition :Number
Current position
Type:
- Number
- Source:
cyclic :Boolean
Whether the audio buffer and grain position are considered as cyclic
Type:
- Boolean
- Default Value:
- false
- Source:
durationAbs :Number
Absolute grain duration in sec
Type:
- Number
- Default Value:
- 0.1
- Source:
durationRel :Number
Grain duration relative to grain period (overlap)
Type:
- Number
- Default Value:
- 0
- Source:
expRampOffset :Number
Offset (start/end value) for exponential attack/release
Type:
- Number
- Default Value:
- 0.0001
- Source:
gain :Number
Linear gain factor
Type:
- Number
- Default Value:
- 1
- Source:
periodAbs :Number
Absolute grain period in sec
Type:
- Number
- Default Value:
- 0.01
- Source:
periodMin :Number
Minimum grain period
Type:
- Number
- Default Value:
- 0.001
- Source:
periodRel :Number
Grain period relative to absolute duration
Type:
- Number
- Default Value:
- 0
- Source:
periodVar :Number
Amout of random grain period variation relative to grain period
Type:
- Number
- Default Value:
- 0
- Source:
position :Number
Grain position (onset time in audio buffer) in sec
Type:
- Number
- Default Value:
- 0
- Source:
positionVar :Number
Amout of random grain position variation in sec
Type:
- Number
- Default Value:
- 0.003
- Source:
releaseAbs :Number
Absolute release time in sec
Type:
- Number
- Default Value:
- 0
- Source:
releaseRel :Number
Release time relative to grain duration
Type:
- Number
- Default Value:
- 0.5
- Source:
releaseShape :String
Shape of release ('lin' for linear ramp, 'exp' for exponential ramp)
Type:
- String
- Default Value:
- 'lin'
- Source:
resampling :Number
Grain resampling in cent
Type:
- Number
- Default Value:
- 0
- Source:
resamplingVar :Number
Amout of random resampling variation in cent
Type:
- Number
- Default Value:
- 0
- Source:
wrapAroundExtension :Number
Portion at the end of the audio buffer that has been copied from the beginning to assure cyclic behavior
Type:
- Number
- Default Value:
- 0
- Source:
Methods
connect(target)
Connect to an audio node (e.g. audioContext.destination)
Parameters:
Name | Type | Description |
---|---|---|
target |
AudioNode | Target audio node |
- Inherited From:
- Source:
disconnect(target)
Disconnect from an audio node (e.g. audioContext.destination). If undefined disconnect from all target nodes.
Parameters:
Name | Type | Description |
---|---|---|
target |
AudioNode | Target audio node. |
- Inherited From:
- Source:
trigger(time) → {Number}
Trigger a grain. This function can be called at any time (whether the engine is scheduled or not) to generate a single grain according to the current grain parameters.
Parameters:
Name | Type | Description |
---|---|---|
time |
Number | grain synthesis audio time |
- Source:
Returns:
- period to next grain
- Type
- Number