MCPcopy
hub / github.com/Tonejs/Tone.js / constructor

Method constructor

Tone/source/buffer/ToneBufferSource.ts:63–88  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

61 constructor(url?: ToneAudioBuffer | AudioBuffer | string, onload?: () => void);
62 constructor(options?: Partial<ToneBufferSourceOptions>);
63 constructor() {
64
65 super(optionsFromArguments(ToneBufferSource.getDefaults(), arguments, ["url", "onload"]));
66 const options = optionsFromArguments(ToneBufferSource.getDefaults(), arguments, ["url", "onload"]);
67
68 connect(this._source, this._gainNode);
69 this._source.onended = () => this._stopSource();
70
71 /**
72 * The playbackRate of the buffer
73 */
74 this.playbackRate = new Param({
75 context: this.context,
76 param: this._source.playbackRate,
77 units: "positive",
78 value: options.playbackRate,
79 });
80
81 // set some values initially
82 this.loop = options.loop;
83 this.loopStart = options.loopStart;
84 this.loopEnd = options.loopEnd;
85 this._buffer = new ToneAudioBuffer(options.url, options.onload, options.onerror);
86
87 this._internalChannels.push(this._source);
88 }
89
90 static getDefaults(): ToneBufferSourceOptions {
91 return Object.assign(OneShotSource.getDefaults(), {

Callers

nothing calls this directly

Calls 4

_stopSourceMethod · 0.95
optionsFromArgumentsFunction · 0.90
connectFunction · 0.90
getDefaultsMethod · 0.45

Tested by

no test coverage detected