Skip to content

Commit bebdfac

Browse files
committed
filling out some more examples
1 parent d0d0770 commit bebdfac

File tree

1 file changed

+47
-15
lines changed

1 file changed

+47
-15
lines changed

Tone/core/context/AbstractParam.ts

Lines changed: 47 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,11 @@ export abstract class AbstractParam<TypeName extends UnitName> {
99
* Schedules a parameter value change at the given time.
1010
* @param value The value to set the signal.
1111
* @param time The time when the change should occur.
12+
* @offline 0.5 1
1213
* @example
13-
* const osc = new Tone.Oscillator().toDestination().start();
14-
* // set the frequency to "G4" in exactly 1 second from now.
15-
* osc.frequency.setValueAtTime("G4", "+1");
14+
* const osc = new Tone.Oscillator(20).toDestination().start();
15+
* // set the frequency to 40 at exactly 0.25 seconds
16+
* osc.frequency.setValueAtTime(40, 0.25);
1617
*/
1718
abstract setValueAtTime(value: UnitMap[TypeName], time: Time): this;
1819

@@ -21,12 +22,14 @@ export abstract class AbstractParam<TypeName extends UnitName> {
2122
* may invalidate the returned value.
2223
* @param time When to get the value
2324
* @example
24-
* const osc = new Tone.Oscillator().toDestination().start();
25-
* // set the frequency to "G4" in exactly 1 second from now.
26-
* osc.frequency.setValueAtTime("G4", "+1");
25+
* const signal = new Tone.Signal().toDestination();
26+
* // ramp up to '8' over 3 seconds
27+
* signal.rampTo(8, 3);
28+
* // ramp back down to '0' over 3 seconds
29+
* signal.rampTo(0, 3, "+3");
2730
* setInterval(() => {
2831
* // check the value every 100 ms
29-
* osc.frequency.getValueAtTime(Tone.now());
32+
* console.log(signal.getValueAtTime(Tone.now()));
3033
* }, 100);
3134
*/
3235
abstract getValueAtTime(time: Time): UnitMap[TypeName];
@@ -49,12 +52,24 @@ export abstract class AbstractParam<TypeName extends UnitName> {
4952
/**
5053
* Schedules a linear continuous change in parameter value from the
5154
* previous scheduled parameter value to the given value.
55+
* @offline 0.5 1
56+
* @example
57+
* const signal = new Tone.Signal(0).toDestination();
58+
* // the ramp is starts from the previously scheduled value
59+
* signal.setValueAtTime(0, 0.1);
60+
* signal.linearRampToValueAtTime(1, 0.4);
5261
*/
5362
abstract linearRampToValueAtTime(value: UnitMap[TypeName], time: Time): this;
5463

5564
/**
5665
* Schedules an exponential continuous change in parameter value from
5766
* the previous scheduled parameter value to the given value.
67+
* @offline 0.5 1
68+
* @example
69+
* const signal = new Tone.Signal(0).toDestination();
70+
* // the ramp is starts from the previously scheduled value
71+
* signal.setValueAtTime(0, 0.1);
72+
* signal.exponentialRampToValueAtTime(1, 0.4);
5873
*/
5974
abstract exponentialRampToValueAtTime(value: UnitMap[TypeName], time: Time): this;
6075

@@ -85,12 +100,10 @@ export abstract class AbstractParam<TypeName extends UnitName> {
85100
* value to ramp from it's current value
86101
* @param startTime When the ramp should start.
87102
* @returns {Param} this
103+
* @offline 0.5 1
88104
* @example
89-
* const delay = new Tone.FeedbackDelay(0.5, 0.98).toDestination();
90-
* // a short burst of noise through the feedback delay
91-
* const noise = new Tone.Noise().connect(delay).start().stop("+0.1");
92-
* // linearly ramp to the value 4 over 3 seconds.
93-
* delay.delayTime.linearRampTo(4, 3);
105+
* const signal = new Tone.Signal(1).toDestination();
106+
* signal.linearRampTo(0, 0.3, 0.1);
94107
*/
95108
abstract linearRampTo(value: UnitMap[TypeName], rampTime: Time, startTime?: Time): this;
96109

@@ -103,9 +116,10 @@ export abstract class AbstractParam<TypeName extends UnitName> {
103116
* value to ramp from it's current value
104117
* @param startTime When the ramp should start.
105118
* @example
106-
* import { Oscillator } from "tone";
107-
* const osc = new Oscillator().toDestination().start();
108-
* osc.frequency.targetRampTo("C4", 4);
119+
* @offline 0.5 1
120+
* @example
121+
* const signal = new Tone.Signal(1).toDestination();
122+
* signal.targetRampTo(0, 0.3, 0.1);
109123
*/
110124
abstract targetRampTo(value: UnitMap[TypeName], rampTime: Time, startTime?: Time): this;
111125

@@ -141,18 +155,36 @@ export abstract class AbstractParam<TypeName extends UnitName> {
141155
* @param startTime
142156
* @param duration
143157
* @param scaling If the values in the curve should be scaled by some value
158+
* @offline 0.5 1
159+
* @example
160+
* const signal = new Tone.Signal(1).toDestination();
161+
* signal.setValueCurveAtTime([1, 0.2, 0.8, 0.1, 0], 0.2, 0.3);
144162
*/
145163
abstract setValueCurveAtTime(values: UnitMap[TypeName][], startTime: Time, duration: Time, scaling?: number): this;
146164

147165
/**
148166
* Cancels all scheduled parameter changes with times greater than or
149167
* equal to startTime.
168+
* @offline 0.5 1
169+
* @example
170+
* const signal = new Tone.Signal(0).toDestination();
171+
* signal.setValueAtTime(0.1, 0.1);
172+
* signal.setValueAtTime(0.2, 0.2);
173+
* signal.setValueAtTime(0.3, 0.3);
174+
* signal.setValueAtTime(0.4, 0.4);
175+
* // cancels the last two scheduled changes
176+
* signal.cancelScheduledValues(0.3);
150177
*/
151178
abstract cancelScheduledValues(time: Time): this;
152179

153180
/**
154181
* This is similar to [[cancelScheduledValues]] except
155182
* it holds the automated value at time until the next automated event.
183+
* @offline 0.5 1
184+
* @example
185+
* const signal = new Tone.Signal(0).toDestination();
186+
* signal.linearRampTo(1, 0.5, 0);
187+
* signal.cancelAndHoldAtTime(0.3);
156188
*/
157189
abstract cancelAndHoldAtTime(time: Time): this;
158190

0 commit comments

Comments
 (0)