rlo-engine 1.0.3 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +15 -4
- package/dist/Core/AudioMath.d.ts +29 -0
- package/dist/Core/AudioMath.d.ts.map +1 -0
- package/dist/Core/AudioMath.js +64 -0
- package/dist/Core/AudioMath.js.map +1 -0
- package/dist/Core/InstrumentMap.d.ts +36 -0
- package/dist/Core/InstrumentMap.d.ts.map +1 -0
- package/dist/Core/InstrumentMap.js +62 -0
- package/dist/Core/InstrumentMap.js.map +1 -0
- package/dist/Core/RLOCore.d.ts +49 -0
- package/dist/Core/RLOCore.d.ts.map +1 -0
- package/dist/Core/RLOCore.js +188 -0
- package/dist/Core/RLOCore.js.map +1 -0
- package/dist/Core/SequenceBuilder.d.ts +23 -0
- package/dist/Core/SequenceBuilder.d.ts.map +1 -0
- package/dist/Core/SequenceBuilder.js +31 -0
- package/dist/Core/SequenceBuilder.js.map +1 -0
- package/dist/Instruments/Analog/AnalogSynthBase.d.ts +17 -7
- package/dist/Instruments/Analog/AnalogSynthBase.d.ts.map +1 -1
- package/dist/Instruments/Analog/AnalogSynthBase.js +27 -16
- package/dist/Instruments/Analog/AnalogSynthBase.js.map +1 -1
- package/dist/Instruments/Analog/BassSynth.d.ts +12 -5
- package/dist/Instruments/Analog/BassSynth.d.ts.map +1 -1
- package/dist/Instruments/Analog/BassSynth.js +17 -10
- package/dist/Instruments/Analog/BassSynth.js.map +1 -1
- package/dist/Instruments/Analog/ChiptuneSynth.d.ts +11 -4
- package/dist/Instruments/Analog/ChiptuneSynth.d.ts.map +1 -1
- package/dist/Instruments/Analog/ChiptuneSynth.js +12 -5
- package/dist/Instruments/Analog/ChiptuneSynth.js.map +1 -1
- package/dist/Instruments/Analog/FMSynth.d.ts +11 -4
- package/dist/Instruments/Analog/FMSynth.d.ts.map +1 -1
- package/dist/Instruments/Analog/FMSynth.js +14 -7
- package/dist/Instruments/Analog/FMSynth.js.map +1 -1
- package/dist/Instruments/Analog/FormantSynth.d.ts +11 -4
- package/dist/Instruments/Analog/FormantSynth.d.ts.map +1 -1
- package/dist/Instruments/Analog/FormantSynth.js +12 -5
- package/dist/Instruments/Analog/FormantSynth.js.map +1 -1
- package/dist/Instruments/Analog/LeadSynth.d.ts +11 -4
- package/dist/Instruments/Analog/LeadSynth.d.ts.map +1 -1
- package/dist/Instruments/Analog/LeadSynth.js +14 -7
- package/dist/Instruments/Analog/LeadSynth.js.map +1 -1
- package/dist/Instruments/Analog/OrganSynth.d.ts +11 -4
- package/dist/Instruments/Analog/OrganSynth.d.ts.map +1 -1
- package/dist/Instruments/Analog/OrganSynth.js +17 -10
- package/dist/Instruments/Analog/OrganSynth.js.map +1 -1
- package/dist/Instruments/Analog/PadSynth.js +7 -7
- package/dist/Instruments/Analog/PadSynth.js.map +1 -1
- package/dist/Instruments/Analog/ReeseBassSynth.d.ts +11 -4
- package/dist/Instruments/Analog/ReeseBassSynth.d.ts.map +1 -1
- package/dist/Instruments/Analog/ReeseBassSynth.js +13 -6
- package/dist/Instruments/Analog/ReeseBassSynth.js.map +1 -1
- package/dist/Instruments/Analog/StringSynth.js +4 -4
- package/dist/Instruments/Analog/StringSynth.js.map +1 -1
- package/dist/Instruments/Analog/WoodwindSynth.d.ts +11 -4
- package/dist/Instruments/Analog/WoodwindSynth.d.ts.map +1 -1
- package/dist/Instruments/Analog/WoodwindSynth.js +19 -12
- package/dist/Instruments/Analog/WoodwindSynth.js.map +1 -1
- package/dist/Instruments/CoreSynthBase.d.ts +31 -24
- package/dist/Instruments/CoreSynthBase.d.ts.map +1 -1
- package/dist/Instruments/CoreSynthBase.js +53 -34
- package/dist/Instruments/CoreSynthBase.js.map +1 -1
- package/dist/Instruments/Decay/AdditiveSynth.d.ts +12 -5
- package/dist/Instruments/Decay/AdditiveSynth.d.ts.map +1 -1
- package/dist/Instruments/Decay/AdditiveSynth.js +9 -2
- package/dist/Instruments/Decay/AdditiveSynth.js.map +1 -1
- package/dist/Instruments/Decay/BrassSynth.d.ts +11 -4
- package/dist/Instruments/Decay/BrassSynth.d.ts.map +1 -1
- package/dist/Instruments/Decay/BrassSynth.js +22 -15
- package/dist/Instruments/Decay/BrassSynth.js.map +1 -1
- package/dist/Instruments/Decay/ChromaticPercussionSynth.d.ts +12 -5
- package/dist/Instruments/Decay/ChromaticPercussionSynth.d.ts.map +1 -1
- package/dist/Instruments/Decay/ChromaticPercussionSynth.js +16 -9
- package/dist/Instruments/Decay/ChromaticPercussionSynth.js.map +1 -1
- package/dist/Instruments/Decay/DecaySynthBase.d.ts +14 -8
- package/dist/Instruments/Decay/DecaySynthBase.d.ts.map +1 -1
- package/dist/Instruments/Decay/DecaySynthBase.js +22 -15
- package/dist/Instruments/Decay/DecaySynthBase.js.map +1 -1
- package/dist/Instruments/Decay/ElectricGuitarSynth.d.ts +12 -5
- package/dist/Instruments/Decay/ElectricGuitarSynth.d.ts.map +1 -1
- package/dist/Instruments/Decay/ElectricGuitarSynth.js +19 -12
- package/dist/Instruments/Decay/ElectricGuitarSynth.js.map +1 -1
- package/dist/Instruments/Decay/EthnicSynth.d.ts +12 -5
- package/dist/Instruments/Decay/EthnicSynth.d.ts.map +1 -1
- package/dist/Instruments/Decay/EthnicSynth.js +13 -6
- package/dist/Instruments/Decay/EthnicSynth.js.map +1 -1
- package/dist/Instruments/Decay/GuitarSynth.d.ts +12 -5
- package/dist/Instruments/Decay/GuitarSynth.d.ts.map +1 -1
- package/dist/Instruments/Decay/GuitarSynth.js +14 -7
- package/dist/Instruments/Decay/GuitarSynth.js.map +1 -1
- package/dist/Instruments/Decay/KarplusSynth.d.ts +7 -0
- package/dist/Instruments/Decay/KarplusSynth.d.ts.map +1 -1
- package/dist/Instruments/Decay/KarplusSynth.js +16 -8
- package/dist/Instruments/Decay/KarplusSynth.js.map +1 -1
- package/dist/Instruments/Decay/PianoSynth.d.ts +12 -5
- package/dist/Instruments/Decay/PianoSynth.d.ts.map +1 -1
- package/dist/Instruments/Decay/PianoSynth.js +19 -12
- package/dist/Instruments/Decay/PianoSynth.js.map +1 -1
- package/dist/Instruments/Decay/SlapBassSynth.d.ts +12 -5
- package/dist/Instruments/Decay/SlapBassSynth.d.ts.map +1 -1
- package/dist/Instruments/Decay/SlapBassSynth.js +13 -6
- package/dist/Instruments/Decay/SlapBassSynth.js.map +1 -1
- package/dist/Instruments/ISynthInstrument.d.ts +6 -0
- package/dist/Instruments/ISynthInstrument.d.ts.map +1 -1
- package/dist/Instruments/Speciality/DrumSynth.d.ts +7 -0
- package/dist/Instruments/Speciality/DrumSynth.d.ts.map +1 -1
- package/dist/Instruments/Speciality/DrumSynth.js +30 -21
- package/dist/Instruments/Speciality/DrumSynth.js.map +1 -1
- package/dist/Instruments/Speciality/SoundEffectsSynth.d.ts +7 -0
- package/dist/Instruments/Speciality/SoundEffectsSynth.d.ts.map +1 -1
- package/dist/Instruments/Speciality/SoundEffectsSynth.js +20 -12
- package/dist/Instruments/Speciality/SoundEffectsSynth.js.map +1 -1
- package/dist/Instruments/Synthesizer.d.ts +5 -0
- package/dist/Instruments/Synthesizer.d.ts.map +1 -1
- package/dist/Instruments/Synthesizer.js +7 -1
- package/dist/Instruments/Synthesizer.js.map +1 -1
- package/dist/Players/RLOGameEngine.d.ts +35 -0
- package/dist/Players/RLOGameEngine.d.ts.map +1 -0
- package/dist/Players/RLOGameEngine.js +98 -0
- package/dist/Players/RLOGameEngine.js.map +1 -0
- package/dist/Players/RLOMusicPlayer.d.ts +35 -0
- package/dist/Players/RLOMusicPlayer.d.ts.map +1 -0
- package/dist/Players/RLOMusicPlayer.js +167 -0
- package/dist/Players/RLOMusicPlayer.js.map +1 -0
- package/dist/RLO-Transpiler.d.ts +37 -15
- package/dist/RLO-Transpiler.d.ts.map +1 -1
- package/dist/RLO-Transpiler.js +139 -117
- package/dist/RLO-Transpiler.js.map +1 -1
- package/dist/compiler.d.ts +50 -31
- package/dist/compiler.d.ts.map +1 -1
- package/dist/compiler.js +165 -230
- package/dist/compiler.js.map +1 -1
- package/dist/crush.d.ts +1 -5
- package/dist/crush.d.ts.map +1 -1
- package/dist/crush.js +10 -3
- package/dist/crush.js.map +1 -1
- package/dist/index.d.ts +15 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +14 -3
- package/dist/index.js.map +1 -1
- package/dist/midi-parser.d.ts +14 -0
- package/dist/midi-parser.d.ts.map +1 -1
- package/dist/midi-parser.js +21 -0
- package/dist/midi-parser.js.map +1 -1
- package/dist/rlo-engine.min.js +441 -439
- package/dist/rlo-engine.min.js.map +1 -1
- package/dist/rlo-engine.min.umd.js +1 -1
- package/dist/rlo-engine.min.umd.js.map +1 -1
- package/dist/types.d.ts +21 -3
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +4 -0
- package/dist/types.js.map +1 -1
- package/dist/vite.config.d.ts.map +1 -1
- package/dist/vite.config.js +16 -3
- package/dist/vite.config.js.map +1 -1
- package/dist/vite.config.js13k.d.ts.map +1 -1
- package/dist/vite.config.js13k.js +1 -0
- package/dist/vite.config.js13k.js.map +1 -1
- package/package.json +1 -1
- package/dist/Instruments/InstrumentFactory.d.ts +0 -2
- package/dist/Instruments/InstrumentFactory.d.ts.map +0 -1
- package/dist/Instruments/InstrumentFactory.js +0 -4
- package/dist/Instruments/InstrumentFactory.js.map +0 -1
- package/dist/RLO-Player.d.ts +0 -298
- package/dist/RLO-Player.d.ts.map +0 -1
- package/dist/RLO-Player.js +0 -724
- package/dist/RLO-Player.js.map +0 -1
|
@@ -3,21 +3,28 @@ import { DecaySynthBase } from "./DecaySynthBase.js";
|
|
|
3
3
|
* Synthesizer strategy for Chromatic Percussion (Bells, Marimba, Vibraphone).
|
|
4
4
|
* Characterized by a pure tone with a very fast attack and immediate decay.
|
|
5
5
|
*/
|
|
6
|
+
/**
|
|
7
|
+
* Emulates struck melodic instruments like a Glockenspiel or Marimba using rapid decay envelopes and metallic overtones.
|
|
8
|
+
*
|
|
9
|
+
* @reason Acoustic Design:
|
|
10
|
+
* Encapsulates the specific Web Audio node routing and ADSR parameters
|
|
11
|
+
* required to physically model this instrument within the 13KB limit.
|
|
12
|
+
*/
|
|
6
13
|
export class ChromaticPercussionSynth extends DecaySynthBase {
|
|
7
14
|
constructor() {
|
|
8
15
|
super(...arguments);
|
|
9
|
-
this.
|
|
16
|
+
this._envelopeConfig = { _peakVelocity: 0.7, _attackTimeSeconds: 0.005, _decayTimeSeconds: 0.5, _maxDurationSeconds: 6.0 };
|
|
10
17
|
}
|
|
11
18
|
_setupSynthesis(ctx, masterGain, gain, time, freq, velocity, safeDuration, stopTime) {
|
|
12
|
-
const osc = this.
|
|
13
|
-
this.
|
|
14
|
-
this.
|
|
15
|
-
const overtoneGain = this.
|
|
16
|
-
this.
|
|
17
|
-
this.
|
|
18
|
-
const overtone = this.
|
|
19
|
+
const osc = this._createOscillator(ctx, "sine", 0, gain);
|
|
20
|
+
this._setValueAtTime(osc.frequency, freq * 1.1, time);
|
|
21
|
+
this._exponentialRampToValue(osc.frequency, freq, time + 0.02);
|
|
22
|
+
const overtoneGain = this._createGain(ctx, 0, masterGain);
|
|
23
|
+
this._setValueAtTime(overtoneGain.gain, Math.max(0.001, velocity * 0.25), time);
|
|
24
|
+
this._exponentialRampToValue(overtoneGain.gain, 0.001, time + safeDuration);
|
|
25
|
+
const overtone = this._createOscillator(ctx, "sine", freq * 2.76, overtoneGain);
|
|
19
26
|
overtoneGain.connect(masterGain);
|
|
20
|
-
this.
|
|
27
|
+
this._scheduleNodeStartStop(time, stopTime, osc, overtone);
|
|
21
28
|
}
|
|
22
29
|
}
|
|
23
30
|
//# sourceMappingURL=ChromaticPercussionSynth.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ChromaticPercussionSynth.js","sourceRoot":"","sources":["../../../Instruments/Decay/ChromaticPercussionSynth.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAGrD;;;GAGG;AACH,MAAM,OAAO,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AAM,EAAE,IAAI,GAAG,IAAI,EAAE,YAAY,CAAC,CAAC;QAEhF,YAAY,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC;QAEjC,IAAI,CAAC,sBAAsB,CAAC,IAAI,EAAE,QAAQ,EAAE,GAAG,EAAE,QAAQ,CAAC,CAAC;IAC7D,CAAC;CACF"}
|
|
@@ -1,18 +1,24 @@
|
|
|
1
1
|
import { CoreSynthBase } from "../CoreSynthBase.js";
|
|
2
2
|
export type DecayCfg = {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
3
|
+
_peakVelocity: number;
|
|
4
|
+
_attackTimeSeconds: number;
|
|
5
|
+
_decayTimeSeconds: number;
|
|
6
|
+
_maxDurationSeconds: number;
|
|
7
7
|
};
|
|
8
8
|
/**
|
|
9
|
-
* Abstract base class for plucked, struck, and decaying synthesizers.
|
|
10
|
-
*
|
|
9
|
+
* Abstract base class for plucked, struck, and decaying synthesizers (e.g. Pianos, Guitars, Marimbas).
|
|
10
|
+
*
|
|
11
|
+
* @reason Physics Simulation:
|
|
12
|
+
* Unlike Analog instruments that hold their peak volume as long as a key is pressed,
|
|
13
|
+
* physical instruments like Guitars or Pianos immediately begin decaying the moment they are struck.
|
|
14
|
+
* This class abstracts the mathematical envelope necessary to simulate that physical decay,
|
|
15
|
+
* including a hard `maxDurationSeconds` limit to prevent infinite resonance loops from
|
|
16
|
+
* leaking memory if a MIDI file passes a malformed 60-second note duration.
|
|
11
17
|
*/
|
|
12
18
|
export declare abstract class DecaySynthBase extends CoreSynthBase {
|
|
13
|
-
protected
|
|
19
|
+
protected _envelopeConfig: DecayCfg;
|
|
14
20
|
_playNote(ctx: AudioContext, masterGain: GainNode, time: number, freq: number, duration: number, velocity: number): void;
|
|
15
|
-
protected
|
|
21
|
+
protected _getEnvelopeConfig(): DecayCfg;
|
|
16
22
|
/** Override this for complex envelopes (like electric guitar compression) */
|
|
17
23
|
protected _applyDecay(gainParam: AudioParam, peakVol: number, time: number, attack: number, safeDuration: number, decayTail: number): void;
|
|
18
24
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DecaySynthBase.d.ts","sourceRoot":"","sources":["../../../Instruments/Decay/DecaySynthBase.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,
|
|
1
|
+
{"version":3,"file":"DecaySynthBase.d.ts","sourceRoot":"","sources":["../../../Instruments/Decay/DecaySynthBase.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAe,MAAM,qBAAqB,CAAC;AAEjE,MAAM,MAAM,QAAQ,GAAG;IAAE,aAAa,EAAE,MAAM,CAAC;IAAC,kBAAkB,EAAE,MAAM,CAAC;IAAC,iBAAiB,EAAE,MAAM,CAAC;IAAC,mBAAmB,EAAE,MAAM,CAAA;CAAE,CAAC;AAErI;;;;;;;;;GASG;AACH,8BAAsB,cAAe,SAAQ,aAAa;IACxD,SAAS,CAAC,eAAe,EAAE,QAAQ,CAAsG;IAElI,SAAS,CACd,GAAG,EAAE,YAAY,EACjB,UAAU,EAAE,QAAQ,EACpB,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM,EACZ,QAAQ,EAAE,MAAM,EAChB,QAAQ,EAAE,MAAM,GACf,IAAI;IAiCP,SAAS,CAAC,kBAAkB,IAAI,QAAQ;IAIxC,6EAA6E;IAC7E,SAAS,CAAC,WAAW,CACnB,SAAS,EAAE,UAAU,EACrB,OAAO,EAAE,MAAM,EACf,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,MAAM,EACd,YAAY,EAAE,MAAM,EACpB,SAAS,EAAE,MAAM,GAChB,IAAI;IAIP;;OAEG;IACH,SAAS,CAAC,QAAQ,CAAC,eAAe,CAChC,GAAG,EAAE,YAAY,EACjB,UAAU,EAAE,QAAQ,EACpB,IAAI,EAAE,QAAQ,EACd,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM,EACZ,QAAQ,EAAE,MAAM,EAChB,YAAY,EAAE,MAAM,EACpB,QAAQ,EAAE,MAAM,GACf,SAAS,GAAG,IAAI;CACpB"}
|
|
@@ -1,35 +1,42 @@
|
|
|
1
|
-
import { CoreSynthBase } from "../CoreSynthBase.js";
|
|
1
|
+
import { CoreSynthBase, hasStrictGC } from "../CoreSynthBase.js";
|
|
2
2
|
/**
|
|
3
|
-
* Abstract base class for plucked, struck, and decaying synthesizers.
|
|
4
|
-
*
|
|
3
|
+
* Abstract base class for plucked, struck, and decaying synthesizers (e.g. Pianos, Guitars, Marimbas).
|
|
4
|
+
*
|
|
5
|
+
* @reason Physics Simulation:
|
|
6
|
+
* Unlike Analog instruments that hold their peak volume as long as a key is pressed,
|
|
7
|
+
* physical instruments like Guitars or Pianos immediately begin decaying the moment they are struck.
|
|
8
|
+
* This class abstracts the mathematical envelope necessary to simulate that physical decay,
|
|
9
|
+
* including a hard `maxDurationSeconds` limit to prevent infinite resonance loops from
|
|
10
|
+
* leaking memory if a MIDI file passes a malformed 60-second note duration.
|
|
5
11
|
*/
|
|
6
12
|
export class DecaySynthBase extends CoreSynthBase {
|
|
7
13
|
constructor() {
|
|
8
14
|
super(...arguments);
|
|
9
|
-
this.
|
|
15
|
+
this._envelopeConfig = { _peakVelocity: 0.5, _attackTimeSeconds: 0.02, _decayTimeSeconds: 0.2, _maxDurationSeconds: 4.0 };
|
|
10
16
|
}
|
|
11
17
|
_playNote(ctx, masterGain, time, freq, duration, velocity) {
|
|
12
18
|
const gain = ctx.createGain();
|
|
13
|
-
const c = this.
|
|
14
|
-
const peakVol = Math.max(0.001, velocity * c.
|
|
19
|
+
const c = this._getEnvelopeConfig();
|
|
20
|
+
const peakVol = Math.max(0.001, velocity * c._peakVelocity);
|
|
15
21
|
/** Physical strings/mallets stop vibrating quickly. Protects against stuck MIDI notes. */
|
|
16
|
-
const safeDuration = Math.max(0.02, Math.min(duration, c.
|
|
17
|
-
this.
|
|
18
|
-
this.
|
|
19
|
-
this._applyDecay(gain.gain, peakVol, time, c.
|
|
22
|
+
const safeDuration = Math.max(0.02, Math.min(duration, c._maxDurationSeconds));
|
|
23
|
+
this._setValueAtTime(gain.gain, 0, time);
|
|
24
|
+
this._linearRampToValue(gain.gain, peakVol, time + c._attackTimeSeconds);
|
|
25
|
+
this._applyDecay(gain.gain, peakVol, time, c._attackTimeSeconds, safeDuration, c._decayTimeSeconds);
|
|
20
26
|
/** Pad the oscillator stop time slightly past the volume decay to prevent digital clicking */
|
|
21
|
-
const stopTime = time + safeDuration + c.
|
|
27
|
+
const stopTime = time + safeDuration + c._decayTimeSeconds + 0.1;
|
|
22
28
|
const output = this._setupSynthesis(ctx, masterGain, gain, time, freq, velocity, safeDuration, stopTime);
|
|
23
29
|
const finalNode = output || gain;
|
|
24
30
|
finalNode.connect(masterGain);
|
|
25
|
-
|
|
31
|
+
if (hasStrictGC)
|
|
32
|
+
this._scheduleNodeDisposal(ctx, time, stopTime + 2.0, finalNode);
|
|
26
33
|
}
|
|
27
|
-
|
|
28
|
-
return this.
|
|
34
|
+
_getEnvelopeConfig() {
|
|
35
|
+
return this._envelopeConfig;
|
|
29
36
|
}
|
|
30
37
|
/** Override this for complex envelopes (like electric guitar compression) */
|
|
31
38
|
_applyDecay(gainParam, peakVol, time, attack, safeDuration, decayTail) {
|
|
32
|
-
this.
|
|
39
|
+
this._exponentialRampToValue(gainParam, 0.001, time + safeDuration + decayTail);
|
|
33
40
|
}
|
|
34
41
|
}
|
|
35
42
|
//# sourceMappingURL=DecaySynthBase.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DecaySynthBase.js","sourceRoot":"","sources":["../../../Instruments/Decay/DecaySynthBase.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"DecaySynthBase.js","sourceRoot":"","sources":["../../../Instruments/Decay/DecaySynthBase.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,qBAA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IAAI,EACJ,QAAQ,EACR,YAAY,EACZ,QAAQ,CACT,CAAC;QAEF,MAAM,SAAS,GAAG,MAAM,IAAI,IAAI,CAAC;QACjC,SAAS,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC;QAC9B,IAAI,WAAW;YAAE,IAAI,CAAC,qBAAqB,CAAC,GAAG,EAAE,IAAI,EAAE,QAAQ,GAAG,GAAG,EAAE,SAAS,CAAC,CAAC;IACpF,CAAC;IAES,kBAAkB;QAC1B,OAAO,IAAI,CAAC,eAAe,CAAC;IAC9B,CAAC;IAED,6EAA6E;IACnE,WAAW,CACnB,SAAqB,EACrB,OAAe,EACf,IAAY,EACZ,MAAc,EACd,YAAoB,EACpB,SAAiB;QAEjB,IAAI,CAAC,uBAAuB,CAAC,SAAS,EAAE,KAAK,EAAE,IAAI,GAAG,YAAY,GAAG,SAAS,CAAC,CAAC;IAClF,CAAC;CAeF"}
|
|
@@ -2,12 +2,19 @@ import { DecaySynthBase } from "./DecaySynthBase.js";
|
|
|
2
2
|
/**
|
|
3
3
|
* Synthesizer strategy for Electric and Distorted Guitars.
|
|
4
4
|
*/
|
|
5
|
+
/**
|
|
6
|
+
* Simulates a distorted electric guitar using a sawtooth wave run through heavy overdrive and bandpass filtering.
|
|
7
|
+
*
|
|
8
|
+
* @reason Acoustic Design:
|
|
9
|
+
* Encapsulates the specific Web Audio node routing and ADSR parameters
|
|
10
|
+
* required to physically model this instrument within the 13KB limit.
|
|
11
|
+
*/
|
|
5
12
|
export declare class ElectricGuitarSynth extends DecaySynthBase {
|
|
6
|
-
protected
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
13
|
+
protected _envelopeConfig: {
|
|
14
|
+
_peakVelocity: number;
|
|
15
|
+
_attackTimeSeconds: number;
|
|
16
|
+
_decayTimeSeconds: number;
|
|
17
|
+
_maxDurationSeconds: number;
|
|
11
18
|
};
|
|
12
19
|
protected _applyDecay(gainParam: AudioParam, peakVol: number, time: number, attack: number, safeDuration: number, decayTail: number): void;
|
|
13
20
|
protected _setupSynthesis(ctx: AudioContext, masterGain: GainNode, gain: GainNode, time: number, freq: number, velocity: number, safeDuration: number, stopTime: number): AudioNode | void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ElectricGuitarSynth.d.ts","sourceRoot":"","sources":["../../../Instruments/Decay/ElectricGuitarSynth.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAGrD;;GAEG;AACH,qBAAa,mBAAoB,SAAQ,cAAc;IACrD,SAAS,CAAC,
|
|
1
|
+
{"version":3,"file":"ElectricGuitarSynth.d.ts","sourceRoot":"","sources":["../../../Instruments/Decay/ElectricGuitarSynth.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAGrD;;GAEG;AACH;;;;;;GAMG;AACH,qBAAa,mBAAoB,SAAQ,cAAc;IACrD,SAAS,CAAC,eAAe;;;;;MAAsG;IAE/H,SAAS,CAAC,WAAW,CACnB,SAAS,EAAE,UAAU,EACrB,OAAO,EAAE,MAAM,EACf,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,MAAM,EACd,YAAY,EAAE,MAAM,EACpB,SAAS,EAAE,MAAM,GAChB,IAAI;IAUP,SAAS,CAAC,eAAe,CACvB,GAAG,EAAE,YAAY,EACjB,UAAU,EAAE,QAAQ,EACpB,IAAI,EAAE,QAAQ,EACd,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM,EACZ,QAAQ,EAAE,MAAM,EAChB,YAAY,EAAE,MAAM,EACpB,QAAQ,EAAE,MAAM,GACf,SAAS,GAAG,IAAI;CA6CpB"}
|
|
@@ -2,29 +2,36 @@ import { DecaySynthBase } from "./DecaySynthBase.js";
|
|
|
2
2
|
/**
|
|
3
3
|
* Synthesizer strategy for Electric and Distorted Guitars.
|
|
4
4
|
*/
|
|
5
|
+
/**
|
|
6
|
+
* Simulates a distorted electric guitar using a sawtooth wave run through heavy overdrive and bandpass filtering.
|
|
7
|
+
*
|
|
8
|
+
* @reason Acoustic Design:
|
|
9
|
+
* Encapsulates the specific Web Audio node routing and ADSR parameters
|
|
10
|
+
* required to physically model this instrument within the 13KB limit.
|
|
11
|
+
*/
|
|
5
12
|
export class ElectricGuitarSynth extends DecaySynthBase {
|
|
6
13
|
constructor() {
|
|
7
14
|
super(...arguments);
|
|
8
|
-
this.
|
|
15
|
+
this._envelopeConfig = { _peakVelocity: 0.5, _attackTimeSeconds: 0.02, _decayTimeSeconds: 0.2, _maxDurationSeconds: 4.0 };
|
|
9
16
|
}
|
|
10
17
|
_applyDecay(gainParam, peakVol, time, attack, safeDuration, decayTail) {
|
|
11
18
|
/** Compressed sustain mimicking an electric guitar amp */
|
|
12
|
-
this.
|
|
13
|
-
this.
|
|
19
|
+
this._exponentialRampToValue(gainParam, Math.max(0.001, peakVol * 0.4), time + Math.min(0.5, safeDuration));
|
|
20
|
+
this._exponentialRampToValue(gainParam, 0.001, time + safeDuration + decayTail);
|
|
14
21
|
}
|
|
15
22
|
_setupSynthesis(ctx, masterGain, gain, time, freq, velocity, safeDuration, stopTime) {
|
|
16
|
-
const filter = this.
|
|
17
|
-
const [osc, osc2] = this.
|
|
18
|
-
this.
|
|
19
|
-
this.
|
|
20
|
-
this.
|
|
21
|
-
this.
|
|
22
|
-
const vibrato = this.
|
|
23
|
+
const filter = this._createFilterSweep(ctx, "lowpass", 2500 + velocity * 1500, 600, time, safeDuration);
|
|
24
|
+
const [osc, osc2] = this._createStereoOscillator(ctx, "sawtooth", 0, 1, 0, gain);
|
|
25
|
+
this._setValueAtTime(osc.frequency, freq * 1.02, time);
|
|
26
|
+
this._exponentialRampToValue(osc.frequency, freq, time + 0.05);
|
|
27
|
+
this._setValueAtTime(osc2.frequency, freq * 1.022, time);
|
|
28
|
+
this._exponentialRampToValue(osc2.frequency, freq * 1.002, time + 0.05);
|
|
29
|
+
const vibrato = this._createLFO(ctx, 5.0, freq * 0.015, time, 0.2, stopTime, osc.frequency, 0.4);
|
|
23
30
|
vibrato.connect(osc2.frequency);
|
|
24
31
|
gain.connect(filter);
|
|
25
32
|
/** Heavy plectrum attack */
|
|
26
|
-
this.
|
|
27
|
-
this.
|
|
33
|
+
this._createTransient(ctx, "square", 3500, masterGain, time, Math.max(0.001, velocity * 0.25), 0.015);
|
|
34
|
+
this._scheduleNodeStartStop(time, stopTime, osc, osc2);
|
|
28
35
|
return filter;
|
|
29
36
|
}
|
|
30
37
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ElectricGuitarSynth.js","sourceRoot":"","sources":["../../../Instruments/Decay/ElectricGuitarSynth.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAGrD;;GAEG;AACH,MAAM,OAAO,mBAAoB,SAAQ,cAAc;IAAvD;;QACY,
|
|
1
|
+
{"version":3,"file":"ElectricGuitarSynth.js","sourceRoot":"","sources":["../../../Instruments/Decay/ElectricGuitarSynth.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAGrD;;GAEG;AACH;;;;;;GAMG;AACH,MAAM,OAAO,mBAAoB,SAAQ,cAAc;IAAvD;;QACY,oBAAe,GAAG,EAAE,aAAa,EAAE,GAAG,EAAE,kBAAkB,EAAE,IAAI,EAAE,iBAAiB,EAAE,GAAG,EAAE,mBAAmB,EAAE,GAAG,EAAE,CAAC;IAyEjI,CAAC;IAvEW,WAAW,CACnB,SAAqB,EACrB,OAAe,EACf,IAAY,EACZ,MAAc,EACd,YAAoB,EACpB,SAAiB;QAEjB,0DAA0D;QAC1D,IAAI,CAAC,uBAAuB,CAC1B,SAAS,EACT,IAAI,CAAC,GAAG,CAAC,KAAK,EAAE,OAAO,GAAG,GAAG,CAAC,EAC9B,IAAI,GAAG,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,YAAY,CAAC,CACnC,CAA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AAI,CAAC,gBAAgB,CACnB,GAAG,EACH,QAAQ,EACR,IAAI,EACJ,UAAU,EACV,IAAI,EACJ,IAAI,CAAC,GAAG,CAAC,KAAK,EAAE,QAAQ,GAAG,IAAI,CAAC,EAChC,KAAK,CACN,CAAC;QAEF,IAAI,CAAC,sBAAsB,CAAC,IAAI,EAAE,QAAQ,EAAE,GAAG,EAAE,IAAI,CAAC,CAAC;QAEvD,OAAO,MAAM,CAAC;IAChB,CAAC;CACF"}
|
|
@@ -3,12 +3,19 @@ import { DecaySynthBase } from "./DecaySynthBase.js";
|
|
|
3
3
|
* Synthesizer strategy for Ethnic instruments (Sitar, Shamisen, Koto).
|
|
4
4
|
* Uses a bandpass filter over a square wave to emulate a hollow, plucked resonator.
|
|
5
5
|
*/
|
|
6
|
+
/**
|
|
7
|
+
* A generalized plucked/struck string synthesizer meant to emulate instruments like a Sitar or Koto.
|
|
8
|
+
*
|
|
9
|
+
* @reason Acoustic Design:
|
|
10
|
+
* Encapsulates the specific Web Audio node routing and ADSR parameters
|
|
11
|
+
* required to physically model this instrument within the 13KB limit.
|
|
12
|
+
*/
|
|
6
13
|
export declare class EthnicSynth extends DecaySynthBase {
|
|
7
|
-
protected
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
14
|
+
protected _envelopeConfig: {
|
|
15
|
+
_peakVelocity: number;
|
|
16
|
+
_attackTimeSeconds: number;
|
|
17
|
+
_decayTimeSeconds: number;
|
|
18
|
+
_maxDurationSeconds: number;
|
|
12
19
|
};
|
|
13
20
|
protected _setupSynthesis(ctx: AudioContext, masterGain: GainNode, gain: GainNode, time: number, freq: number, velocity: number, safeDuration: number, stopTime: number): AudioNode | void;
|
|
14
21
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EthnicSynth.d.ts","sourceRoot":"","sources":["../../../Instruments/Decay/EthnicSynth.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAGrD;;;GAGG;AACH,qBAAa,WAAY,SAAQ,cAAc;IAC7C,SAAS,CAAC,
|
|
1
|
+
{"version":3,"file":"EthnicSynth.d.ts","sourceRoot":"","sources":["../../../Instruments/Decay/EthnicSynth.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAGrD;;;GAGG;AACH;;;;;;GAMG;AACH,qBAAa,WAAY,SAAQ,cAAc;IAC7C,SAAS,CAAC,eAAe;;;;;MAAsG;IAE/H,SAAS,CAAC,eAAe,CACvB,GAAG,EAAE,YAAY,EACjB,UAAU,EAAE,QAAQ,EACpB,IAAI,EAAE,QAAQ,EACd,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM,EACZ,QAAQ,EAAE,MAAM,EAChB,YAAY,EAAE,MAAM,EACpB,QAAQ,EAAE,MAAM,GACf,SAAS,GAAG,IAAI;CAmBpB"}
|
|
@@ -3,19 +3,26 @@ import { DecaySynthBase } from "./DecaySynthBase.js";
|
|
|
3
3
|
* Synthesizer strategy for Ethnic instruments (Sitar, Shamisen, Koto).
|
|
4
4
|
* Uses a bandpass filter over a square wave to emulate a hollow, plucked resonator.
|
|
5
5
|
*/
|
|
6
|
+
/**
|
|
7
|
+
* A generalized plucked/struck string synthesizer meant to emulate instruments like a Sitar or Koto.
|
|
8
|
+
*
|
|
9
|
+
* @reason Acoustic Design:
|
|
10
|
+
* Encapsulates the specific Web Audio node routing and ADSR parameters
|
|
11
|
+
* required to physically model this instrument within the 13KB limit.
|
|
12
|
+
*/
|
|
6
13
|
export class EthnicSynth extends DecaySynthBase {
|
|
7
14
|
constructor() {
|
|
8
15
|
super(...arguments);
|
|
9
|
-
this.
|
|
16
|
+
this._envelopeConfig = { _peakVelocity: 0.6, _attackTimeSeconds: 0.02, _decayTimeSeconds: 0.1, _maxDurationSeconds: 4.0 };
|
|
10
17
|
}
|
|
11
18
|
_setupSynthesis(ctx, masterGain, gain, time, freq, velocity, safeDuration, stopTime) {
|
|
12
|
-
const osc = this.
|
|
13
|
-
this.
|
|
14
|
-
this.
|
|
15
|
-
const filter = this.
|
|
19
|
+
const osc = this._createOscillator(ctx, "square", 0, gain);
|
|
20
|
+
this._setValueAtTime(osc.frequency, freq * 1.05, time);
|
|
21
|
+
this._exponentialRampToValue(osc.frequency, freq, time + 0.08);
|
|
22
|
+
const filter = this._createFilterSweep(ctx, "bandpass", freq * 2.5, freq, time, safeDuration);
|
|
16
23
|
filter.Q.value = 2;
|
|
17
24
|
filter.connect(gain);
|
|
18
|
-
this.
|
|
25
|
+
this._scheduleNodeStartStop(time, stopTime, osc);
|
|
19
26
|
}
|
|
20
27
|
}
|
|
21
28
|
//# sourceMappingURL=EthnicSynth.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EthnicSynth.js","sourceRoot":"","sources":["../../../Instruments/Decay/EthnicSynth.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAGrD;;;GAGG;AACH,MAAM,OAAO,WAAY,SAAQ,cAAc;IAA/C;;QACY,
|
|
1
|
+
{"version":3,"file":"EthnicSynth.js","sourceRoot":"","sources":["../../../Instruments/Decay/EthnicSynth.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAGrD;;;GAGG;AACH;;;;;;GAMG;AACH,MAAM,OAAO,WAAY,SAAQ,cAAc;IAA/C;;QACY,oBAAe,GAAG,EAAE,aAAa,EAAE,GAAG,EAAE,kBAAkB,EAAE,IAAI,EAAE,iBAAiB,EAAE,GAAG,EAAE,mBAAmB,EAAE,GAAG,EAAE,CAAC;IA8BjI,CAAC;IA5BW,eAAe,CACvB,GAAiB,EACjB,UAAoB,EACpB,IAAc,EACd,IAAY,EACZ,IAAY,EACZ,QAAgB,EAChB,YAAoB,EACpB,QAAgB;QAEhB,MAAM,GAAG,GAAG,IAAI,CAAC,iBAAiB,CAAC,GAAG,EAAE,QAAQ,EAAE,CAAC,EAAE,IAAI,CAAC,CAAC;QAC3D,IAAI,CAAC,eAAe,CAAC,GAAG,CAAC,SAAS,EAAE,IAAI,GAAG,IAAI,EAAE,IAAI,CAAC,CAAC;QACvD,IAAI,CAAC,uBAAuB,CAAC,GAAG,CAAC,SAAS,EAAE,IAAI,EAAE,IAAI,GAAG,IAAI,CAAC,CAAC;QAE/D,MAAM,MAAM,GAAG,IAAI,CAAC,kBAAkB,CACpC,GAAG,EACH,UAAU,EACV,IAAI,GAAG,GAAG,EACV,IAAI,EACJ,IAAI,EACJ,YAAY,CACb,CAAC;QACF,MAAM,CAAC,CAAC,CAAC,KAAK,GAAG,CAAC,CAAC;QAEnB,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;QAErB,IAAI,CAAC,sBAAsB,CAAC,IAAI,EAAE,QAAQ,EAAE,GAAG,CAAC,CAAC;IACnD,CAAC;CACF"}
|
|
@@ -2,12 +2,19 @@ import { DecaySynthBase } from "./DecaySynthBase.js";
|
|
|
2
2
|
/**
|
|
3
3
|
* Synthesizer strategy for Acoustic Guitars using a plucked sawtooth.
|
|
4
4
|
*/
|
|
5
|
+
/**
|
|
6
|
+
* Simulates an acoustic guitar pluck using the Karplus-Strong algorithm or filtered sawtooth impulses.
|
|
7
|
+
*
|
|
8
|
+
* @reason Acoustic Design:
|
|
9
|
+
* Encapsulates the specific Web Audio node routing and ADSR parameters
|
|
10
|
+
* required to physically model this instrument within the 13KB limit.
|
|
11
|
+
*/
|
|
5
12
|
export declare class GuitarSynth extends DecaySynthBase {
|
|
6
|
-
protected
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
13
|
+
protected _envelopeConfig: {
|
|
14
|
+
_peakVelocity: number;
|
|
15
|
+
_attackTimeSeconds: number;
|
|
16
|
+
_decayTimeSeconds: number;
|
|
17
|
+
_maxDurationSeconds: number;
|
|
11
18
|
};
|
|
12
19
|
protected _setupSynthesis(ctx: AudioContext, masterGain: GainNode, gain: GainNode, time: number, freq: number, velocity: number, safeDuration: number, stopTime: number): AudioNode | void;
|
|
13
20
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GuitarSynth.d.ts","sourceRoot":"","sources":["../../../Instruments/Decay/GuitarSynth.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAGrD;;GAEG;AACH,qBAAa,WAAY,SAAQ,cAAc;IAC7C,SAAS,CAAC,
|
|
1
|
+
{"version":3,"file":"GuitarSynth.d.ts","sourceRoot":"","sources":["../../../Instruments/Decay/GuitarSynth.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAGrD;;GAEG;AACH;;;;;;GAMG;AACH,qBAAa,WAAY,SAAQ,cAAc;IAC7C,SAAS,CAAC,eAAe;;;;;MAAsG;IAE/H,SAAS,CAAC,eAAe,CACvB,GAAG,EAAE,YAAY,EACjB,UAAU,EAAE,QAAQ,EACpB,IAAI,EAAE,QAAQ,EACd,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM,EACZ,QAAQ,EAAE,MAAM,EAChB,YAAY,EAAE,MAAM,EACpB,QAAQ,EAAE,MAAM,GACf,SAAS,GAAG,IAAI;CAgCpB"}
|
|
@@ -2,21 +2,28 @@ import { DecaySynthBase } from "./DecaySynthBase.js";
|
|
|
2
2
|
/**
|
|
3
3
|
* Synthesizer strategy for Acoustic Guitars using a plucked sawtooth.
|
|
4
4
|
*/
|
|
5
|
+
/**
|
|
6
|
+
* Simulates an acoustic guitar pluck using the Karplus-Strong algorithm or filtered sawtooth impulses.
|
|
7
|
+
*
|
|
8
|
+
* @reason Acoustic Design:
|
|
9
|
+
* Encapsulates the specific Web Audio node routing and ADSR parameters
|
|
10
|
+
* required to physically model this instrument within the 13KB limit.
|
|
11
|
+
*/
|
|
5
12
|
export class GuitarSynth extends DecaySynthBase {
|
|
6
13
|
constructor() {
|
|
7
14
|
super(...arguments);
|
|
8
|
-
this.
|
|
15
|
+
this._envelopeConfig = { _peakVelocity: 0.6, _attackTimeSeconds: 0.02, _decayTimeSeconds: 0.2, _maxDurationSeconds: 4.0 };
|
|
9
16
|
}
|
|
10
17
|
_setupSynthesis(ctx, masterGain, gain, time, freq, velocity, safeDuration, stopTime) {
|
|
11
18
|
/** Bright attack that quickly muffles as the acoustic string loses kinetic energy */
|
|
12
|
-
const filter = this.
|
|
13
|
-
const osc = this.
|
|
14
|
-
this.
|
|
15
|
-
this.
|
|
19
|
+
const filter = this._createFilterSweep(ctx, "lowpass", 2000 + velocity * 1000, 200, time, safeDuration);
|
|
20
|
+
const osc = this._createOscillator(ctx, "sawtooth", 0, gain);
|
|
21
|
+
this._setValueAtTime(osc.frequency, freq * 1.02, time);
|
|
22
|
+
this._exponentialRampToValue(osc.frequency, freq, time + 0.05);
|
|
16
23
|
gain.connect(filter);
|
|
17
24
|
/** Plectrum Pluck: the sharp, plastic click of a pick striking a steel string */
|
|
18
|
-
this.
|
|
19
|
-
this.
|
|
25
|
+
this._createTransient(ctx, "square", 3500, masterGain, time, Math.max(0.001, velocity * 0.25), 0.015);
|
|
26
|
+
this._scheduleNodeStartStop(time, stopTime, osc);
|
|
20
27
|
return filter;
|
|
21
28
|
}
|
|
22
29
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GuitarSynth.js","sourceRoot":"","sources":["../../../Instruments/Decay/GuitarSynth.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAGrD;;GAEG;AACH,MAAM,OAAO,WAAY,SAAQ,cAAc;IAA/C;;QACY,
|
|
1
|
+
{"version":3,"file":"GuitarSynth.js","sourceRoot":"","sources":["../../../Instruments/Decay/GuitarSynth.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAGrD;;GAEG;AACH;;;;;;GA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back filter
|
|
5
5
|
* to accurately simulate the physics of plucked strings (Acoustic Guitar, Harp).
|
|
6
6
|
*/
|
|
7
|
+
/**
|
|
8
|
+
* Implements the Karplus-Strong string synthesis algorithm using a short noise burst fed through a tightly tuned feedback delay line.
|
|
9
|
+
*
|
|
10
|
+
* @reason Acoustic Design:
|
|
11
|
+
* Encapsulates the specific Web Audio node routing and ADSR parameters
|
|
12
|
+
* required to physically model this instrument within the 13KB limit.
|
|
13
|
+
*/
|
|
7
14
|
export declare class KarplusSynth extends CoreSynthBase {
|
|
8
15
|
_playNote(ctx: AudioContext, masterGain: GainNode, time: number, freq: number, duration: number, velocity: number): void;
|
|
9
16
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"KarplusSynth.d.ts","sourceRoot":"","sources":["../../../Instruments/Decay/KarplusSynth.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,
|
|
1
|
+
{"version":3,"file":"KarplusSynth.d.ts","sourceRoot":"","sources":["../../../Instruments/Decay/KarplusSynth.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAuB,MAAM,qBAAqB,CAAC;AAEzE;;;;GAIG;AACH;;;;;;GAMG;AACH,qBAAa,YAAa,SAAQ,aAAa;IACtC,SAAS,CACd,GAAG,EAAE,YAAY,EACjB,UAAU,EAAE,QAAQ,EACpB,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM,EACZ,QAAQ,EAAE,MAAM,EAChB,QAAQ,EAAE,MAAM,GACf,IAAI;CAsCR"}
|
|
@@ -1,9 +1,16 @@
|
|
|
1
|
-
import { CoreSynthBase } from "../CoreSynthBase.js";
|
|
1
|
+
import { CoreSynthBase, hasStrictGC } from "../CoreSynthBase.js";
|
|
2
2
|
/**
|
|
3
3
|
* Synthesizer strategy for Karplus-Strong physical modeling.
|
|
4
4
|
* Uses a noise burst fed into a tuned delay line with a feedback filter
|
|
5
5
|
* to accurately simulate the physics of plucked strings (Acoustic Guitar, Harp).
|
|
6
6
|
*/
|
|
7
|
+
/**
|
|
8
|
+
* Implements the Karplus-Strong string synthesis algorithm using a short noise burst fed through a tightly tuned feedback delay line.
|
|
9
|
+
*
|
|
10
|
+
* @reason Acoustic Design:
|
|
11
|
+
* Encapsulates the specific Web Audio node routing and ADSR parameters
|
|
12
|
+
* required to physically model this instrument within the 13KB limit.
|
|
13
|
+
*/
|
|
7
14
|
export class KarplusSynth extends CoreSynthBase {
|
|
8
15
|
_playNote(ctx, masterGain, time, freq, duration, velocity) {
|
|
9
16
|
const delayTime = 1 / freq;
|
|
@@ -18,17 +25,18 @@ export class KarplusSynth extends CoreSynthBase {
|
|
|
18
25
|
const delay = ctx.createDelay(delayTime);
|
|
19
26
|
delay.delayTime.value = delayTime;
|
|
20
27
|
// 3. The Body Damping (Lowpass filter inside the feedback loop to absorb high frequencies)
|
|
21
|
-
const filter = this.
|
|
28
|
+
const filter = this._createFilter(ctx, "lowpass");
|
|
22
29
|
filter.frequency.value = Math.min(22000, freq * 6);
|
|
23
30
|
// 4. The Tension (Feedback gain)
|
|
24
|
-
const feedback = this.
|
|
31
|
+
const feedback = this._createGain(ctx, 0.98); // Higher value = longer ring time
|
|
25
32
|
burst.connect(delay).connect(filter).connect(feedback).connect(delay);
|
|
26
|
-
const output = this.
|
|
27
|
-
this.
|
|
28
|
-
this.
|
|
33
|
+
const output = this._createGain(ctx, 0, masterGain);
|
|
34
|
+
this._setValueAtTime(output.gain, 1, time);
|
|
35
|
+
this._exponentialRampToValue(output.gain, 0.001, time + duration);
|
|
29
36
|
delay.connect(output);
|
|
30
|
-
this.
|
|
31
|
-
|
|
37
|
+
this._scheduleNodeStartStop(time, time + duration, burst);
|
|
38
|
+
if (hasStrictGC)
|
|
39
|
+
this._scheduleNodeDisposal(ctx, time, time + duration + 3.0, output, delay, filter, feedback);
|
|
32
40
|
}
|
|
33
41
|
}
|
|
34
42
|
//# sourceMappingURL=KarplusSynth.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"KarplusSynth.js","sourceRoot":"","sources":["../../../Instruments/Decay/KarplusSynth.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAU,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"KarplusSynth.js","sourceRoot":"","sources":["../../../Instruments/Decay/KarplusSynth.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAU,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAEzE;;;;GAIG;AACH;;;;;;GAMG;AACH,MAAM,OAAO,YAAa,SAAQ,aAAa;IACtC,SAAS,CACd,GAAiB,EACjB,UAAoB,EACpB,IAAY,EACZ,IAAY,EACZ,QAAgB,EAChB,QAAgB;QAEhB,MAAM,SAAS,GAAG,CAAC,GAAG,IAAI,CAAC;QAE3B,uDAAuD;QACvD,MAAM,WAAW,GAAG,GAAG,CAAC,YAAY,CAClC,CAAC,EACD,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,GAAG,CAAC,UAAU,GAAG,SAAS,CAAC,EACvC,GAAG,CAAC,UAAU,CACf,CAAC;QACF,MAAM,IAAI,GAAG,WAAW,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC;QAC3C,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC,EAAE;YAClC,IAAI,CAAC,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,CAAC,CAAC,GAAG,QAAQ,CAAC;QAE/C,MAAM,KAAK,GAAG,GAAG,CAAC,kBAAkB,EAAE,CAAC;QACvC,KAAK,CAAC,MAAM,GAAG,WAAW,CAAC;QAE3B,mEAAmE;QACnE,MAAM,KAAK,GAAG,GAAG,CAAC,WAAW,CAAC,SAAS,CAAC,CAAC;QACzC,KAAK,CAAC,SAAS,CAAC,KAAK,GAAG,SAAS,CAAC;QAElC,2FAA2F;QAC3F,MAAM,MAAM,GAAG,IAAI,CAAC,aAAa,CAAC,GAAG,EAAE,SAAS,CAAC,CAAC;QAClD,MAAM,CAAC,SAAS,CAAC,KAAK,GAAG,IAAI,CAAC,GAAG,CAAC,KAAK,EAAE,IAAI,GAAG,CAAC,CAAC,CAAC;QAEnD,iCAAiC;QACjC,MAAM,QAAQ,GAAG,IAAI,CAAC,WAAW,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC,CAAC,kCAAkC;QAEhF,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;QAEtE,MAAM,MAAM,GAAG,IAAI,CAAC,WAAW,CAAC,GAAG,EAAE,CAAC,EAAE,UAAU,CAAC,CAAC;QACpD,IAAI,CAAC,eAAe,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC,EAAE,IAAI,CAAC,CAAC;QAC3C,IAAI,CAAC,uBAAuB,CAAC,MAAM,CAAC,IAAI,EAAE,KAAK,EAAE,IAAI,GAAG,QAAQ,CAAC,CAAC;QAElE,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;QACtB,IAAI,CAAC,sBAAsB,CAAC,IAAI,EAAE,IAAI,GAAG,QAAQ,EAAE,KAAK,CAAC,CAAC;QAE1D,IAAI,WAAW;YAAE,IAAI,CAAC,qBAAqB,CAAC,GAAG,EAAE,IAAI,EAAE,IAAI,GAAG,QAAQ,GAAG,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,QAAQ,CAAC,CAAC;IACjH,CAAC;CACF"}
|
|
@@ -2,12 +2,19 @@ import { DecaySynthBase } from "./DecaySynthBase.js";
|
|
|
2
2
|
/**
|
|
3
3
|
* Synthesizer strategy for Piano and similar percussive-melodic instruments.
|
|
4
4
|
*/
|
|
5
|
+
/**
|
|
6
|
+
* Simulates a piano using a complex decay envelope, subtle detuning for string realism, and a lowpass filter that closes over time.
|
|
7
|
+
*
|
|
8
|
+
* @reason Acoustic Design:
|
|
9
|
+
* Encapsulates the specific Web Audio node routing and ADSR parameters
|
|
10
|
+
* required to physically model this instrument within the 13KB limit.
|
|
11
|
+
*/
|
|
5
12
|
export declare class PianoSynth extends DecaySynthBase {
|
|
6
|
-
protected
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
13
|
+
protected _envelopeConfig: {
|
|
14
|
+
_peakVelocity: number;
|
|
15
|
+
_attackTimeSeconds: number;
|
|
16
|
+
_decayTimeSeconds: number;
|
|
17
|
+
_maxDurationSeconds: number;
|
|
11
18
|
};
|
|
12
19
|
protected _setupSynthesis(ctx: AudioContext, masterGain: GainNode, gain: GainNode, time: number, freq: number, velocity: number, safeDuration: number, stopTime: number): AudioNode | void;
|
|
13
20
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PianoSynth.d.ts","sourceRoot":"","sources":["../../../Instruments/Decay/PianoSynth.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAGrD;;GAEG;AACH,qBAAa,UAAW,SAAQ,cAAc;IAC5C,SAAS,CAAC,
|
|
1
|
+
{"version":3,"file":"PianoSynth.d.ts","sourceRoot":"","sources":["../../../Instruments/Decay/PianoSynth.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAGrD;;GAEG;AACH;;;;;;GAMG;AACH,qBAAa,UAAW,SAAQ,cAAc;IAC5C,SAAS,CAAC,eAAe;;;;;MAAuG;IAEhI,SAAS,CAAC,eAAe,CACvB,GAAG,EAAE,YAAY,EACjB,UAAU,EAAE,QAAQ,EACpB,IAAI,EAAE,QAAQ,EACd,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM,EACZ,QAAQ,EAAE,MAAM,EAChB,YAAY,EAAE,MAAM,EACpB,QAAQ,EAAE,MAAM,GACf,SAAS,GAAG,IAAI;CA+CpB"}
|
|
@@ -2,30 +2,37 @@ import { DecaySynthBase } from "./DecaySynthBase.js";
|
|
|
2
2
|
/**
|
|
3
3
|
* Synthesizer strategy for Piano and similar percussive-melodic instruments.
|
|
4
4
|
*/
|
|
5
|
+
/**
|
|
6
|
+
* Simulates a piano using a complex decay envelope, subtle detuning for string realism, and a lowpass filter that closes over time.
|
|
7
|
+
*
|
|
8
|
+
* @reason Acoustic Design:
|
|
9
|
+
* Encapsulates the specific Web Audio node routing and ADSR parameters
|
|
10
|
+
* required to physically model this instrument within the 13KB limit.
|
|
11
|
+
*/
|
|
5
12
|
export class PianoSynth extends DecaySynthBase {
|
|
6
13
|
constructor() {
|
|
7
14
|
super(...arguments);
|
|
8
|
-
this.
|
|
15
|
+
this._envelopeConfig = { _peakVelocity: 0.8, _attackTimeSeconds: 0.015, _decayTimeSeconds: 0.1, _maxDurationSeconds: 5.0 };
|
|
9
16
|
}
|
|
10
17
|
_setupSynthesis(ctx, masterGain, gain, time, freq, velocity, safeDuration, stopTime) {
|
|
11
18
|
/** Key-tracking the filter ensures high notes aren't artificially muffled or phase-distorted. Capped at Nyquist. */
|
|
12
|
-
const filter = this.
|
|
13
|
-
const osc1 = this.
|
|
19
|
+
const filter = this._createFilterSweep(ctx, "lowpass", freq + 800 + velocity * 1000, freq + 200, time, Math.min(safeDuration, 1.0));
|
|
20
|
+
const osc1 = this._createOscillator(ctx, "triangle", freq, gain);
|
|
14
21
|
/** Slight inharmonicity stretching, strictly capped below Nyquist to prevent digital aliasing */
|
|
15
|
-
const overtoneGain = this.
|
|
16
|
-
const osc2 = this.
|
|
17
|
-
const osc3 = this.
|
|
22
|
+
const overtoneGain = this._createGain(ctx, 0);
|
|
23
|
+
const osc2 = this._createOscillator(ctx, "sine", freq * 2.003, overtoneGain);
|
|
24
|
+
const osc3 = this._createOscillator(ctx, "sine", freq * 3.007, overtoneGain);
|
|
18
25
|
/** Dynamically pan lower keys to the left ear, and higher keys to the right ear */
|
|
19
|
-
const panner = this.
|
|
26
|
+
const panner = this._createStereoPanner(ctx, Math.max(-0.8, Math.min(0.8, (freq - 261.6) / 800)));
|
|
20
27
|
/** Sympathetic string resonance: metallic clangs decay much faster than the fundamental */
|
|
21
|
-
this.
|
|
22
|
-
this.
|
|
23
|
-
this.
|
|
28
|
+
this._setValueAtTime(overtoneGain.gain, 0, time);
|
|
29
|
+
this._linearRampToValue(overtoneGain.gain, Math.max(0.001, velocity * 0.15), time + 0.01);
|
|
30
|
+
this._exponentialRampToValue(overtoneGain.gain, 0.001, time + Math.min(safeDuration, 0.5));
|
|
24
31
|
overtoneGain.connect(panner);
|
|
25
32
|
/** Mechanical Hammer Thump: the physical impact of the wooden hammer on the strings */
|
|
26
|
-
this.
|
|
33
|
+
this._createTransient(ctx, "sine", 60, panner, time, Math.max(0.001, velocity * 0.4), 0.05, 0.005);
|
|
27
34
|
gain.connect(panner).connect(filter);
|
|
28
|
-
this.
|
|
35
|
+
this._scheduleNodeStartStop(time, stopTime, osc1, osc2, osc3);
|
|
29
36
|
return filter;
|
|
30
37
|
}
|
|
31
38
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PianoSynth.js","sourceRoot":"","sources":["../../../Instruments/Decay/PianoSynth.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAGrD;;GAEG;AACH,MAAM,OAAO,UAAW,SAAQ,cAAc;IAA9C;;QACY,
|
|
1
|
+
{"version":3,"file":"PianoSynth.js","sourceRoot":"","sources":["../../../Instruments/Decay/PianoSynth.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAGrD;;GAEG;AACH;;;;;;GAMG;AACH,MAAM,OAAO,UAAW,SAAQ,cAAc;IAA9C;;QACY,oBAAe,GAAG,EAAE,aAAa,EAAE,GAAG,EAAE,kBAAkB,EAAE,KAAK,EAAE,iBAAiB,EAAE,GAAG,EAAE,mBAAmB,E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