@blibliki/engine 0.1.25 → 0.1.27

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.
Files changed (75) hide show
  1. package/dist/index.js +19484 -0
  2. package/dist/index.umd.cjs +227 -0
  3. package/dist/{build → src}/Engine.d.ts +10 -8
  4. package/dist/{build → src}/core/IO/AudioNode.d.ts +10 -9
  5. package/dist/{build → src}/core/IO/Collection.d.ts +5 -4
  6. package/dist/src/core/IO/ForwardNode/Base.d.ts +19 -0
  7. package/dist/src/core/IO/ForwardNode/index.d.ts +28 -0
  8. package/dist/{build → src}/core/IO/MidiNode.d.ts +9 -8
  9. package/dist/{build → src}/core/IO/Node.d.ts +11 -6
  10. package/dist/src/core/IO/index.d.ts +22 -0
  11. package/dist/{build → src}/core/Module/MonoModule.d.ts +9 -8
  12. package/dist/{build → src}/core/Module/PolyModule.d.ts +13 -10
  13. package/dist/src/core/Module/index.d.ts +7 -0
  14. package/dist/{build → src}/core/midi/ComputerKeyboardInput.d.ts +3 -2
  15. package/dist/{build → src}/core/midi/MidiDevice.d.ts +2 -1
  16. package/dist/{build → src}/core/midi/MidiDeviceManager.d.ts +2 -1
  17. package/dist/{build → src}/core/midi/MidiEvent.d.ts +3 -2
  18. package/dist/src/core/midi/index.d.ts +5 -0
  19. package/dist/src/index.d.ts +9 -0
  20. package/dist/src/main.d.ts +0 -0
  21. package/dist/{build → src}/modules/BitCrusher.d.ts +3 -2
  22. package/dist/{build → src}/modules/Delay.d.ts +3 -2
  23. package/dist/{build → src}/modules/Distortion.d.ts +3 -2
  24. package/dist/{build → src}/modules/Effect.d.ts +3 -2
  25. package/dist/{build → src}/modules/Envelope/AmpEnvelope.d.ts +3 -2
  26. package/dist/{build → src}/modules/Envelope/Base.d.ts +4 -3
  27. package/dist/{build → src}/modules/Envelope/FreqEnvelope.d.ts +4 -3
  28. package/dist/src/modules/Envelope/index.d.ts +3 -0
  29. package/dist/{build → src}/modules/Filter.d.ts +4 -3
  30. package/dist/{build → src}/modules/LFO.d.ts +5 -4
  31. package/dist/{build → src}/modules/Master.d.ts +3 -2
  32. package/dist/{build → src}/modules/MidiSelector.d.ts +3 -2
  33. package/dist/{build → src}/modules/Oscillator.d.ts +7 -6
  34. package/dist/{build → src}/modules/Reverb.d.ts +3 -2
  35. package/dist/{build → src}/modules/Sequencer.d.ts +4 -3
  36. package/dist/{build → src}/modules/VirtualMidi.d.ts +7 -6
  37. package/dist/{build → src}/modules/VoiceScheduler.d.ts +6 -5
  38. package/dist/{build → src}/modules/Volume.d.ts +4 -3
  39. package/dist/src/modules/index.d.ts +18 -0
  40. package/dist/{build → src}/routes.d.ts +2 -1
  41. package/dist/test/MockingModules.d.ts +22 -0
  42. package/dist/test/Module/Oscillator.test.d.ts +1 -0
  43. package/dist/test/core/IO.test.d.ts +1 -0
  44. package/package.json +15 -16
  45. package/src/Engine.ts +14 -1
  46. package/src/core/IO/AudioNode.ts +8 -7
  47. package/src/core/IO/Collection.ts +11 -11
  48. package/src/core/IO/ForwardNode/Base.ts +99 -0
  49. package/src/core/IO/ForwardNode/index.ts +60 -0
  50. package/src/core/IO/MidiNode.ts +5 -5
  51. package/src/core/IO/Node.ts +49 -48
  52. package/src/core/IO/index.ts +28 -13
  53. package/src/core/Module/PolyModule.ts +26 -16
  54. package/src/main.ts +1 -0
  55. package/src/modules/Filter.ts +1 -1
  56. package/src/modules/LFO.ts +2 -3
  57. package/src/modules/Oscillator.ts +16 -8
  58. package/src/modules/index.ts +2 -2
  59. package/src/vite-env.d.ts +1 -0
  60. package/dist/build/core/IO/ForwardNode.d.ts +0 -38
  61. package/dist/build/core/IO/index.d.ts +0 -12
  62. package/dist/build/core/Module/index.d.ts +0 -6
  63. package/dist/build/core/midi/index.d.ts +0 -5
  64. package/dist/build/index.d.ts +0 -9
  65. package/dist/build/modules/Envelope/index.d.ts +0 -3
  66. package/dist/build/modules/index.d.ts +0 -17
  67. package/dist/main.cjs.js +0 -25
  68. package/dist/main.cjs.js.map +0 -1
  69. package/dist/main.esm.js +0 -25
  70. package/dist/main.esm.js.map +0 -1
  71. package/src/core/IO/ForwardNode.ts +0 -194
  72. /package/dist/{build → src}/core/Note/frequencyTable.d.ts +0 -0
  73. /package/dist/{build → src}/core/Note/index.d.ts +0 -0
  74. /package/dist/{build → src}/types.d.ts +0 -0
  75. /package/dist/{build → src}/utils.d.ts +0 -0
@@ -3,19 +3,23 @@ import { v4 as uuidv4 } from "uuid";
3
3
  import Module, { Connectable } from "./MonoModule";
4
4
  import {
5
5
  IOCollection,
6
- ForwardInput,
7
- ForwardOutput,
8
6
  IOType,
9
7
  IMidiInput,
10
8
  IMidiOutput,
11
- IForwardInput,
12
- IForwardOutput,
13
9
  MidiOutput,
14
10
  MidiInput,
11
+ AnyInput,
12
+ AnyOuput,
13
+ ForwardAudioInput,
15
14
  } from "../IO";
16
15
  import { AudioModule } from "./index";
17
16
  import { plugCompatibleIO } from "../IO/Node";
18
17
  import { deterministicId } from "../../utils";
18
+ import {
19
+ ForwardAudioOutput,
20
+ IForwardAudioInput,
21
+ IForwardAudioOutput,
22
+ } from "../IO/ForwardNode";
19
23
 
20
24
  interface PolyModuleInterface<MonoAudioModule, PropsInterface> {
21
25
  id?: string;
@@ -43,8 +47,8 @@ export default abstract class PolyModule<
43
47
  }) => MonoAudioModule;
44
48
  _name: string;
45
49
  audioModules: MonoAudioModule[];
46
- inputs: IOCollection<ForwardInput | MidiInput>;
47
- outputs: IOCollection<ForwardOutput | MidiOutput>;
50
+ inputs: IOCollection<AnyInput>;
51
+ outputs: IOCollection<AnyOuput>;
48
52
  private _numberOfVoices: number;
49
53
 
50
54
  constructor(params: PolyModuleInterface<MonoAudioModule, PropsInterface>) {
@@ -58,8 +62,8 @@ export default abstract class PolyModule<
58
62
  Object.assign(this, basicProps);
59
63
 
60
64
  this.numberOfVoices = params.numberOfVoices || 1;
61
- this.inputs = new IOCollection<ForwardInput>(this);
62
- this.outputs = new IOCollection<ForwardOutput>(this);
65
+ this.inputs = new IOCollection<AnyInput>(this);
66
+ this.outputs = new IOCollection<AnyOuput>(this);
63
67
 
64
68
  Object.assign(this, { props: extraProps });
65
69
  }
@@ -147,14 +151,16 @@ export default abstract class PolyModule<
147
151
  return this.audioModules.find((m) => m.voiceNo === voiceNo);
148
152
  }
149
153
 
150
- protected registerInput(props: Omit<IForwardInput, "ioType">): ForwardInput {
151
- return this.inputs.add({ ...props, ioType: IOType.ForwardInput });
154
+ protected registerForwardAudioInput(
155
+ props: Omit<IForwardAudioInput, "ioType">
156
+ ): ForwardAudioInput {
157
+ return this.inputs.add({ ...props, ioType: IOType.ForwardAudioInput });
152
158
  }
153
159
 
154
- protected registerOutput(
155
- props: Omit<IForwardOutput, "ioType">
156
- ): ForwardOutput {
157
- return this.outputs.add({ ...props, ioType: IOType.ForwardOutput });
160
+ protected registerForwardAudioOutput(
161
+ props: Omit<IForwardAudioOutput, "ioType">
162
+ ): ForwardAudioOutput {
163
+ return this.outputs.add({ ...props, ioType: IOType.ForwardAudioOutput });
158
164
  }
159
165
 
160
166
  protected registerMidiInput(props: Omit<IMidiInput, "ioType">): MidiInput {
@@ -166,11 +172,15 @@ export default abstract class PolyModule<
166
172
  }
167
173
 
168
174
  protected registerBasicOutputs() {
169
- this.registerOutput({ name: "output" });
175
+ this.registerForwardAudioOutput({ name: "output" });
170
176
  }
171
177
 
172
178
  protected registerBasicInputs() {
173
- this.registerInput({ name: "input" });
179
+ this.registerForwardAudioInput({ name: "input" });
180
+ this.registerMidiIn();
181
+ }
182
+
183
+ protected registerMidiIn() {
174
184
  this.registerMidiInput({
175
185
  name: "midi in",
176
186
  onMidiEvent: this.onMidiEvent,
package/src/main.ts ADDED
@@ -0,0 +1 @@
1
+ console.log("Hello from Blibliki");
@@ -143,6 +143,6 @@ export default class Filter extends PolyModule<MonoFilter, FilterInterface> {
143
143
 
144
144
  private registerOutputs() {
145
145
  this.registerBasicOutputs();
146
- this.registerInput({ name: "cutoff" });
146
+ this.registerForwardAudioInput({ name: "cutoff" });
147
147
  }
148
148
  }
@@ -110,7 +110,6 @@ class MonoLFO extends Module<LFOInternal, LFOInterface> implements Startable {
110
110
  };
111
111
 
112
112
  private registerInputs() {
113
- this.registerDefaultMidiInput();
114
113
  this.registerAudioInput({
115
114
  name: "amount",
116
115
  internalModule: this.internalModule.amplitude,
@@ -136,8 +135,8 @@ export default class LFO extends PolyModule<MonoLFO, LFOInterface> {
136
135
  });
137
136
 
138
137
  this.registerBasicOutputs();
139
- this.registerInput({ name: "midi in" });
140
- this.registerInput({ name: "amount" });
138
+ this.registerMidiIn();
139
+ this.registerForwardAudioInput({ name: "amount" });
141
140
  }
142
141
 
143
142
  start(time: number) {
@@ -1,4 +1,10 @@
1
- import { Multiply, now, Oscillator as Osc, ToneOscillatorType } from "tone";
1
+ import {
2
+ Multiply,
3
+ now,
4
+ Oscillator as Osc,
5
+ Signal,
6
+ ToneOscillatorType,
7
+ } from "tone";
2
8
  import Engine from "../Engine";
3
9
 
4
10
  import Note from "../core/Note";
@@ -24,12 +30,13 @@ const InitialProps: OscillatorInterface = {
24
30
  volume: 0,
25
31
  };
26
32
 
27
- class MonoOscillator
33
+ export class MonoOscillator
28
34
  extends Module<Osc, OscillatorInterface>
29
35
  implements Startable
30
36
  {
31
37
  private _note: Note;
32
- private _fineSignal: Multiply;
38
+ private _fineMulti: Multiply;
39
+ private _fineSignal: Signal;
33
40
 
34
41
  constructor(params: {
35
42
  id?: string;
@@ -75,8 +82,10 @@ class MonoOscillator
75
82
  get fineSingal() {
76
83
  if (this._fineSignal) return this._fineSignal;
77
84
 
78
- this._fineSignal = new Multiply(100);
79
- this._fineSignal.connect(this.internalModule.detune);
85
+ this._fineSignal = new Signal();
86
+ this._fineMulti = new Multiply(100);
87
+ this._fineSignal.connect(this._fineMulti);
88
+ this._fineMulti.connect(this.internalModule.detune);
80
89
 
81
90
  return this._fineSignal;
82
91
  }
@@ -171,7 +180,6 @@ class MonoOscillator
171
180
  }
172
181
 
173
182
  private registerInputs() {
174
- this.registerDefaultMidiInput();
175
183
  this.registerAudioInput({
176
184
  name: "fine",
177
185
  internalModule: this.fineSingal,
@@ -200,8 +208,8 @@ export default class Oscillator extends PolyModule<
200
208
  });
201
209
 
202
210
  this.registerBasicOutputs();
203
- this.registerInput({ name: "midi in" });
204
- this.registerInput({ name: "fine" });
211
+ this.registerMidiIn();
212
+ this.registerForwardAudioInput({ name: "fine" });
205
213
  }
206
214
 
207
215
  start(time: number) {
@@ -1,5 +1,5 @@
1
1
  import { Envelope, AmpEnvelope, FreqEnvelope } from "./Envelope";
2
- import Oscillator from "./Oscillator";
2
+ import Oscillator, { MonoOscillator } from "./Oscillator";
3
3
  import Filter from "./Filter";
4
4
  import Master from "./Master";
5
5
  import VoiceScheduler from "./VoiceScheduler";
@@ -16,7 +16,7 @@ import { AudioModule } from "../core/Module";
16
16
 
17
17
  export { default as Master } from "./Master";
18
18
  export { default as Filter } from "./Filter";
19
- export { default as Oscillator } from "./Oscillator";
19
+ export { default as Oscillator, MonoOscillator } from "./Oscillator";
20
20
  export { default as VirtualMidi } from "./VirtualMidi";
21
21
  export { default as VoiceScheduler } from "./VoiceScheduler";
22
22
  export { default as Sequencer } from "./Sequencer";
@@ -0,0 +1 @@
1
+ /// <reference types="vite/client" />
@@ -1,38 +0,0 @@
1
- import IONode, { IOType, IIONode } from "./Node";
2
- import Module, { Connectable, PolyModule } from "../Module";
3
- import { AnyObject } from "../../types";
4
- import { AnyInput, AnyOuput } from ".";
5
- export interface IForwardInput extends IIONode {
6
- ioType: IOType.ForwardInput;
7
- }
8
- export interface IForwardOutput extends IIONode {
9
- ioType: IOType.ForwardOutput;
10
- }
11
- export declare class ForwardInput extends IONode implements IForwardInput {
12
- plugableModule: PolyModule<Module<Connectable, AnyObject>, AnyObject>;
13
- ioType: IOType.ForwardInput;
14
- connections: ForwardOutput[];
15
- constructor(plugableModule: PolyModule<Module<Connectable, AnyObject>, AnyObject>, props: IForwardInput);
16
- get subInputs(): (import("./MidiNode").MidiInput | import("./AudioNode").AudioInput)[];
17
- get subModules(): Module<Connectable, AnyObject>[];
18
- subModule(voiceNo: number): Module<Connectable, AnyObject>;
19
- subInput(voiceNo: number): import("./MidiNode").MidiInput | import("./AudioNode").AudioInput;
20
- plug(io: AnyOuput, plugOther?: boolean): void;
21
- unPlug(io: AnyOuput, plugOther?: boolean): void;
22
- unPlugAll(): void;
23
- private checkNameValidity;
24
- }
25
- export declare class ForwardOutput extends IONode implements IForwardOutput {
26
- plugableModule: PolyModule<Module<Connectable, AnyObject>, AnyObject>;
27
- ioType: IOType.ForwardOutput;
28
- connections: ForwardInput[];
29
- constructor(plugableModule: PolyModule<Module<Connectable, AnyObject>, AnyObject>, props: IForwardOutput);
30
- get subOutputs(): (import("./MidiNode").MidiOutput | import("./AudioNode").AudioOutput)[];
31
- get subModules(): Module<Connectable, AnyObject>[];
32
- subModule(voiceNo: number): Module<Connectable, AnyObject>;
33
- subOutput(voiceNo: number): import("./MidiNode").MidiOutput | import("./AudioNode").AudioOutput;
34
- plug(io: AnyInput, plugOther?: boolean): void;
35
- unPlug(io: AnyInput, plugOther?: boolean): void;
36
- unPlugAll(): void;
37
- private checkNameValidity;
38
- }
@@ -1,12 +0,0 @@
1
- import { default as IOCollection } from "./Collection";
2
- import { IIONode, IOType, IIOSerialize } from "./Node";
3
- import { AudioInput, AudioOutput, IAudioInput, IAudioOutput } from "./AudioNode";
4
- import { IMidiInput, IMidiOutput, MidiInput, MidiOutput } from "./MidiNode";
5
- import { ForwardInput, ForwardOutput, IForwardInput, IForwardOutput } from "./ForwardNode";
6
- type AnyInput = AudioInput | MidiInput | ForwardInput;
7
- type AnyOuput = AudioOutput | MidiOutput | ForwardOutput;
8
- type IAnyInput = IAudioInput | IMidiInput | IForwardInput;
9
- type IAnyOutput = IAudioOutput | IMidiOutput | IForwardOutput;
10
- type IAnyIO = IAnyInput | IAnyOutput | IForwardOutput;
11
- export { IOCollection, IOType, AudioInput, AudioOutput, MidiInput, MidiOutput, ForwardInput, ForwardOutput, };
12
- export type { IAnyIO, IIONode, IAudioInput, IAudioOutput, IMidiInput, IMidiOutput, IForwardInput, IForwardOutput, IAnyInput, IAnyOutput, IIOSerialize, AnyInput, AnyOuput, };
@@ -1,6 +0,0 @@
1
- import Module, { Connectable } from "./MonoModule";
2
- import PolyModule from "./PolyModule";
3
- export { default, DummnyInternalModule } from "./MonoModule";
4
- export { default as PolyModule } from "./PolyModule";
5
- export type { ModuleInterface, Connectable, Triggerable, Startable, } from "./MonoModule";
6
- export type AudioModule = Module<Connectable, any> | PolyModule<Module<Connectable, any>, any>;
@@ -1,5 +0,0 @@
1
- export { default as MidiEvent } from "./MidiEvent";
2
- export { default as MidiDevice } from "./MidiDevice";
3
- export { default as MidiDeviceManager } from "./MidiDeviceManager";
4
- export type { MidiDeviceInterface } from "./MidiDevice";
5
- export type { MidiEventType } from "./MidiEvent";
@@ -1,9 +0,0 @@
1
- export { default } from "./Engine";
2
- export { MidiDevice, MidiDeviceManager } from "./core/midi";
3
- export { default as Note } from "./core/Note";
4
- export type { MidiDeviceInterface } from "./core/midi";
5
- export type { INote } from "./core/Note";
6
- export type { ModuleInterface, AudioModule } from "./core/Module";
7
- export type { ISequence } from "./modules";
8
- export type { RouteInterface, RouteProps } from "./routes";
9
- export type { IIOSerialize as IOProps } from "./core/IO";
@@ -1,3 +0,0 @@
1
- export { default, Envelope, EnvelopeStages } from "./Base";
2
- export { default as AmpEnvelope } from "./AmpEnvelope";
3
- export { default as FreqEnvelope, MonoFreqEnvelope } from "./FreqEnvelope";
@@ -1,17 +0,0 @@
1
- import { AudioModule } from "../core/Module";
2
- export { default as Master } from "./Master";
3
- export { default as Filter } from "./Filter";
4
- export { default as Oscillator } from "./Oscillator";
5
- export { default as VirtualMidi } from "./VirtualMidi";
6
- export { default as VoiceScheduler } from "./VoiceScheduler";
7
- export { default as Sequencer } from "./Sequencer";
8
- export type { ISequence } from "./Sequencer";
9
- export { Envelope, AmpEnvelope, FreqEnvelope, EnvelopeStages, } from "./Envelope";
10
- export interface ICreateModule {
11
- id?: string;
12
- name: string;
13
- numberOfVoices?: number;
14
- type: string;
15
- props: any;
16
- }
17
- export declare function createModule(params: ICreateModule): AudioModule;