@scorelabs/core 1.0.1

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.
@@ -0,0 +1,202 @@
1
+ /**
2
+ * Shared types and enums for ScoreLabs
3
+ */
4
+ export declare enum StemDirection {
5
+ Up = "up",
6
+ Down = "down"
7
+ }
8
+ export declare enum Clef {
9
+ Treble = "treble",
10
+ Bass = "bass",
11
+ Alto = "alto",
12
+ Tenor = "tenor",
13
+ Percussion = "percussion",
14
+ Tab = "tab"
15
+ }
16
+ export declare enum Duration {
17
+ Whole = "whole",
18
+ Half = "half",
19
+ Quarter = "quarter",
20
+ Eighth = "eighth",
21
+ Sixteenth = "sixteenth",
22
+ ThirtySecond = "thirty-second",
23
+ SixtyFourth = "sixty-fourth",
24
+ OneHundredTwentyEighth = "one-hundred-twenty-eighth",
25
+ TwoHundredFiftySixth = "two-hundred-fifty-sixth"
26
+ }
27
+ export declare enum Accidental {
28
+ Sharp = "sharp",
29
+ Flat = "flat",
30
+ Natural = "natural",
31
+ DoubleSharp = "double-sharp",
32
+ DoubleFlat = "double-flat"
33
+ }
34
+ export declare enum Articulation {
35
+ Staccato = "staccato",
36
+ Accent = "accent",
37
+ Tenuto = "tenuto",
38
+ Marcato = "marcato",
39
+ Fermata = "fermata",
40
+ Staccatissimo = "staccatissimo"
41
+ }
42
+ export declare enum Bowing {
43
+ DownBow = "down-bow",
44
+ UpBow = "up-bow"
45
+ }
46
+ export declare enum NoteheadShape {
47
+ Normal = "normal",
48
+ Cross = "cross",// X shape (percussion, spoken)
49
+ Diamond = "diamond",// Harmonics
50
+ Slash = "slash",// Rhythmic notation
51
+ Triangle = "triangle",// Percussion
52
+ Square = "square"
53
+ }
54
+ export declare enum Dynamic {
55
+ PPP = "ppp",
56
+ PP = "pp",
57
+ P = "p",
58
+ MP = "mp",
59
+ MF = "mf",
60
+ F = "f",
61
+ FF = "ff",
62
+ FFF = "fff",
63
+ SFZ = "sfz",
64
+ FP = "fp"
65
+ }
66
+ export declare enum Genre {
67
+ Blues = "Blues",
68
+ Children = "Children",
69
+ Christian = "Christian",
70
+ Christmas = "Christmas",
71
+ Classical = "Classical",
72
+ ContestFestival = "Contest/Festival",
73
+ Country = "Country",
74
+ Educational = "Educational",
75
+ FilmTV = "Film/TV",
76
+ Folk = "Folk",
77
+ Games = "Games",
78
+ Gospel = "Gospel",
79
+ Holiday = "Holiday",
80
+ Jazz = "Jazz",
81
+ Latin = "Latin",
82
+ Musicals = "Musicals",
83
+ Pop = "Pop",
84
+ RBHipHop = "R&B/Hip-Hop",
85
+ Rock = "Rock",
86
+ Standards = "Standards",
87
+ Traditional = "Traditional",
88
+ Wedding = "Wedding",
89
+ World = "World",
90
+ Worship = "Worship",
91
+ Unknown = "unknown"
92
+ }
93
+ export interface TimeSignature {
94
+ beats: number;
95
+ beatType: number;
96
+ symbol?: 'common' | 'cut' | 'normal';
97
+ }
98
+ export interface KeySignature {
99
+ fifths: number;
100
+ }
101
+ export interface Tempo {
102
+ bpm: number;
103
+ duration: Duration;
104
+ isDotted: boolean;
105
+ text?: string;
106
+ }
107
+ export interface Slur {
108
+ placement: 'start' | 'stop';
109
+ direction?: 'up' | 'down';
110
+ }
111
+ export interface Tuplet {
112
+ actual: number;
113
+ normal: number;
114
+ type: 'start' | 'stop' | 'middle';
115
+ }
116
+ export declare enum HairpinType {
117
+ Crescendo = "crescendo",
118
+ Decrescendo = "decrescendo"
119
+ }
120
+ export interface Hairpin {
121
+ type: HairpinType;
122
+ placement: 'start' | 'stop';
123
+ }
124
+ export interface Repeat {
125
+ type: 'start' | 'end';
126
+ times?: number;
127
+ }
128
+ export interface Volta {
129
+ type: 'start' | 'stop' | 'both';
130
+ number: number;
131
+ }
132
+ export declare enum BarlineStyle {
133
+ Regular = "regular",
134
+ Double = "light-light",// Double barline (often used for key changes)
135
+ Final = "light-heavy",
136
+ Dotted = "dotted",
137
+ Dashed = "dashed",
138
+ Heavy = "heavy",
139
+ None = "none"
140
+ }
141
+ export declare enum GlissandoType {
142
+ Wavy = "wavy",
143
+ Straight = "straight"
144
+ }
145
+ export interface Glissando {
146
+ type: GlissandoType;
147
+ placement: 'start' | 'stop';
148
+ }
149
+ export declare enum Arpeggio {
150
+ Normal = "normal",
151
+ Up = "up",
152
+ Down = "down"
153
+ }
154
+ export declare enum OttavaType {
155
+ OttavaAlta = "8va",
156
+ OttavaBassa = "8vb",
157
+ QuindicesimaAlta = "15ma",
158
+ QuindicesimaBassa = "15mb"
159
+ }
160
+ export interface Ottava {
161
+ type: OttavaType;
162
+ placement: 'start' | 'stop';
163
+ }
164
+ export interface Pedal {
165
+ type: 'sustain' | 'una-corda';
166
+ placement: 'start' | 'stop';
167
+ }
168
+ export declare enum Ornament {
169
+ Trill = "trill",
170
+ Mordent = "mordent",
171
+ InvertedMordent = "inverted-mordent",
172
+ Turn = "turn",
173
+ InvertedTurn = "inverted-turn"
174
+ }
175
+ export declare const DURATION_VALUES: Record<Duration, number>;
176
+ /**
177
+ * Decomposes a duration value (quarter = 1) into a list of duration/dot pairs.
178
+ */
179
+ export declare function decomposeDuration(value: number): {
180
+ duration: Duration;
181
+ isDotted: boolean;
182
+ val: number;
183
+ }[];
184
+ export interface FretboardDot {
185
+ string: number;
186
+ fret: number;
187
+ label?: string;
188
+ }
189
+ export interface FretboardBarre {
190
+ fret: number;
191
+ startString: number;
192
+ endString: number;
193
+ }
194
+ export interface FretboardDiagram {
195
+ strings: number;
196
+ frets: number;
197
+ startingFret?: number;
198
+ dots: FretboardDot[];
199
+ barres?: FretboardBarre[];
200
+ openStrings?: number[];
201
+ mutedStrings?: number[];
202
+ }
@@ -0,0 +1,205 @@
1
+ /**
2
+ * Shared types and enums for ScoreLabs
3
+ */
4
+ // Stem direction
5
+ export var StemDirection;
6
+ (function (StemDirection) {
7
+ StemDirection["Up"] = "up";
8
+ StemDirection["Down"] = "down";
9
+ })(StemDirection || (StemDirection = {}));
10
+ // Clef types supported
11
+ export var Clef;
12
+ (function (Clef) {
13
+ Clef["Treble"] = "treble";
14
+ Clef["Bass"] = "bass";
15
+ Clef["Alto"] = "alto";
16
+ Clef["Tenor"] = "tenor";
17
+ Clef["Percussion"] = "percussion";
18
+ Clef["Tab"] = "tab";
19
+ })(Clef || (Clef = {}));
20
+ // Note duration types
21
+ export var Duration;
22
+ (function (Duration) {
23
+ Duration["Whole"] = "whole";
24
+ Duration["Half"] = "half";
25
+ Duration["Quarter"] = "quarter";
26
+ Duration["Eighth"] = "eighth";
27
+ Duration["Sixteenth"] = "sixteenth";
28
+ Duration["ThirtySecond"] = "thirty-second";
29
+ Duration["SixtyFourth"] = "sixty-fourth";
30
+ Duration["OneHundredTwentyEighth"] = "one-hundred-twenty-eighth";
31
+ Duration["TwoHundredFiftySixth"] = "two-hundred-fifty-sixth";
32
+ })(Duration || (Duration = {}));
33
+ // Accidental types
34
+ export var Accidental;
35
+ (function (Accidental) {
36
+ Accidental["Sharp"] = "sharp";
37
+ Accidental["Flat"] = "flat";
38
+ Accidental["Natural"] = "natural";
39
+ Accidental["DoubleSharp"] = "double-sharp";
40
+ Accidental["DoubleFlat"] = "double-flat";
41
+ })(Accidental || (Accidental = {}));
42
+ // Articulation types
43
+ export var Articulation;
44
+ (function (Articulation) {
45
+ Articulation["Staccato"] = "staccato";
46
+ Articulation["Accent"] = "accent";
47
+ Articulation["Tenuto"] = "tenuto";
48
+ Articulation["Marcato"] = "marcato";
49
+ Articulation["Fermata"] = "fermata";
50
+ Articulation["Staccatissimo"] = "staccatissimo";
51
+ })(Articulation || (Articulation = {}));
52
+ // Bowing markings
53
+ export var Bowing;
54
+ (function (Bowing) {
55
+ Bowing["DownBow"] = "down-bow";
56
+ Bowing["UpBow"] = "up-bow";
57
+ })(Bowing || (Bowing = {}));
58
+ // Notehead shapes
59
+ export var NoteheadShape;
60
+ (function (NoteheadShape) {
61
+ NoteheadShape["Normal"] = "normal";
62
+ NoteheadShape["Cross"] = "cross";
63
+ NoteheadShape["Diamond"] = "diamond";
64
+ NoteheadShape["Slash"] = "slash";
65
+ NoteheadShape["Triangle"] = "triangle";
66
+ NoteheadShape["Square"] = "square";
67
+ })(NoteheadShape || (NoteheadShape = {}));
68
+ // Dynamic markings
69
+ export var Dynamic;
70
+ (function (Dynamic) {
71
+ Dynamic["PPP"] = "ppp";
72
+ Dynamic["PP"] = "pp";
73
+ Dynamic["P"] = "p";
74
+ Dynamic["MP"] = "mp";
75
+ Dynamic["MF"] = "mf";
76
+ Dynamic["F"] = "f";
77
+ Dynamic["FF"] = "ff";
78
+ Dynamic["FFF"] = "fff";
79
+ Dynamic["SFZ"] = "sfz";
80
+ Dynamic["FP"] = "fp";
81
+ })(Dynamic || (Dynamic = {}));
82
+ // Genre types
83
+ export var Genre;
84
+ (function (Genre) {
85
+ Genre["Blues"] = "Blues";
86
+ Genre["Children"] = "Children";
87
+ Genre["Christian"] = "Christian";
88
+ Genre["Christmas"] = "Christmas";
89
+ Genre["Classical"] = "Classical";
90
+ Genre["ContestFestival"] = "Contest/Festival";
91
+ Genre["Country"] = "Country";
92
+ Genre["Educational"] = "Educational";
93
+ Genre["FilmTV"] = "Film/TV";
94
+ Genre["Folk"] = "Folk";
95
+ Genre["Games"] = "Games";
96
+ Genre["Gospel"] = "Gospel";
97
+ Genre["Holiday"] = "Holiday";
98
+ Genre["Jazz"] = "Jazz";
99
+ Genre["Latin"] = "Latin";
100
+ Genre["Musicals"] = "Musicals";
101
+ Genre["Pop"] = "Pop";
102
+ Genre["RBHipHop"] = "R&B/Hip-Hop";
103
+ Genre["Rock"] = "Rock";
104
+ Genre["Standards"] = "Standards";
105
+ Genre["Traditional"] = "Traditional";
106
+ Genre["Wedding"] = "Wedding";
107
+ Genre["World"] = "World";
108
+ Genre["Worship"] = "Worship";
109
+ Genre["Unknown"] = "unknown";
110
+ })(Genre || (Genre = {}));
111
+ // Hairpin (Crescendo/Decrescendo)
112
+ export var HairpinType;
113
+ (function (HairpinType) {
114
+ HairpinType["Crescendo"] = "crescendo";
115
+ HairpinType["Decrescendo"] = "decrescendo";
116
+ })(HairpinType || (HairpinType = {}));
117
+ // Barline styles
118
+ export var BarlineStyle;
119
+ (function (BarlineStyle) {
120
+ BarlineStyle["Regular"] = "regular";
121
+ BarlineStyle["Double"] = "light-light";
122
+ BarlineStyle["Final"] = "light-heavy";
123
+ BarlineStyle["Dotted"] = "dotted";
124
+ BarlineStyle["Dashed"] = "dashed";
125
+ BarlineStyle["Heavy"] = "heavy";
126
+ BarlineStyle["None"] = "none";
127
+ })(BarlineStyle || (BarlineStyle = {}));
128
+ // Glissando
129
+ export var GlissandoType;
130
+ (function (GlissandoType) {
131
+ GlissandoType["Wavy"] = "wavy";
132
+ GlissandoType["Straight"] = "straight";
133
+ })(GlissandoType || (GlissandoType = {}));
134
+ // Arpeggio (rolled chords)
135
+ export var Arpeggio;
136
+ (function (Arpeggio) {
137
+ Arpeggio["Normal"] = "normal";
138
+ Arpeggio["Up"] = "up";
139
+ Arpeggio["Down"] = "down";
140
+ })(Arpeggio || (Arpeggio = {}));
141
+ // Ottava (8va, 8vb, etc.)
142
+ export var OttavaType;
143
+ (function (OttavaType) {
144
+ OttavaType["OttavaAlta"] = "8va";
145
+ OttavaType["OttavaBassa"] = "8vb";
146
+ OttavaType["QuindicesimaAlta"] = "15ma";
147
+ OttavaType["QuindicesimaBassa"] = "15mb";
148
+ })(OttavaType || (OttavaType = {}));
149
+ // Ornaments
150
+ export var Ornament;
151
+ (function (Ornament) {
152
+ Ornament["Trill"] = "trill";
153
+ Ornament["Mordent"] = "mordent";
154
+ Ornament["InvertedMordent"] = "inverted-mordent";
155
+ Ornament["Turn"] = "turn";
156
+ Ornament["InvertedTurn"] = "inverted-turn";
157
+ })(Ornament || (Ornament = {}));
158
+ // Duration values in terms of quarter note = 1
159
+ export const DURATION_VALUES = {
160
+ [Duration.Whole]: 4,
161
+ [Duration.Half]: 2,
162
+ [Duration.Quarter]: 1,
163
+ [Duration.Eighth]: 0.5,
164
+ [Duration.Sixteenth]: 0.25,
165
+ [Duration.ThirtySecond]: 0.125,
166
+ [Duration.SixtyFourth]: 0.0625,
167
+ [Duration.OneHundredTwentyEighth]: 0.03125,
168
+ [Duration.TwoHundredFiftySixth]: 0.015625,
169
+ };
170
+ /**
171
+ * Decomposes a duration value (quarter = 1) into a list of duration/dot pairs.
172
+ */
173
+ export function decomposeDuration(value) {
174
+ const result = [];
175
+ let remaining = value;
176
+ const options = [
177
+ { val: 4, dur: Duration.Whole, dot: false },
178
+ { val: 3, dur: Duration.Half, dot: true },
179
+ { val: 2, dur: Duration.Half, dot: false },
180
+ { val: 1.5, dur: Duration.Quarter, dot: true },
181
+ { val: 1, dur: Duration.Quarter, dot: false },
182
+ { val: 0.75, dur: Duration.Eighth, dot: true },
183
+ { val: 0.5, dur: Duration.Eighth, dot: false },
184
+ { val: 0.375, dur: Duration.Sixteenth, dot: true },
185
+ { val: 0.25, dur: Duration.Sixteenth, dot: false },
186
+ { val: 0.1875, dur: Duration.ThirtySecond, dot: true },
187
+ { val: 0.125, dur: Duration.ThirtySecond, dot: false },
188
+ { val: 0.09375, dur: Duration.SixtyFourth, dot: true },
189
+ { val: 0.0625, dur: Duration.SixtyFourth, dot: false },
190
+ ];
191
+ // Protect against infinite loop with max iterations
192
+ let loops = 0;
193
+ while (remaining > 0.001 && loops < 100) {
194
+ const match = options.find((o) => o.val <= remaining + 0.001);
195
+ if (match) {
196
+ result.push({ duration: match.dur, isDotted: match.dot, val: match.val });
197
+ remaining -= match.val;
198
+ }
199
+ else {
200
+ break;
201
+ }
202
+ loops++;
203
+ }
204
+ return result;
205
+ }
package/package.json ADDED
@@ -0,0 +1,34 @@
1
+ {
2
+ "name": "@scorelabs/core",
3
+ "version": "1.0.1",
4
+ "description": "Core logic and models for ScoreLabs music notation",
5
+ "type": "module",
6
+ "files": [
7
+ "dist"
8
+ ],
9
+ "main": "./dist/index.js",
10
+ "module": "./dist/index.js",
11
+ "types": "./dist/index.d.ts",
12
+ "exports": {
13
+ ".": {
14
+ "import": "./dist/index.js",
15
+ "types": "./dist/index.d.ts"
16
+ }
17
+ },
18
+ "scripts": {
19
+ "build": "tsc",
20
+ "preversion": "npm run build",
21
+ "postversion": "git push && git push --tags",
22
+ "release:patch": "npm version patch && npm publish --access public",
23
+ "release:minor": "npm version minor && npm publish --access public",
24
+ "release:major": "npm version major && npm publish --access public",
25
+ "release": "npm run release:patch"
26
+ },
27
+ "dependencies": {
28
+ "jszip": "^3.10.1"
29
+ },
30
+ "devDependencies": {
31
+ "@types/jszip": "^3.4.0",
32
+ "typescript": "^5.3.3"
33
+ }
34
+ }