1 | import { Source, SourceOptions } from "../Source.js";
|
2 | import { ToneAudioBuffer } from "../../core/context/ToneAudioBuffer.js";
|
3 | import { Cents, Positive, Seconds, Time } from "../../core/type/Units.js";
|
4 | interface GrainPlayerOptions extends SourceOptions {
|
5 | onload: () => void;
|
6 | onerror: (error: Error) => void;
|
7 | reverse: boolean;
|
8 | url?: ToneAudioBuffer | string | AudioBuffer;
|
9 | overlap: Seconds;
|
10 | grainSize: Seconds;
|
11 | playbackRate: Positive;
|
12 | detune: Cents;
|
13 | loop: boolean;
|
14 | loopStart: Time;
|
15 | loopEnd: Time;
|
16 | }
|
17 |
|
18 |
|
19 |
|
20 |
|
21 |
|
22 |
|
23 |
|
24 | export declare class GrainPlayer extends Source<GrainPlayerOptions> {
|
25 | readonly name: string;
|
26 | |
27 |
|
28 |
|
29 | buffer: ToneAudioBuffer;
|
30 | |
31 |
|
32 |
|
33 | private _clock;
|
34 | |
35 |
|
36 |
|
37 | private _loopStart;
|
38 | |
39 |
|
40 |
|
41 | private _loopEnd;
|
42 | |
43 |
|
44 |
|
45 | private _activeSources;
|
46 | |
47 |
|
48 |
|
49 | private _playbackRate;
|
50 | |
51 |
|
52 |
|
53 | private _grainSize;
|
54 | |
55 |
|
56 |
|
57 | private _overlap;
|
58 | |
59 |
|
60 |
|
61 | detune: Cents;
|
62 | |
63 |
|
64 |
|
65 | loop: boolean;
|
66 | |
67 |
|
68 |
|
69 |
|
70 | constructor(url?: string | AudioBuffer | ToneAudioBuffer, onload?: () => void);
|
71 | constructor(options?: Partial<GrainPlayerOptions>);
|
72 | static getDefaults(): GrainPlayerOptions;
|
73 | /**
|
74 | * Internal start method
|
75 | */
|
76 | protected _start(time?: Time, offset?: Time, duration?: Time): void;
|
77 | /**
|
78 | * Stop and then restart the player from the beginning (or offset)
|
79 | * @param time When the player should start.
|
80 | * @param offset The offset from the beginning of the sample to start at.
|
81 | * @param duration How long the sample should play. If no duration is given,
|
82 | * it will default to the full length of the sample (minus any offset)
|
83 | */
|
84 | restart(time?: Seconds, offset?: Time, duration?: Time): this;
|
85 | protected _restart(time?: Seconds, offset?: Time, duration?: Time): void;
|
86 | /**
|
87 | * Internal stop method
|
88 | */
|
89 | protected _stop(time?: Time): void;
|
90 | /**
|
91 | * Invoked when the clock is stopped
|
92 | */
|
93 | private _onstop;
|
94 | /**
|
95 | * Invoked on each clock tick. scheduled a new grain at this time.
|
96 | */
|
97 | private _tick;
|
98 | /**
|
99 | * The playback rate of the sample
|
100 | */
|
101 | get playbackRate(): Positive;
|
102 | set playbackRate(rate: Positive);
|
103 | /**
|
104 | * The loop start time.
|
105 | */
|
106 | get loopStart(): Time;
|
107 | set loopStart(time: Time);
|
108 | /**
|
109 | * The loop end time.
|
110 | */
|
111 | get loopEnd(): Time;
|
112 | set loopEnd(time: Time);
|
113 | /**
|
114 | * The direction the buffer should play in
|
115 | */
|
116 | get reverse(): boolean;
|
117 | set reverse(rev: boolean);
|
118 | /**
|
119 | * The size of each chunk of audio that the
|
120 | * buffer is chopped into and played back at.
|
121 | */
|
122 | get grainSize(): Time;
|
123 | set grainSize(size: Time);
|
124 | /**
|
125 | * The duration of the cross-fade between successive grains.
|
126 | */
|
127 | get overlap(): Time;
|
128 | set overlap(time: Time);
|
129 | /**
|
130 | * If all the buffer is loaded
|
131 | */
|
132 | get loaded(): boolean;
|
133 | dispose(): this;
|
134 | }
|
135 | export {};
|