1 | import { Param } from "./Param.js";
|
2 | import { ToneWithContext, ToneWithContextOptions } from "./ToneWithContext.js";
|
3 | export type InputNode = ToneAudioNode | AudioNode | Param<any> | AudioParam;
|
4 | export type OutputNode = ToneAudioNode | AudioNode;
|
5 | /**
|
6 | * The possible options for this node
|
7 | */
|
8 | export type ToneAudioNodeOptions = ToneWithContextOptions;
|
9 | /**
|
10 | * ToneAudioNode is the base class for classes which process audio.
|
11 | * @category Core
|
12 | */
|
13 | export declare abstract class ToneAudioNode<Options extends ToneAudioNodeOptions = ToneAudioNodeOptions> extends ToneWithContext<Options> {
|
14 | /**
|
15 | * The name of the class
|
16 | */
|
17 | abstract readonly name: string;
|
18 | /**
|
19 | * The input node or nodes. If the object is a source,
|
20 | * it does not have any input and this.input is undefined.
|
21 | */
|
22 | abstract input: InputNode | undefined;
|
23 | /**
|
24 | * The output nodes. If the object is a sink,
|
25 | * it does not have any output and this.output is undefined.
|
26 | */
|
27 | abstract output: OutputNode | undefined;
|
28 | /**
|
29 | * The number of inputs feeding into the AudioNode.
|
30 | * For source nodes, this will be 0.
|
31 | * @example
|
32 | * const node = new Tone.Gain();
|
33 | * console.log(node.numberOfInputs);
|
34 | */
|
35 | get numberOfInputs(): number;
|
36 | /**
|
37 | * The number of outputs of the AudioNode.
|
38 | * @example
|
39 | * const node = new Tone.Gain();
|
40 | * console.log(node.numberOfOutputs);
|
41 | */
|
42 | get numberOfOutputs(): number;
|
43 | /**
|
44 | * List all of the node that must be set to match the ChannelProperties
|
45 | */
|
46 | protected _internalChannels: OutputNode[];
|
47 | /**
|
48 | * Used to decide which nodes to get/set properties on
|
49 | */
|
50 | private _isAudioNode;
|
51 | /**
|
52 | * Get all of the audio nodes (either internal or input/output) which together
|
53 | * make up how the class node responds to channel input/output
|
54 | */
|
55 | private _getInternalNodes;
|
56 | /**
|
57 | * Set the audio options for this node such as channelInterpretation
|
58 | * channelCount, etc.
|
59 | * @param options
|
60 | */
|
61 | private _setChannelProperties;
|
62 | /**
|
63 | * Get the current audio options for this node such as channelInterpretation
|
64 | * channelCount, etc.
|
65 | */
|
66 | private _getChannelProperties;
|
67 | /**
|
68 | * channelCount is the number of channels used when up-mixing and down-mixing
|
69 | * connections to any inputs to the node. The default value is 2 except for
|
70 | * specific nodes where its value is specially determined.
|
71 | */
|
72 | get channelCount(): number;
|
73 | set channelCount(channelCount: number);
|
74 | /**
|
75 | * channelCountMode determines how channels will be counted when up-mixing and
|
76 | * down-mixing connections to any inputs to the node.
|
77 | * The default value is "max". This attribute has no effect for nodes with no inputs.
|
78 | * * "max" - computedNumberOfChannels is the maximum of the number of channels of all connections to an input. In this mode channelCount is ignored.
|
79 | * * "clamped-max" - computedNumberOfChannels is determined as for "max" and then clamped to a maximum value of the given channelCount.
|
80 | * * "explicit" - computedNumberOfChannels is the exact value as specified by the channelCount.
|
81 | */
|
82 | get channelCountMode(): ChannelCountMode;
|
83 | set channelCountMode(channelCountMode: ChannelCountMode);
|
84 | /**
|
85 | * channelInterpretation determines how individual channels will be treated
|
86 | * when up-mixing and down-mixing connections to any inputs to the node.
|
87 | * The default value is "speakers".
|
88 | */
|
89 | get channelInterpretation(): ChannelInterpretation;
|
90 | set channelInterpretation(channelInterpretation: ChannelInterpretation);
|
91 | /**
|
92 | * connect the output of a ToneAudioNode to an AudioParam, AudioNode, or ToneAudioNode
|
93 | * @param destination The output to connect to
|
94 | * @param outputNum The output to connect from
|
95 | * @param inputNum The input to connect to
|
96 | */
|
97 | connect(destination: InputNode, outputNum?: number, inputNum?: number): this;
|
98 | /**
|
99 | * Connect the output to the context's destination node.
|
100 | * @example
|
101 | * const osc = new Tone.Oscillator("C2").start();
|
102 | * osc.toDestination();
|
103 | */
|
104 | toDestination(): this;
|
105 | /**
|
106 | * Connect the output to the context's destination node.
|
107 | * @see {@link toDestination}
|
108 | * @deprecated
|
109 | */
|
110 | toMaster(): this;
|
111 | /**
|
112 | * disconnect the output
|
113 | */
|
114 | disconnect(destination?: InputNode, outputNum?: number, inputNum?: number): this;
|
115 | /**
|
116 | * Connect the output of this node to the rest of the nodes in series.
|
117 | * @example
|
118 | * const player = new Tone.Player("https://tonejs.github.io/audio/drum-samples/handdrum-loop.mp3");
|
119 | * player.autostart = true;
|
120 | * const filter = new Tone.AutoFilter(4).start();
|
121 | * const distortion = new Tone.Distortion(0.5);
|
122 | * // connect the player to the filter, distortion and then to the master output
|
123 | * player.chain(filter, distortion, Tone.Destination);
|
124 | */
|
125 | chain(...nodes: InputNode[]): this;
|
126 | /**
|
127 | * connect the output of this node to the rest of the nodes in parallel.
|
128 | * @example
|
129 | * const player = new Tone.Player("https://tonejs.github.io/audio/drum-samples/conga-rhythm.mp3");
|
130 | * player.autostart = true;
|
131 | * const pitchShift = new Tone.PitchShift(4).toDestination();
|
132 | * const filter = new Tone.Filter("G5").toDestination();
|
133 | * // connect a node to the pitch shift and filter in parallel
|
134 | * player.fan(pitchShift, filter);
|
135 | */
|
136 | fan(...nodes: InputNode[]): this;
|
137 | /**
|
138 | * Dispose and disconnect
|
139 | */
|
140 | dispose(): this;
|
141 | }
|
142 | /**
|
143 | * connect together all of the arguments in series
|
144 | * @param nodes
|
145 | */
|
146 | export declare function connectSeries(...nodes: InputNode[]): void;
|
147 | /**
|
148 | * Connect two nodes together so that signal flows from the
|
149 | * first node to the second. Optionally specify the input and output channels.
|
150 | * @param srcNode The source node
|
151 | * @param dstNode The destination node
|
152 | * @param outputNumber The output channel of the srcNode
|
153 | * @param inputNumber The input channel of the dstNode
|
154 | */
|
155 | export declare function connect(srcNode: OutputNode, dstNode: InputNode, outputNumber?: number, inputNumber?: number): void;
|
156 | /**
|
157 | * Disconnect a node from all nodes or optionally include a destination node and input/output channels.
|
158 | * @param srcNode The source node
|
159 | * @param dstNode The destination node
|
160 | * @param outputNumber The output channel of the srcNode
|
161 | * @param inputNumber The input channel of the dstNode
|
162 | */
|
163 | export declare function disconnect(srcNode: OutputNode, dstNode?: InputNode, outputNumber?: number, inputNumber?: number): void;
|
164 | /**
|
165 | * Connect the output of one or more source nodes to a single destination node
|
166 | * @param nodes One or more source nodes followed by one destination node
|
167 | * @example
|
168 | * const player = new Tone.Player("https://tonejs.github.io/audio/drum-samples/conga-rhythm.mp3");
|
169 | * const player1 = new Tone.Player("https://tonejs.github.io/audio/drum-samples/conga-rhythm.mp3");
|
170 | * const filter = new Tone.Filter("G5").toDestination();
|
171 | * // connect nodes to a common destination
|
172 | * Tone.fanIn(player, player1, filter);
|
173 | */
|
174 | export declare function fanIn(...nodes: OutputNode[]): void;
|