@tspro/web-music-score 4.0.1 → 4.1.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.
@@ -1,9 +1,9 @@
1
1
  import { N as Note } from '../note-eA2xPPiG.js';
2
2
  export { A as Accidental, d as DefaultGuitarNoteLabel, D as DefaultPitchNotation, G as GuitarNoteLabel, e as GuitarNoteLabelList, a as NoteLetter, P as ParsedNote, b as PitchNotation, c as PitchNotationList, S as SymbolSet, g as getPitchNotationName, f as validateGuitarNoteLabel, v as validatePitchNotation } from '../note-eA2xPPiG.js';
3
- import { D as Degree } from '../scale-B2Icbetz.js';
4
- export { b as Interval, I as IntervalDirection, a as IntervalQuality, c as Scale, d as ScaleFactory, S as ScaleType, i as getDefaultScale, h as getScale, e as getScaleFactory, g as getScaleFactoryList, v as validateIntervalQuality, f as validateScaleType } from '../scale-B2Icbetz.js';
3
+ import { D as Degree } from '../scale-DQNA-YLD.js';
4
+ export { b as Interval, I as IntervalDirection, a as IntervalQuality, c as Scale, d as ScaleFactory, S as ScaleType, i as getDefaultScale, h as getScale, e as getScaleFactory, g as getScaleFactoryList, v as validateIntervalQuality, f as validateScaleType } from '../scale-DQNA-YLD.js';
5
5
  export { D as DefaultHandedness, a as DefaultTuningName, H as Handedness, T as TuningNameList, g as getTuningStrings, v as validateHandedness, b as validateTuningName } from '../guitar-CaZJDA05.js';
6
- export { A as AccidentalType, K as KeySignature, M as Mode, N as NoteLength, i as NoteLengthProps, h as NoteLengthStr, R as RhythmProps, c as Tempo, a as TimeSignature, T as TimeSignatureString, l as Tuplet, j as TupletRatio, f as alterTempoSpeed, g as getDefaultKeySignature, d as getDefaultTempo, b as getDefaultTimeSignature, e as getTempoString, v as validateNoteLength, k as validateTupletRatio } from '../tempo-Dt8aHpol.js';
6
+ export { A as AccidentalType, B as BeamGrouping, K as KeySignature, M as Mode, N as NoteLength, j as NoteLengthProps, i as NoteLengthStr, R as RhythmProps, d as Tempo, b as TimeSignature, a as TimeSignatureString, T as TimeSignatures, m as Tuplet, k as TupletRatio, h as alterTempoSpeed, g as getDefaultKeySignature, e as getDefaultTempo, c as getDefaultTimeSignature, f as getTempoString, v as validateNoteLength, l as validateTupletRatio } from '../tempo-Bp1UzsrZ.js';
7
7
 
8
8
  /** Chord info type. */
9
9
  type ChordInfo = {
@@ -1,4 +1,4 @@
1
- /* WebMusicScore v4.0.1 | (c) 2023 PahkaSoft | MIT License | Includes: Tone.js (MIT License) */
1
+ /* WebMusicScore v4.1.0 | (c) 2023 PahkaSoft | MIT License | Includes: Tone.js (MIT License) */
2
2
  "use strict";
3
3
  var __defProp = Object.defineProperty;
4
4
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
@@ -24,6 +24,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
24
24
  var theory_exports = {};
25
25
  __export(theory_exports, {
26
26
  AccidentalType: () => AccidentalType,
27
+ BeamGrouping: () => BeamGrouping,
27
28
  Chord: () => Chord,
28
29
  DefaultGuitarNoteLabel: () => DefaultGuitarNoteLabel,
29
30
  DefaultHandedness: () => DefaultHandedness,
@@ -46,6 +47,7 @@ __export(theory_exports, {
46
47
  ScaleType: () => ScaleType,
47
48
  SymbolSet: () => SymbolSet,
48
49
  TimeSignature: () => TimeSignature,
50
+ TimeSignatures: () => TimeSignatures,
49
51
  TuningNameList: () => TuningNameList,
50
52
  Tuplet: () => Tuplet,
51
53
  alterTempoSpeed: () => alterTempoSpeed,
@@ -2129,6 +2131,24 @@ var RhythmProps = _RhythmProps;
2129
2131
 
2130
2132
  // src/theory/time-signature.ts
2131
2133
  var import_core9 = require("@tspro/web-music-score/core");
2134
+ var TimeSignatures = /* @__PURE__ */ ((TimeSignatures2) => {
2135
+ TimeSignatures2["_2_4"] = "2/4";
2136
+ TimeSignatures2["_3_4"] = "3/4";
2137
+ TimeSignatures2["_4_4"] = "4/4";
2138
+ TimeSignatures2["_5_8"] = "5/8";
2139
+ TimeSignatures2["_6_8"] = "6/8";
2140
+ TimeSignatures2["_7_8"] = "7/8";
2141
+ TimeSignatures2["_9_8"] = "9/8";
2142
+ TimeSignatures2["_12_8"] = "12/8";
2143
+ return TimeSignatures2;
2144
+ })(TimeSignatures || {});
2145
+ var BeamGrouping = /* @__PURE__ */ ((BeamGrouping2) => {
2146
+ BeamGrouping2["_2_3"] = "2-3";
2147
+ BeamGrouping2["_3_2"] = "3-2";
2148
+ BeamGrouping2["_2_2_3"] = "2-2-3";
2149
+ BeamGrouping2["_3_2_2"] = "3-2-2";
2150
+ return BeamGrouping2;
2151
+ })(BeamGrouping || {});
2132
2152
  var TimeSignature = class {
2133
2153
  constructor(...args) {
2134
2154
  /** Number of beats in measure, upper value (e.g. "3" in "3/4"). */
@@ -2139,17 +2159,22 @@ var TimeSignature = class {
2139
2159
  __publicField(this, "beatLength");
2140
2160
  /** Number of ticks in measure. */
2141
2161
  __publicField(this, "measureTicks");
2142
- /** Number of beam groups in measure. */
2143
- __publicField(this, "beamGroupCount");
2144
- /** Length of one beam group. */
2145
- __publicField(this, "beamGroupLength");
2146
- if (args.length === 1 && typeof args[0] === "string") {
2162
+ /** Beam groups (e.g. [[2], [2]] or [[2, 2], [2, 2]] (first try as [[4], [4]])). */
2163
+ __publicField(this, "beamGroupSizes", []);
2164
+ let beamGrouping;
2165
+ if (import_ts_utils_lib9.Utils.Is.isEnumValue(args[0], TimeSignatures)) {
2147
2166
  let parts = args[0].split("/");
2148
2167
  this.beatCount = +parts[0];
2149
2168
  this.beatSize = +parts[1];
2150
- } else if (args.length === 2 && typeof args[0] === "number" && typeof args[1] === "number") {
2169
+ if (import_ts_utils_lib9.Utils.Is.isEnumValue(args[1], BeamGrouping)) {
2170
+ beamGrouping = args[1];
2171
+ }
2172
+ } else if (import_ts_utils_lib9.Utils.Is.isIntegerGte(args[0], 2) && import_ts_utils_lib9.Utils.Is.isIntegerGte(args[1], 2)) {
2151
2173
  this.beatCount = args[0];
2152
2174
  this.beatSize = args[1];
2175
+ if (import_ts_utils_lib9.Utils.Is.isEnumValue(args[2], BeamGrouping)) {
2176
+ beamGrouping = args[2];
2177
+ }
2153
2178
  } else {
2154
2179
  throw new import_core9.MusicError(import_core9.MusicErrorType.Timesignature, `Invalid args: ${args}`);
2155
2180
  }
@@ -2158,20 +2183,40 @@ var TimeSignature = class {
2158
2183
  } else if (!import_ts_utils_lib9.Utils.Is.isIntegerGte(this.beatSize, 1)) {
2159
2184
  throw new import_core9.MusicError(import_core9.MusicErrorType.Timesignature, `Invalid beatSize: ${this.beatSize}`);
2160
2185
  }
2161
- let props = NoteLengthProps.create(this.beatSize);
2162
- this.beatLength = props.noteLength;
2163
- this.measureTicks = this.beatCount * props.ticks;
2164
- if (this.is(2, 4) || this.is(3, 4) || this.is(4, 4)) {
2165
- this.beamGroupCount = this.beatCount;
2166
- } else if (this.is(6, 8) || this.is(9, 8)) {
2167
- this.beamGroupCount = this.beatCount / 3;
2168
- } else {
2169
- console.warn("Not necessarily an error, but unsupported time signature: " + this.toString());
2170
- this.beamGroupCount = 1;
2186
+ let { noteLength, ticks } = NoteLengthProps.create(this.beatSize);
2187
+ this.beatLength = noteLength;
2188
+ this.measureTicks = this.beatCount * ticks;
2189
+ if (this.is(2, 4)) {
2190
+ this.beamGroupSizes = [[2], [2]];
2191
+ } else if (this.is(3, 4)) {
2192
+ this.beamGroupSizes = [[2], [2], [2]];
2193
+ } else if (this.is(4, 4)) {
2194
+ this.beamGroupSizes = [[2, 2], [2, 2]];
2195
+ } else if (this.is(5, 8)) {
2196
+ if (!import_ts_utils_lib9.Utils.Is.isUndefined(beamGrouping) && beamGrouping !== "2-3" /* _2_3 */ && beamGrouping !== "3-2" /* _3_2 */) {
2197
+ throw new import_core9.MusicError(import_core9.MusicErrorType.Timesignature, `Invalid beam grouping "${beamGrouping}" for time signature "${this.toString()}".`);
2198
+ } else {
2199
+ this.beamGroupSizes = beamGrouping === "3-2" /* _3_2 */ ? [[3], [2]] : [[2], [3]];
2200
+ beamGrouping = void 0;
2201
+ }
2202
+ } else if (this.is(6, 8)) {
2203
+ this.beamGroupSizes = [[3], [3]];
2204
+ } else if (this.is(7, 8)) {
2205
+ if (!import_ts_utils_lib9.Utils.Is.isUndefined(beamGrouping) && beamGrouping !== "2-2-3" /* _2_2_3 */ && beamGrouping !== "3-2-2" /* _3_2_2 */) {
2206
+ throw new import_core9.MusicError(import_core9.MusicErrorType.Timesignature, `Invalid beam grouping "${beamGrouping}" for time signature "${this.toString()}".`);
2207
+ } else {
2208
+ this.beamGroupSizes = beamGrouping === "3-2-2" /* _3_2_2 */ ? [[3], [2], [2]] : [[2], [2], [3]];
2209
+ beamGrouping = void 0;
2210
+ }
2211
+ } else if (this.is(9, 8)) {
2212
+ this.beamGroupSizes = [[3], [3], [3]];
2213
+ } else if (this.is(12, 8)) {
2214
+ this.beamGroupSizes = [[3], [3], [3], [3]];
2171
2215
  }
2172
- this.beamGroupLength = this.measureTicks / this.beamGroupCount;
2173
- if (!import_ts_utils_lib9.Utils.Is.isIntegerGte(this.beamGroupLength, 1)) {
2174
- throw new import_core9.MusicError(import_core9.MusicErrorType.Timesignature, `Invalid beamGroupLength: ${this.beamGroupLength}`);
2216
+ if (this.beamGroupSizes.length === 0) {
2217
+ throw new import_core9.MusicError(import_core9.MusicErrorType.Timesignature, `Unimplemented time signature "${this.toString()}".`);
2218
+ } else if (beamGrouping !== void 0) {
2219
+ throw new import_core9.MusicError(import_core9.MusicErrorType.Timesignature, `Invalid beam grouping "${beamGrouping}" for time signature "${this.toString()}".`);
2175
2220
  }
2176
2221
  }
2177
2222
  /**
@@ -2223,6 +2268,7 @@ var import_core10 = require("@tspro/web-music-score/core");
2223
2268
  // Annotate the CommonJS export names for ESM import in node:
2224
2269
  0 && (module.exports = {
2225
2270
  AccidentalType,
2271
+ BeamGrouping,
2226
2272
  Chord,
2227
2273
  DefaultGuitarNoteLabel,
2228
2274
  DefaultHandedness,
@@ -2245,6 +2291,7 @@ var import_core10 = require("@tspro/web-music-score/core");
2245
2291
  ScaleType,
2246
2292
  SymbolSet,
2247
2293
  TimeSignature,
2294
+ TimeSignatures,
2248
2295
  TuningNameList,
2249
2296
  Tuplet,
2250
2297
  alterTempoSpeed,
@@ -1,7 +1,7 @@
1
- /* WebMusicScore v4.0.1 | (c) 2023 PahkaSoft | MIT License | Includes: Tone.js (MIT License) */
1
+ /* WebMusicScore v4.1.0 | (c) 2023 PahkaSoft | MIT License | Includes: Tone.js (MIT License) */
2
2
  import {
3
3
  __publicField
4
- } from "../chunk-YFPLOHP2.mjs";
4
+ } from "../chunk-MHNTJ6FU.mjs";
5
5
 
6
6
  // src/theory/chord.ts
7
7
  import { Utils as Utils6 } from "@tspro/ts-utils-lib";
@@ -2062,6 +2062,24 @@ var RhythmProps = _RhythmProps;
2062
2062
 
2063
2063
  // src/theory/time-signature.ts
2064
2064
  import { MusicError as MusicError9, MusicErrorType as MusicErrorType9 } from "@tspro/web-music-score/core";
2065
+ var TimeSignatures = /* @__PURE__ */ ((TimeSignatures2) => {
2066
+ TimeSignatures2["_2_4"] = "2/4";
2067
+ TimeSignatures2["_3_4"] = "3/4";
2068
+ TimeSignatures2["_4_4"] = "4/4";
2069
+ TimeSignatures2["_5_8"] = "5/8";
2070
+ TimeSignatures2["_6_8"] = "6/8";
2071
+ TimeSignatures2["_7_8"] = "7/8";
2072
+ TimeSignatures2["_9_8"] = "9/8";
2073
+ TimeSignatures2["_12_8"] = "12/8";
2074
+ return TimeSignatures2;
2075
+ })(TimeSignatures || {});
2076
+ var BeamGrouping = /* @__PURE__ */ ((BeamGrouping2) => {
2077
+ BeamGrouping2["_2_3"] = "2-3";
2078
+ BeamGrouping2["_3_2"] = "3-2";
2079
+ BeamGrouping2["_2_2_3"] = "2-2-3";
2080
+ BeamGrouping2["_3_2_2"] = "3-2-2";
2081
+ return BeamGrouping2;
2082
+ })(BeamGrouping || {});
2065
2083
  var TimeSignature = class {
2066
2084
  constructor(...args) {
2067
2085
  /** Number of beats in measure, upper value (e.g. "3" in "3/4"). */
@@ -2072,17 +2090,22 @@ var TimeSignature = class {
2072
2090
  __publicField(this, "beatLength");
2073
2091
  /** Number of ticks in measure. */
2074
2092
  __publicField(this, "measureTicks");
2075
- /** Number of beam groups in measure. */
2076
- __publicField(this, "beamGroupCount");
2077
- /** Length of one beam group. */
2078
- __publicField(this, "beamGroupLength");
2079
- if (args.length === 1 && typeof args[0] === "string") {
2093
+ /** Beam groups (e.g. [[2], [2]] or [[2, 2], [2, 2]] (first try as [[4], [4]])). */
2094
+ __publicField(this, "beamGroupSizes", []);
2095
+ let beamGrouping;
2096
+ if (Utils9.Is.isEnumValue(args[0], TimeSignatures)) {
2080
2097
  let parts = args[0].split("/");
2081
2098
  this.beatCount = +parts[0];
2082
2099
  this.beatSize = +parts[1];
2083
- } else if (args.length === 2 && typeof args[0] === "number" && typeof args[1] === "number") {
2100
+ if (Utils9.Is.isEnumValue(args[1], BeamGrouping)) {
2101
+ beamGrouping = args[1];
2102
+ }
2103
+ } else if (Utils9.Is.isIntegerGte(args[0], 2) && Utils9.Is.isIntegerGte(args[1], 2)) {
2084
2104
  this.beatCount = args[0];
2085
2105
  this.beatSize = args[1];
2106
+ if (Utils9.Is.isEnumValue(args[2], BeamGrouping)) {
2107
+ beamGrouping = args[2];
2108
+ }
2086
2109
  } else {
2087
2110
  throw new MusicError9(MusicErrorType9.Timesignature, `Invalid args: ${args}`);
2088
2111
  }
@@ -2091,20 +2114,40 @@ var TimeSignature = class {
2091
2114
  } else if (!Utils9.Is.isIntegerGte(this.beatSize, 1)) {
2092
2115
  throw new MusicError9(MusicErrorType9.Timesignature, `Invalid beatSize: ${this.beatSize}`);
2093
2116
  }
2094
- let props = NoteLengthProps.create(this.beatSize);
2095
- this.beatLength = props.noteLength;
2096
- this.measureTicks = this.beatCount * props.ticks;
2097
- if (this.is(2, 4) || this.is(3, 4) || this.is(4, 4)) {
2098
- this.beamGroupCount = this.beatCount;
2099
- } else if (this.is(6, 8) || this.is(9, 8)) {
2100
- this.beamGroupCount = this.beatCount / 3;
2101
- } else {
2102
- console.warn("Not necessarily an error, but unsupported time signature: " + this.toString());
2103
- this.beamGroupCount = 1;
2117
+ let { noteLength, ticks } = NoteLengthProps.create(this.beatSize);
2118
+ this.beatLength = noteLength;
2119
+ this.measureTicks = this.beatCount * ticks;
2120
+ if (this.is(2, 4)) {
2121
+ this.beamGroupSizes = [[2], [2]];
2122
+ } else if (this.is(3, 4)) {
2123
+ this.beamGroupSizes = [[2], [2], [2]];
2124
+ } else if (this.is(4, 4)) {
2125
+ this.beamGroupSizes = [[2, 2], [2, 2]];
2126
+ } else if (this.is(5, 8)) {
2127
+ if (!Utils9.Is.isUndefined(beamGrouping) && beamGrouping !== "2-3" /* _2_3 */ && beamGrouping !== "3-2" /* _3_2 */) {
2128
+ throw new MusicError9(MusicErrorType9.Timesignature, `Invalid beam grouping "${beamGrouping}" for time signature "${this.toString()}".`);
2129
+ } else {
2130
+ this.beamGroupSizes = beamGrouping === "3-2" /* _3_2 */ ? [[3], [2]] : [[2], [3]];
2131
+ beamGrouping = void 0;
2132
+ }
2133
+ } else if (this.is(6, 8)) {
2134
+ this.beamGroupSizes = [[3], [3]];
2135
+ } else if (this.is(7, 8)) {
2136
+ if (!Utils9.Is.isUndefined(beamGrouping) && beamGrouping !== "2-2-3" /* _2_2_3 */ && beamGrouping !== "3-2-2" /* _3_2_2 */) {
2137
+ throw new MusicError9(MusicErrorType9.Timesignature, `Invalid beam grouping "${beamGrouping}" for time signature "${this.toString()}".`);
2138
+ } else {
2139
+ this.beamGroupSizes = beamGrouping === "3-2-2" /* _3_2_2 */ ? [[3], [2], [2]] : [[2], [2], [3]];
2140
+ beamGrouping = void 0;
2141
+ }
2142
+ } else if (this.is(9, 8)) {
2143
+ this.beamGroupSizes = [[3], [3], [3]];
2144
+ } else if (this.is(12, 8)) {
2145
+ this.beamGroupSizes = [[3], [3], [3], [3]];
2104
2146
  }
2105
- this.beamGroupLength = this.measureTicks / this.beamGroupCount;
2106
- if (!Utils9.Is.isIntegerGte(this.beamGroupLength, 1)) {
2107
- throw new MusicError9(MusicErrorType9.Timesignature, `Invalid beamGroupLength: ${this.beamGroupLength}`);
2147
+ if (this.beamGroupSizes.length === 0) {
2148
+ throw new MusicError9(MusicErrorType9.Timesignature, `Unimplemented time signature "${this.toString()}".`);
2149
+ } else if (beamGrouping !== void 0) {
2150
+ throw new MusicError9(MusicErrorType9.Timesignature, `Invalid beam grouping "${beamGrouping}" for time signature "${this.toString()}".`);
2108
2151
  }
2109
2152
  }
2110
2153
  /**
@@ -2155,6 +2198,7 @@ import { init as initCore } from "@tspro/web-music-score/core";
2155
2198
  initCore();
2156
2199
  export {
2157
2200
  AccidentalType,
2201
+ BeamGrouping,
2158
2202
  Chord,
2159
2203
  DefaultGuitarNoteLabel,
2160
2204
  DefaultHandedness,
@@ -2177,6 +2221,7 @@ export {
2177
2221
  ScaleType,
2178
2222
  SymbolSet,
2179
2223
  TimeSignature,
2224
+ TimeSignatures,
2180
2225
  TuningNameList,
2181
2226
  Tuplet,
2182
2227
  alterTempoSpeed,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tspro/web-music-score",
3
- "version": "4.0.1",
3
+ "version": "4.1.0",
4
4
  "author": "PahkaSoft",
5
5
  "license": "MIT",
6
6
  "private": false,
@@ -102,6 +102,7 @@
102
102
  "@tspro/tsup-plugin-inline-assets": "^1.0.0",
103
103
  "@types/react": "^18.0.0",
104
104
  "@types/react-dom": "^18.0.0",
105
+ "rimraf": "^6.0.1",
105
106
  "tsup": "^8.5.0",
106
107
  "typedoc": "^0.28.6",
107
108
  "typescript": "latest"
@@ -117,4 +118,4 @@
117
118
  "build:prod (all workspaces)": "npm run build && npm run build:prod --workspaces --if-present",
118
119
  "docs": "typedoc"
119
120
  }
120
- }
121
+ }