rlo-engine 1.0.3
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 +493 -0
- package/dist/AudioEffects.d.ts +16 -0
- package/dist/AudioEffects.d.ts.map +1 -0
- package/dist/AudioEffects.js +41 -0
- package/dist/AudioEffects.js.map +1 -0
- package/dist/Instruments/Analog/AnalogSynthBase.d.ts +22 -0
- package/dist/Instruments/Analog/AnalogSynthBase.d.ts.map +1 -0
- package/dist/Instruments/Analog/AnalogSynthBase.js +30 -0
- package/dist/Instruments/Analog/AnalogSynthBase.js.map +1 -0
- package/dist/Instruments/Analog/BassSynth.d.ts +14 -0
- package/dist/Instruments/Analog/BassSynth.d.ts.map +1 -0
- package/dist/Instruments/Analog/BassSynth.js +25 -0
- package/dist/Instruments/Analog/BassSynth.js.map +1 -0
- package/dist/Instruments/Analog/ChiptuneSynth.d.ts +14 -0
- package/dist/Instruments/Analog/ChiptuneSynth.d.ts.map +1 -0
- package/dist/Instruments/Analog/ChiptuneSynth.js +19 -0
- package/dist/Instruments/Analog/ChiptuneSynth.js.map +1 -0
- package/dist/Instruments/Analog/FMSynth.d.ts +15 -0
- package/dist/Instruments/Analog/FMSynth.d.ts.map +1 -0
- package/dist/Instruments/Analog/FMSynth.js +23 -0
- package/dist/Instruments/Analog/FMSynth.js.map +1 -0
- package/dist/Instruments/Analog/FormantSynth.d.ts +14 -0
- package/dist/Instruments/Analog/FormantSynth.d.ts.map +1 -0
- package/dist/Instruments/Analog/FormantSynth.js +26 -0
- package/dist/Instruments/Analog/FormantSynth.js.map +1 -0
- package/dist/Instruments/Analog/LeadSynth.d.ts +13 -0
- package/dist/Instruments/Analog/LeadSynth.d.ts.map +1 -0
- package/dist/Instruments/Analog/LeadSynth.js +21 -0
- package/dist/Instruments/Analog/LeadSynth.js.map +1 -0
- package/dist/Instruments/Analog/OrganSynth.d.ts +13 -0
- package/dist/Instruments/Analog/OrganSynth.d.ts.map +1 -0
- package/dist/Instruments/Analog/OrganSynth.js +24 -0
- package/dist/Instruments/Analog/OrganSynth.js.map +1 -0
- package/dist/Instruments/Analog/PadSynth.d.ts +14 -0
- package/dist/Instruments/Analog/PadSynth.d.ts.map +1 -0
- package/dist/Instruments/Analog/PadSynth.js +22 -0
- package/dist/Instruments/Analog/PadSynth.js.map +1 -0
- package/dist/Instruments/Analog/ReeseBassSynth.d.ts +14 -0
- package/dist/Instruments/Analog/ReeseBassSynth.d.ts.map +1 -0
- package/dist/Instruments/Analog/ReeseBassSynth.js +22 -0
- package/dist/Instruments/Analog/ReeseBassSynth.js.map +1 -0
- package/dist/Instruments/Analog/StringSynth.d.ts +13 -0
- package/dist/Instruments/Analog/StringSynth.d.ts.map +1 -0
- package/dist/Instruments/Analog/StringSynth.js +19 -0
- package/dist/Instruments/Analog/StringSynth.js.map +1 -0
- package/dist/Instruments/Analog/WoodwindSynth.d.ts +14 -0
- package/dist/Instruments/Analog/WoodwindSynth.d.ts.map +1 -0
- package/dist/Instruments/Analog/WoodwindSynth.js +35 -0
- package/dist/Instruments/Analog/WoodwindSynth.js.map +1 -0
- package/dist/Instruments/CoreSynthBase.d.ts +29 -0
- package/dist/Instruments/CoreSynthBase.d.ts.map +1 -0
- package/dist/Instruments/CoreSynthBase.js +91 -0
- package/dist/Instruments/CoreSynthBase.js.map +1 -0
- package/dist/Instruments/Decay/AdditiveSynth.d.ts +15 -0
- package/dist/Instruments/Decay/AdditiveSynth.d.ts.map +1 -0
- package/dist/Instruments/Decay/AdditiveSynth.js +24 -0
- package/dist/Instruments/Decay/AdditiveSynth.js.map +1 -0
- package/dist/Instruments/Decay/BrassSynth.d.ts +13 -0
- package/dist/Instruments/Decay/BrassSynth.d.ts.map +1 -0
- package/dist/Instruments/Decay/BrassSynth.js +29 -0
- package/dist/Instruments/Decay/BrassSynth.js.map +1 -0
- package/dist/Instruments/Decay/ChromaticPercussionSynth.d.ts +15 -0
- package/dist/Instruments/Decay/ChromaticPercussionSynth.d.ts.map +1 -0
- package/dist/Instruments/Decay/ChromaticPercussionSynth.js +23 -0
- package/dist/Instruments/Decay/ChromaticPercussionSynth.js.map +1 -0
- package/dist/Instruments/Decay/DecaySynthBase.d.ts +23 -0
- package/dist/Instruments/Decay/DecaySynthBase.d.ts.map +1 -0
- package/dist/Instruments/Decay/DecaySynthBase.js +35 -0
- package/dist/Instruments/Decay/DecaySynthBase.js.map +1 -0
- package/dist/Instruments/Decay/ElectricGuitarSynth.d.ts +15 -0
- package/dist/Instruments/Decay/ElectricGuitarSynth.d.ts.map +1 -0
- package/dist/Instruments/Decay/ElectricGuitarSynth.js +31 -0
- package/dist/Instruments/Decay/ElectricGuitarSynth.js.map +1 -0
- package/dist/Instruments/Decay/EthnicSynth.d.ts +15 -0
- package/dist/Instruments/Decay/EthnicSynth.d.ts.map +1 -0
- package/dist/Instruments/Decay/EthnicSynth.js +21 -0
- package/dist/Instruments/Decay/EthnicSynth.js.map +1 -0
- package/dist/Instruments/Decay/GuitarSynth.d.ts +14 -0
- package/dist/Instruments/Decay/GuitarSynth.d.ts.map +1 -0
- package/dist/Instruments/Decay/GuitarSynth.js +23 -0
- package/dist/Instruments/Decay/GuitarSynth.js.map +1 -0
- package/dist/Instruments/Decay/KarplusSynth.d.ts +10 -0
- package/dist/Instruments/Decay/KarplusSynth.d.ts.map +1 -0
- package/dist/Instruments/Decay/KarplusSynth.js +34 -0
- package/dist/Instruments/Decay/KarplusSynth.js.map +1 -0
- package/dist/Instruments/Decay/PianoSynth.d.ts +14 -0
- package/dist/Instruments/Decay/PianoSynth.d.ts.map +1 -0
- package/dist/Instruments/Decay/PianoSynth.js +32 -0
- package/dist/Instruments/Decay/PianoSynth.js.map +1 -0
- package/dist/Instruments/Decay/SlapBassSynth.d.ts +15 -0
- package/dist/Instruments/Decay/SlapBassSynth.d.ts.map +1 -0
- package/dist/Instruments/Decay/SlapBassSynth.js +28 -0
- package/dist/Instruments/Decay/SlapBassSynth.js.map +1 -0
- package/dist/Instruments/ISynthInstrument.d.ts +16 -0
- package/dist/Instruments/ISynthInstrument.d.ts.map +1 -0
- package/dist/Instruments/ISynthInstrument.js +2 -0
- package/dist/Instruments/ISynthInstrument.js.map +1 -0
- package/dist/Instruments/InstrumentFactory.d.ts +2 -0
- package/dist/Instruments/InstrumentFactory.d.ts.map +1 -0
- package/dist/Instruments/InstrumentFactory.js +4 -0
- package/dist/Instruments/InstrumentFactory.js.map +1 -0
- package/dist/Instruments/Speciality/DrumSynth.d.ts +11 -0
- package/dist/Instruments/Speciality/DrumSynth.d.ts.map +1 -0
- package/dist/Instruments/Speciality/DrumSynth.js +61 -0
- package/dist/Instruments/Speciality/DrumSynth.js.map +1 -0
- package/dist/Instruments/Speciality/SoundEffectsSynth.d.ts +12 -0
- package/dist/Instruments/Speciality/SoundEffectsSynth.d.ts.map +1 -0
- package/dist/Instruments/Speciality/SoundEffectsSynth.js +27 -0
- package/dist/Instruments/Speciality/SoundEffectsSynth.js.map +1 -0
- package/dist/Instruments/Synthesizer.d.ts +15 -0
- package/dist/Instruments/Synthesizer.d.ts.map +1 -0
- package/dist/Instruments/Synthesizer.js +27 -0
- package/dist/Instruments/Synthesizer.js.map +1 -0
- package/dist/RLO-Player.d.ts +298 -0
- package/dist/RLO-Player.d.ts.map +1 -0
- package/dist/RLO-Player.js +724 -0
- package/dist/RLO-Player.js.map +1 -0
- package/dist/RLO-Transpiler.d.ts +22 -0
- package/dist/RLO-Transpiler.d.ts.map +1 -0
- package/dist/RLO-Transpiler.js +133 -0
- package/dist/RLO-Transpiler.js.map +1 -0
- package/dist/compiler.d.ts +40 -0
- package/dist/compiler.d.ts.map +1 -0
- package/dist/compiler.js +268 -0
- package/dist/compiler.js.map +1 -0
- package/dist/crush.d.ts +9 -0
- package/dist/crush.d.ts.map +1 -0
- package/dist/crush.js +20 -0
- package/dist/crush.js.map +1 -0
- package/dist/index.d.ts +36 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +59 -0
- package/dist/index.js.map +1 -0
- package/dist/midi-parser.d.ts +10 -0
- package/dist/midi-parser.d.ts.map +1 -0
- package/dist/midi-parser.js +130 -0
- package/dist/midi-parser.js.map +1 -0
- package/dist/rlo-engine.min.js +655 -0
- package/dist/rlo-engine.min.js.map +1 -0
- package/dist/rlo-engine.min.umd.js +2 -0
- package/dist/rlo-engine.min.umd.js.map +1 -0
- package/dist/types.d.ts +16 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +7 -0
- package/dist/types.js.map +1 -0
- package/dist/vite.config.d.ts +7 -0
- package/dist/vite.config.d.ts.map +1 -0
- package/dist/vite.config.js +244 -0
- package/dist/vite.config.js.map +1 -0
- package/dist/vite.config.js13k.d.ts +7 -0
- package/dist/vite.config.js13k.d.ts.map +1 -0
- package/dist/vite.config.js13k.js +72 -0
- package/dist/vite.config.js13k.js.map +1 -0
- package/package.json +50 -0
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { DecaySynthBase } from "./DecaySynthBase.js";
|
|
2
|
+
/**
|
|
3
|
+
* Synthesizer strategy for Inharmonic Additive bells/glass.
|
|
4
|
+
* Stacks sine waves at non-integer multiples to create metallic, clanging overtones.
|
|
5
|
+
*/
|
|
6
|
+
export declare class AdditiveSynth extends DecaySynthBase {
|
|
7
|
+
protected _c: {
|
|
8
|
+
v: number;
|
|
9
|
+
a: number;
|
|
10
|
+
d: number;
|
|
11
|
+
m: number;
|
|
12
|
+
};
|
|
13
|
+
protected _setupSynthesis(ctx: AudioContext, masterGain: GainNode, gain: GainNode, time: number, freq: number, velocity: number, safeDuration: number, stopTime: number): AudioNode | void;
|
|
14
|
+
}
|
|
15
|
+
//# sourceMappingURL=AdditiveSynth.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AdditiveSynth.d.ts","sourceRoot":"","sources":["../../../Instruments/Decay/AdditiveSynth.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAY,MAAM,qBAAqB,CAAC;AAG/D;;;GAGG;AACH,qBAAa,aAAc,SAAQ,cAAc;IAC/C,SAAS,CAAC,EAAE;;;;;MAAwC;IAEpD,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;CAapB"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { DecaySynthBase } from "./DecaySynthBase.js";
|
|
2
|
+
/**
|
|
3
|
+
* Synthesizer strategy for Inharmonic Additive bells/glass.
|
|
4
|
+
* Stacks sine waves at non-integer multiples to create metallic, clanging overtones.
|
|
5
|
+
*/
|
|
6
|
+
export class AdditiveSynth extends DecaySynthBase {
|
|
7
|
+
constructor() {
|
|
8
|
+
super(...arguments);
|
|
9
|
+
this._c = { v: 0.6, a: 0.005, d: 0.5, m: 5.0 };
|
|
10
|
+
}
|
|
11
|
+
_setupSynthesis(ctx, masterGain, gain, time, freq, velocity, safeDuration, stopTime) {
|
|
12
|
+
const ratios = [1.0, 2.76, 5.4, 8.9, 13.3];
|
|
13
|
+
const decays = [1.0, 0.6, 0.4, 0.2, 0.1]; // Higher frequencies die out much faster
|
|
14
|
+
ratios.forEach((ratio, i) => {
|
|
15
|
+
const hFreq = freq * ratio;
|
|
16
|
+
if (hFreq < 22000) {
|
|
17
|
+
const peak = Math.max(0.001, velocity * (1 / (i + 1.5)));
|
|
18
|
+
const dur = Math.max(0.1, safeDuration * decays[i]);
|
|
19
|
+
this._transient(ctx, 0 /* Osc.Sine */, hFreq, gain, time, peak, dur, 0.005);
|
|
20
|
+
}
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
//# sourceMappingURL=AdditiveSynth.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"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|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { AnalogSynthBase } from "../Analog/AnalogSynthBase.js";
|
|
2
|
+
/**
|
|
3
|
+
* Synthesizer strategy for Brass and Wind instruments with a slow filter envelope.
|
|
4
|
+
*/
|
|
5
|
+
export declare class BrassSynth extends AnalogSynthBase {
|
|
6
|
+
protected _c: {
|
|
7
|
+
v: number;
|
|
8
|
+
a: number;
|
|
9
|
+
r: number;
|
|
10
|
+
};
|
|
11
|
+
protected _setupSynthesis(ctx: AudioContext, gain: GainNode, time: number, freq: number, velocity: number, sustainTime: number, releaseTime: number, stopTime: number): AudioNode | void;
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=BrassSynth.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BrassSynth.d.ts","sourceRoot":"","sources":["../../../Instruments/Decay/BrassSynth.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAG/D;;GAEG;AACH,qBAAa,UAAW,SAAQ,eAAe;IAC7C,SAAS,CAAC,EAAE;;;;MAA8B;IAE1C,SAAS,CAAC,eAAe,CACvB,GAAG,EAAE,YAAY,EACjB,IAAI,EAAE,QAAQ,EACd,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM,EACZ,QAAQ,EAAE,MAAM,EAChB,WAAW,EAAE,MAAM,EACnB,WAAW,EAAE,MAAM,EACnB,QAAQ,EAAE,MAAM,GACf,SAAS,GAAG,IAAI;CAsBpB"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { AnalogSynthBase } from "../Analog/AnalogSynthBase.js";
|
|
2
|
+
/**
|
|
3
|
+
* Synthesizer strategy for Brass and Wind instruments with a slow filter envelope.
|
|
4
|
+
*/
|
|
5
|
+
export class BrassSynth extends AnalogSynthBase {
|
|
6
|
+
constructor() {
|
|
7
|
+
super(...arguments);
|
|
8
|
+
this._c = { v: 0.5, a: 0.1, r: 0.1 };
|
|
9
|
+
}
|
|
10
|
+
_setupSynthesis(ctx, gain, time, freq, velocity, sustainTime, releaseTime, stopTime) {
|
|
11
|
+
const osc = this._osc(ctx, 1 /* Osc.Square */, 0, gain);
|
|
12
|
+
this._set(osc.frequency, freq * 0.95, time);
|
|
13
|
+
this._exp(osc.frequency, freq, time + 0.05);
|
|
14
|
+
const blareGain = this._gain(ctx, 0, gain);
|
|
15
|
+
this._set(blareGain.gain, 0, time);
|
|
16
|
+
this._lin(blareGain.gain, Math.max(0.001, velocity * 0.25), time + 0.05);
|
|
17
|
+
this._exp(blareGain.gain, 0.001, time + 0.2);
|
|
18
|
+
const blare = this._osc(ctx, 2 /* Osc.Sawtooth */, freq * 2, blareGain);
|
|
19
|
+
const filter = this._filter(ctx, 0 /* Filter.Lowpass */);
|
|
20
|
+
this._set(filter.frequency, freq + 400, time);
|
|
21
|
+
this._lin(filter.frequency, freq + 1500 + velocity * 1000, time + 0.1);
|
|
22
|
+
this._exp(filter.frequency, freq + 400, time + sustainTime + releaseTime);
|
|
23
|
+
gain.connect(filter);
|
|
24
|
+
this._on(time, stopTime, osc);
|
|
25
|
+
this._on(time, time + 0.2, blare);
|
|
26
|
+
return filter;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
//# sourceMappingURL=BrassSynth.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BrassSynth.js","sourceRoot":"","sources":["../../../Instruments/Decay/BrassSynth.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAG/D;;GAEG;AACH,MAAM,OAAO,UAAW,SAAQ,eAAe;IAA/C;;QACY,OAAE,GAAG,EAAE,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,GAAG,EAAE,CAAC;IAiC5C,CAAC;IA/BW,eAAe,CACvB,GAAiB,EACjB,IAAc,EACd,IAAY,EACZ,IAAY,EACZ,QAAgB,EACh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IAAI,GAAG,WAAW,GAAG,WAAW,CAAC,CAAC;QAE1E,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;QACrB,IAAI,CAAC,GAAG,CAAC,IAAI,EAAE,QAAQ,EAAE,GAAG,CAAC,CAAC;QAC9B,IAAI,CAAC,GAAG,CAAC,IAAI,EAAE,IAAI,GAAG,GAAG,EAAE,KAAK,CAAC,CAAC;QAElC,OAAO,MAAM,CAAC;IAChB,CAAC;CACF"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { DecaySynthBase } from "./DecaySynthBase.js";
|
|
2
|
+
/**
|
|
3
|
+
* Synthesizer strategy for Chromatic Percussion (Bells, Marimba, Vibraphone).
|
|
4
|
+
* Characterized by a pure tone with a very fast attack and immediate decay.
|
|
5
|
+
*/
|
|
6
|
+
export declare class ChromaticPercussionSynth extends DecaySynthBase {
|
|
7
|
+
protected _c: {
|
|
8
|
+
v: number;
|
|
9
|
+
a: number;
|
|
10
|
+
d: number;
|
|
11
|
+
m: number;
|
|
12
|
+
};
|
|
13
|
+
protected _setupSynthesis(ctx: AudioContext, masterGain: GainNode, gain: GainNode, time: number, freq: number, velocity: number, safeDuration: number, stopTime: number): AudioNode | void;
|
|
14
|
+
}
|
|
15
|
+
//# sourceMappingURL=ChromaticPercussionSynth.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ChromaticPercussionSynth.d.ts","sourceRoot":"","sources":["../../../Instruments/Decay/ChromaticPercussionSynth.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAGrD;;;GAGG;AACH,qBAAa,wBAAyB,SAAQ,cAAc;IAC1D,SAAS,CAAC,EAAE;;;;;MAAwC;IAEpD,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;CAcpB"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { DecaySynthBase } from "./DecaySynthBase.js";
|
|
2
|
+
/**
|
|
3
|
+
* Synthesizer strategy for Chromatic Percussion (Bells, Marimba, Vibraphone).
|
|
4
|
+
* Characterized by a pure tone with a very fast attack and immediate decay.
|
|
5
|
+
*/
|
|
6
|
+
export class ChromaticPercussionSynth extends DecaySynthBase {
|
|
7
|
+
constructor() {
|
|
8
|
+
super(...arguments);
|
|
9
|
+
this._c = { v: 0.7, a: 0.005, d: 0.5, m: 6.0 };
|
|
10
|
+
}
|
|
11
|
+
_setupSynthesis(ctx, masterGain, gain, time, freq, velocity, safeDuration, stopTime) {
|
|
12
|
+
const osc = this._osc(ctx, 0 /* Osc.Sine */, 0, gain);
|
|
13
|
+
this._set(osc.frequency, freq * 1.1, time);
|
|
14
|
+
this._exp(osc.frequency, freq, time + 0.02);
|
|
15
|
+
const overtoneGain = this._gain(ctx, 0, masterGain);
|
|
16
|
+
this._set(overtoneGain.gain, Math.max(0.001, velocity * 0.25), time);
|
|
17
|
+
this._exp(overtoneGain.gain, 0.001, time + safeDuration);
|
|
18
|
+
const overtone = this._osc(ctx, 0 /* Osc.Sine */, freq * 2.76, overtoneGain);
|
|
19
|
+
overtoneGain.connect(masterGain);
|
|
20
|
+
this._on(time, stopTime, osc, overtone);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
//# sourceMappingURL=ChromaticPercussionSynth.js.map
|
|
@@ -0,0 +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,wBAAyB,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
export type DecayCfg = {
|
|
3
|
+
v: number;
|
|
4
|
+
a: number;
|
|
5
|
+
d: number;
|
|
6
|
+
m: number;
|
|
7
|
+
};
|
|
8
|
+
/**
|
|
9
|
+
* Abstract base class for plucked, struck, and decaying synthesizers.
|
|
10
|
+
* Handles GainNode creation, Nyquist safety limits, and decay volume envelopes.
|
|
11
|
+
*/
|
|
12
|
+
export declare abstract class DecaySynthBase extends CoreSynthBase {
|
|
13
|
+
protected _c: DecayCfg;
|
|
14
|
+
_playNote(ctx: AudioContext, masterGain: GainNode, time: number, freq: number, duration: number, velocity: number): void;
|
|
15
|
+
protected _cfg(): DecayCfg;
|
|
16
|
+
/** Override this for complex envelopes (like electric guitar compression) */
|
|
17
|
+
protected _applyDecay(gainParam: AudioParam, peakVol: number, time: number, attack: number, safeDuration: number, decayTail: number): void;
|
|
18
|
+
/**
|
|
19
|
+
* Set up the specific oscillators and filters for this instrument.
|
|
20
|
+
*/
|
|
21
|
+
protected abstract _setupSynthesis(ctx: AudioContext, masterGain: GainNode, gain: GainNode, time: number, freq: number, velocity: number, safeDuration: number, stopTime: number): AudioNode | void;
|
|
22
|
+
}
|
|
23
|
+
//# sourceMappingURL=DecaySynthBase.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DecaySynthBase.d.ts","sourceRoot":"","sources":["../../../Instruments/Decay/DecaySynthBase.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAEpD,MAAM,MAAM,QAAQ,GAAG;IAAE,CAAC,EAAE,MAAM,CAAC;IAAC,CAAC,EAAE,MAAM,CAAC;IAAC,CAAC,EAAE,MAAM,CAAC;IAAC,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC;AAEtE;;;GAGG;AACH,8BAAsB,cAAe,SAAQ,aAAa;IACxD,SAAS,CAAC,EAAE,EAAE,QAAQ,CAAuC;IAEtD,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,IAAI,IAAI,QAAQ;IAI1B,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"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { CoreSynthBase } from "../CoreSynthBase.js";
|
|
2
|
+
/**
|
|
3
|
+
* Abstract base class for plucked, struck, and decaying synthesizers.
|
|
4
|
+
* Handles GainNode creation, Nyquist safety limits, and decay volume envelopes.
|
|
5
|
+
*/
|
|
6
|
+
export class DecaySynthBase extends CoreSynthBase {
|
|
7
|
+
constructor() {
|
|
8
|
+
super(...arguments);
|
|
9
|
+
this._c = { v: 0.5, a: 0.02, d: 0.2, m: 4.0 };
|
|
10
|
+
}
|
|
11
|
+
_playNote(ctx, masterGain, time, freq, duration, velocity) {
|
|
12
|
+
const gain = ctx.createGain();
|
|
13
|
+
const c = this._cfg();
|
|
14
|
+
const peakVol = Math.max(0.001, velocity * c.v);
|
|
15
|
+
/** Physical strings/mallets stop vibrating quickly. Protects against stuck MIDI notes. */
|
|
16
|
+
const safeDuration = Math.max(0.02, Math.min(duration, c.m));
|
|
17
|
+
this._set(gain.gain, 0, time);
|
|
18
|
+
this._lin(gain.gain, peakVol, time + c.a);
|
|
19
|
+
this._applyDecay(gain.gain, peakVol, time, c.a, safeDuration, c.d);
|
|
20
|
+
/** Pad the oscillator stop time slightly past the volume decay to prevent digital clicking */
|
|
21
|
+
const stopTime = time + safeDuration + c.d + 0.1;
|
|
22
|
+
const output = this._setupSynthesis(ctx, masterGain, gain, time, freq, velocity, safeDuration, stopTime);
|
|
23
|
+
const finalNode = output || gain;
|
|
24
|
+
finalNode.connect(masterGain);
|
|
25
|
+
this._gc(ctx, time, stopTime + 2.0, finalNode);
|
|
26
|
+
}
|
|
27
|
+
_cfg() {
|
|
28
|
+
return this._c;
|
|
29
|
+
}
|
|
30
|
+
/** Override this for complex envelopes (like electric guitar compression) */
|
|
31
|
+
_applyDecay(gainParam, peakVol, time, attack, safeDuration, decayTail) {
|
|
32
|
+
this._exp(gainParam, 0.001, time + safeDuration + decayTail);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
//# sourceMappingURL=DecaySynthBase.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DecaySynthBase.js","sourceRoot":"","sources":["../../../Instruments/Decay/DecaySynthBase.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAIpD;;;GAGG;AACH,MAAM,OAAgB,cAAe,SAAQ,aAAa;IAA1D;;QACY,OAAE,GAAa,EAAE,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,GAAG,EAAE,CAAC;IAuE/D,CAAC;IArEQ,SAAS,CACd,GAAiB,EACjB,UAAoB,EACpB,IAAY,EACZ,IAAY,EACZ,QAAgB,EAChB,QAAgB;QAEhB,MAAM,IAAI,GAAG,GAAG,CAAC,UAAU,EAAE,CAAC;QAE9B,MAAM,CAAC,GAAG,IAAI,CAAC,IAAI,EAAE,CAAC;QACtB,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AC,SAAS,EAAE,KAAK,EAAE,IAAI,GAAG,YAAY,GAAG,SAAS,CAAC,CAAC;IAC/D,CAAC;CAeF"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { DecaySynthBase } from "./DecaySynthBase.js";
|
|
2
|
+
/**
|
|
3
|
+
* Synthesizer strategy for Electric and Distorted Guitars.
|
|
4
|
+
*/
|
|
5
|
+
export declare class ElectricGuitarSynth extends DecaySynthBase {
|
|
6
|
+
protected _c: {
|
|
7
|
+
v: number;
|
|
8
|
+
a: number;
|
|
9
|
+
d: number;
|
|
10
|
+
m: number;
|
|
11
|
+
};
|
|
12
|
+
protected _applyDecay(gainParam: AudioParam, peakVol: number, time: number, attack: number, safeDuration: number, decayTail: number): void;
|
|
13
|
+
protected _setupSynthesis(ctx: AudioContext, masterGain: GainNode, gain: GainNode, time: number, freq: number, velocity: number, safeDuration: number, stopTime: number): AudioNode | void;
|
|
14
|
+
}
|
|
15
|
+
//# sourceMappingURL=ElectricGuitarSynth.d.ts.map
|
|
@@ -0,0 +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,EAAE;;;;;MAAuC;IAEnD,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"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { DecaySynthBase } from "./DecaySynthBase.js";
|
|
2
|
+
/**
|
|
3
|
+
* Synthesizer strategy for Electric and Distorted Guitars.
|
|
4
|
+
*/
|
|
5
|
+
export class ElectricGuitarSynth extends DecaySynthBase {
|
|
6
|
+
constructor() {
|
|
7
|
+
super(...arguments);
|
|
8
|
+
this._c = { v: 0.5, a: 0.02, d: 0.2, m: 4.0 };
|
|
9
|
+
}
|
|
10
|
+
_applyDecay(gainParam, peakVol, time, attack, safeDuration, decayTail) {
|
|
11
|
+
/** Compressed sustain mimicking an electric guitar amp */
|
|
12
|
+
this._exp(gainParam, Math.max(0.001, peakVol * 0.4), time + Math.min(0.5, safeDuration));
|
|
13
|
+
this._exp(gainParam, 0.001, time + safeDuration + decayTail);
|
|
14
|
+
}
|
|
15
|
+
_setupSynthesis(ctx, masterGain, gain, time, freq, velocity, safeDuration, stopTime) {
|
|
16
|
+
const filter = this._filterSweep(ctx, 0 /* Filter.Lowpass */, 2500 + velocity * 1500, 600, time, safeDuration);
|
|
17
|
+
const [osc, osc2] = this._stereoOsc(ctx, 2 /* Osc.Sawtooth */, 0, 1, 0, gain);
|
|
18
|
+
this._set(osc.frequency, freq * 1.02, time);
|
|
19
|
+
this._exp(osc.frequency, freq, time + 0.05);
|
|
20
|
+
this._set(osc2.frequency, freq * 1.022, time);
|
|
21
|
+
this._exp(osc2.frequency, freq * 1.002, time + 0.05);
|
|
22
|
+
const vibrato = this._lfo(ctx, 5.0, freq * 0.015, time, 0.2, stopTime, osc.frequency, 0.4);
|
|
23
|
+
vibrato.connect(osc2.frequency);
|
|
24
|
+
gain.connect(filter);
|
|
25
|
+
/** Heavy plectrum attack */
|
|
26
|
+
this._transient(ctx, 1 /* Osc.Square */, 3500, masterGain, time, Math.max(0.001, velocity * 0.25), 0.015);
|
|
27
|
+
this._on(time, stopTime, osc, osc2);
|
|
28
|
+
return filter;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
//# sourceMappingURL=ElectricGuitarSynth.js.map
|
|
@@ -0,0 +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,OAAE,GAAG,EAAE,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,GAAG,EAAE,CAAC;IAyErD,CAAC;IAvEW,WAAW,CACnB,SAAqB,EACrB,OAAe,EACf,IAAY,EACZ,MAAc,EACd,YAAoB,EACpB,SAAiB;QAEjB,0DAA0D;QAC1D,IAAI,CAAC,IAAI,CACP,SAAS,EACT,IAAI,CAAC,GAAG,CAAC,KAAK,EAAE,OAAO,GAAG,GAAG,CAAC,EAC9B,IAAI,GAAG,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,YAAY,CAAC,CACnC,CAAC;QACF,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,KAAK,EAAE,IAAI,GAAG,YAAY,GAAG,SAAS,CAAC,CAAC;IAC/D,CAAC;IAES,eAAe,CACvB,GAAiB,EACjB,UAAoB,EACpB,IAAc,EACd,IAAY,EACZ,IAAY,EACZ,QAAgB,EAChB,YAAoB,EACpB,QAAgB;QAEhB,MAAM,MAAM,GAAG,IAAI,CAAC,YAAY,CAC9B,GAAG,0BAEH,IAAI,GAAG,QAAQ,GAAG,IAAI,EACtB,GAAG,EACH,IAAI,EACJ,YAAY,CACb,CAAC;QAEF,MAAM,CAAC,GAAG,EAAE,IAAI,CAAC,GAAG,IAAI,CAAC,UAAU,CAAC,GAAG,wBAAgB,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,IAAI,CAAC,CAAC;QACtE,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,SAAS,EAAE,IAAI,GAAG,IAAI,EAAE,IAAI,CAAC,CAAC;QAC5C,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,SAAS,EAAE,IAAI,EAAE,IAAI,GAAG,IAAI,CAAC,CAAC;QAC5C,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,IAAI,GAAG,KAAK,EAAE,IAAI,CAAC,CAAC;QAC9C,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,IAAI,GAAG,KAAK,EAAE,IAAI,GAAG,IAAI,CAAC,CAAC;QAErD,MAAM,OAAO,GAAG,IAAI,CAAC,IAAI,CACvB,GAAG,EACH,GAAG,EACH,IAAI,GAAG,KAAK,EACZ,IAAI,EACJ,GAAG,EACH,QAAQ,EACR,GAAG,CAAC,SAAS,EACb,GAAG,CACJ,CAAC;QACF,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;QAEhC,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;QAErB,4BAA4B;QAC5B,IAAI,CAAC,UAAU,CACb,GAAG,sBAEH,IAAI,EACJ,UAAU,EACV,IAAI,EACJ,IAAI,CAAC,GAAG,CAAC,KAAK,EAAE,QAAQ,GAAG,IAAI,CAAC,EAChC,KAAK,CACN,CAAC;QAEF,IAAI,CAAC,GAAG,CAAC,IAAI,EAAE,QAAQ,EAAE,GAAG,EAAE,IAAI,CAAC,CAAC;QAEpC,OAAO,MAAM,CAAC;IAChB,CAAC;CACF"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { DecaySynthBase } from "./DecaySynthBase.js";
|
|
2
|
+
/**
|
|
3
|
+
* Synthesizer strategy for Ethnic instruments (Sitar, Shamisen, Koto).
|
|
4
|
+
* Uses a bandpass filter over a square wave to emulate a hollow, plucked resonator.
|
|
5
|
+
*/
|
|
6
|
+
export declare class EthnicSynth extends DecaySynthBase {
|
|
7
|
+
protected _c: {
|
|
8
|
+
v: number;
|
|
9
|
+
a: number;
|
|
10
|
+
d: number;
|
|
11
|
+
m: number;
|
|
12
|
+
};
|
|
13
|
+
protected _setupSynthesis(ctx: AudioContext, masterGain: GainNode, gain: GainNode, time: number, freq: number, velocity: number, safeDuration: number, stopTime: number): AudioNode | void;
|
|
14
|
+
}
|
|
15
|
+
//# sourceMappingURL=EthnicSynth.d.ts.map
|
|
@@ -0,0 +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,EAAE;;;;;MAAuC;IAEnD,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"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { DecaySynthBase } from "./DecaySynthBase.js";
|
|
2
|
+
/**
|
|
3
|
+
* Synthesizer strategy for Ethnic instruments (Sitar, Shamisen, Koto).
|
|
4
|
+
* Uses a bandpass filter over a square wave to emulate a hollow, plucked resonator.
|
|
5
|
+
*/
|
|
6
|
+
export class EthnicSynth extends DecaySynthBase {
|
|
7
|
+
constructor() {
|
|
8
|
+
super(...arguments);
|
|
9
|
+
this._c = { v: 0.6, a: 0.02, d: 0.1, m: 4.0 };
|
|
10
|
+
}
|
|
11
|
+
_setupSynthesis(ctx, masterGain, gain, time, freq, velocity, safeDuration, stopTime) {
|
|
12
|
+
const osc = this._osc(ctx, 1 /* Osc.Square */, 0, gain);
|
|
13
|
+
this._set(osc.frequency, freq * 1.05, time);
|
|
14
|
+
this._exp(osc.frequency, freq, time + 0.08);
|
|
15
|
+
const filter = this._filterSweep(ctx, 2 /* Filter.Bandpass */, freq * 2.5, freq, time, safeDuration);
|
|
16
|
+
filter.Q.value = 2;
|
|
17
|
+
filter.connect(gain);
|
|
18
|
+
this._on(time, stopTime, osc);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
//# sourceMappingURL=EthnicSynth.js.map
|
|
@@ -0,0 +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,OAAE,GAAG,EAAE,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,GAAG,EAAE,CAAC;IA8BrD,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,IAAI,CAAC,GAAG,sBAAc,CAAC,EAAE,IAAI,CAAC,CAAC;QAChD,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,SAAS,EAAE,IAAI,GAAG,IAAI,EAAE,IAAI,CAAC,CAAC;QAC5C,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,SAAS,EAAE,IAAI,EAAE,IAAI,GAAG,IAAI,CAAC,CAAC;QAE5C,MAAM,MAAM,GAAG,IAAI,CAAC,YAAY,CAC9B,GAAG,2BAEH,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,GAAG,CAAC,IAAI,EAAE,QAAQ,EAAE,GAAG,CAAC,CAAC;IAChC,CAAC;CACF"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { DecaySynthBase } from "./DecaySynthBase.js";
|
|
2
|
+
/**
|
|
3
|
+
* Synthesizer strategy for Acoustic Guitars using a plucked sawtooth.
|
|
4
|
+
*/
|
|
5
|
+
export declare class GuitarSynth extends DecaySynthBase {
|
|
6
|
+
protected _c: {
|
|
7
|
+
v: number;
|
|
8
|
+
a: number;
|
|
9
|
+
d: number;
|
|
10
|
+
m: number;
|
|
11
|
+
};
|
|
12
|
+
protected _setupSynthesis(ctx: AudioContext, masterGain: GainNode, gain: GainNode, time: number, freq: number, velocity: number, safeDuration: number, stopTime: number): AudioNode | void;
|
|
13
|
+
}
|
|
14
|
+
//# sourceMappingURL=GuitarSynth.d.ts.map
|
|
@@ -0,0 +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,EAAE;;;;;MAAuC;IAEnD,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"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { DecaySynthBase } from "./DecaySynthBase.js";
|
|
2
|
+
/**
|
|
3
|
+
* Synthesizer strategy for Acoustic Guitars using a plucked sawtooth.
|
|
4
|
+
*/
|
|
5
|
+
export class GuitarSynth extends DecaySynthBase {
|
|
6
|
+
constructor() {
|
|
7
|
+
super(...arguments);
|
|
8
|
+
this._c = { v: 0.6, a: 0.02, d: 0.2, m: 4.0 };
|
|
9
|
+
}
|
|
10
|
+
_setupSynthesis(ctx, masterGain, gain, time, freq, velocity, safeDuration, stopTime) {
|
|
11
|
+
/** Bright attack that quickly muffles as the acoustic string loses kinetic energy */
|
|
12
|
+
const filter = this._filterSweep(ctx, 0 /* Filter.Lowpass */, 2000 + velocity * 1000, 200, time, safeDuration);
|
|
13
|
+
const osc = this._osc(ctx, 2 /* Osc.Sawtooth */, 0, gain);
|
|
14
|
+
this._set(osc.frequency, freq * 1.02, time);
|
|
15
|
+
this._exp(osc.frequency, freq, time + 0.05);
|
|
16
|
+
gain.connect(filter);
|
|
17
|
+
/** Plectrum Pluck: the sharp, plastic click of a pick striking a steel string */
|
|
18
|
+
this._transient(ctx, 1 /* Osc.Square */, 3500, masterGain, time, Math.max(0.001, velocity * 0.25), 0.015);
|
|
19
|
+
this._on(time, stopTime, osc);
|
|
20
|
+
return filter;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
//# sourceMappingURL=GuitarSynth.js.map
|
|
@@ -0,0 +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,OAAE,GAAG,EAAE,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,GAAG,EAAE,CAAC;IA2CrD,CAAC;IAzCW,eAAe,CACvB,GAAiB,EACjB,UAAoB,EACpB,IAAc,EACd,IAAY,EACZ,IAAY,EACZ,QAAgB,EAChB,YAAoB,EACpB,QAAgB;QAEhB,qFAAqF;QACrF,MAAM,MAAM,GAAG,IAAI,CAAC,YAAY,CAC9B,GAAG,0BAEH,IAAI,GAAG,QAAQ,GAAG,IAAI,EACtB,GAAG,EACH,IAAI,EACJ,YAAY,CACb,CAAC;QAEF,MAAM,GAAG,GAAG,IAAI,CAAC,IAAI,CAAC,GAAG,wBAAgB,CAAC,EAAE,IAAI,CAAC,CAAC;QAClD,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,SAAS,EAAE,IAAI,GAAG,IAAI,EAAE,IAAI,CAAC,CAAC;QAC5C,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,SAAS,EAAE,IAAI,EAAE,IAAI,GAAG,IAAI,CAAC,CAAC;QAE5C,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;QAErB,iFAAiF;QACjF,IAAI,CAAC,UAAU,CACb,GAAG,sBAEH,IAAI,EACJ,UAAU,EACV,IAAI,EACJ,IAAI,CAAC,GAAG,CAAC,KAAK,EAAE,QAAQ,GAAG,IAAI,CAAC,EAChC,KAAK,CACN,CAAC;QAEF,IAAI,CAAC,GAAG,CAAC,IAAI,EAAE,QAAQ,EAAE,GAAG,CAAC,CAAC;QAE9B,OAAO,MAAM,CAAC;IAChB,CAAC;CACF"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { CoreSynthBase } from "../CoreSynthBase.js";
|
|
2
|
+
/**
|
|
3
|
+
* Synthesizer strategy for Karplus-Strong physical modeling.
|
|
4
|
+
* Uses a noise burst fed into a tuned delay line with a feedback filter
|
|
5
|
+
* to accurately simulate the physics of plucked strings (Acoustic Guitar, Harp).
|
|
6
|
+
*/
|
|
7
|
+
export declare class KarplusSynth extends CoreSynthBase {
|
|
8
|
+
_playNote(ctx: AudioContext, masterGain: GainNode, time: number, freq: number, duration: number, velocity: number): void;
|
|
9
|
+
}
|
|
10
|
+
//# sourceMappingURL=KarplusSynth.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"KarplusSynth.d.ts","sourceRoot":"","sources":["../../../Instruments/Decay/KarplusSynth.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAU,MAAM,qBAAqB,CAAC;AAE5D;;;;GAIG;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"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { CoreSynthBase } from "../CoreSynthBase.js";
|
|
2
|
+
/**
|
|
3
|
+
* Synthesizer strategy for Karplus-Strong physical modeling.
|
|
4
|
+
* Uses a noise burst fed into a tuned delay line with a feedback filter
|
|
5
|
+
* to accurately simulate the physics of plucked strings (Acoustic Guitar, Harp).
|
|
6
|
+
*/
|
|
7
|
+
export class KarplusSynth extends CoreSynthBase {
|
|
8
|
+
_playNote(ctx, masterGain, time, freq, duration, velocity) {
|
|
9
|
+
const delayTime = 1 / freq;
|
|
10
|
+
// 1. The Plectrum (A microscopic burst of white noise)
|
|
11
|
+
const burstBuffer = ctx.createBuffer(1, Math.max(1, ctx.sampleRate * delayTime), ctx.sampleRate);
|
|
12
|
+
const data = burstBuffer.getChannelData(0);
|
|
13
|
+
for (let i = 0; i < data.length; i++)
|
|
14
|
+
data[i] = (Math.random() * 2 - 1) * velocity;
|
|
15
|
+
const burst = ctx.createBufferSource();
|
|
16
|
+
burst.buffer = burstBuffer;
|
|
17
|
+
// 2. The String (A delay node exactly the length of the frequency)
|
|
18
|
+
const delay = ctx.createDelay(delayTime);
|
|
19
|
+
delay.delayTime.value = delayTime;
|
|
20
|
+
// 3. The Body Damping (Lowpass filter inside the feedback loop to absorb high frequencies)
|
|
21
|
+
const filter = this._filter(ctx, 0 /* Filter.Lowpass */);
|
|
22
|
+
filter.frequency.value = Math.min(22000, freq * 6);
|
|
23
|
+
// 4. The Tension (Feedback gain)
|
|
24
|
+
const feedback = this._gain(ctx, 0.98); // Higher value = longer ring time
|
|
25
|
+
burst.connect(delay).connect(filter).connect(feedback).connect(delay);
|
|
26
|
+
const output = this._gain(ctx, 0, masterGain);
|
|
27
|
+
this._set(output.gain, 1, time);
|
|
28
|
+
this._exp(output.gain, 0.001, time + duration);
|
|
29
|
+
delay.connect(output);
|
|
30
|
+
this._on(time, time + duration, burst);
|
|
31
|
+
this._gc(ctx, time, time + duration + 3.0, output, delay, filter, feedback);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
//# sourceMappingURL=KarplusSynth.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"KarplusSynth.js","sourceRoot":"","sources":["../../../Instruments/Decay/KarplusSynth.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAU,MAAM,qBAAqB,CAAC;AAE5D;;;;GAIG;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,I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CAAC;QAEvC,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,IAAI,EAAE,IAAI,GAAG,QAAQ,GAAG,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,QAAQ,CAAC,CAAC;IAC9E,CAAC;CACF"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { DecaySynthBase } from "./DecaySynthBase.js";
|
|
2
|
+
/**
|
|
3
|
+
* Synthesizer strategy for Piano and similar percussive-melodic instruments.
|
|
4
|
+
*/
|
|
5
|
+
export declare class PianoSynth extends DecaySynthBase {
|
|
6
|
+
protected _c: {
|
|
7
|
+
v: number;
|
|
8
|
+
a: number;
|
|
9
|
+
d: number;
|
|
10
|
+
m: number;
|
|
11
|
+
};
|
|
12
|
+
protected _setupSynthesis(ctx: AudioContext, masterGain: GainNode, gain: GainNode, time: number, freq: number, velocity: number, safeDuration: number, stopTime: number): AudioNode | void;
|
|
13
|
+
}
|
|
14
|
+
//# sourceMappingURL=PianoSynth.d.ts.map
|
|
@@ -0,0 +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,EAAE;;;;;MAAwC;IAEpD,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"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { DecaySynthBase } from "./DecaySynthBase.js";
|
|
2
|
+
/**
|
|
3
|
+
* Synthesizer strategy for Piano and similar percussive-melodic instruments.
|
|
4
|
+
*/
|
|
5
|
+
export class PianoSynth extends DecaySynthBase {
|
|
6
|
+
constructor() {
|
|
7
|
+
super(...arguments);
|
|
8
|
+
this._c = { v: 0.8, a: 0.015, d: 0.1, m: 5.0 };
|
|
9
|
+
}
|
|
10
|
+
_setupSynthesis(ctx, masterGain, gain, time, freq, velocity, safeDuration, stopTime) {
|
|
11
|
+
/** Key-tracking the filter ensures high notes aren't artificially muffled or phase-distorted. Capped at Nyquist. */
|
|
12
|
+
const filter = this._filterSweep(ctx, 0 /* Filter.Lowpass */, freq + 800 + velocity * 1000, freq + 200, time, Math.min(safeDuration, 1.0));
|
|
13
|
+
const osc1 = this._osc(ctx, 3 /* Osc.Triangle */, freq, gain);
|
|
14
|
+
/** Slight inharmonicity stretching, strictly capped below Nyquist to prevent digital aliasing */
|
|
15
|
+
const overtoneGain = this._gain(ctx, 0);
|
|
16
|
+
const osc2 = this._osc(ctx, 0 /* Osc.Sine */, freq * 2.003, overtoneGain);
|
|
17
|
+
const osc3 = this._osc(ctx, 0 /* Osc.Sine */, freq * 3.007, overtoneGain);
|
|
18
|
+
/** Dynamically pan lower keys to the left ear, and higher keys to the right ear */
|
|
19
|
+
const panner = this._pan(ctx, Math.max(-0.8, Math.min(0.8, (freq - 261.6) / 800)));
|
|
20
|
+
/** Sympathetic string resonance: metallic clangs decay much faster than the fundamental */
|
|
21
|
+
this._set(overtoneGain.gain, 0, time);
|
|
22
|
+
this._lin(overtoneGain.gain, Math.max(0.001, velocity * 0.15), time + 0.01);
|
|
23
|
+
this._exp(overtoneGain.gain, 0.001, time + Math.min(safeDuration, 0.5));
|
|
24
|
+
overtoneGain.connect(panner);
|
|
25
|
+
/** Mechanical Hammer Thump: the physical impact of the wooden hammer on the strings */
|
|
26
|
+
this._transient(ctx, 0 /* Osc.Sine */, 60, panner, time, Math.max(0.001, velocity * 0.4), 0.05, 0.005);
|
|
27
|
+
gain.connect(panner).connect(filter);
|
|
28
|
+
this._on(time, stopTime, osc1, osc2, osc3);
|
|
29
|
+
return filter;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
//# sourceMappingURL=PianoSynth.js.map
|
|
@@ -0,0 +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,OAAE,GAAG,EAAE,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,GAAG,EAAE,CAAC;IA0DtD,CAAC;IAxDW,eAAe,CACvB,GAAiB,EACjB,UAAoB,EACpB,IAAc,EACd,IAAY,EACZ,IAAY,EACZ,QAAgB,EAChB,YAAoB,EACpB,QAAgB;QAEhB,oHAAoH;QACpH,MAAM,MAAM,GAAG,IAAI,CAAC,YAAY,CAC9B,GAAG,0BAEH,IAAI,GAAG,GAAG,GAAG,QAAQ,GAAG,IAAI,EAC5B,IAAI,GAAG,GAAG,EACV,IAAI,EACJ,IAAI,CAAC,GAAG,CAAC,YAAY,EAAE,GAAG,CAAC,CAC5B,CAAC;QACF,MAAM,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC,GAAG,wBAAgB,IAAI,EAAE,IAAI,CAAC,CAAC;QAEtD,iGAAiG;QACjG,MAAM,YAAY,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC;QACxC,MAAM,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC,GAAG,oBAAY,IAAI,GAAG,KAAK,EAAE,YAAY,CAAC,CAAC;QAClE,MAAM,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC,GAAG,oBAAY,IAAI,GAAG,KAAK,EAAE,YAAY,CAAC,CAAC;QAElE,mFAAmF;QACnF,MAAM,MAAM,GAAG,IAAI,CAAC,IAAI,CACtB,GAAG,EACH,IAAI,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,CAAC,IAAI,GAAG,KAAK,CAAC,GAAG,GAAG,CAAC,CAAC,CACpD,CAAC;QAEF,2FAA2F;QAC3F,IAAI,CAAC,IAAI,CAAC,YAAY,CAAC,IAAI,EAAE,CAAC,EAAE,IAAI,CAAC,CAAC;QACtC,IAAI,CAAC,IAAI,CAAC,YAAY,CAAC,IAAI,EAAE,IAAI,CAAC,GAAG,CAAC,KAAK,EAAE,QAAQ,GAAG,IAAI,CAAC,EAAE,IAAI,GAAG,IAAI,CAAC,CAAC;QAC5E,IAAI,CAAC,IAAI,CAAC,YAAY,CAAC,IAAI,EAAE,KAAK,EAAE,IAAI,GAAG,IAAI,CAAC,GAAG,CAAC,YAAY,EAAE,GAAG,CAAC,CAAC,CAAC;QACxE,YAAY,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;QAE7B,uFAAuF;QACvF,IAAI,CAAC,UAAU,CACb,GAAG,oBAEH,EAAE,EACF,MAAM,EACN,IAAI,EACJ,IAAI,CAAC,GAAG,CAAC,KAAK,EAAE,QAAQ,GAAG,GAAG,CAAC,EAC/B,IAAI,EACJ,KAAK,CACN,CAAC;QAEF,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;QAErC,IAAI,CAAC,GAAG,CAAC,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC;QAE3C,OAAO,MAAM,CAAC;IAChB,CAAC;CACF"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { DecaySynthBase } from "./DecaySynthBase.js";
|
|
2
|
+
/**
|
|
3
|
+
* Synthesizer strategy for 80s Slap Bass (DX7/Seinfeld style).
|
|
4
|
+
* Characterized by a very snappy filter envelope and a metallic transient "pop".
|
|
5
|
+
*/
|
|
6
|
+
export declare class SlapBassSynth extends DecaySynthBase {
|
|
7
|
+
protected _c: {
|
|
8
|
+
v: number;
|
|
9
|
+
a: number;
|
|
10
|
+
d: number;
|
|
11
|
+
m: number;
|
|
12
|
+
};
|
|
13
|
+
protected _setupSynthesis(ctx: AudioContext, masterGain: GainNode, gain: GainNode, time: number, freq: number, velocity: number, safeDuration: number, stopTime: number): AudioNode | void;
|
|
14
|
+
}
|
|
15
|
+
//# sourceMappingURL=SlapBassSynth.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SlapBassSynth.d.ts","sourceRoot":"","sources":["../../../Instruments/Decay/SlapBassSynth.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAGrD;;;GAGG;AACH,qBAAa,aAAc,SAAQ,cAAc;IAC/C,SAAS,CAAC,EAAE;;;;;MAAyC;IAErD,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;CAkCpB"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { DecaySynthBase } from "./DecaySynthBase.js";
|
|
2
|
+
/**
|
|
3
|
+
* Synthesizer strategy for 80s Slap Bass (DX7/Seinfeld style).
|
|
4
|
+
* Characterized by a very snappy filter envelope and a metallic transient "pop".
|
|
5
|
+
*/
|
|
6
|
+
export class SlapBassSynth extends DecaySynthBase {
|
|
7
|
+
constructor() {
|
|
8
|
+
super(...arguments);
|
|
9
|
+
this._c = { v: 0.9, a: 0.005, d: 0.15, m: 3.0 }; // Ultra-fast attack for the slap
|
|
10
|
+
}
|
|
11
|
+
_setupSynthesis(ctx, masterGain, gain, time, freq, velocity, safeDuration, stopTime) {
|
|
12
|
+
/** The "Pop" - An aggressive lowpass filter sweep that opens bright and snaps shut */
|
|
13
|
+
const filter = this._filterSweep(ctx, 0 /* Filter.Lowpass */, freq * 8 + velocity * 3000, // Very bright on hard velocities
|
|
14
|
+
freq + 100, // Quickly muffles down to the fundamental
|
|
15
|
+
time, 0.1);
|
|
16
|
+
filter.Q.value = 3; // Adds a "quack" resonance to the slap
|
|
17
|
+
/** The Body - Sawtooth for rich harmonics */
|
|
18
|
+
const osc = this._osc(ctx, 2 /* Osc.Sawtooth */, freq, gain);
|
|
19
|
+
/** The Sub - Deep sine wave an octave down to anchor the low end */
|
|
20
|
+
const subOsc = this._osc(ctx, 0 /* Osc.Sine */, freq / 2, gain);
|
|
21
|
+
/** The "Thumb Slap" - A quick, inharmonic metallic burst simulating the string hitting the fretboard */
|
|
22
|
+
this._transient(ctx, 1 /* Osc.Square */, freq * 3.5, filter, time, Math.max(0.001, velocity * 0.4), 0.04);
|
|
23
|
+
gain.connect(filter);
|
|
24
|
+
this._on(time, stopTime, osc, subOsc);
|
|
25
|
+
return filter;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
//# sourceMappingURL=SlapBassSynth.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SlapBassSynth.js","sourceRoot":"","sources":["../../../Instruments/Decay/SlapBassSynth.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAGrD;;;GAGG;AACH,MAAM,OAAO,aAAc,SAAQ,cAAc;IAAjD;;QACY,OAAE,GAAG,EAAE,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,GAAG,EAAE,CAAC,CAAC,iCAAiC;IA6CzF,CAAC;IA3CW,eAAe,CACvB,GAAiB,EACjB,UAAoB,EACpB,IAAc,EACd,IAAY,EACZ,IAAY,EACZ,QAAgB,EAChB,YAAoB,EACpB,QAAgB;QAEhB,sFAAsF;QACtF,MAAM,MAAM,GAAG,IAAI,CAAC,YAAY,CAC9B,GAAG,0BAEH,IAAI,GAAG,CAAC,GAAG,QAAQ,GAAG,IAAI,EAAE,iCAAiC;QAC7D,IAAI,GAAG,GAAG,EAAE,0CAA0C;QACtD,IAAI,EACJ,GAAG,CACJ,CAAC;QACF,MAAM,CAAC,CAAC,CAAC,KAAK,GAAG,CAAC,CAAC,CAAC,uCAAuC;QAE3D,6CAA6C;QAC7C,MAAM,GAAG,GAAG,IAAI,CAAC,IAAI,CAAC,GAAG,wBAAgB,IAAI,EAAE,IAAI,CAAC,CAAC;QAErD,oEAAoE;QACpE,MAAM,MAAM,GAAG,IAAI,CAAC,IAAI,CAAC,GAAG,oBAAY,IAAI,GAAG,CAAC,EAAE,IAAI,CAAC,CAAC;QAExD,wGAAwG;QACxG,IAAI,CAAC,UAAU,CACb,GAAG,sBAEH,IAAI,GAAG,GAAG,EACV,MAAM,EACN,IAAI,EACJ,IAAI,CAAC,GAAG,CAAC,KAAK,EAAE,QAAQ,GAAG,GAAG,CAAC,EAC/B,IAAI,CACL,CAAC;QAEF,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;QACrB,IAAI,CAAC,GAAG,CAAC,IAAI,EAAE,QAAQ,EAAE,GAAG,EAAE,MAAM,CAAC,CAAC;QAEtC,OAAO,MAAM,CAAC;IAChB,CAAC;CACF"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Interface for all synthesizer instrument strategies.
|
|
3
|
+
*/
|
|
4
|
+
export interface ISynthInstrument {
|
|
5
|
+
/**
|
|
6
|
+
* Synthesizes and schedules a note.
|
|
7
|
+
* @param {AudioContext} ctx - The active AudioContext.
|
|
8
|
+
* @param {GainNode} masterGain - The master output gain node.
|
|
9
|
+
* @param {number} time - The AudioContext time to start the note.
|
|
10
|
+
* @param {number} freq - Note frequency in Hz.
|
|
11
|
+
* @param {number} duration - The duration in seconds.
|
|
12
|
+
* @param {number} velocity - The velocity/volume between 0.0 and 1.0.
|
|
13
|
+
*/
|
|
14
|
+
_playNote(ctx: AudioContext, masterGain: GainNode, time: number, freq: number, duration: number, velocity: number): void;
|
|
15
|
+
}
|
|
16
|
+
//# sourceMappingURL=ISynthInstrument.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ISynthInstrument.d.ts","sourceRoot":"","sources":["../../Instruments/ISynthInstrument.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B;;;;;;;;OAQG;IACH,SAAS,CAAC,GAAG,EAAE,YAAY,EAAE,UAAU,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;CAC1H"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ISynthInstrument.js","sourceRoot":"","sources":["../../Instruments/ISynthInstrument.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"InstrumentFactory.d.ts","sourceRoot":"","sources":["../../Instruments/InstrumentFactory.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"InstrumentFactory.js","sourceRoot":"","sources":["../../Instruments/InstrumentFactory.ts"],"names":[],"mappings":";AAAA,0CAA0C;AAC1C,sHAAsH"}
|