sonolus-d4dj-engine 1.1.19 → 1.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -74,6 +74,13 @@ Converts D4DJ (bangbangboom-editor) chart to Level Data.
74
74
  - `chart`: D4DJ chart.
75
75
  - `offset`: offset (default: `0`).
76
76
 
77
+ ### `d4cToLevelData(chart, offset?)`
78
+
79
+ Converts D4C chart to Level Data.
80
+
81
+ - `chart`: D4C chart.
82
+ - `offset`: offset (default: `0`).
83
+
77
84
  ### Assets
78
85
 
79
86
  The following assets are exposed as package entry points:
Binary file
Binary file
@@ -0,0 +1,268 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.d4cToLevelData = void 0;
4
+ const index_cjs_1 = require("./index.cjs");
5
+ function d4cToLevelData(chart, offset = 0) {
6
+ // let d4chart: any = []
7
+ // d4chart[0] = chart.MusicName
8
+ // d4chart[1] = []
9
+ // d4chart[2] = chart.BarLineList
10
+ // d4chart[3] = chart.NoteDataList.map((note: B34DJNoteData) => [note.LaneId, D4DJNoteType[note.Type], note.Time, note.NextId, note.Direction, note.EffectType, note.EffectParameter])
11
+ // const timescale = chart.SoflanDataList.map((soflan: B34DJSoflanData) => [soflan.Time, soflan.TimeScale, soflan.LeftRight])
12
+ // timescale.forEach((ts: any) => {
13
+ // const i = d4chart[1].findIndex((tsc: number[]) => (tsc[0] === ts[0]) && (tsc[1] === ts[1]))
14
+ // if (i === -1) d4chart[1].push(ts)
15
+ // else d4chart[1][i][2] = 3
16
+ // })
17
+ let disc = {
18
+ left: chart.TimeScaleGroupList.flatMap(tsg => tsg.SoflanDataList).filter((soflan) => [1, 3].includes(soflan.LeftRight)).sort((a, b) => a.Beat - b.Beat),
19
+ right: chart.TimeScaleGroupList.flatMap(tsg => tsg.SoflanDataList).filter((soflan) => [2, 3].includes(soflan.LeftRight)).sort((a, b) => a.Beat - b.Beat)
20
+ };
21
+ chart.TimeScaleGroupList.push({ id: -4, SoflanDataList: disc.left }, { id: -3, SoflanDataList: disc.right });
22
+ let data = {
23
+ bgmOffset: chart.Offset + offset,
24
+ entities: [
25
+ {
26
+ archetype: "Initialization",
27
+ data: [],
28
+ },
29
+ {
30
+ archetype: "Stage",
31
+ data: [
32
+ {
33
+ name: "discTsgL",
34
+ ref: "tsg:-4"
35
+ },
36
+ {
37
+ name: "discTsgR",
38
+ ref: "tsg:-3"
39
+ }
40
+ ],
41
+ },
42
+ ],
43
+ };
44
+ let bpm = chart.BpmDataList.map(({ Bpm, Beat }) => ({
45
+ archetype: "#BPM_CHANGE",
46
+ data: [
47
+ {
48
+ name: "#BEAT",
49
+ value: Beat,
50
+ },
51
+ {
52
+ name: "#BPM",
53
+ value: Bpm,
54
+ },
55
+ ],
56
+ }));
57
+ let ts = chart.TimeScaleGroupList.map(({ id, SoflanDataList }) => ([
58
+ {
59
+ archetype: "TimeScaleGroup",
60
+ data: [
61
+ {
62
+ name: "first",
63
+ ref: `tsc:${id}:-1`,
64
+ },
65
+ {
66
+ name: "length",
67
+ value: SoflanDataList.length + 1,
68
+ }
69
+ ],
70
+ name: `tsg:${id}`,
71
+ },
72
+ {
73
+ archetype: "TimeScaleChange",
74
+ data: [
75
+ {
76
+ name: "#BEAT",
77
+ value: 0,
78
+ },
79
+ {
80
+ name: "timeScale",
81
+ value: 1,
82
+ },
83
+ {
84
+ name: "next",
85
+ ref: `tsc:${id}:0`,
86
+ },
87
+ ],
88
+ name: `tsc:${id}:-1`,
89
+ }, ...SoflanDataList.map(({ Beat, TimeScale }, i) => ({
90
+ archetype: "TimeScaleChange",
91
+ data: [
92
+ {
93
+ name: "#BEAT",
94
+ value: Beat,
95
+ },
96
+ {
97
+ name: "timeScale",
98
+ value: TimeScale,
99
+ },
100
+ {
101
+ name: "next",
102
+ ref: `tsc:${id}:${i + 1}`,
103
+ },
104
+ ],
105
+ name: `tsc:${id}:${i}`,
106
+ }))
107
+ ]));
108
+ let bl = chart.BarLine.List.map((br) => ({
109
+ archetype: "BarLine",
110
+ data: [
111
+ {
112
+ name: "#BEAT",
113
+ value: typeof br == "number" ? br : br.Time,
114
+ },
115
+ {
116
+ name: "timeScaleGroup",
117
+ ref: typeof br == "number" ? `tsg:${chart.BarLine.DefaultTimeScaleGroupId}` : `tsg:${br.TimeScaleGroupId || chart.BarLine.DefaultTimeScaleGroupId}`,
118
+ },
119
+ ],
120
+ }));
121
+ let notes = note(chart);
122
+ data.entities.push(...bpm, ...ts.flat(), ...notes, ...bl);
123
+ return data;
124
+ }
125
+ exports.d4cToLevelData = d4cToLevelData;
126
+ function note(chart) {
127
+ let hold = [];
128
+ let slider = [];
129
+ let notes = {};
130
+ let nots = chart.NoteDataList.map(({ Beat, Type, LaneId, NextId, Direction, EffectType, EffectParameter, TimeScaleGroupId }, i) => {
131
+ const not = {
132
+ archetype: Type === index_cjs_1.D4CNoteType.Tap1
133
+ ? "DarkTapNote"
134
+ : Type === index_cjs_1.D4CNoteType.Tap2
135
+ ? "LightTapNote"
136
+ : Type === index_cjs_1.D4CNoteType.Scratch
137
+ ? "ScratchNote"
138
+ : Type === index_cjs_1.D4CNoteType.StopStart
139
+ ? "StopStartNote"
140
+ : Type === index_cjs_1.D4CNoteType.StopEnd
141
+ ? "StopEndNote"
142
+ : Type === index_cjs_1.D4CNoteType.LongStart
143
+ ? "HoldStartNote"
144
+ : Type === index_cjs_1.D4CNoteType.LongEnd
145
+ ? "HoldEndNote"
146
+ : Type === index_cjs_1.D4CNoteType.LongMiddle
147
+ ? "HoldMiddleNote"
148
+ : Direction !== 0
149
+ ? "SliderFlickNote"
150
+ : "SliderTickNote",
151
+ data: [
152
+ {
153
+ name: "#BEAT",
154
+ value: Beat,
155
+ },
156
+ {
157
+ name: "lane",
158
+ value: LaneId - 3,
159
+ },
160
+ {
161
+ name: "timeScaleGroup",
162
+ ref: `tsg:${TimeScaleGroupId}`,
163
+ },
164
+ ],
165
+ name: `note${i}`,
166
+ };
167
+ notes[Beat]
168
+ ? notes[Beat].push({ name: `note${i}`, lane: LaneId })
169
+ : (notes[Beat] = [{ name: `note${i}`, lane: LaneId }]);
170
+ if (NextId && (Type === index_cjs_1.D4CNoteType.LongStart || Type === index_cjs_1.D4CNoteType.StopStart)) {
171
+ let note = {};
172
+ note.head = not.name;
173
+ note.tail = `note${NextId}`;
174
+ hold.push(note);
175
+ not.data.push({
176
+ name: "tail",
177
+ ref: `note${NextId}`,
178
+ });
179
+ }
180
+ if (Type === index_cjs_1.D4CNoteType.Slide) {
181
+ if (NextId && NextId > 0) {
182
+ slider.push({ prev: not.name, next: `note${NextId}` });
183
+ not.data.push({
184
+ name: "next",
185
+ ref: `note${NextId}`,
186
+ });
187
+ }
188
+ const sld = slider.find((note) => note.next === not.name);
189
+ if (sld)
190
+ not.data.push({
191
+ name: "prev",
192
+ ref: sld.prev,
193
+ });
194
+ }
195
+ if (Type === index_cjs_1.D4CNoteType.LongEnd || Type === index_cjs_1.D4CNoteType.StopEnd) {
196
+ not.data.push({
197
+ name: "head",
198
+ ref: hold.find((note) => note.tail === not.name).head,
199
+ });
200
+ }
201
+ if (Direction)
202
+ not.data.push({
203
+ name: "direction",
204
+ value: Direction,
205
+ });
206
+ return not;
207
+ });
208
+ hold.forEach(({ head, tail }, i) => nots.splice(parseInt(head.replace("note", "")) + 1 + i, 0, {
209
+ archetype: "HoldConnector",
210
+ data: [
211
+ {
212
+ name: "head",
213
+ ref: head,
214
+ },
215
+ {
216
+ name: "tail",
217
+ ref: tail,
218
+ },
219
+ ],
220
+ }));
221
+ for (const beat in notes) {
222
+ const sim = notes[beat].sort((a, b) => a.lane - b.lane);
223
+ if (sim.length === 2) {
224
+ nots.push({
225
+ archetype: "SimLine",
226
+ data: [
227
+ {
228
+ name: "a",
229
+ ref: sim[0].name,
230
+ },
231
+ {
232
+ name: "b",
233
+ ref: sim[1].name,
234
+ },
235
+ ],
236
+ });
237
+ }
238
+ else if (sim.length === 3) {
239
+ nots.push({
240
+ archetype: "SimLine",
241
+ data: [
242
+ {
243
+ name: "a",
244
+ ref: sim[0].name,
245
+ },
246
+ {
247
+ name: "b",
248
+ ref: sim[1].name,
249
+ },
250
+ ],
251
+ });
252
+ nots.push({
253
+ archetype: "SimLine",
254
+ data: [
255
+ {
256
+ name: "a",
257
+ ref: sim[1].name,
258
+ },
259
+ {
260
+ name: "b",
261
+ ref: sim[2].name,
262
+ },
263
+ ],
264
+ });
265
+ }
266
+ }
267
+ return nots;
268
+ }
@@ -0,0 +1,3 @@
1
+ import { LevelData } from '@sonolus/core';
2
+ import { D4CChartData } from './index.cjs';
3
+ export declare function d4cToLevelData(chart: D4CChartData, offset?: number): LevelData;
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.D4CNoteType = void 0;
4
+ var D4CNoteType;
5
+ (function (D4CNoteType) {
6
+ D4CNoteType["Tap1"] = "Tap1";
7
+ D4CNoteType["Tap2"] = "Tap2";
8
+ D4CNoteType["Scratch"] = "Scratch";
9
+ D4CNoteType["StopStart"] = "StopStart";
10
+ D4CNoteType["StopEnd"] = "StopEnd";
11
+ D4CNoteType["LongStart"] = "LongStart";
12
+ D4CNoteType["LongMiddle"] = "LongMiddle";
13
+ D4CNoteType["LongEnd"] = "LongEnd";
14
+ D4CNoteType["Slide"] = "Slide";
15
+ })(D4CNoteType || (exports.D4CNoteType = D4CNoteType = {}));
@@ -0,0 +1,48 @@
1
+ export declare enum D4CNoteType {
2
+ Tap1 = "Tap1",
3
+ Tap2 = "Tap2",
4
+ Scratch = "Scratch",
5
+ StopStart = "StopStart",
6
+ StopEnd = "StopEnd",
7
+ LongStart = "LongStart",
8
+ LongMiddle = "LongMiddle",
9
+ LongEnd = "LongEnd",
10
+ Slide = "Slide"
11
+ }
12
+ export type D4CNoteData = {
13
+ LaneId: number;
14
+ Type: D4CNoteType;
15
+ Beat: number;
16
+ NextId?: number;
17
+ TimeScaleGroupId: number;
18
+ Direction?: number;
19
+ EffectType?: number;
20
+ EffectParameter?: number;
21
+ };
22
+ export type D4CSoflanData = {
23
+ Beat: number;
24
+ TimeScale: number;
25
+ LeftRight: number;
26
+ };
27
+ export type D4CSoflanGroup = {
28
+ id: number;
29
+ SoflanDataList: D4CSoflanData[];
30
+ };
31
+ export type D4CBarLineData = number | {
32
+ Time: number;
33
+ TimeScaleGroupId?: string;
34
+ };
35
+ export type D4CChartData = {
36
+ Offset: number;
37
+ BpmDataList: D4CBpmData[];
38
+ TimeScaleGroupList: D4CSoflanGroup[];
39
+ BarLine: {
40
+ DefaultTimeScaleGroupId: number;
41
+ List: D4CBarLineData[];
42
+ };
43
+ NoteDataList: D4CNoteData[];
44
+ };
45
+ export type D4CBpmData = {
46
+ Beat: number;
47
+ Bpm: number;
48
+ };
package/dist/index.cjs CHANGED
@@ -14,12 +14,15 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
- exports.databaseEngineItem = exports.version = exports.d4djToLevelData = exports.b34djToLevelData = void 0;
17
+ exports.databaseEngineItem = exports.version = exports.d4cToLevelData = exports.d4djToLevelData = exports.b34djToLevelData = void 0;
18
18
  var convert_cjs_1 = require("./b34dj/convert.cjs");
19
19
  Object.defineProperty(exports, "b34djToLevelData", { enumerable: true, get: function () { return convert_cjs_1.b34djToLevelData; } });
20
20
  Object.defineProperty(exports, "d4djToLevelData", { enumerable: true, get: function () { return convert_cjs_1.d4djToLevelData; } });
21
+ var convert_cjs_2 = require("./d4c/convert.cjs");
22
+ Object.defineProperty(exports, "d4cToLevelData", { enumerable: true, get: function () { return convert_cjs_2.d4cToLevelData; } });
21
23
  __exportStar(require("./b34dj/index.cjs"), exports);
22
- exports.version = '1.1.19';
24
+ __exportStar(require("./d4c/index.cjs"), exports);
25
+ exports.version = '1.2.0';
23
26
  exports.databaseEngineItem = {
24
27
  name: 'd4dj',
25
28
  version: 12,
package/dist/index.d.cts CHANGED
@@ -1,6 +1,8 @@
1
1
  export { b34djToLevelData, d4djToLevelData } from './b34dj/convert.cjs';
2
+ export { d4cToLevelData } from './d4c/convert.cjs';
2
3
  export * from './b34dj/index.cjs';
3
- export declare const version = "1.1.19";
4
+ export * from './d4c/index.cjs';
5
+ export declare const version = "1.2.0";
4
6
  export declare const databaseEngineItem: {
5
7
  readonly name: "d4dj";
6
8
  readonly version: 12;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sonolus-d4dj-engine",
3
- "version": "1.1.19",
3
+ "version": "1.2.0",
4
4
  "description": "A recreation of D4DJ Groovy Mix engine in Sonolus.",
5
5
  "type": "module",
6
6
  "author": "Gorengan Hunter",