diff --git a/Tone/instrument/Sampler.test.ts b/Tone/instrument/Sampler.test.ts index 7c170bf6..2e4d39a0 100644 --- a/Tone/instrument/Sampler.test.ts +++ b/Tone/instrument/Sampler.test.ts @@ -6,7 +6,6 @@ import { InstrumentTest } from "test/helper/InstrumentTests"; import { atTime, Offline } from "test/helper/Offline"; import { ToneAudioBuffer } from "Tone/core/context/ToneAudioBuffer"; import { Sampler } from "Tone/instrument/Sampler"; -import { ToneAudioBuffers } from "Tone/core/context/ToneAudioBuffers"; describe("Sampler", () => { @@ -145,33 +144,6 @@ describe("Sampler", () => { }, 0.3); }); - it("can be constructed with a ToneAudioBuffers in an object", () => { - const sampler = new Sampler({ - urls: new ToneAudioBuffers({ - A4: A4_buffer - }) - }); - sampler.dispose(); - }); - - it("can be constructed with unloaded a ToneAudioBuffers", (done) => { - const sampler = new Sampler({ - urls: new ToneAudioBuffers({ - A4: "./audio/sine.wav", - }, () => { - sampler.dispose(); - done(); - }) - }); - }); - - it("can be constructed with ToneAudioBuffers", () => { - const sampler = new Sampler(new ToneAudioBuffers({ - A4: A4_buffer, - })); - sampler.dispose(); - }); - }); context("Makes sound", () => { diff --git a/Tone/instrument/Sampler.ts b/Tone/instrument/Sampler.ts index cb69d0be..8e0e0bc6 100644 --- a/Tone/instrument/Sampler.ts +++ b/Tone/instrument/Sampler.ts @@ -23,7 +23,7 @@ export interface SamplerOptions extends InstrumentOptions { onerror: (error: Error) => void; baseUrl: string; curve: ToneBufferSourceCurve; - urls: SamplesMap | ToneAudioBuffers; + urls: SamplesMap; } /** @@ -102,31 +102,27 @@ export class Sampler extends Instrument { super(optionsFromArguments(Sampler.getDefaults(), arguments, ["urls", "onload", "baseUrl"], "urls")); const options = optionsFromArguments(Sampler.getDefaults(), arguments, ["urls", "onload", "baseUrl"], "urls"); - if (options.urls instanceof ToneAudioBuffers) { - this._buffers = options.urls; - } else { - const urlMap = {}; - Object.keys(options.urls).forEach((note) => { - const noteNumber = parseInt(note, 10); - assert(isNote(note) - || (isNumber(noteNumber) && isFinite(noteNumber)), `url key is neither a note or midi pitch: ${note}`); - if (isNote(note)) { - // convert the note name to MIDI - const mid = new FrequencyClass(this.context, note).toMidi(); - urlMap[mid] = options.urls[note]; - } else if (isNumber(noteNumber) && isFinite(noteNumber)) { - // otherwise if it's numbers assume it's midi - urlMap[noteNumber] = options.urls[noteNumber]; - } - }); + const urlMap = {}; + Object.keys(options.urls).forEach((note) => { + const noteNumber = parseInt(note, 10); + assert(isNote(note) + || (isNumber(noteNumber) && isFinite(noteNumber)), `url key is neither a note or midi pitch: ${note}`); + if (isNote(note)) { + // convert the note name to MIDI + const mid = new FrequencyClass(this.context, note).toMidi(); + urlMap[mid] = options.urls[note]; + } else if (isNumber(noteNumber) && isFinite(noteNumber)) { + // otherwise if it's numbers assume it's midi + urlMap[noteNumber] = options.urls[noteNumber]; + } + }); - this._buffers = new ToneAudioBuffers({ - urls: urlMap, - onload: options.onload, - baseUrl: options.baseUrl, - onerror: options.onerror, - }); - } + this._buffers = new ToneAudioBuffers({ + urls: urlMap, + onload: options.onload, + baseUrl: options.baseUrl, + onerror: options.onerror, + }); this.attack = options.attack; this.release = options.release; this.curve = options.curve;