mirror of
https://github.com/Tonejs/Tone.js
synced 2024-12-26 19:43:12 +00:00
aaf880c925
* WIP moving tests to web-test-runner * updating thresholds * Adding file extensions * Testing integrations * linting * fixing dep * moving back to root dir * prettier all of the files * updating eslint rules to use with prettier * remove import package * moving tsignore around * removing unneeded ignores * all tests run on puppeteer, no need for testing guards * linting * import type syntax * cleaning up * Update package.json
72 lines
2 KiB
TypeScript
72 lines
2 KiB
TypeScript
import { PitchShift } from "./PitchShift.js";
|
|
import { BasicTests } from "../../test/helper/Basic.js";
|
|
import { EffectTests } from "../../test/helper/EffectTests.js";
|
|
import { expect } from "chai";
|
|
import { Oscillator } from "../source/oscillator/Oscillator.js";
|
|
import { CompareToFile } from "../../test/helper/CompareToFile.js";
|
|
|
|
describe("PitchShift", () => {
|
|
BasicTests(PitchShift);
|
|
EffectTests(PitchShift);
|
|
|
|
it("matches a file", () => {
|
|
return CompareToFile(
|
|
() => {
|
|
const pitchShift = new PitchShift(4).toDestination();
|
|
const osc = new Oscillator()
|
|
.toDestination()
|
|
.connect(pitchShift);
|
|
osc.start(0);
|
|
},
|
|
"pitchShift.wav",
|
|
0.3
|
|
);
|
|
});
|
|
|
|
context("API", () => {
|
|
it("can pass in options in the constructor", () => {
|
|
const pitchShift = new PitchShift({
|
|
windowSize: 0.2,
|
|
pitch: 2,
|
|
});
|
|
expect(pitchShift.windowSize).to.be.closeTo(0.2, 0.01);
|
|
expect(pitchShift.pitch).to.be.closeTo(2, 0.01);
|
|
pitchShift.dispose();
|
|
});
|
|
|
|
it("can set positive and negative pitches", () => {
|
|
const pitchShift = new PitchShift();
|
|
pitchShift.pitch = 2;
|
|
expect(pitchShift.pitch).to.be.equal(2);
|
|
pitchShift.pitch = -2;
|
|
expect(pitchShift.pitch).to.be.equal(-2);
|
|
pitchShift.pitch = -4.5;
|
|
expect(pitchShift.pitch).to.be.equal(-4.5);
|
|
pitchShift.dispose();
|
|
});
|
|
|
|
it("can get/set the options", () => {
|
|
const pitchShift = new PitchShift();
|
|
pitchShift.set({
|
|
windowSize: 0.4,
|
|
});
|
|
expect(pitchShift.get().windowSize).to.be.closeTo(0.4, 0.01);
|
|
pitchShift.dispose();
|
|
});
|
|
|
|
it("can set set the feedback and delay times", () => {
|
|
const pitchShift = new PitchShift({
|
|
delayTime: "4n",
|
|
feedback: 0.3,
|
|
});
|
|
expect(pitchShift.delayTime.value).to.be.closeTo(
|
|
pitchShift.toSeconds("4n"),
|
|
0.01
|
|
);
|
|
expect(pitchShift.feedback.value).to.be.closeTo(0.3, 0.01);
|
|
pitchShift.delayTime.value = 0.2;
|
|
expect(pitchShift.delayTime.value).to.be.closeTo(0.2, 0.01);
|
|
pitchShift.dispose();
|
|
});
|
|
});
|
|
});
|