tja-parser 0.2.2 → 0.2.4
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/dist/class/Bar.d.ts +1 -0
- package/dist/class/Bar.d.ts.map +1 -1
- package/dist/class/Bar.js +5 -0
- package/dist/class/Bar.js.map +1 -1
- package/dist/class/Course.d.ts +1 -0
- package/dist/class/Course.d.ts.map +1 -1
- package/dist/class/Course.js +58 -6
- package/dist/class/Course.js.map +1 -1
- package/format.mediawiki +714 -714
- package/package.json +1 -1
- package/src/class/Bar.ts +72 -67
- package/src/class/Branch.ts +33 -33
- package/src/class/Command.ts +138 -138
- package/src/class/Course.ts +496 -437
- package/src/class/Item.ts +26 -26
- package/src/class/Note.ts +171 -171
- package/src/class/NoteGroup.ts +23 -23
- package/src/class/Song.ts +87 -87
- package/src/exception/ParseException.ts +12 -12
- package/src/index.ts +12 -12
- package/tsconfig.json +22 -22
- package/dist/class/BarLine.d.ts +0 -14
- package/dist/class/BarLine.d.ts.map +0 -1
- package/dist/class/BarLine.js +0 -26
- package/dist/class/BarLine.js.map +0 -1
package/package.json
CHANGED
package/src/class/Bar.ts
CHANGED
|
@@ -1,68 +1,73 @@
|
|
|
1
|
-
import { Command } from "./Command.js";
|
|
2
|
-
import { Item } from "./Item.js";
|
|
3
|
-
import { Note } from "./Note.js";
|
|
4
|
-
import { NoteGroup } from "./NoteGroup.js";
|
|
5
|
-
import * as math from 'mathjs';
|
|
6
|
-
|
|
7
|
-
export class Bar extends NoteGroup {
|
|
8
|
-
private items: Item[] = [];
|
|
9
|
-
private notes: Note[] = [];
|
|
10
|
-
private commands: Command[] = [];
|
|
11
|
-
private measure = math.fraction(1);
|
|
12
|
-
private barlineHidden = false;
|
|
13
|
-
private bpm: number = 160;
|
|
14
|
-
private scroll: number = 1;
|
|
15
|
-
|
|
16
|
-
pushItem(...items: Item[]) {
|
|
17
|
-
this.items.push(...items);
|
|
18
|
-
this.notes.push(...items.filter((item) => item instanceof Note));
|
|
19
|
-
this.commands.push(...items.filter((item) => item instanceof Command));
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
1
|
+
import { Command } from "./Command.js";
|
|
2
|
+
import { Item } from "./Item.js";
|
|
3
|
+
import { Note } from "./Note.js";
|
|
4
|
+
import { NoteGroup } from "./NoteGroup.js";
|
|
5
|
+
import * as math from 'mathjs';
|
|
6
|
+
|
|
7
|
+
export class Bar extends NoteGroup {
|
|
8
|
+
private items: Item[] = [];
|
|
9
|
+
private notes: Note[] = [];
|
|
10
|
+
private commands: Command[] = [];
|
|
11
|
+
private measure = math.fraction(1);
|
|
12
|
+
private barlineHidden = false;
|
|
13
|
+
private bpm: number = 160;
|
|
14
|
+
private scroll: number = 1;
|
|
15
|
+
|
|
16
|
+
pushItem(...items: Item[]) {
|
|
17
|
+
this.items.push(...items);
|
|
18
|
+
this.notes.push(...items.filter((item) => item instanceof Note));
|
|
19
|
+
this.commands.push(...items.filter((item) => item instanceof Command));
|
|
20
|
+
}
|
|
21
|
+
clearItems() {
|
|
22
|
+
this.items = [];
|
|
23
|
+
this.notes = [];
|
|
24
|
+
this.commands = [];
|
|
25
|
+
}
|
|
26
|
+
getItems() {
|
|
27
|
+
return Array.from(this.items);
|
|
28
|
+
}
|
|
29
|
+
getNotes() {
|
|
30
|
+
return Array.from(this.notes);
|
|
31
|
+
}
|
|
32
|
+
getCommands() {
|
|
33
|
+
return Array.from(this.commands);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
setMeasure(measure: math.Fraction) {
|
|
37
|
+
this.measure = measure;
|
|
38
|
+
}
|
|
39
|
+
getMeasure() {
|
|
40
|
+
return this.measure;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
getBarlineHidden() {
|
|
44
|
+
return this.barlineHidden;
|
|
45
|
+
}
|
|
46
|
+
setBarlineHidden(barlineHidden: boolean) {
|
|
47
|
+
this.barlineHidden = barlineHidden;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
setBpm(bpm: number) {
|
|
51
|
+
this.bpm = bpm;
|
|
52
|
+
}
|
|
53
|
+
getBpm() {
|
|
54
|
+
return this.bpm;
|
|
55
|
+
}
|
|
56
|
+
setScroll(scroll: number) {
|
|
57
|
+
this.scroll = scroll;
|
|
58
|
+
}
|
|
59
|
+
getScroll() {
|
|
60
|
+
return this.scroll;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
toJSON(): any {
|
|
64
|
+
return {
|
|
65
|
+
start: this.getStart().valueOf(),
|
|
66
|
+
end: this.getEnd().valueOf(),
|
|
67
|
+
items: this.items,
|
|
68
|
+
notes: this.notes,
|
|
69
|
+
commands: this.commands,
|
|
70
|
+
type: 'bar'
|
|
71
|
+
}
|
|
72
|
+
}
|
|
68
73
|
}
|
package/src/class/Branch.ts
CHANGED
|
@@ -1,34 +1,34 @@
|
|
|
1
|
-
import * as math from 'mathjs';
|
|
2
|
-
import { Bar } from './Bar.js';
|
|
3
|
-
import { NoteGroup } from './NoteGroup.js';
|
|
4
|
-
|
|
5
|
-
export class Branch extends NoteGroup {
|
|
6
|
-
type: Branch.Type;
|
|
7
|
-
criteria: [number, number];
|
|
8
|
-
normal?: Bar[];
|
|
9
|
-
advanced?: Bar[];
|
|
10
|
-
master?: Bar[];
|
|
11
|
-
|
|
12
|
-
constructor(type: Branch.Type, criteria1: [number, number], start: math.Fraction, end: math.Fraction) {
|
|
13
|
-
super(start, end);
|
|
14
|
-
this.type = type;
|
|
15
|
-
this.criteria = criteria1;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
toJSON() {
|
|
19
|
-
return {
|
|
20
|
-
start: this.getStart().valueOf(),
|
|
21
|
-
end: this.getEnd().valueOf(),
|
|
22
|
-
normal: this.normal,
|
|
23
|
-
advanced: this.advanced,
|
|
24
|
-
master: this.master,
|
|
25
|
-
criteria: this.criteria,
|
|
26
|
-
type: 'branch',
|
|
27
|
-
branchType: this.type === Branch.Type.ROLL ? 'roll' : 'acc'
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
export namespace Branch {
|
|
33
|
-
export enum Type { ROLL, ACCURACY }
|
|
1
|
+
import * as math from 'mathjs';
|
|
2
|
+
import { Bar } from './Bar.js';
|
|
3
|
+
import { NoteGroup } from './NoteGroup.js';
|
|
4
|
+
|
|
5
|
+
export class Branch extends NoteGroup {
|
|
6
|
+
type: Branch.Type;
|
|
7
|
+
criteria: [number, number];
|
|
8
|
+
normal?: Bar[];
|
|
9
|
+
advanced?: Bar[];
|
|
10
|
+
master?: Bar[];
|
|
11
|
+
|
|
12
|
+
constructor(type: Branch.Type, criteria1: [number, number], start: math.Fraction, end: math.Fraction) {
|
|
13
|
+
super(start, end);
|
|
14
|
+
this.type = type;
|
|
15
|
+
this.criteria = criteria1;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
toJSON() {
|
|
19
|
+
return {
|
|
20
|
+
start: this.getStart().valueOf(),
|
|
21
|
+
end: this.getEnd().valueOf(),
|
|
22
|
+
normal: this.normal,
|
|
23
|
+
advanced: this.advanced,
|
|
24
|
+
master: this.master,
|
|
25
|
+
criteria: this.criteria,
|
|
26
|
+
type: 'branch',
|
|
27
|
+
branchType: this.type === Branch.Type.ROLL ? 'roll' : 'acc'
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export namespace Branch {
|
|
33
|
+
export enum Type { ROLL, ACCURACY }
|
|
34
34
|
}
|
package/src/class/Command.ts
CHANGED
|
@@ -1,139 +1,139 @@
|
|
|
1
|
-
import { Item } from "./Item.js";
|
|
2
|
-
import * as math from 'mathjs';
|
|
3
|
-
|
|
4
|
-
export class Command extends Item {
|
|
5
|
-
static parse(line: string): Command | null {
|
|
6
|
-
if (line === '#BARLINEON') {
|
|
7
|
-
return new BarlineCommand(false, math.fraction(0));
|
|
8
|
-
}
|
|
9
|
-
else if (line === "#BARLINEOFF") {
|
|
10
|
-
return new BarlineCommand(true, math.fraction(0));
|
|
11
|
-
}
|
|
12
|
-
else if (line === "#GOGOSTART") {
|
|
13
|
-
return new GOGOCommand(GOGOCommand.Type.START, math.fraction(0));
|
|
14
|
-
}
|
|
15
|
-
else if (line === "#GOGOEND") {
|
|
16
|
-
return new GOGOCommand(GOGOCommand.Type.END, math.fraction(0));
|
|
17
|
-
}
|
|
18
|
-
else if (line === "#SECTION") {
|
|
19
|
-
return new SectionCommand(math.fraction(0));
|
|
20
|
-
}
|
|
21
|
-
else if (line.startsWith('#BPMCHANGE')) {
|
|
22
|
-
const value = Number(line.replace('#BPMCHANGE', ''));
|
|
23
|
-
if (Number.isNaN(value)) return null;
|
|
24
|
-
return new BPMChangeCommand(value, math.fraction(0));
|
|
25
|
-
}
|
|
26
|
-
else if (line.startsWith('#MEASURE')) {
|
|
27
|
-
return new MeasureCommand(math.fraction(line.replace('#MEASURE', '').trim()), math.fraction(0));
|
|
28
|
-
}
|
|
29
|
-
else if (line.startsWith('#SCROLL')) {
|
|
30
|
-
const value = Number(line.replace('#SCROLL', ''));
|
|
31
|
-
if (Number.isNaN(value)) return null;
|
|
32
|
-
return new ScrollCommand(value, math.fraction(0));
|
|
33
|
-
}
|
|
34
|
-
return null;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
constructor(timing: math.Fraction) {
|
|
38
|
-
super(timing);
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
export class BarlineCommand extends Command {
|
|
43
|
-
private hide: boolean;
|
|
44
|
-
constructor(hide: boolean, timing: math.Fraction) {
|
|
45
|
-
super(timing);
|
|
46
|
-
this.hide = hide;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
getHide(){
|
|
50
|
-
return this.hide;
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
toJSON(){
|
|
54
|
-
return {
|
|
55
|
-
...super.toJSON(),
|
|
56
|
-
type: 'command-barline',
|
|
57
|
-
hide: this.hide
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
export class BPMChangeCommand extends Command {
|
|
63
|
-
value: number;
|
|
64
|
-
constructor(value: number, timing: math.Fraction) {
|
|
65
|
-
super(timing);
|
|
66
|
-
this.value = value;
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
toJSON(){
|
|
70
|
-
return {
|
|
71
|
-
...super.toJSON(),
|
|
72
|
-
type: 'command-bpmchange',
|
|
73
|
-
value: this.value
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
export class MeasureCommand extends Command {
|
|
79
|
-
value: math.Fraction;
|
|
80
|
-
constructor(value: math.Fraction, timing: math.Fraction) {
|
|
81
|
-
super(timing);
|
|
82
|
-
this.value = value;
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
toJSON(){
|
|
86
|
-
return {
|
|
87
|
-
...super.toJSON(),
|
|
88
|
-
type: 'command-measure',
|
|
89
|
-
value: this.value.toString()
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
export class ScrollCommand extends Command {
|
|
95
|
-
value: number;
|
|
96
|
-
constructor(value: number, timing: math.Fraction) {
|
|
97
|
-
super(timing);
|
|
98
|
-
this.value = value;
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
toJSON(){
|
|
102
|
-
return {
|
|
103
|
-
...super.toJSON(),
|
|
104
|
-
type: 'command-scroll',
|
|
105
|
-
value: this.value
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
export class SectionCommand extends Command {
|
|
111
|
-
toJSON() {
|
|
112
|
-
return {
|
|
113
|
-
...super.toJSON(),
|
|
114
|
-
type: 'command-section'
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
export class GOGOCommand extends Command {
|
|
120
|
-
type: GOGOCommand.Type;
|
|
121
|
-
constructor(type: GOGOCommand.Type, timing: math.Fraction) {
|
|
122
|
-
super(timing);
|
|
123
|
-
this.type = type;
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
toJSON(){
|
|
127
|
-
return {
|
|
128
|
-
...super.toJSON(),
|
|
129
|
-
type: 'command-gogo',
|
|
130
|
-
start: this.type === GOGOCommand.Type.START
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
|
-
export namespace GOGOCommand {
|
|
135
|
-
export enum Type {
|
|
136
|
-
START,
|
|
137
|
-
END
|
|
138
|
-
}
|
|
1
|
+
import { Item } from "./Item.js";
|
|
2
|
+
import * as math from 'mathjs';
|
|
3
|
+
|
|
4
|
+
export class Command extends Item {
|
|
5
|
+
static parse(line: string): Command | null {
|
|
6
|
+
if (line === '#BARLINEON') {
|
|
7
|
+
return new BarlineCommand(false, math.fraction(0));
|
|
8
|
+
}
|
|
9
|
+
else if (line === "#BARLINEOFF") {
|
|
10
|
+
return new BarlineCommand(true, math.fraction(0));
|
|
11
|
+
}
|
|
12
|
+
else if (line === "#GOGOSTART") {
|
|
13
|
+
return new GOGOCommand(GOGOCommand.Type.START, math.fraction(0));
|
|
14
|
+
}
|
|
15
|
+
else if (line === "#GOGOEND") {
|
|
16
|
+
return new GOGOCommand(GOGOCommand.Type.END, math.fraction(0));
|
|
17
|
+
}
|
|
18
|
+
else if (line === "#SECTION") {
|
|
19
|
+
return new SectionCommand(math.fraction(0));
|
|
20
|
+
}
|
|
21
|
+
else if (line.startsWith('#BPMCHANGE')) {
|
|
22
|
+
const value = Number(line.replace('#BPMCHANGE', ''));
|
|
23
|
+
if (Number.isNaN(value)) return null;
|
|
24
|
+
return new BPMChangeCommand(value, math.fraction(0));
|
|
25
|
+
}
|
|
26
|
+
else if (line.startsWith('#MEASURE')) {
|
|
27
|
+
return new MeasureCommand(math.fraction(line.replace('#MEASURE', '').trim()), math.fraction(0));
|
|
28
|
+
}
|
|
29
|
+
else if (line.startsWith('#SCROLL')) {
|
|
30
|
+
const value = Number(line.replace('#SCROLL', ''));
|
|
31
|
+
if (Number.isNaN(value)) return null;
|
|
32
|
+
return new ScrollCommand(value, math.fraction(0));
|
|
33
|
+
}
|
|
34
|
+
return null;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
constructor(timing: math.Fraction) {
|
|
38
|
+
super(timing);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export class BarlineCommand extends Command {
|
|
43
|
+
private hide: boolean;
|
|
44
|
+
constructor(hide: boolean, timing: math.Fraction) {
|
|
45
|
+
super(timing);
|
|
46
|
+
this.hide = hide;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
getHide(){
|
|
50
|
+
return this.hide;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
toJSON(){
|
|
54
|
+
return {
|
|
55
|
+
...super.toJSON(),
|
|
56
|
+
type: 'command-barline',
|
|
57
|
+
hide: this.hide
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export class BPMChangeCommand extends Command {
|
|
63
|
+
value: number;
|
|
64
|
+
constructor(value: number, timing: math.Fraction) {
|
|
65
|
+
super(timing);
|
|
66
|
+
this.value = value;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
toJSON(){
|
|
70
|
+
return {
|
|
71
|
+
...super.toJSON(),
|
|
72
|
+
type: 'command-bpmchange',
|
|
73
|
+
value: this.value
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
export class MeasureCommand extends Command {
|
|
79
|
+
value: math.Fraction;
|
|
80
|
+
constructor(value: math.Fraction, timing: math.Fraction) {
|
|
81
|
+
super(timing);
|
|
82
|
+
this.value = value;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
toJSON(){
|
|
86
|
+
return {
|
|
87
|
+
...super.toJSON(),
|
|
88
|
+
type: 'command-measure',
|
|
89
|
+
value: this.value.toString()
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
export class ScrollCommand extends Command {
|
|
95
|
+
value: number;
|
|
96
|
+
constructor(value: number, timing: math.Fraction) {
|
|
97
|
+
super(timing);
|
|
98
|
+
this.value = value;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
toJSON(){
|
|
102
|
+
return {
|
|
103
|
+
...super.toJSON(),
|
|
104
|
+
type: 'command-scroll',
|
|
105
|
+
value: this.value
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
export class SectionCommand extends Command {
|
|
111
|
+
toJSON() {
|
|
112
|
+
return {
|
|
113
|
+
...super.toJSON(),
|
|
114
|
+
type: 'command-section'
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
export class GOGOCommand extends Command {
|
|
120
|
+
type: GOGOCommand.Type;
|
|
121
|
+
constructor(type: GOGOCommand.Type, timing: math.Fraction) {
|
|
122
|
+
super(timing);
|
|
123
|
+
this.type = type;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
toJSON(){
|
|
127
|
+
return {
|
|
128
|
+
...super.toJSON(),
|
|
129
|
+
type: 'command-gogo',
|
|
130
|
+
start: this.type === GOGOCommand.Type.START
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
export namespace GOGOCommand {
|
|
135
|
+
export enum Type {
|
|
136
|
+
START,
|
|
137
|
+
END
|
|
138
|
+
}
|
|
139
139
|
}
|