mirror of
https://github.com/Tonejs/Tone.js
synced 2025-01-14 12:53:59 +00:00
additional examples
This commit is contained in:
parent
15d5584f97
commit
8b62ceddac
1 changed files with 25 additions and 11 deletions
|
@ -37,17 +37,15 @@ export interface EnvelopeOptions extends ToneAudioNodeOptions {
|
||||||
* / \
|
* / \
|
||||||
* / \
|
* / \
|
||||||
* ```
|
* ```
|
||||||
*
|
* @offline 2 1
|
||||||
* @example
|
* @example
|
||||||
* // an amplitude envelope
|
|
||||||
* const gainNode = new Tone.Gain();
|
|
||||||
* const env = new Tone.Envelope({
|
* const env = new Tone.Envelope({
|
||||||
* attack: 0.1,
|
* attack: 0.1,
|
||||||
* decay: 0.2,
|
* decay: 0.2,
|
||||||
* sustain: 1,
|
* sustain: 1,
|
||||||
* release: 0.8,
|
* release: 0.8,
|
||||||
* });
|
* }).toDestination();
|
||||||
* env.connect(gainNode.gain);
|
* env.triggerAttackRelease(0.5);
|
||||||
* @category Component
|
* @category Component
|
||||||
*/
|
*/
|
||||||
export class Envelope extends ToneAudioNode<EnvelopeOptions> {
|
export class Envelope extends ToneAudioNode<EnvelopeOptions> {
|
||||||
|
@ -277,13 +275,16 @@ export class Envelope extends ToneAudioNode<EnvelopeOptions> {
|
||||||
* Can also be an array which describes the curve. Values
|
* Can also be an array which describes the curve. Values
|
||||||
* in the array are evenly subdivided and linearly
|
* in the array are evenly subdivided and linearly
|
||||||
* interpolated over the duration of the attack.
|
* interpolated over the duration of the attack.
|
||||||
|
* @offline 1 1
|
||||||
* @example
|
* @example
|
||||||
* const env = new Tone.Envelope();
|
* const env = new Tone.Envelope().toDestination();
|
||||||
* env.attackCurve = "linear";
|
* env.attackCurve = "linear";
|
||||||
|
* env.triggerAttack();
|
||||||
* @example
|
* @example
|
||||||
* const env = new Tone.Envelope();
|
* const env = new Tone.Envelope().toDestination();
|
||||||
* // can also be an array
|
* // can also be an array
|
||||||
* env.attackCurve = [0, 0.2, 0.3, 0.4, 1];
|
* env.attackCurve = [0, 0.2, 0.3, 0.4, 1];
|
||||||
|
* env.triggerAttack();
|
||||||
*/
|
*/
|
||||||
get attackCurve(): EnvelopeCurve {
|
get attackCurve(): EnvelopeCurve {
|
||||||
return this._getCurve(this._attackCurve, "In");
|
return this._getCurve(this._attackCurve, "In");
|
||||||
|
@ -294,9 +295,14 @@ export class Envelope extends ToneAudioNode<EnvelopeOptions> {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The shape of the release. See the attack curve types.
|
* The shape of the release. See the attack curve types.
|
||||||
|
* @offline 1 1
|
||||||
* @example
|
* @example
|
||||||
* const env = new Tone.Envelope();
|
* const env = new Tone.Envelope({
|
||||||
|
* release: 0.5
|
||||||
|
* });
|
||||||
* env.releaseCurve = "linear";
|
* env.releaseCurve = "linear";
|
||||||
|
* env.triggerAttack();
|
||||||
|
* env.triggerRelease(0.5);
|
||||||
*/
|
*/
|
||||||
get releaseCurve(): EnvelopeCurve {
|
get releaseCurve(): EnvelopeCurve {
|
||||||
return this._getCurve(this._releaseCurve, "Out");
|
return this._getCurve(this._releaseCurve, "Out");
|
||||||
|
@ -307,9 +313,14 @@ export class Envelope extends ToneAudioNode<EnvelopeOptions> {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The shape of the decay either "linear" or "exponential"
|
* The shape of the decay either "linear" or "exponential"
|
||||||
|
* @offline 1 1
|
||||||
* @example
|
* @example
|
||||||
* const env = new Tone.Envelope();
|
* const env = new Tone.Envelope({
|
||||||
|
* sustain: 0.1,
|
||||||
|
* decay: 0.5
|
||||||
|
* });
|
||||||
* env.decayCurve = "linear";
|
* env.decayCurve = "linear";
|
||||||
|
* env.triggerAttack();
|
||||||
*/
|
*/
|
||||||
get decayCurve(): BasicEnvelopeCurve {
|
get decayCurve(): BasicEnvelopeCurve {
|
||||||
return this._decayCurve;
|
return this._decayCurve;
|
||||||
|
@ -388,7 +399,9 @@ export class Envelope extends ToneAudioNode<EnvelopeOptions> {
|
||||||
* @param time When the release portion of the envelope should start.
|
* @param time When the release portion of the envelope should start.
|
||||||
* @example
|
* @example
|
||||||
* const env = new Tone.AmplitudeEnvelope().toDestination();
|
* const env = new Tone.AmplitudeEnvelope().toDestination();
|
||||||
* const osc = new Tone.Oscillator().connect(env).start();
|
* const osc = new Tone.Oscillator({
|
||||||
|
* type: "sawtooth"
|
||||||
|
* }).connect(env).start();
|
||||||
* env.triggerAttack();
|
* env.triggerAttack();
|
||||||
* // trigger the release half a second after the attack
|
* // trigger the release half a second after the attack
|
||||||
* env.triggerRelease("+0.5");
|
* env.triggerRelease("+0.5");
|
||||||
|
@ -459,7 +472,8 @@ export class Envelope extends ToneAudioNode<EnvelopeOptions> {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Render the envelope curve to an array of the given length.
|
* Render the envelope curve to an array of the given length.
|
||||||
* Good for visualizing the envelope curve
|
* Good for visualizing the envelope curve. Rescales the duration of the
|
||||||
|
* envelope to fit the length.
|
||||||
*/
|
*/
|
||||||
async asArray(length = 1024): Promise<Float32Array> {
|
async asArray(length = 1024): Promise<Float32Array> {
|
||||||
const duration = length / this.context.sampleRate;
|
const duration = length / this.context.sampleRate;
|
||||||
|
|
Loading…
Reference in a new issue