2019-09-01 11:17:32 +00:00
|
|
|
import { expect } from "chai";
|
2024-05-03 18:31:14 +00:00
|
|
|
import { BasicTests } from "../../test/helper/Basic.js";
|
|
|
|
import { CompareToFile } from "../../test/helper/CompareToFile.js";
|
|
|
|
import { InstrumentTest } from "../../test/helper/InstrumentTests.js";
|
|
|
|
import { PluckSynth } from "./PluckSynth.js";
|
2019-09-01 11:17:32 +00:00
|
|
|
|
|
|
|
describe("PluckSynth", () => {
|
|
|
|
BasicTests(PluckSynth);
|
|
|
|
InstrumentTest(PluckSynth, "C3");
|
|
|
|
|
2019-09-17 17:37:43 +00:00
|
|
|
it("matches a file", () => {
|
2024-05-03 18:31:14 +00:00
|
|
|
return CompareToFile(
|
|
|
|
() => {
|
|
|
|
const synth = new PluckSynth().toDestination();
|
|
|
|
synth.triggerAttack("C4");
|
|
|
|
},
|
|
|
|
"pluckSynth.wav",
|
|
|
|
0.02
|
|
|
|
);
|
2019-09-29 21:25:31 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
it("matches a file with release", () => {
|
2024-05-03 18:31:14 +00:00
|
|
|
return CompareToFile(
|
|
|
|
() => {
|
|
|
|
const synth = new PluckSynth({
|
|
|
|
resonance: 0.97,
|
|
|
|
release: 0.2,
|
|
|
|
}).toDestination();
|
|
|
|
synth.triggerAttackRelease("C4", 0.6);
|
|
|
|
},
|
|
|
|
"pluckSynth2.wav",
|
|
|
|
0.06
|
|
|
|
);
|
2019-09-17 17:37:43 +00:00
|
|
|
});
|
2019-09-01 11:17:32 +00:00
|
|
|
|
2024-05-03 18:31:14 +00:00
|
|
|
context("API", () => {
|
2019-09-01 11:17:32 +00:00
|
|
|
it("can get and set resonance", () => {
|
|
|
|
const pluck = new PluckSynth();
|
2019-09-29 21:25:31 +00:00
|
|
|
pluck.resonance = 0.4;
|
|
|
|
expect(pluck.resonance).to.be.closeTo(0.4, 0.001);
|
2019-09-01 11:17:32 +00:00
|
|
|
pluck.dispose();
|
|
|
|
});
|
|
|
|
|
|
|
|
it("can get and set dampening", () => {
|
|
|
|
const pluck = new PluckSynth();
|
2019-09-25 02:41:58 +00:00
|
|
|
pluck.dampening = 2000;
|
|
|
|
expect(pluck.dampening).to.be.closeTo(2000, 0.1);
|
2019-09-01 11:17:32 +00:00
|
|
|
pluck.dispose();
|
|
|
|
});
|
|
|
|
|
|
|
|
it("can get and set the attackNoise", () => {
|
|
|
|
const pluck = new PluckSynth();
|
|
|
|
pluck.attackNoise = 0.2;
|
|
|
|
expect(pluck.attackNoise).to.be.closeTo(0.2, 0.1);
|
|
|
|
pluck.dispose();
|
|
|
|
});
|
|
|
|
|
|
|
|
it("can be constructed with an options object", () => {
|
|
|
|
const pluck = new PluckSynth({
|
|
|
|
dampening: 300,
|
|
|
|
resonance: 0.5,
|
|
|
|
});
|
2019-09-25 02:41:58 +00:00
|
|
|
expect(pluck.dampening).to.be.closeTo(300, 0.1);
|
2019-09-29 21:25:31 +00:00
|
|
|
expect(pluck.resonance).to.be.closeTo(0.5, 0.001);
|
2019-09-01 11:17:32 +00:00
|
|
|
pluck.dispose();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|