@blibliki/engine 0.1.10 → 0.1.11
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 -2
- package/build/Module/Sequencer.d.ts +3 -3
- package/build/Module/Sequencer.js +25 -14
- package/build/Module/Sequencer.js.map +1 -1
- package/package.json +1 -1
- package/src/Module/Sequencer.ts +26 -15
package/README.md
CHANGED
|
@@ -1,4 +1,17 @@
|
|
|
1
1
|
# Blibliki Engine
|
|
2
|
-
This is an engine for making synth systems.
|
|
3
2
|
|
|
4
|
-
|
|
3
|
+
Blibliki Engine is a data-driven, non-UI JavaScript library written in TypeScript that serves as a framework for building synthesizers.
|
|
4
|
+
Built on top of ToneJS, it aims to provide a streamlined interface for creating custom synthesizers.
|
|
5
|
+
|
|
6
|
+
## Approach
|
|
7
|
+
|
|
8
|
+
The engine operates in a data-driven manner, allowing developers to provide changes to the current module configuration rather than directly accessing the modules themselves.
|
|
9
|
+
This approach facilitates seamless integration with state management libraries like Redux, making it easy to build applications with centralized state management.
|
|
10
|
+
|
|
11
|
+
One notable advantage of the data-driven approach is the ability to easily save and recall patches. By representing the synthesizer configuration as data, developers can effortlessly store and load patches, enabling users to save and share their custom presets.
|
|
12
|
+
|
|
13
|
+
Blibliki Engine offers polyphony support and provides access to essential audio modules such as oscillators, filters, envelopes, and effects. It's important to note that the list of available audio modules will be extended as the development of the engine continues.
|
|
14
|
+
|
|
15
|
+
## Contributing
|
|
16
|
+
|
|
17
|
+
As a work-in-progress project, Blibliki Engine actively welcomes contributions and feedback from the community. Whether it's reporting issues, suggesting new features, or submitting code changes, contributors are encouraged to get involved and help shape the future of Blibliki Engine.
|
|
@@ -8,7 +8,7 @@ export interface ISequence {
|
|
|
8
8
|
}
|
|
9
9
|
interface ISequencer {
|
|
10
10
|
sequences: ISequence[][];
|
|
11
|
-
|
|
11
|
+
steps: number;
|
|
12
12
|
bars: number;
|
|
13
13
|
}
|
|
14
14
|
export default class Sequencer extends Module<DummnyInternalModule, ISequencer> {
|
|
@@ -17,8 +17,8 @@ export default class Sequencer extends Module<DummnyInternalModule, ISequencer>
|
|
|
17
17
|
private part;
|
|
18
18
|
private barParts;
|
|
19
19
|
constructor(name: string, props: Partial<ISequencer>);
|
|
20
|
-
get
|
|
21
|
-
set
|
|
20
|
+
get steps(): number;
|
|
21
|
+
set steps(value: number);
|
|
22
22
|
get bars(): number;
|
|
23
23
|
set bars(value: number);
|
|
24
24
|
get sequences(): ISequence[][];
|
|
@@ -3,7 +3,7 @@ import Module, { DummnyInternalModule } from "./Base";
|
|
|
3
3
|
import MidiEvent from "../MidiEvent";
|
|
4
4
|
const InitialProps = () => ({
|
|
5
5
|
sequences: [],
|
|
6
|
-
|
|
6
|
+
steps: 16,
|
|
7
7
|
bars: 1,
|
|
8
8
|
});
|
|
9
9
|
export default class Sequencer extends Module {
|
|
@@ -20,11 +20,11 @@ export default class Sequencer extends Module {
|
|
|
20
20
|
this.start();
|
|
21
21
|
this.registerOutputs();
|
|
22
22
|
}
|
|
23
|
-
get
|
|
24
|
-
return this._props["
|
|
23
|
+
get steps() {
|
|
24
|
+
return this._props["steps"];
|
|
25
25
|
}
|
|
26
|
-
set
|
|
27
|
-
this._props
|
|
26
|
+
set steps(value) {
|
|
27
|
+
this._props = { ...this.props, steps: value };
|
|
28
28
|
this.adjustNumberOfSequences();
|
|
29
29
|
this.updateBarParts();
|
|
30
30
|
}
|
|
@@ -32,7 +32,7 @@ export default class Sequencer extends Module {
|
|
|
32
32
|
return this.props["bars"];
|
|
33
33
|
}
|
|
34
34
|
set bars(value) {
|
|
35
|
-
this._props
|
|
35
|
+
this._props = { ...this.props, bars: value };
|
|
36
36
|
this.adjustNumberOfBars();
|
|
37
37
|
this.adjustNumberOfSequences();
|
|
38
38
|
this.updateBarParts();
|
|
@@ -65,23 +65,32 @@ export default class Sequencer extends Module {
|
|
|
65
65
|
adjustNumberOfBars() {
|
|
66
66
|
const currentBar = this.sequences.length;
|
|
67
67
|
const num = currentBar - this.bars;
|
|
68
|
+
const sequences = [...this.sequences];
|
|
68
69
|
if (num === 0)
|
|
69
70
|
return;
|
|
70
71
|
if (num > 0) {
|
|
71
|
-
this.part
|
|
72
|
-
|
|
72
|
+
if (this.part) {
|
|
73
|
+
this.part.remove(`${currentBar}:0:0`);
|
|
74
|
+
this.part.loopEnd = this.loopEnd;
|
|
75
|
+
}
|
|
76
|
+
sequences.pop();
|
|
73
77
|
}
|
|
74
78
|
else {
|
|
75
|
-
this.part
|
|
76
|
-
|
|
79
|
+
if (this.part) {
|
|
80
|
+
this.part.add(`${currentBar}:0:0`, currentBar);
|
|
81
|
+
this.part.loopEnd = this.loopEnd;
|
|
82
|
+
}
|
|
83
|
+
sequences.push([]);
|
|
77
84
|
}
|
|
85
|
+
this.sequences = sequences;
|
|
78
86
|
this.adjustNumberOfBars();
|
|
79
87
|
}
|
|
80
88
|
adjustNumberOfSequences(bar = 0) {
|
|
81
89
|
if (!this.bars)
|
|
82
90
|
return;
|
|
83
|
-
const
|
|
84
|
-
const
|
|
91
|
+
const allSequences = [...this.sequences];
|
|
92
|
+
const sequences = [...allSequences[bar]];
|
|
93
|
+
const num = sequences.length - this.steps;
|
|
85
94
|
if (num === 0) {
|
|
86
95
|
if (bar === this.bars - 1)
|
|
87
96
|
return;
|
|
@@ -93,12 +102,14 @@ export default class Sequencer extends Module {
|
|
|
93
102
|
}
|
|
94
103
|
else {
|
|
95
104
|
const index = sequences.length;
|
|
96
|
-
sequences.push({ active: false, time:
|
|
105
|
+
sequences.push({ active: false, time: `0:0:${index}`, notes: [] });
|
|
97
106
|
}
|
|
107
|
+
allSequences[bar] = sequences;
|
|
108
|
+
this.sequences = allSequences;
|
|
98
109
|
this.adjustNumberOfSequences(bar);
|
|
99
110
|
}
|
|
100
111
|
updateBarParts() {
|
|
101
|
-
this.barParts = this.sequences.map((barSeqs,
|
|
112
|
+
this.barParts = this.sequences.map((barSeqs, _) => {
|
|
102
113
|
const part = new Part(this.onSequenceEvent, []);
|
|
103
114
|
barSeqs.forEach((seq) => part.add(seq.time, seq));
|
|
104
115
|
return part;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Sequencer.js","sourceRoot":"","sources":["../../src/Module/Sequencer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAClC,OAAO,MAAM,EAAE,EAAE,oBAAoB,EAAE,MAAM,QAAQ,CAAC;AAGtD,OAAO,SAAS,MAAM,cAAc,CAAC;AAarC,MAAM,YAAY,GAAG,GAAG,EAAE,CAAC,CAAC;IAC1B,SAAS,EAAE,EAAE;IACb,
|
|
1
|
+
{"version":3,"file":"Sequencer.js","sourceRoot":"","sources":["../../src/Module/Sequencer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAClC,OAAO,MAAM,EAAE,EAAE,oBAAoB,EAAE,MAAM,QAAQ,CAAC;AAGtD,OAAO,SAAS,MAAM,cAAc,CAAC;AAarC,MAAM,YAAY,GAAG,GAAG,EAAE,CAAC,CAAC;IAC1B,SAAS,EAAE,EAAE;IACb,KAAK,EAAE,EAAE;IACT,IAAI,EAAE,CAAC;CACR,CAAC,CAAC;AAEH,MAAM,CAAC,OAAO,OAAO,SAAU,SAAQ,MAGtC;IACC,MAAM,CAAC,UAAU,GAAG,WAAW,CAAC;IAChC,UAAU,CAAS;IACX,IAAI,CAAe;IACnB,QAAQ,GAAsB,EAAE,CAAC;IAEzC,YAAY,IAAY,EAAE,KAA0B;QAClD,KAAK,CAAC,IAAI,oBAAoB,EAAE,EAAE;YAChC,IAAI;YACJ,KAAK,EAAE,EAAE,GAAG,YAAY,EAAE,EAAE,GAAG,KAAK,EAAE;SACvC,CAAC,CAAC;QAEH,IAAI,CAAC,cAAc,EAAE,CAAC;QACtB,IAAI,CAAC,KAAK,EAAE,CAAC;QACb,IAAI,CAAC,eAAe,EAAE,CA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CAAC;YAElD,OAAO,IAAI,CAAC;QACd,CAAC,CAAC,CAAC;IACL,CAAC;IAED,IAAY,OAAO;QACjB,OAAO,GAAG,IAAI,CAAC,IAAI,MAAM,CAAC;IAC5B,CAAC;IAEO,WAAW,GAAG,CAAC,IAAY,EAAE,GAAkB,EAAE,EAAE;QACzD,IAAI,GAAG,KAAK,IAAI;YAAE,OAAO;QAEzB,MAAM,IAAI,GAAG,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC;QAChC,IAAI,CAAC,IAAI;YAAE,OAAO;QAElB,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;QACjB,IAAI,CAAC,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC,CAAC,SAAS,EAAE,CAAC,CAAC;IAC3C,CAAC,CAAC;IAEM,eAAe,GAAG,CAAC,IAAY,EAAE,QAAmB,EAAE,EAAE;QAC9D,IAAI,CAAC,QAAQ,CAAC,MAAM;YAAE,OAAO;QAE7B,MAAM,KAAK,GAAG,SAAS,CAAC,YAAY,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAC;QAErD,IAAI,CAAC,UAAU,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC,KAAK,EAAE,EAAE;YAC5C,KAAK,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;QACzB,CAAC,CAAC,CAAC;IACL,CAAC,CAAC"}
|
package/package.json
CHANGED
package/src/Module/Sequencer.ts
CHANGED
|
@@ -11,13 +11,13 @@ export interface ISequence {
|
|
|
11
11
|
}
|
|
12
12
|
interface ISequencer {
|
|
13
13
|
sequences: ISequence[][];
|
|
14
|
-
|
|
14
|
+
steps: number;
|
|
15
15
|
bars: number;
|
|
16
16
|
}
|
|
17
17
|
|
|
18
18
|
const InitialProps = () => ({
|
|
19
19
|
sequences: [],
|
|
20
|
-
|
|
20
|
+
steps: 16,
|
|
21
21
|
bars: 1,
|
|
22
22
|
});
|
|
23
23
|
|
|
@@ -41,12 +41,12 @@ export default class Sequencer extends Module<
|
|
|
41
41
|
this.registerOutputs();
|
|
42
42
|
}
|
|
43
43
|
|
|
44
|
-
get
|
|
45
|
-
return this._props["
|
|
44
|
+
get steps() {
|
|
45
|
+
return this._props["steps"];
|
|
46
46
|
}
|
|
47
47
|
|
|
48
|
-
set
|
|
49
|
-
this._props
|
|
48
|
+
set steps(value: number) {
|
|
49
|
+
this._props = { ...this.props, steps: value };
|
|
50
50
|
this.adjustNumberOfSequences();
|
|
51
51
|
this.updateBarParts();
|
|
52
52
|
}
|
|
@@ -56,7 +56,7 @@ export default class Sequencer extends Module<
|
|
|
56
56
|
}
|
|
57
57
|
|
|
58
58
|
set bars(value: number) {
|
|
59
|
-
this._props
|
|
59
|
+
this._props = { ...this.props, bars: value };
|
|
60
60
|
this.adjustNumberOfBars();
|
|
61
61
|
this.adjustNumberOfSequences();
|
|
62
62
|
this.updateBarParts();
|
|
@@ -97,25 +97,34 @@ export default class Sequencer extends Module<
|
|
|
97
97
|
private adjustNumberOfBars() {
|
|
98
98
|
const currentBar = this.sequences.length;
|
|
99
99
|
const num = currentBar - this.bars;
|
|
100
|
+
const sequences = [...this.sequences];
|
|
100
101
|
|
|
101
102
|
if (num === 0) return;
|
|
102
103
|
|
|
103
104
|
if (num > 0) {
|
|
104
|
-
this.part
|
|
105
|
-
|
|
105
|
+
if (this.part) {
|
|
106
|
+
this.part.remove(`${currentBar}:0:0`);
|
|
107
|
+
this.part.loopEnd = this.loopEnd;
|
|
108
|
+
}
|
|
109
|
+
sequences.pop();
|
|
106
110
|
} else {
|
|
107
|
-
this.part
|
|
108
|
-
|
|
111
|
+
if (this.part) {
|
|
112
|
+
this.part.add(`${currentBar}:0:0`, currentBar);
|
|
113
|
+
this.part.loopEnd = this.loopEnd;
|
|
114
|
+
}
|
|
115
|
+
sequences.push([]);
|
|
109
116
|
}
|
|
110
117
|
|
|
118
|
+
this.sequences = sequences;
|
|
111
119
|
this.adjustNumberOfBars();
|
|
112
120
|
}
|
|
113
121
|
|
|
114
122
|
private adjustNumberOfSequences(bar = 0) {
|
|
115
123
|
if (!this.bars) return;
|
|
116
124
|
|
|
117
|
-
const
|
|
118
|
-
const
|
|
125
|
+
const allSequences = [...this.sequences];
|
|
126
|
+
const sequences = [...allSequences[bar]];
|
|
127
|
+
const num = sequences.length - this.steps;
|
|
119
128
|
|
|
120
129
|
if (num === 0) {
|
|
121
130
|
if (bar === this.bars - 1) return;
|
|
@@ -128,14 +137,16 @@ export default class Sequencer extends Module<
|
|
|
128
137
|
sequences.pop();
|
|
129
138
|
} else {
|
|
130
139
|
const index = sequences.length;
|
|
131
|
-
sequences.push({ active: false, time:
|
|
140
|
+
sequences.push({ active: false, time: `0:0:${index}`, notes: [] });
|
|
132
141
|
}
|
|
142
|
+
allSequences[bar] = sequences;
|
|
143
|
+
this.sequences = allSequences;
|
|
133
144
|
|
|
134
145
|
this.adjustNumberOfSequences(bar);
|
|
135
146
|
}
|
|
136
147
|
|
|
137
148
|
private updateBarParts() {
|
|
138
|
-
this.barParts = this.sequences.map((barSeqs,
|
|
149
|
+
this.barParts = this.sequences.map((barSeqs, _) => {
|
|
139
150
|
const part = new Part(this.onSequenceEvent, [] as Array<ISequence>);
|
|
140
151
|
barSeqs.forEach((seq) => part.add(seq.time, seq));
|
|
141
152
|
|