@blibliki/engine 0.1.5 → 0.1.7
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/build/Engine.d.ts +5 -41
- package/build/Engine.js +3 -3
- package/build/Engine.js.map +1 -1
- package/build/Module/Base.d.ts +6 -20
- package/build/Module/Base.js +4 -20
- package/build/Module/Base.js.map +1 -1
- package/build/Module/BitCrusher.d.ts +2 -1
- package/build/Module/BitCrusher.js +3 -3
- package/build/Module/BitCrusher.js.map +1 -1
- package/build/Module/Delay.d.ts +1 -0
- package/build/Module/Delay.js +2 -2
- package/build/Module/Delay.js.map +1 -1
- package/build/Module/Distortion.d.ts +1 -0
- package/build/Module/Distortion.js +2 -2
- package/build/Module/Distortion.js.map +1 -1
- package/build/Module/Effect.d.ts +2 -2
- package/build/Module/Effect.js +1 -2
- package/build/Module/Effect.js.map +1 -1
- package/build/Module/Envelope/AmpEnvelope.d.ts +4 -2
- package/build/Module/Envelope/AmpEnvelope.js +5 -6
- package/build/Module/Envelope/AmpEnvelope.js.map +1 -1
- package/build/Module/Envelope/Base.d.ts +9 -7
- package/build/Module/Envelope/Base.js +11 -11
- package/build/Module/Envelope/Base.js.map +1 -1
- package/build/Module/Envelope/FreqEnvelope.d.ts +3 -2
- package/build/Module/Envelope/FreqEnvelope.js +5 -6
- package/build/Module/Envelope/FreqEnvelope.js.map +1 -1
- package/build/Module/Envelope/index.d.ts +1 -1
- package/build/Module/Envelope/index.js +1 -1
- package/build/Module/Envelope/index.js.map +1 -1
- package/build/Module/Filter.d.ts +9 -8
- package/build/Module/Filter.js +10 -9
- package/build/Module/Filter.js.map +1 -1
- package/build/Module/Master.d.ts +2 -1
- package/build/Module/Master.js +2 -2
- package/build/Module/Master.js.map +1 -1
- package/build/Module/MidiSelector.d.ts +3 -0
- package/build/Module/MidiSelector.js +13 -6
- package/build/Module/MidiSelector.js.map +1 -1
- package/build/Module/Oscillator.d.ts +6 -5
- package/build/Module/Oscillator.js +7 -7
- package/build/Module/Oscillator.js.map +1 -1
- package/build/Module/PolyModule.d.ts +10 -18
- package/build/Module/PolyModule.js +11 -26
- package/build/Module/PolyModule.js.map +1 -1
- package/build/Module/Reverb.d.ts +1 -0
- package/build/Module/Reverb.js +2 -2
- package/build/Module/Reverb.js.map +1 -1
- package/build/Module/VirtualMidi.d.ts +3 -2
- package/build/Module/VirtualMidi.js +2 -2
- package/build/Module/VirtualMidi.js.map +1 -1
- package/build/Module/VoiceScheduler.d.ts +8 -7
- package/build/Module/VoiceScheduler.js +6 -6
- package/build/Module/VoiceScheduler.js.map +1 -1
- package/build/Module/Volume.d.ts +6 -5
- package/build/Module/Volume.js +7 -7
- package/build/Module/Volume.js.map +1 -1
- package/build/Module/index.d.ts +2 -17
- package/build/Module/index.js +24 -41
- package/build/Module/index.js.map +1 -1
- package/build/index.d.ts +0 -1
- package/build/index.js +0 -1
- package/build/index.js.map +1 -1
- package/package.json +3 -1
- package/src/Engine.ts +2 -7
- package/src/Module/Base.ts +9 -21
- package/src/Module/BitCrusher.ts +4 -3
- package/src/Module/Delay.ts +3 -2
- package/src/Module/Distortion.ts +3 -2
- package/src/Module/Effect.ts +1 -3
- package/src/Module/Envelope/AmpEnvelope.ts +6 -6
- package/src/Module/Envelope/Base.ts +12 -13
- package/src/Module/Envelope/FreqEnvelope.ts +6 -6
- package/src/Module/Envelope/index.ts +1 -1
- package/src/Module/Filter.ts +17 -15
- package/src/Module/Master.ts +3 -2
- package/src/Module/MidiSelector.ts +15 -6
- package/src/Module/Oscillator.ts +10 -10
- package/src/Module/PolyModule.ts +19 -30
- package/src/Module/Reverb.ts +3 -2
- package/src/Module/VirtualMidi.ts +2 -2
- package/src/Module/VoiceScheduler.ts +8 -10
- package/src/Module/Volume.ts +9 -9
- package/src/Module/index.ts +27 -41
- package/src/index.ts +0 -1
package/src/Module/Filter.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { Filter as InternalFilter } from "tone";
|
|
2
2
|
|
|
3
|
-
import { FreqEnvelope } from "./Envelope";
|
|
4
|
-
import Module, {
|
|
5
|
-
import PolyModule
|
|
6
|
-
import { PolyFreqEnvelope } from "./Envelope/FreqEnvelope";
|
|
3
|
+
import { FreqEnvelope, MonoFreqEnvelope } from "./Envelope";
|
|
4
|
+
import Module, { Voicable } from "./Base";
|
|
5
|
+
import PolyModule from "./PolyModule";
|
|
7
6
|
|
|
8
|
-
interface FilterInterface {
|
|
7
|
+
interface FilterInterface extends Voicable {
|
|
9
8
|
cutoff: number;
|
|
9
|
+
filterType: BiquadFilterType;
|
|
10
10
|
resonance: number;
|
|
11
11
|
envelopeAmount: number;
|
|
12
12
|
voiceNo?: number;
|
|
@@ -18,16 +18,16 @@ const InitialProps: FilterInterface = {
|
|
|
18
18
|
cutoff: 20000,
|
|
19
19
|
resonance: 0,
|
|
20
20
|
envelopeAmount: 0,
|
|
21
|
+
filterType: "lowpass",
|
|
21
22
|
};
|
|
22
23
|
|
|
23
|
-
|
|
24
|
-
private _envelope:
|
|
24
|
+
class MonoFilter extends Module<InternalFilter, FilterInterface> {
|
|
25
|
+
private _envelope: MonoFreqEnvelope;
|
|
25
26
|
|
|
26
27
|
constructor(name: string, props: FilterProps) {
|
|
27
28
|
super(new InternalFilter({ type: "lowpass" }), {
|
|
28
29
|
name,
|
|
29
30
|
props: { ...InitialProps, ...props },
|
|
30
|
-
type: ModuleType.Filter,
|
|
31
31
|
});
|
|
32
32
|
}
|
|
33
33
|
|
|
@@ -71,19 +71,21 @@ export default class Filter extends Module<InternalFilter, FilterInterface> {
|
|
|
71
71
|
this._envelope.amount = value;
|
|
72
72
|
}
|
|
73
73
|
|
|
74
|
-
conntectedEnvelope(envelope:
|
|
74
|
+
conntectedEnvelope(envelope: MonoFreqEnvelope) {
|
|
75
75
|
this._envelope = envelope;
|
|
76
76
|
this._envelope.frequency = this.cutoff;
|
|
77
77
|
this._envelope.amount = this.envelopeAmount;
|
|
78
78
|
}
|
|
79
79
|
}
|
|
80
80
|
|
|
81
|
-
export class
|
|
81
|
+
export default class Filter extends PolyModule<MonoFilter, FilterInterface> {
|
|
82
|
+
static moduleName = "Filter";
|
|
83
|
+
|
|
82
84
|
constructor(name: string, props: Partial<FilterInterface>) {
|
|
83
|
-
super(
|
|
85
|
+
super({
|
|
84
86
|
name,
|
|
87
|
+
child: MonoFilter,
|
|
85
88
|
props: { ...InitialProps, ...props },
|
|
86
|
-
type: ModuleType.Filter,
|
|
87
89
|
});
|
|
88
90
|
|
|
89
91
|
this.registerBasicInputs();
|
|
@@ -96,13 +98,13 @@ export class PolyFilter extends PolyModule<Filter, FilterInterface> {
|
|
|
96
98
|
name: "frequency",
|
|
97
99
|
pluggable: "frequency",
|
|
98
100
|
onPlug: (output) => {
|
|
99
|
-
this.conntectedEnvelope(output.audioModule as
|
|
101
|
+
this.conntectedEnvelope(output.audioModule as FreqEnvelope);
|
|
100
102
|
},
|
|
101
103
|
});
|
|
102
104
|
}
|
|
103
105
|
|
|
104
|
-
conntectedEnvelope(
|
|
105
|
-
|
|
106
|
+
conntectedEnvelope(freqEnvelope: FreqEnvelope) {
|
|
107
|
+
freqEnvelope.audioModules.forEach((envelope) => {
|
|
106
108
|
if (envelope.voiceNo === undefined) return;
|
|
107
109
|
|
|
108
110
|
const filter = this.findVoice(envelope.voiceNo);
|
package/src/Module/Master.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Destination, getDestination } from "tone";
|
|
2
|
-
import Module
|
|
2
|
+
import Module from "./Base";
|
|
3
3
|
|
|
4
4
|
export interface MasterInterface {}
|
|
5
5
|
|
|
@@ -7,10 +7,11 @@ export default class Master extends Module<
|
|
|
7
7
|
typeof Destination,
|
|
8
8
|
MasterInterface
|
|
9
9
|
> {
|
|
10
|
+
static moduleName = "Master";
|
|
11
|
+
|
|
10
12
|
constructor() {
|
|
11
13
|
super(getDestination(), {
|
|
12
14
|
name: "Master",
|
|
13
|
-
type: ModuleType.Master,
|
|
14
15
|
});
|
|
15
16
|
|
|
16
17
|
this.registerBasicInputs();
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import Engine from "../Engine";
|
|
2
2
|
import MidiEvent from "../MidiEvent";
|
|
3
|
-
import Module, {
|
|
3
|
+
import Module, { DummnyInternalModule } from "./Base";
|
|
4
4
|
import { Output } from "./IO";
|
|
5
5
|
|
|
6
6
|
export interface MidiSelectorInterface {
|
|
@@ -15,13 +15,13 @@ export default class MidiSelector extends Module<
|
|
|
15
15
|
DummnyInternalModule,
|
|
16
16
|
MidiSelectorInterface
|
|
17
17
|
> {
|
|
18
|
+
static moduleName = "MidiSelector";
|
|
18
19
|
midiOutput: Output;
|
|
19
20
|
|
|
20
21
|
constructor(name: string, props: Partial<MidiSelectorInterface>) {
|
|
21
22
|
super(new DummnyInternalModule(), {
|
|
22
23
|
name,
|
|
23
24
|
props: { ...InitialProps, ...props },
|
|
24
|
-
type: ModuleType.MidiSelector,
|
|
25
25
|
});
|
|
26
26
|
|
|
27
27
|
this.registerOutputs();
|
|
@@ -33,16 +33,18 @@ export default class MidiSelector extends Module<
|
|
|
33
33
|
}
|
|
34
34
|
|
|
35
35
|
set selectedId(value: string | null) {
|
|
36
|
-
|
|
37
|
-
const prevMidiDevice = Engine.midiDeviceManager.find(this.selectedId);
|
|
38
|
-
prevMidiDevice?.removeEventListener(this.onMidiEvent);
|
|
39
|
-
}
|
|
36
|
+
this.removeEventListener();
|
|
40
37
|
|
|
41
38
|
this._props = { ...this.props, selectedId: value };
|
|
42
39
|
|
|
43
40
|
this.addEventListener(value);
|
|
44
41
|
}
|
|
45
42
|
|
|
43
|
+
dispose() {
|
|
44
|
+
this.removeEventListener();
|
|
45
|
+
super.dispose();
|
|
46
|
+
}
|
|
47
|
+
|
|
46
48
|
private registerOutputs() {
|
|
47
49
|
this.midiOutput = this.registerOutput({ name: "midi out" });
|
|
48
50
|
}
|
|
@@ -59,4 +61,11 @@ export default class MidiSelector extends Module<
|
|
|
59
61
|
const midiDevice = Engine.midiDeviceManager.find(midiId);
|
|
60
62
|
midiDevice?.addEventListener(this.onMidiEvent);
|
|
61
63
|
}
|
|
64
|
+
|
|
65
|
+
private removeEventListener() {
|
|
66
|
+
if (!this.selectedId) return;
|
|
67
|
+
|
|
68
|
+
const midiDevice = Engine.midiDeviceManager.find(this.selectedId);
|
|
69
|
+
midiDevice?.removeEventListener(this.onMidiEvent);
|
|
70
|
+
}
|
|
62
71
|
}
|
package/src/Module/Oscillator.ts
CHANGED
|
@@ -1,18 +1,17 @@
|
|
|
1
1
|
import MidiEvent from "../MidiEvent";
|
|
2
2
|
import { Oscillator as Osc, ToneOscillatorType } from "tone";
|
|
3
3
|
|
|
4
|
-
import Module, { ModuleType } from "../Module";
|
|
5
4
|
import Note from "../Note";
|
|
6
|
-
import
|
|
5
|
+
import Module, { Voicable } from "./Base";
|
|
6
|
+
import PolyModule from "./PolyModule";
|
|
7
7
|
|
|
8
|
-
export interface OscillatorInterface {
|
|
8
|
+
export interface OscillatorInterface extends Voicable {
|
|
9
9
|
noteName: string;
|
|
10
10
|
fine: number;
|
|
11
11
|
coarse: number;
|
|
12
12
|
wave: string;
|
|
13
13
|
volume: number;
|
|
14
14
|
range: number;
|
|
15
|
-
voiceNo?: number;
|
|
16
15
|
}
|
|
17
16
|
|
|
18
17
|
const InitialProps: OscillatorInterface = {
|
|
@@ -24,14 +23,13 @@ const InitialProps: OscillatorInterface = {
|
|
|
24
23
|
volume: 0,
|
|
25
24
|
};
|
|
26
25
|
|
|
27
|
-
|
|
26
|
+
class MonoOscillator extends Module<Osc, OscillatorInterface> {
|
|
28
27
|
private _note: Note;
|
|
29
28
|
|
|
30
29
|
constructor(name: string, props: Partial<OscillatorInterface>) {
|
|
31
30
|
super(new Osc(), {
|
|
32
31
|
name,
|
|
33
32
|
props: { ...InitialProps, ...props },
|
|
34
|
-
type: ModuleType.Oscillator,
|
|
35
33
|
});
|
|
36
34
|
|
|
37
35
|
this.note = new Note("C3");
|
|
@@ -142,15 +140,17 @@ export default class Oscillator extends Module<Osc, OscillatorInterface> {
|
|
|
142
140
|
}
|
|
143
141
|
}
|
|
144
142
|
|
|
145
|
-
export class
|
|
146
|
-
|
|
143
|
+
export default class Oscillator extends PolyModule<
|
|
144
|
+
MonoOscillator,
|
|
147
145
|
OscillatorInterface
|
|
148
146
|
> {
|
|
147
|
+
static moduleName = "Oscillator";
|
|
148
|
+
|
|
149
149
|
constructor(name: string, props: Partial<OscillatorInterface>) {
|
|
150
|
-
super(
|
|
150
|
+
super({
|
|
151
151
|
name,
|
|
152
|
+
child: MonoOscillator,
|
|
152
153
|
props: { ...InitialProps, ...props },
|
|
153
|
-
type: ModuleType.Oscillator,
|
|
154
154
|
});
|
|
155
155
|
|
|
156
156
|
this.registerBasicOutputs();
|
package/src/Module/PolyModule.ts
CHANGED
|
@@ -1,42 +1,35 @@
|
|
|
1
1
|
import MidiEvent from "../MidiEvent";
|
|
2
2
|
import { v4 as uuidv4 } from "uuid";
|
|
3
|
-
import {
|
|
4
|
-
import Module, { ModuleInterface, ModuleType, Connectable } from "./Base";
|
|
3
|
+
import Module, { Connectable, Voicable } from "./Base";
|
|
5
4
|
import { Input, Output, IOInterface } from "./IO";
|
|
6
5
|
import { AudioModule } from "../Module";
|
|
7
6
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
FreqEnvelope = "freqEnvelope",
|
|
13
|
-
VoiceScheduler = "voiceScheduler",
|
|
14
|
-
Filter = "filter",
|
|
15
|
-
Volume = "volume",
|
|
7
|
+
interface PolyModuleInterface<MonoAudioModule, PropsInterface> {
|
|
8
|
+
name: string;
|
|
9
|
+
child: new (name: string, props: PropsInterface) => MonoAudioModule;
|
|
10
|
+
props: PropsInterface;
|
|
16
11
|
}
|
|
17
12
|
|
|
18
|
-
interface PolyModuleInterface extends ModuleInterface {}
|
|
19
|
-
|
|
20
13
|
export default abstract class PolyModule<
|
|
21
14
|
MonoAudioModule extends Module<Connectable, any>,
|
|
22
|
-
PropsInterface
|
|
15
|
+
PropsInterface extends Voicable
|
|
23
16
|
> {
|
|
17
|
+
static readonly moduleName: string;
|
|
18
|
+
|
|
24
19
|
readonly id: string;
|
|
20
|
+
readonly child: new (name: string, props: PropsInterface) => MonoAudioModule;
|
|
25
21
|
_name: string;
|
|
26
22
|
audioModules: MonoAudioModule[];
|
|
27
23
|
inputs: Input[] = [];
|
|
28
24
|
outputs: Output[] = [];
|
|
29
|
-
readonly _type: PolyModuleType;
|
|
30
|
-
readonly childrenType: ModuleType;
|
|
31
25
|
private _numberOfVoices: number;
|
|
32
26
|
|
|
33
|
-
constructor(
|
|
27
|
+
constructor(params: PolyModuleInterface<MonoAudioModule, PropsInterface>) {
|
|
34
28
|
this.id = uuidv4();
|
|
35
|
-
this._type = type;
|
|
36
|
-
this.childrenType = props.type;
|
|
37
29
|
this.audioModules = [];
|
|
38
30
|
|
|
39
|
-
const { props: extraProps, ...basicProps } =
|
|
31
|
+
const { child, props: extraProps, ...basicProps } = params;
|
|
32
|
+
this.child = child;
|
|
40
33
|
Object.assign(this, basicProps);
|
|
41
34
|
|
|
42
35
|
this.numberOfVoices = 1;
|
|
@@ -45,10 +38,6 @@ export default abstract class PolyModule<
|
|
|
45
38
|
this.registerNumberOfVoicesInput();
|
|
46
39
|
}
|
|
47
40
|
|
|
48
|
-
get type() {
|
|
49
|
-
return this._type;
|
|
50
|
-
}
|
|
51
|
-
|
|
52
41
|
get name() {
|
|
53
42
|
return this._name;
|
|
54
43
|
}
|
|
@@ -58,10 +47,6 @@ export default abstract class PolyModule<
|
|
|
58
47
|
this.audioModules.forEach((m) => (m.name = value));
|
|
59
48
|
}
|
|
60
49
|
|
|
61
|
-
// Do nothing
|
|
62
|
-
// This is a little hack to avoid override type by children module
|
|
63
|
-
set type(value: PolyModuleType) {}
|
|
64
|
-
|
|
65
50
|
get props() {
|
|
66
51
|
if (this.audioModules.length === 0) {
|
|
67
52
|
throw Error("There isn't any initialized module");
|
|
@@ -114,10 +99,12 @@ export default abstract class PolyModule<
|
|
|
114
99
|
if (this.audioModules.length === 0)
|
|
115
100
|
throw Error("There isn't any initialized module");
|
|
116
101
|
|
|
102
|
+
const klass = this.constructor as typeof PolyModule;
|
|
103
|
+
|
|
117
104
|
return {
|
|
118
105
|
...this.audioModules[0].serialize(),
|
|
119
106
|
id: this.id,
|
|
120
|
-
type:
|
|
107
|
+
type: klass.moduleName,
|
|
121
108
|
inputs: this.inputs.map((i) => i.serialize()),
|
|
122
109
|
outputs: this.outputs.map((i) => i.serialize()),
|
|
123
110
|
};
|
|
@@ -224,8 +211,10 @@ export default abstract class PolyModule<
|
|
|
224
211
|
const audioModule = this.audioModules.pop();
|
|
225
212
|
audioModule?.dispose();
|
|
226
213
|
} else {
|
|
227
|
-
const props = this.audioModules.length
|
|
228
|
-
|
|
214
|
+
const props = this.audioModules.length
|
|
215
|
+
? this.props
|
|
216
|
+
: ({} as PropsInterface);
|
|
217
|
+
const audioModule = new this.child(this.name, {
|
|
229
218
|
...props,
|
|
230
219
|
voiceNo: this.audioModules.length,
|
|
231
220
|
});
|
package/src/Module/Reverb.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { Reverb as InternalReverb } from "tone";
|
|
2
2
|
|
|
3
|
-
import { ModuleType } from "./Base";
|
|
4
3
|
import Effect, { EffectInterface } from "./Effect";
|
|
5
4
|
|
|
6
5
|
interface ReverbInterface extends EffectInterface {
|
|
@@ -14,8 +13,10 @@ const InitialProps: Partial<ReverbInterface> = {
|
|
|
14
13
|
};
|
|
15
14
|
|
|
16
15
|
export default class Reverb extends Effect<InternalReverb, ReverbInterface> {
|
|
16
|
+
static moduleName = "Reverb";
|
|
17
|
+
|
|
17
18
|
constructor(name: string, props: Partial<ReverbInterface>) {
|
|
18
|
-
super(name,
|
|
19
|
+
super(name, new InternalReverb(), {
|
|
19
20
|
...InitialProps,
|
|
20
21
|
...props,
|
|
21
22
|
});
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import Engine from "../Engine";
|
|
2
2
|
import MidiEvent from "../MidiEvent";
|
|
3
|
-
import Module, {
|
|
3
|
+
import Module, { DummnyInternalModule } from "./Base";
|
|
4
4
|
import { Output } from "./IO";
|
|
5
5
|
|
|
6
6
|
export interface VirtualMidiInterface {
|
|
@@ -15,13 +15,13 @@ export default class VirtualMidi extends Module<
|
|
|
15
15
|
DummnyInternalModule,
|
|
16
16
|
VirtualMidiInterface
|
|
17
17
|
> {
|
|
18
|
+
static moduleName = "VirtualMidi";
|
|
18
19
|
midiOutput: Output;
|
|
19
20
|
|
|
20
21
|
constructor(name: string, props: VirtualMidiInterface) {
|
|
21
22
|
super(new DummnyInternalModule(), {
|
|
22
23
|
name,
|
|
23
24
|
props: { ...InitialProps, ...props },
|
|
24
|
-
type: ModuleType.VirtualMidi,
|
|
25
25
|
});
|
|
26
26
|
|
|
27
27
|
this.registerInputs();
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import Module, {
|
|
1
|
+
import Module, { DummnyInternalModule, Voicable } from "./Base";
|
|
2
2
|
import MidiEvent from "../MidiEvent";
|
|
3
3
|
import { Input, Output } from "./IO";
|
|
4
|
-
import PolyModule
|
|
4
|
+
import PolyModule from "./PolyModule";
|
|
5
5
|
|
|
6
|
-
export interface VoiceSchedulerInterface {
|
|
6
|
+
export interface VoiceSchedulerInterface extends Voicable {
|
|
7
7
|
polyNumber: number;
|
|
8
8
|
}
|
|
9
9
|
|
|
@@ -11,14 +11,15 @@ export default class VoiceScheduler extends PolyModule<
|
|
|
11
11
|
Voice,
|
|
12
12
|
VoiceSchedulerInterface
|
|
13
13
|
> {
|
|
14
|
+
static moduleName = "VoiceScheduler";
|
|
14
15
|
midiOutput: Output;
|
|
15
16
|
numberOfVoicesOut: Output;
|
|
16
17
|
|
|
17
18
|
constructor(name: string, props: VoiceSchedulerInterface) {
|
|
18
|
-
super(
|
|
19
|
+
super({
|
|
19
20
|
name,
|
|
21
|
+
child: Voice,
|
|
20
22
|
props,
|
|
21
|
-
type: ModuleType.Voice,
|
|
22
23
|
});
|
|
23
24
|
|
|
24
25
|
this.registerInputs();
|
|
@@ -111,11 +112,9 @@ export default class VoiceScheduler extends PolyModule<
|
|
|
111
112
|
}
|
|
112
113
|
}
|
|
113
114
|
|
|
114
|
-
export interface VoiceInterface {
|
|
115
|
-
voiceNo?: number;
|
|
116
|
-
}
|
|
115
|
+
export interface VoiceInterface extends Voicable {}
|
|
117
116
|
|
|
118
|
-
|
|
117
|
+
class Voice extends Module<DummnyInternalModule, VoiceInterface> {
|
|
119
118
|
midiEvent: MidiEvent | null;
|
|
120
119
|
activeNote: string | null;
|
|
121
120
|
triggeredAt: number;
|
|
@@ -124,7 +123,6 @@ export class Voice extends Module<DummnyInternalModule, VoiceInterface> {
|
|
|
124
123
|
constructor(name: string, props: VoiceInterface) {
|
|
125
124
|
super(new DummnyInternalModule(), {
|
|
126
125
|
name,
|
|
127
|
-
type: ModuleType.Voice,
|
|
128
126
|
props,
|
|
129
127
|
});
|
|
130
128
|
}
|
package/src/Module/Volume.ts
CHANGED
|
@@ -1,23 +1,21 @@
|
|
|
1
1
|
import { Volume as Vol } from "tone";
|
|
2
2
|
|
|
3
|
-
import Module, {
|
|
4
|
-
import PolyModule
|
|
3
|
+
import Module, { Voicable } from "./Base";
|
|
4
|
+
import PolyModule from "./PolyModule";
|
|
5
5
|
|
|
6
|
-
export interface VolumeInterface {
|
|
6
|
+
export interface VolumeInterface extends Voicable {
|
|
7
7
|
volume: number;
|
|
8
|
-
voiceNo?: number;
|
|
9
8
|
}
|
|
10
9
|
|
|
11
10
|
const InitialProps: VolumeInterface = {
|
|
12
11
|
volume: -100,
|
|
13
12
|
};
|
|
14
13
|
|
|
15
|
-
|
|
14
|
+
class MonoVolume extends Module<Vol, VolumeInterface> {
|
|
16
15
|
constructor(name: string, props: Partial<VolumeInterface>) {
|
|
17
16
|
super(new Vol(), {
|
|
18
17
|
name,
|
|
19
18
|
props: { ...InitialProps, ...props },
|
|
20
|
-
type: ModuleType.Volume,
|
|
21
19
|
});
|
|
22
20
|
}
|
|
23
21
|
|
|
@@ -32,12 +30,14 @@ export default class Volume extends Module<Vol, VolumeInterface> {
|
|
|
32
30
|
}
|
|
33
31
|
}
|
|
34
32
|
|
|
35
|
-
export class
|
|
33
|
+
export default class Volume extends PolyModule<MonoVolume, VolumeInterface> {
|
|
34
|
+
static moduleName = "Volume";
|
|
35
|
+
|
|
36
36
|
constructor(name: string, props: Partial<VolumeInterface>) {
|
|
37
|
-
super(
|
|
37
|
+
super({
|
|
38
38
|
name,
|
|
39
|
+
child: MonoVolume,
|
|
39
40
|
props: { ...InitialProps, ...props },
|
|
40
|
-
type: ModuleType.Volume,
|
|
41
41
|
});
|
|
42
42
|
|
|
43
43
|
this.registerBasicInputs();
|
package/src/Module/index.ts
CHANGED
|
@@ -1,23 +1,21 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
1
|
+
import { camelCase, upperFirst } from "lodash";
|
|
2
|
+
import Module, { Connectable } from "./Base";
|
|
3
|
+
import PolyModule from "./PolyModule";
|
|
4
|
+
import Oscillator from "./Oscillator";
|
|
4
5
|
import { Envelope, AmpEnvelope, FreqEnvelope } from "./Envelope";
|
|
5
|
-
import Filter
|
|
6
|
+
import Filter from "./Filter";
|
|
6
7
|
import Master from "./Master";
|
|
7
|
-
import VoiceScheduler
|
|
8
|
+
import VoiceScheduler from "./VoiceScheduler";
|
|
8
9
|
import MidiSelector from "./MidiSelector";
|
|
9
|
-
import
|
|
10
|
-
import { PolyFreqEnvelope } from "./Envelope/FreqEnvelope";
|
|
11
|
-
import { PolyEnvelope } from "./Envelope/Base";
|
|
12
|
-
import Volume, { PolyVolume } from "./Volume";
|
|
10
|
+
import Volume from "./Volume";
|
|
13
11
|
import VirtualMidi from "./VirtualMidi";
|
|
14
12
|
import Reverb from "./Reverb";
|
|
15
13
|
import Delay from "./Delay";
|
|
16
14
|
import Distortion from "./Distortion";
|
|
17
15
|
import BitCrusher from "./BitCrusher";
|
|
18
16
|
|
|
19
|
-
export { default
|
|
20
|
-
export { default as PolyModule
|
|
17
|
+
export { default } from "./Base";
|
|
18
|
+
export { default as PolyModule } from "./PolyModule";
|
|
21
19
|
export type { ModuleInterface, Connectable, Triggerable } from "./Base";
|
|
22
20
|
|
|
23
21
|
export { default as Filter } from "./Filter";
|
|
@@ -43,51 +41,39 @@ export function createModule(
|
|
|
43
41
|
return new klass(name, props);
|
|
44
42
|
}
|
|
45
43
|
|
|
46
|
-
|
|
44
|
+
function moduleClassFromType(type: string) {
|
|
45
|
+
type = upperFirst(camelCase(type));
|
|
46
|
+
|
|
47
47
|
switch (type) {
|
|
48
|
-
case
|
|
48
|
+
case Oscillator.moduleName:
|
|
49
49
|
return Oscillator;
|
|
50
|
-
case
|
|
50
|
+
case Envelope.moduleName:
|
|
51
51
|
return Envelope;
|
|
52
|
-
case
|
|
52
|
+
case AmpEnvelope.moduleName:
|
|
53
53
|
return AmpEnvelope;
|
|
54
|
-
case
|
|
54
|
+
case FreqEnvelope.moduleName:
|
|
55
55
|
return FreqEnvelope;
|
|
56
|
-
case
|
|
56
|
+
case Filter.moduleName:
|
|
57
57
|
return Filter;
|
|
58
|
-
case
|
|
58
|
+
case Volume.moduleName:
|
|
59
59
|
return Volume;
|
|
60
|
-
case
|
|
61
|
-
return PolyOscillator;
|
|
62
|
-
case PolyModuleType.Envelope:
|
|
63
|
-
return PolyEnvelope;
|
|
64
|
-
case PolyModuleType.AmpEnvelope:
|
|
65
|
-
return PolyAmpEnvelope;
|
|
66
|
-
case PolyModuleType.FreqEnvelope:
|
|
67
|
-
return PolyFreqEnvelope;
|
|
68
|
-
case PolyModuleType.Filter:
|
|
69
|
-
return PolyFilter;
|
|
70
|
-
case PolyModuleType.Volume:
|
|
71
|
-
return PolyVolume;
|
|
72
|
-
case ModuleType.Master:
|
|
60
|
+
case Master.moduleName:
|
|
73
61
|
return Master;
|
|
74
|
-
case
|
|
75
|
-
return Voice;
|
|
76
|
-
case PolyModuleType.VoiceScheduler:
|
|
62
|
+
case VoiceScheduler.moduleName:
|
|
77
63
|
return VoiceScheduler;
|
|
78
|
-
case
|
|
64
|
+
case MidiSelector.moduleName:
|
|
79
65
|
return MidiSelector;
|
|
80
|
-
case
|
|
66
|
+
case VirtualMidi.moduleName:
|
|
81
67
|
return VirtualMidi;
|
|
82
|
-
case
|
|
68
|
+
case Reverb.moduleName:
|
|
83
69
|
return Reverb;
|
|
84
|
-
case
|
|
70
|
+
case Delay.moduleName:
|
|
85
71
|
return Delay;
|
|
86
|
-
case
|
|
72
|
+
case Distortion.moduleName:
|
|
87
73
|
return Distortion;
|
|
88
|
-
case
|
|
74
|
+
case BitCrusher.moduleName:
|
|
89
75
|
return BitCrusher;
|
|
90
76
|
default:
|
|
91
|
-
throw Error(
|
|
77
|
+
throw Error(`Unknown module type ${type}`);
|
|
92
78
|
}
|
|
93
79
|
}
|
package/src/index.ts
CHANGED