UNPKG

3.84 kBPlain TextView Raw
1export { getContext, setContext } from "./core/Global.js";
2import { Context } from "./core/context/Context.js";
3export * from "./classes.js";
4export * from "./version.js";
5import { getContext } from "./core/Global.js";
6import { ToneAudioBuffer } from "./core/context/ToneAudioBuffer.js";
7export { start } from "./core/Global.js";
8import { Seconds } from "./core/type/Units.js";
9export { supported } from "./core/context/AudioContext.js";
10import type { TransportClass } from "./core/clock/Transport.js";
11import type { DestinationClass } from "./core/context/Destination.js";
12import type { DrawClass } from "./core/util/Draw.js";
13import type { ListenerClass } from "./core/context/Listener.js";
14
15/**
16 * The current audio context time of the global {@link BaseContext}.
17 * @see {@link Context.now}
18 * @category Core
19 */
20export function now(): Seconds {
21 return getContext().now();
22}
23
24/**
25 * The current audio context time of the global {@link Context} without the {@link Context.lookAhead}
26 * @see {@link Context.immediate}
27 * @category Core
28 */
29export function immediate(): Seconds {
30 return getContext().immediate();
31}
32
33/**
34 * The Transport object belonging to the global Tone.js Context.
35 * @see {@link TransportClass}
36 * @category Core
37 * @deprecated Use {@link getTransport} instead
38 */
39export const Transport = getContext().transport;
40
41/**
42 * The Transport object belonging to the global Tone.js Context.
43 * @see {@link TransportClass}
44 * @category Core
45 */
46export function getTransport(): TransportClass {
47 return getContext().transport;
48}
49
50/**
51 * The Destination (output) belonging to the global Tone.js Context.
52 * @see {@link DestinationClass}
53 * @category Core
54 * @deprecated Use {@link getDestination} instead
55 */
56export const Destination = getContext().destination;
57
58/**
59 * @deprecated Use {@link getDestination} instead
60 */
61export const Master = getContext().destination;
62
63/**
64 * The Destination (output) belonging to the global Tone.js Context.
65 * @see {@link DestinationClass}
66 * @category Core
67 */
68export function getDestination(): DestinationClass {
69 return getContext().destination;
70}
71
72/**
73 * The {@link ListenerClass} belonging to the global Tone.js Context.
74 * @category Core
75 * @deprecated Use {@link getListener} instead
76 */
77export const Listener = getContext().listener;
78
79/**
80 * The {@link ListenerClass} belonging to the global Tone.js Context.
81 * @category Core
82 */
83export function getListener(): ListenerClass {
84 return getContext().listener;
85}
86
87/**
88 * Draw is used to synchronize the draw frame with the Transport's callbacks.
89 * @see {@link DrawClass}
90 * @category Core
91 * @deprecated Use {@link getDraw} instead
92 */
93export const Draw = getContext().draw;
94
95/**
96 * Get the singleton attached to the global context.
97 * Draw is used to synchronize the draw frame with the Transport's callbacks.
98 * @see {@link DrawClass}
99 * @category Core
100 */
101export function getDraw(): DrawClass {
102 return getContext().draw;
103}
104
105/**
106 * A reference to the global context
107 * @see {@link Context}
108 * @deprecated Use {@link getContext} instead
109 */
110export const context = getContext();
111
112/**
113 * Promise which resolves when all of the loading promises are resolved.
114 * Alias for static {@link ToneAudioBuffer.loaded} method.
115 * @category Core
116 */
117export function loaded() {
118 return ToneAudioBuffer.loaded();
119}
120
121// this fills in name changes from 13.x to 14.x
122import { ToneAudioBuffers } from "./core/context/ToneAudioBuffers.js";
123import { ToneBufferSource } from "./source/buffer/ToneBufferSource.js";
124/** @deprecated Use {@link ToneAudioBuffer} */
125export const Buffer: typeof ToneAudioBuffer = ToneAudioBuffer;
126/** @deprecated Use {@link ToneAudioBuffers} */
127export const Buffers: typeof ToneAudioBuffers = ToneAudioBuffers;
128/** @deprecated Use {@link ToneBufferSource} */
129export const BufferSource: typeof ToneBufferSource = ToneBufferSource;