mirror of
https://github.com/Tonejs/Tone.js
synced 2024-12-26 11:33:09 +00:00
using OnePoleFilter in LowpassCombFilter and PluckSynth
means an API change since dampening is no longer a signal rate parameter
This commit is contained in:
parent
52c0b7d56f
commit
ce93214e43
6 changed files with 33 additions and 24 deletions
|
@ -1,4 +1,4 @@
|
|||
### 14.3.0
|
||||
### 14.4.0
|
||||
|
||||
* **Converted to typescript!!! (WIP)**
|
||||
* Input/Outputs are no longer arrays.
|
||||
|
@ -9,6 +9,8 @@
|
|||
* PolySynth does not require a polyphony value.
|
||||
* Voice allocation and disposing is done automatically based on demand.
|
||||
* MetalSynth and MembraneSynth extends Monophonic enabling them to be used in PolySynth
|
||||
* OnePoleFilter is a 6b-per-octave lowpass or highpass filter
|
||||
* Using OnePoleFilter in PluckSynth and LowpassCombFilter
|
||||
|
||||
### 13.8.25
|
||||
|
||||
|
|
|
@ -19,7 +19,7 @@ describe("LowpassCombFilter", () => {
|
|||
});
|
||||
expect(lpcf.delayTime.value).to.be.closeTo(0.2, 0.001);
|
||||
expect(lpcf.resonance.value).to.be.closeTo(0.3, 0.001);
|
||||
expect(lpcf.dampening.value).to.be.closeTo(2400, 0.001);
|
||||
expect(lpcf.dampening).to.be.closeTo(2400, 0.001);
|
||||
lpcf.dispose();
|
||||
});
|
||||
|
||||
|
|
|
@ -3,9 +3,9 @@ import { InputNode, OutputNode, ToneAudioNode, ToneAudioNodeOptions } from "../.
|
|||
import { Frequency, NormalRange, Time } from "../../core/type/Units";
|
||||
import { optionsFromArguments } from "../../core/util/Defaults";
|
||||
import { RecursivePartial } from "../../core/util/Interface";
|
||||
import { Signal } from "../../signal/Signal";
|
||||
import { FeedbackCombFilter } from "./FeedbackCombFilter";
|
||||
import { Filter } from "./Filter";
|
||||
import { OnePoleFilter } from "./OnePoleFilter";
|
||||
|
||||
interface LowpassCombFilterOptions extends ToneAudioNodeOptions {
|
||||
delayTime: Time;
|
||||
|
@ -29,18 +29,13 @@ export class LowpassCombFilter extends ToneAudioNode<LowpassCombFilterOptions> {
|
|||
/**
|
||||
* The lowpass filter
|
||||
*/
|
||||
private _lowpass: Filter;
|
||||
private _lowpass: OnePoleFilter;
|
||||
|
||||
/**
|
||||
* The delayTime of the comb filter.
|
||||
*/
|
||||
readonly delayTime: Param<Time>;
|
||||
|
||||
/**
|
||||
* The dampening control of the feedback
|
||||
*/
|
||||
readonly dampening: Signal<Frequency>;
|
||||
|
||||
/**
|
||||
* The amount of feedback of the delayed signal.
|
||||
*/
|
||||
|
@ -68,11 +63,9 @@ export class LowpassCombFilter extends ToneAudioNode<LowpassCombFilterOptions> {
|
|||
this.delayTime = this._combFilter.delayTime;
|
||||
this.resonance = this._combFilter.resonance;
|
||||
|
||||
this._lowpass = this.input = new Filter({
|
||||
this._lowpass = this.input = new OnePoleFilter({
|
||||
context: this.context,
|
||||
Q: 0,
|
||||
frequency: options.dampening,
|
||||
rolloff: -12,
|
||||
type: "lowpass",
|
||||
});
|
||||
this.dampening = this._lowpass.frequency;
|
||||
|
@ -88,6 +81,16 @@ export class LowpassCombFilter extends ToneAudioNode<LowpassCombFilterOptions> {
|
|||
resonance: 0.5,
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* The dampening control of the feedback
|
||||
*/
|
||||
get dampening(): Frequency {
|
||||
return this._lowpass.frequency;
|
||||
}
|
||||
set dampening(fq) {
|
||||
this._lowpass.frequency = fq;
|
||||
}
|
||||
|
||||
dispose(): this {
|
||||
super.dispose();
|
||||
|
|
|
@ -27,8 +27,8 @@ describe("PluckSynth", () => {
|
|||
|
||||
it("can get and set dampening", () => {
|
||||
const pluck = new PluckSynth();
|
||||
pluck.dampening.value = 2000;
|
||||
expect(pluck.dampening.value).to.be.closeTo(2000, 0.1);
|
||||
pluck.dampening = 2000;
|
||||
expect(pluck.dampening).to.be.closeTo(2000, 0.1);
|
||||
pluck.dispose();
|
||||
});
|
||||
|
||||
|
@ -44,7 +44,7 @@ describe("PluckSynth", () => {
|
|||
dampening: 300,
|
||||
resonance: 0.5,
|
||||
});
|
||||
expect(pluck.dampening.value).to.be.closeTo(300, 0.1);
|
||||
expect(pluck.dampening).to.be.closeTo(300, 0.1);
|
||||
expect(pluck.resonance.value).to.be.closeTo(0.5, 0.001);
|
||||
pluck.dispose();
|
||||
});
|
||||
|
|
|
@ -45,13 +45,6 @@ export class PluckSynth extends Instrument<PluckSynthOptions> {
|
|||
*/
|
||||
readonly resonance: Param<NormalRange>;
|
||||
|
||||
/**
|
||||
* The dampening control. i.e. the lowpass filter frequency of the comb filter
|
||||
* @min 0
|
||||
* @max 7000
|
||||
*/
|
||||
readonly dampening: Signal<Frequency>;
|
||||
|
||||
constructor(options?: RecursivePartial<PluckSynthOptions>)
|
||||
constructor() {
|
||||
|
||||
|
@ -72,7 +65,6 @@ export class PluckSynth extends Instrument<PluckSynthOptions> {
|
|||
});
|
||||
|
||||
this.resonance = this._lfcf.resonance;
|
||||
this.dampening = this._lfcf.dampening;
|
||||
|
||||
this._noise.connect(this._lfcf);
|
||||
this._lfcf.connect(this.output);
|
||||
|
@ -86,6 +78,18 @@ export class PluckSynth extends Instrument<PluckSynthOptions> {
|
|||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* The dampening control. i.e. the lowpass filter frequency of the comb filter
|
||||
* @min 0
|
||||
* @max 7000
|
||||
*/
|
||||
get dampening(): Frequency {
|
||||
return this._lfcf.dampening;
|
||||
}
|
||||
set dampening(fq) {
|
||||
this._lfcf.dampening = fq;
|
||||
}
|
||||
|
||||
triggerAttack(note: Frequency, time?: Time): this {
|
||||
const freq = this.toFrequency(note);
|
||||
time = this.toSeconds(time);
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "tone",
|
||||
"version": "14.3.0",
|
||||
"version": "14.4.0",
|
||||
"description": "A Web Audio framework for making interactive music in the browser.",
|
||||
"main": "build/Tone.js",
|
||||
"module": "build/esm/index.js",
|
||||
|
|
Loading…
Reference in a new issue