mirror of
https://github.com/Tonejs/Tone.js
synced 2024-12-27 12:03:12 +00:00
Revert "feat: Sampler can be loaded with ToneAudioBuffers"
This reverts commit 368a7f43cb
.
This commit is contained in:
parent
ba8e82b1ca
commit
510a08df4e
2 changed files with 21 additions and 53 deletions
|
@ -6,7 +6,6 @@ import { InstrumentTest } from "test/helper/InstrumentTests";
|
||||||
import { atTime, Offline } from "test/helper/Offline";
|
import { atTime, Offline } from "test/helper/Offline";
|
||||||
import { ToneAudioBuffer } from "Tone/core/context/ToneAudioBuffer";
|
import { ToneAudioBuffer } from "Tone/core/context/ToneAudioBuffer";
|
||||||
import { Sampler } from "Tone/instrument/Sampler";
|
import { Sampler } from "Tone/instrument/Sampler";
|
||||||
import { ToneAudioBuffers } from "Tone/core/context/ToneAudioBuffers";
|
|
||||||
|
|
||||||
describe("Sampler", () => {
|
describe("Sampler", () => {
|
||||||
|
|
||||||
|
@ -145,33 +144,6 @@ describe("Sampler", () => {
|
||||||
}, 0.3);
|
}, 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", () => {
|
context("Makes sound", () => {
|
||||||
|
|
|
@ -23,7 +23,7 @@ export interface SamplerOptions extends InstrumentOptions {
|
||||||
onerror: (error: Error) => void;
|
onerror: (error: Error) => void;
|
||||||
baseUrl: string;
|
baseUrl: string;
|
||||||
curve: ToneBufferSourceCurve;
|
curve: ToneBufferSourceCurve;
|
||||||
urls: SamplesMap | ToneAudioBuffers;
|
urls: SamplesMap;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -102,9 +102,6 @@ export class Sampler extends Instrument<SamplerOptions> {
|
||||||
super(optionsFromArguments(Sampler.getDefaults(), arguments, ["urls", "onload", "baseUrl"], "urls"));
|
super(optionsFromArguments(Sampler.getDefaults(), arguments, ["urls", "onload", "baseUrl"], "urls"));
|
||||||
const options = 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 = {};
|
const urlMap = {};
|
||||||
Object.keys(options.urls).forEach((note) => {
|
Object.keys(options.urls).forEach((note) => {
|
||||||
const noteNumber = parseInt(note, 10);
|
const noteNumber = parseInt(note, 10);
|
||||||
|
@ -126,7 +123,6 @@ export class Sampler extends Instrument<SamplerOptions> {
|
||||||
baseUrl: options.baseUrl,
|
baseUrl: options.baseUrl,
|
||||||
onerror: options.onerror,
|
onerror: options.onerror,
|
||||||
});
|
});
|
||||||
}
|
|
||||||
this.attack = options.attack;
|
this.attack = options.attack;
|
||||||
this.release = options.release;
|
this.release = options.release;
|
||||||
this.curve = options.curve;
|
this.curve = options.curve;
|
||||||
|
|
Loading…
Reference in a new issue