UNPKG

3.33 kBTypeScriptView Raw
1import { Tone } from "../Tone.js";
2import { TimeClass } from "../type/Time.js";
3import { Frequency, Hertz, Seconds, Ticks, Time } from "../type/Units.js";
4import { RecursivePartial } from "../util/Interface.js";
5import { BaseContext } from "./BaseContext.js";
6/**
7 * A unit which process audio
8 */
9export interface ToneWithContextOptions {
10 context: BaseContext;
11}
12/**
13 * The Base class for all nodes that have an AudioContext.
14 */
15export declare abstract class ToneWithContext<Options extends ToneWithContextOptions> extends Tone {
16 /**
17 * The context belonging to the node.
18 */
19 readonly context: BaseContext;
20 /**
21 * The default context to use if no AudioContext is passed in to the constructor.
22 * Probably should not be set manually. Used internally.
23 * @hidden
24 */
25 readonly defaultContext?: BaseContext;
26 /**
27 * Pass in a constructor as the first argument
28 */
29 constructor(context?: BaseContext);
30 constructor(options?: Partial<ToneWithContextOptions>);
31 static getDefaults(): ToneWithContextOptions;
32 /**
33 * Return the current time of the Context clock plus the lookAhead.
34 * @example
35 * setInterval(() => {
36 * console.log(Tone.now());
37 * }, 100);
38 */
39 now(): Seconds;
40 /**
41 * Return the current time of the Context clock without any lookAhead.
42 * @example
43 * setInterval(() => {
44 * console.log(Tone.immediate());
45 * }, 100);
46 */
47 immediate(): Seconds;
48 /**
49 * The duration in seconds of one sample.
50 */
51 get sampleTime(): Seconds;
52 /**
53 * The number of seconds of 1 processing block (128 samples)
54 * @example
55 * console.log(Tone.Destination.blockTime);
56 */
57 get blockTime(): Seconds;
58 /**
59 * Convert the incoming time to seconds.
60 * This is calculated against the current {@link TransportClass} bpm
61 * @example
62 * const gain = new Tone.Gain();
63 * setInterval(() => console.log(gain.toSeconds("4n")), 100);
64 * // ramp the tempo to 60 bpm over 30 seconds
65 * Tone.getTransport().bpm.rampTo(60, 30);
66 */
67 toSeconds(time?: Time): Seconds;
68 /**
69 * Convert the input to a frequency number
70 * @example
71 * const gain = new Tone.Gain();
72 * console.log(gain.toFrequency("4n"));
73 */
74 toFrequency(freq: Frequency): Hertz;
75 /**
76 * Convert the input time into ticks
77 * @example
78 * const gain = new Tone.Gain();
79 * console.log(gain.toTicks("4n"));
80 */
81 toTicks(time?: Time | TimeClass): Ticks;
82 /**
83 * Get a subset of the properties which are in the partial props
84 */
85 protected _getPartialProperties(props: Options): Partial<Options>;
86 /**
87 * Get the object's attributes.
88 * @example
89 * const osc = new Tone.Oscillator();
90 * console.log(osc.get());
91 */
92 get(): Options;
93 /**
94 * Set multiple properties at once with an object.
95 * @example
96 * const filter = new Tone.Filter().toDestination();
97 * // set values using an object
98 * filter.set({
99 * frequency: "C6",
100 * type: "highpass"
101 * });
102 * const player = new Tone.Player("https://tonejs.github.io/audio/berklee/Analogsynth_octaves_highmid.mp3").connect(filter);
103 * player.autostart = true;
104 */
105 set(props: RecursivePartial<Options>): this;
106}
107
\No newline at end of file