Skip to content

Commit

Permalink
Add processNY
Browse files Browse the repository at this point in the history
  • Loading branch information
ryukau committed May 19, 2024
1 parent 19e7f93 commit 6446c43
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
2 changes: 1 addition & 1 deletion CollidingComb/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ function render() {
const scales = {
boolean: new parameter.IntScale(0, 1),

renderDuration: new parameter.DecibelScale(-40, 40, false),
renderDuration: new parameter.DecibelScale(-60, 40, false),
fade: new parameter.DecibelScale(-60, 40, true),
decayTo: new parameter.DecibelScale(util.ampToDB(1 / 2 ** 24), 0, false),
stereoMerge: new parameter.LinearScale(0, 1),
Expand Down
18 changes: 18 additions & 0 deletions common/dsp/drumcompressor.js
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,7 @@ class BandSplitter {
this.hp[i].reset();
this.ap[i].reset();
}
this.output.fill(0);
}

split(input) {
Expand All @@ -283,6 +284,8 @@ class BandSplitter {
}
return input.at(-1) + sig;
}

correctDry(input) { return this.merge(this.split(input)); }
}

export class DrumCompressor {
Expand All @@ -307,6 +310,7 @@ export class DrumCompressor {
this.outputGain = [1, 1, 1];

this.splitter = new BandSplitter([200 / sampleRate, 3200 / sampleRate], [2, 1]);
this.corrector = new BandSplitter([200 / sampleRate, 3200 / sampleRate], [2, 1]);
}

process(input) {
Expand All @@ -319,4 +323,18 @@ export class DrumCompressor {
}
return this.splitter.merge(band);
}

// NY compression. `mix` is in [0, 1].
processNY(input, mix) {
const band = this.splitter.split(input);
for (let i = 0; i < this.compressor.length; ++i) {
band[i] *= this.inputGain[i];
band[i] = this.compressor[i].process(band[i]);
band[i] = this.saturator[i](band[i]);
band[i] *= this.outputGain[i];
}
const comp = this.splitter.merge(band);
const dry = this.corrector.correctDry(input);
return comp + mix * (dry - comp);
}
}

0 comments on commit 6446c43

Please sign in to comment.