more convenient way to set resonance

This commit is contained in:
2023-10-24 17:35:44 +02:00
parent d62e1f6065
commit eb7382126a
2 changed files with 28 additions and 5 deletions

View File

@ -134,11 +134,20 @@ export class SoundEvent extends AudibleEvent {
public lps = this.lpsustain; public lps = this.lpsustain;
public lprelease = (value: number) => this.updateValue("lprelease", value); public lprelease = (value: number) => this.updateValue("lprelease", value);
public lpr = this.lprelease; public lpr = this.lprelease;
public cutoff = (value: number) => this.updateValue("cutoff", value); public cutoff = (value: number, resonance?: number) => {
this.updateValue("cutoff", value);
if (resonance) {
this.resonance(resonance)
}
return this;
}
public lpf = this.cutoff; public lpf = this.cutoff;
public resonance = (value: number) => { public resonance = (value: number) => {
if (value >= 0 || value <= 1) { if (value >= 0 && value <= 1) {
this.updateValue("resonance", 50 * Math.min(Math.max(value, 0), 1)); this.updateValue(
"resonance",
50 * value
);
} }
} }
public lpq = this.resonance; public lpq = this.resonance;
@ -182,7 +191,13 @@ export class SoundEvent extends AudibleEvent {
public hpr = this.hprelease; public hpr = this.hprelease;
public hcutoff = (value: number) => this.updateValue("hcutoff", value); public hcutoff = (value: number) => this.updateValue("hcutoff", value);
public hpf = this.hcutoff; public hpf = this.hcutoff;
public hresonance = (value: number) => this.updateValue("hresonance", value); public hresonance = (value: number, resonance?: number) => {
this.updateValue("hresonance", value);
if (resonance) {
this.resonance(resonance)
}
return this;
}
public hpq = this.hresonance; public hpq = this.hresonance;
public hpadsr = ( public hpadsr = (
depth: number, depth: number,
@ -221,7 +236,13 @@ export class SoundEvent extends AudibleEvent {
public bps = this.bpsustain; public bps = this.bpsustain;
public bprelease = (value: number) => this.updateValue("bprelease", value); public bprelease = (value: number) => this.updateValue("bprelease", value);
public bpr = this.bprelease; public bpr = this.bprelease;
public bandf = (value: number) => this.updateValue("bandf", value); public bandf = (value: number, resonance?: number) => {
this.updateValue("bandf", value);
if (resonance) {
this.resonance(resonance)
}
return this;
}
public bpf = this.bandf; public bpf = this.bandf;
public bandq = (value: number) => this.updateValue("bandq", value); public bandq = (value: number) => this.updateValue("bandq", value);
public bpq = this.bandq; public bpq = this.bandq;

View File

@ -230,6 +230,8 @@ ${makeExample(
true true
)} )}
Alternatively, <ic>lpf</ic>, <ic>hpf</ic> and <ic>bpf</ic> can take a second argument, the **resonance**.
## Filter order (type) ## Filter order (type)
You can also use the <ic>ftype</ic> method to change the filter type (order). There are two types by default, <ic>12db</ic> for a gentle slope or <ic>24db</ic> for a really steep filtering slope. The <ic>24db</ic> type is particularly useful for substractive synthesis if you are trying to emulate some of the Moog or Prophet sounds: You can also use the <ic>ftype</ic> method to change the filter type (order). There are two types by default, <ic>12db</ic> for a gentle slope or <ic>24db</ic> for a really steep filtering slope. The <ic>24db</ic> type is particularly useful for substractive synthesis if you are trying to emulate some of the Moog or Prophet sounds: