From c4deff6a3ec50e748e5db5e4310f1a064d827987 Mon Sep 17 00:00:00 2001 From: Raphael Forment Date: Sun, 17 Sep 2023 13:53:31 +0200 Subject: [PATCH] Declaration of new controls and refactoring --- package.json | 2 +- src/classes/SoundEvent.ts | 123 +++++++++++++++++++++++++++++--------- yarn.lock | 8 +-- 3 files changed, 99 insertions(+), 34 deletions(-) diff --git a/package.json b/package.json index 5c8230d..7aea213 100644 --- a/package.json +++ b/package.json @@ -33,7 +33,7 @@ "postcss": "^8.4.27", "showdown": "^2.1.0", "showdown-highlight": "^3.1.0", - "superdough": "^0.9.6", + "superdough": "^0.9.8", "tailwind-highlightjs": "^2.0.1", "tailwindcss": "^3.3.3", "tone": "^14.8.49", diff --git a/src/classes/SoundEvent.ts b/src/classes/SoundEvent.ts index 748df3e..6b47c92 100644 --- a/src/classes/SoundEvent.ts +++ b/src/classes/SoundEvent.ts @@ -54,8 +54,6 @@ export class SoundEvent extends AudibleEvent { public zdelay = (value: number) => this.updateValue("zdelay", value); public sustainVolume = (value: number) => this.updateValue("sustainVolume", value); - public decay = (value: number) => this.updateValue("decay", value); - public dec = this.decay; public tremolo = (value: number) => this.updateValue("tremolo", value); public duration = (value: number) => this.updateValue("duration", value); public zzfx = (value: number[]) => this.updateValue("zzfx", value); @@ -64,6 +62,7 @@ export class SoundEvent extends AudibleEvent { // Basic Audio Engine Parameters // ================================================================================ + // FM Synthesis public fmi = (value: number) => this.updateValue("fmi", value); public fmh = (value: number) => this.updateValue("fmh", value); public fmenv = (value: "lin" | "exp") => this.updateValue("fmenv", value); @@ -80,16 +79,76 @@ export class SoundEvent extends AudibleEvent { public fmwave = (value: "sine" | "triangle" | "sawtooth" | "square") => this.updateValue("fmwave", value); public fmw = this.fmwave; + + // Filter type + public ftype = (value: "12db" | "24db") => this.updateValue("ftype", value); + public fanchor = (value: number) => this.updateValue("fanchor", value); + + // Amplitude Envelope public attack = (value: number) => this.updateValue("attack", value); public atk = this.attack; - public release = (value: number) => this.updateValue("release", value); - public rel = this.release; + public decay = (value: number) => this.updateValue("decay", value); + public dec = this.decay; public sustain = (value: number) => this.updateValue("sustain", value); public sus = this.sustain; - public unit = (value: number) => this.updateValue("unit", value); - public u = this.unit; + public release = (value: number) => this.updateValue("release", value); + public rel = this.release; + + // Lowpass filter + public lpenv = (value: number) => this.updateValue("lpenv", value); + public lpe = (value: number) => this.updateValue("lpe", value); + public lpattack = (value: number) => this.updateValue("lpattack", value); + public lpa = this.lpattack; + public lbdecay = (value: number) => this.updateValue("lbdecay", value); + public lbd = this.lbdecay; + public lpsustain = (value: number) => this.updateValue("lpsustain", value); + public lpsus = this.lpsustain; + public lprelease = (value: number) => this.updateValue("lprelease", value); + public lpr = this.lprelease; + public cutoff = (value: number) => this.updateValue("cutoff", value); + public lpf = this.cutoff; + public resonance = (value: number) => + this.updateValue("resonance", Math.min(Math.max(value, 0), 50)); + public lpq = this.resonance; + + // Highpass filter + + public hpenv = (value: number) => this.updateValue("hpenv", value); + public hpe = (value: number) => this.updateValue("hpe", value); + public hpattack = (value: number) => this.updateValue("hpattack", value); + public hpa = this.hpattack; + public hpdecay = (value: number) => this.updateValue("hpdecay", value); + public hpd = this.hpdecay; + public hpsustain = (value: number) => this.updateValue("hpsustain", value); + public hpsus = this.hpsustain; + public hprelease = (value: number) => this.updateValue("hprelease", value); + public hpr = this.hprelease; + public hcutoff = (value: number) => this.updateValue("hcutoff", value); + public hpf = this.hcutoff; + public hresonance = (value: number) => this.updateValue("hresonance", value); + public hpq = this.hresonance; + + // Bandpass filter + + public bpenv = (value: number) => this.updateValue("bpenv", value); + public bpe = (value: number) => this.updateValue("bpe", value); + public bpattack = (value: number) => this.updateValue("bpattack", value); + public bpa = this.bpattack; + public bpdecay = (value: number) => this.updateValue("bpdecay", value); + public bpd = this.bpdecay; + public bpsustain = (value: number) => this.updateValue("bpsustain", value); + public bps = this.bpsustain; + public bprelease = (value: number) => this.updateValue("bprelease", value); + public bpr = this.bprelease; + public bandf = (value: number) => this.updateValue("bandf", value); + public bpf = this.bandf; + public bandq = (value: number) => this.updateValue("bandq", value); + public bpq = this.bandq; + public freq = (value: number) => this.updateValue("freq", value); public f = this.freq; + public vib = (value: number) => this.updateValue("vib", value); + public vibmod = (value: number) => this.updateValue("vibmod", value); public fm = (value: number | string) => { if (typeof value === "number") { this.values["fmi"] = value; @@ -100,42 +159,46 @@ export class SoundEvent extends AudibleEvent { } return this; }; + + // Sampler looping + public loop = (value: number) => this.updateValue("loop", value); + public loopBegin = (value: number) => this.updateValue("loopBegin", value); + public loopEnd = (value: number) => this.updateValue("loopEnd", value); + public begin = (value: number) => this.updateValue("begin", value); + public end = (value: number) => this.updateValue("end", value); + + // Gain management + public gain = (value: number) => this.updateValue("gain", value); + public dbgain = (value: number) => + this.updateValue("gain", Math.min(Math.pow(10, value / 20), 10)); + public db = this.dbgain; + public velocity = (value: number) => this.updateValue("velocity", value); + public vel = this.velocity; + + // Panoramic control (stereo) + public pan = (value: number) => this.updateValue("pan", value); + + // Frequency management + public sound = (value: string) => this.updateValue("s", value); public chord = (value: number[]) => this.updateValue("chord", value); public snd = this.sound; public nudge = (value: number) => this.updateValue("nudge", value); public cut = (value: number) => this.updateValue("cut", value); - public loop = (value: number) => this.updateValue("loop", value); public clip = (value: number) => this.updateValue("clip", value); public n = (value: number) => this.updateValue("n", value); public note = (value: number) => this.updateValue("note", value); public speed = (value: number) => this.updateValue("speed", value); public spd = this.speed; - public begin = (value: number) => this.updateValue("begin", value); - public end = (value: number) => this.updateValue("end", value); - public gain = (value: number) => this.updateValue("gain", value); - public dbgain = (value: number) => - this.updateValue("gain", Math.min(Math.pow(10, value / 20), 10)); - public db = this.dbgain; - public cutoff = (value: number) => this.updateValue("cutoff", value); - public lpf = this.cutoff; - public resonance = (value: number) => - this.updateValue("resonance", Math.min(Math.max(value, 0), 50)); - public lpq = this.resonance; - public hcutoff = (value: number) => this.updateValue("hcutoff", value); - public hpf = this.hcutoff; - public hresonance = (value: number) => this.updateValue("hresonance", value); - public hpq = this.hresonance; - public bandf = (value: number) => this.updateValue("bandf", value); - public bpf = this.bandf; - public bandq = (value: number) => this.updateValue("bandq", value); - public bpq = this.bandq; + + // Creative sampler effects public coarse = (value: number) => this.updateValue("coarse", value); public crush = (value: number) => this.updateValue("crush", value); public shape = (value: number) => this.updateValue("shape", value); - public pan = (value: number) => this.updateValue("pan", value); public vowel = (value: number) => this.updateValue("vowel", value); public vow = this.vowel; + + // Delay control public delay = (value: number) => this.updateValue("delay", value); public del = this.delay; public delayfeedback = (value: number) => @@ -143,14 +206,16 @@ export class SoundEvent extends AudibleEvent { public delayfb = this.delayfeedback; public delaytime = (value: number) => this.updateValue("delaytime", value); public delayt = this.delaytime; + + // Orbit management public orbit = (value: number) => this.updateValue("orbit", value); public o = this.orbit; + + // Reverb management public room = (value: number) => this.updateValue("room", value); public rm = this.room; public size = (value: number) => this.updateValue("size", value); public sz = this.size; - public velocity = (value: number) => this.updateValue("velocity", value); - public vel = this.velocity; // ================================================================================ // AbstactEvent overrides diff --git a/yarn.lock b/yarn.lock index ec0ad2f..bd0a155 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1272,10 +1272,10 @@ sucrase@^3.32.0: pirates "^4.0.1" ts-interface-checker "^0.1.9" -superdough@^0.9.6: - version "0.9.6" - resolved "https://registry.yarnpkg.com/superdough/-/superdough-0.9.6.tgz#4955827d01d6fd56a24beca50cd310b690519e14" - integrity sha512-f6Aey9+qDJ+NHTuIRO3hXBAhuxg1Z7TeSAdKbG9yrSbfDGcqOWN3Gmfy5ZKe3s34djHWnMotRIHCfzuJcuabuA== +superdough@^0.9.8: + version "0.9.8" + resolved "https://registry.yarnpkg.com/superdough/-/superdough-0.9.8.tgz#de30e364b2613a15a46f35f359a2a0ce30d52611" + integrity sha512-3xy2LXAH4K0JMwwY4G0eJz+u1VIhSFxIE4YZL7E4isjUQZTN9Y0jpX17EzQgvFIW1V3PUJMkDiDgEDWZTRCTKg== dependencies: nanostores "^0.8.1"