@coderline/alphatab 1.3.0-alpha.355 → 1.3.0-alpha.374

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/alphaTab.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * alphaTab v1.3.0-alpha.355 (develop, build 355)
2
+ * alphaTab v1.3.0-alpha.374 (develop, build 374)
3
3
  *
4
4
  * Copyright © 2022, Daniel Kuschny and Contributors, All rights reserved.
5
5
  *
@@ -4037,6 +4037,73 @@
4037
4037
  }
4038
4038
  }
4039
4039
 
4040
+ /**
4041
+ * This public enumeration lists all available key signatures
4042
+ */
4043
+ var KeySignature;
4044
+ (function (KeySignature) {
4045
+ /**
4046
+ * Cb (7 flats)
4047
+ */
4048
+ KeySignature[KeySignature["Cb"] = -7] = "Cb";
4049
+ /**
4050
+ * Gb (6 flats)
4051
+ */
4052
+ KeySignature[KeySignature["Gb"] = -6] = "Gb";
4053
+ /**
4054
+ * Db (5 flats)
4055
+ */
4056
+ KeySignature[KeySignature["Db"] = -5] = "Db";
4057
+ /**
4058
+ * Ab (4 flats)
4059
+ */
4060
+ KeySignature[KeySignature["Ab"] = -4] = "Ab";
4061
+ /**
4062
+ * Eb (3 flats)
4063
+ */
4064
+ KeySignature[KeySignature["Eb"] = -3] = "Eb";
4065
+ /**
4066
+ * Bb (2 flats)
4067
+ */
4068
+ KeySignature[KeySignature["Bb"] = -2] = "Bb";
4069
+ /**
4070
+ * F (1 flat)
4071
+ */
4072
+ KeySignature[KeySignature["F"] = -1] = "F";
4073
+ /**
4074
+ * C (no signs)
4075
+ */
4076
+ KeySignature[KeySignature["C"] = 0] = "C";
4077
+ /**
4078
+ * G (1 sharp)
4079
+ */
4080
+ KeySignature[KeySignature["G"] = 1] = "G";
4081
+ /**
4082
+ * D (2 sharp)
4083
+ */
4084
+ KeySignature[KeySignature["D"] = 2] = "D";
4085
+ /**
4086
+ * A (3 sharp)
4087
+ */
4088
+ KeySignature[KeySignature["A"] = 3] = "A";
4089
+ /**
4090
+ * E (4 sharp)
4091
+ */
4092
+ KeySignature[KeySignature["E"] = 4] = "E";
4093
+ /**
4094
+ * B (5 sharp)
4095
+ */
4096
+ KeySignature[KeySignature["B"] = 5] = "B";
4097
+ /**
4098
+ * F# (6 sharp)
4099
+ */
4100
+ KeySignature[KeySignature["FSharp"] = 6] = "FSharp";
4101
+ /**
4102
+ * C# (7 sharp)
4103
+ */
4104
+ KeySignature[KeySignature["CSharp"] = 7] = "CSharp";
4105
+ })(KeySignature || (KeySignature = {}));
4106
+
4040
4107
  var LyricsState;
4041
4108
  (function (LyricsState) {
4042
4109
  LyricsState[LyricsState["IgnoreSpaces"] = 0] = "IgnoreSpaces";
@@ -4172,73 +4239,6 @@
4172
4239
  Lyrics.CharCodeBrackedOpen = 91;
4173
4240
  Lyrics.CharCodeDash = 45;
4174
4241
 
4175
- /**
4176
- * This public enumeration lists all available key signatures
4177
- */
4178
- var KeySignature;
4179
- (function (KeySignature) {
4180
- /**
4181
- * Cb (7 flats)
4182
- */
4183
- KeySignature[KeySignature["Cb"] = -7] = "Cb";
4184
- /**
4185
- * Gb (6 flats)
4186
- */
4187
- KeySignature[KeySignature["Gb"] = -6] = "Gb";
4188
- /**
4189
- * Db (5 flats)
4190
- */
4191
- KeySignature[KeySignature["Db"] = -5] = "Db";
4192
- /**
4193
- * Ab (4 flats)
4194
- */
4195
- KeySignature[KeySignature["Ab"] = -4] = "Ab";
4196
- /**
4197
- * Eb (3 flats)
4198
- */
4199
- KeySignature[KeySignature["Eb"] = -3] = "Eb";
4200
- /**
4201
- * Bb (2 flats)
4202
- */
4203
- KeySignature[KeySignature["Bb"] = -2] = "Bb";
4204
- /**
4205
- * F (1 flat)
4206
- */
4207
- KeySignature[KeySignature["F"] = -1] = "F";
4208
- /**
4209
- * C (no signs)
4210
- */
4211
- KeySignature[KeySignature["C"] = 0] = "C";
4212
- /**
4213
- * G (1 sharp)
4214
- */
4215
- KeySignature[KeySignature["G"] = 1] = "G";
4216
- /**
4217
- * D (2 sharp)
4218
- */
4219
- KeySignature[KeySignature["D"] = 2] = "D";
4220
- /**
4221
- * A (3 sharp)
4222
- */
4223
- KeySignature[KeySignature["A"] = 3] = "A";
4224
- /**
4225
- * E (4 sharp)
4226
- */
4227
- KeySignature[KeySignature["E"] = 4] = "E";
4228
- /**
4229
- * B (5 sharp)
4230
- */
4231
- KeySignature[KeySignature["B"] = 5] = "B";
4232
- /**
4233
- * F# (6 sharp)
4234
- */
4235
- KeySignature[KeySignature["FSharp"] = 6] = "FSharp";
4236
- /**
4237
- * C# (8 sharp)
4238
- */
4239
- KeySignature[KeySignature["CSharp"] = 7] = "CSharp";
4240
- })(KeySignature || (KeySignature = {}));
4241
-
4242
4242
  /**
4243
4243
  * This public enumeration lists all available types of KeySignatures
4244
4244
  */
@@ -5707,11 +5707,11 @@
5707
5707
  }
5708
5708
  static symbolError(position, nonTerm, expected, symbol, symbolData = null) {
5709
5709
  let message;
5710
- if (!symbolData) {
5710
+ if (expected !== symbol) {
5711
5711
  message = `MalFormed AlphaTex: @${position}: Error on block ${nonTerm}, expected a ${AlphaTexSymbols[expected]} found a ${AlphaTexSymbols[symbol]}: '${symbolData}'`;
5712
5712
  }
5713
5713
  else {
5714
- message = `MalFormed AlphaTex: @${position}: Error on block ${nonTerm}, invalid value: ${symbolData}`;
5714
+ message = `MalFormed AlphaTex: @${position}: Error on block ${nonTerm}, invalid value: '${symbolData}'`;
5715
5715
  }
5716
5716
  let exception = new AlphaTexError(message);
5717
5717
  exception.position = position;
@@ -5722,7 +5722,7 @@
5722
5722
  return exception;
5723
5723
  }
5724
5724
  static errorMessage(position, message) {
5725
- message = 'MalFormed AlphaTex: @' + position + ': ' + message;
5725
+ message = `MalFormed AlphaTex: @${position}: ${message}`;
5726
5726
  let exception = new AlphaTexError(message);
5727
5727
  exception.position = position;
5728
5728
  return exception;
@@ -5810,7 +5810,7 @@
5810
5810
  error(nonterm, expected, symbolError = true) {
5811
5811
  let e;
5812
5812
  if (symbolError) {
5813
- e = AlphaTexError.symbolError(this._curChPos, nonterm, expected, this._sy, null);
5813
+ e = AlphaTexError.symbolError(this._curChPos, nonterm, expected, this._sy, this._syData);
5814
5814
  }
5815
5815
  else {
5816
5816
  e = AlphaTexError.symbolError(this._curChPos, nonterm, expected, expected, this._syData);
@@ -5951,37 +5951,65 @@
5951
5951
  parseKeySignature(str) {
5952
5952
  switch (str.toLowerCase()) {
5953
5953
  case 'cb':
5954
- return -7;
5954
+ case 'cbmajor':
5955
+ return KeySignature.Cb;
5955
5956
  case 'gb':
5956
- return -6;
5957
+ case 'gbmajor':
5958
+ case 'd#minor':
5959
+ return KeySignature.Gb;
5957
5960
  case 'db':
5958
- return -5;
5961
+ case 'dbmajor':
5962
+ case 'bbminor':
5963
+ return KeySignature.Db;
5959
5964
  case 'ab':
5960
- return -4;
5965
+ case 'abmajor':
5966
+ case 'fminor':
5967
+ return KeySignature.Ab;
5961
5968
  case 'eb':
5962
- return -3;
5969
+ case 'ebmajor':
5970
+ case 'cminor':
5971
+ return KeySignature.Eb;
5963
5972
  case 'bb':
5964
- return -2;
5973
+ case 'bbmajor':
5974
+ case 'gminor':
5975
+ return KeySignature.Bb;
5965
5976
  case 'f':
5966
- return -1;
5977
+ case 'fmajor':
5978
+ case 'dminor':
5979
+ return KeySignature.F;
5967
5980
  case 'c':
5968
- return 0;
5981
+ case 'cmajor':
5982
+ case 'aminor':
5983
+ return KeySignature.C;
5969
5984
  case 'g':
5970
- return 1;
5985
+ case 'gmajor':
5986
+ case 'eminor':
5987
+ return KeySignature.G;
5971
5988
  case 'd':
5972
- return 2;
5989
+ case 'dmajor':
5990
+ case 'bminor':
5991
+ return KeySignature.D;
5973
5992
  case 'a':
5974
- return 3;
5993
+ case 'amajor':
5994
+ case 'f#minor':
5995
+ return KeySignature.A;
5975
5996
  case 'e':
5976
- return 4;
5997
+ case 'emajor':
5998
+ case 'c#minor':
5999
+ return KeySignature.E;
5977
6000
  case 'b':
5978
- return 5;
6001
+ case 'bmajor':
6002
+ case 'g#minor':
6003
+ return KeySignature.B;
5979
6004
  case 'f#':
5980
- return 6;
6005
+ case 'f#major':
6006
+ case 'ebminor':
6007
+ return KeySignature.FSharp;
5981
6008
  case 'c#':
5982
- return 7;
6009
+ case 'c#major':
6010
+ return KeySignature.CSharp;
5983
6011
  default:
5984
- return 0;
6012
+ return KeySignature.C;
5985
6013
  // error("keysignature-value", AlphaTexSymbols.String, false); return 0
5986
6014
  }
5987
6015
  }
@@ -6022,7 +6050,7 @@
6022
6050
  }
6023
6051
  else if (this._ch === 0x2a /* * */) {
6024
6052
  // multiline comment
6025
- while (this._ch !== 0) {
6053
+ while (this._ch !== AlphaTexImporter.Eof) {
6026
6054
  if (this._ch === 0x2a /* * */) {
6027
6055
  this._ch = this.nextChar();
6028
6056
  if (this._ch === 0x2f /* / */) {
@@ -6055,9 +6083,8 @@
6055
6083
  // negative number
6056
6084
  // is number?
6057
6085
  if (this._allowNegatives && this.isDigit(this._ch)) {
6058
- let num = this.readNumber();
6059
6086
  this._sy = AlphaTexSymbols.Number;
6060
- this._syData = num;
6087
+ this._syData = this.readNumber();
6061
6088
  }
6062
6089
  else {
6063
6090
  this._sy = AlphaTexSymbols.String;
@@ -6078,9 +6105,8 @@
6078
6105
  }
6079
6106
  else if (this._ch === 0x5c /* \ */) {
6080
6107
  this._ch = this.nextChar();
6081
- let name = this.readName();
6082
6108
  this._sy = AlphaTexSymbols.MetaCommand;
6083
- this._syData = name;
6109
+ this._syData = this.readName();
6084
6110
  }
6085
6111
  else if (this._ch === 0x29 /* ) */) {
6086
6112
  this._sy = AlphaTexSymbols.RParensis;
@@ -6107,9 +6133,8 @@
6107
6133
  this._ch = this.nextChar();
6108
6134
  }
6109
6135
  else if (this.isDigit(this._ch)) {
6110
- let num = this.readNumber();
6111
6136
  this._sy = AlphaTexSymbols.Number;
6112
- this._syData = num;
6137
+ this._syData = this.readNumber();
6113
6138
  }
6114
6139
  else if (AlphaTexImporter.isLetter(this._ch)) {
6115
6140
  let name = this.readName();
@@ -7372,8 +7397,8 @@
7372
7397
  }
7373
7398
  this._sy = this.newSy();
7374
7399
  }
7375
- toFinger(syData) {
7376
- switch (syData) {
7400
+ toFinger(num) {
7401
+ switch (num) {
7377
7402
  case 1:
7378
7403
  return Fingers.Thumb;
7379
7404
  case 2:
@@ -7409,6 +7434,8 @@
7409
7434
  return Duration.SixtyFourth;
7410
7435
  case 128:
7411
7436
  return Duration.OneHundredTwentyEighth;
7437
+ case 256:
7438
+ return Duration.TwoHundredFiftySixth;
7412
7439
  default:
7413
7440
  return Duration.Quarter;
7414
7441
  }
@@ -7441,6 +7468,9 @@
7441
7468
  if (this._sy !== AlphaTexSymbols.Number) {
7442
7469
  this.error('repeatclose', AlphaTexSymbols.Number, true);
7443
7470
  }
7471
+ if (this._syData > 2048) {
7472
+ this.error('repeatclose', AlphaTexSymbols.Number, false);
7473
+ }
7444
7474
  master.repeatCount = this._syData;
7445
7475
  this._sy = this.newSy();
7446
7476
  }
@@ -7472,14 +7502,14 @@
7472
7502
  if (this._sy !== AlphaTexSymbols.String) {
7473
7503
  this.error('keysignature', AlphaTexSymbols.String, true);
7474
7504
  }
7475
- master.keySignature = this.parseKeySignature(this._syData.toLowerCase());
7505
+ master.keySignature = this.parseKeySignature(this._syData);
7476
7506
  this._sy = this.newSy();
7477
7507
  }
7478
7508
  else if (syData === 'clef') {
7479
7509
  this._sy = this.newSy();
7480
7510
  switch (this._sy) {
7481
7511
  case AlphaTexSymbols.String:
7482
- bar.clef = this.parseClefFromString(this._syData.toLowerCase());
7512
+ bar.clef = this.parseClefFromString(this._syData);
7483
7513
  break;
7484
7514
  case AlphaTexSymbols.Number:
7485
7515
  bar.clef = this.parseClefFromInt(this._syData);
@@ -7530,7 +7560,7 @@
7530
7560
  this._allowTuning = true;
7531
7561
  switch (this._sy) {
7532
7562
  case AlphaTexSymbols.String:
7533
- master.tripletFeel = this.parseTripletFeelFromString(this._syData.toLowerCase());
7563
+ master.tripletFeel = this.parseTripletFeelFromString(this._syData);
7534
7564
  break;
7535
7565
  case AlphaTexSymbols.Number:
7536
7566
  master.tripletFeel = this.parseTripletFeelFromInt(this._syData);
@@ -14536,7 +14566,7 @@
14536
14566
  }
14537
14567
  }
14538
14568
  get currentTime() {
14539
- return this._currentState.currentTime;
14569
+ return this._currentState.currentTime / this.playbackSpeed;
14540
14570
  }
14541
14571
  /**
14542
14572
  * Gets the duration of the song in ticks.
@@ -17463,6 +17493,11 @@
17463
17493
  this._notPlayedSamples += samples.length;
17464
17494
  this.output.addSamples(samples);
17465
17495
  }
17496
+ else {
17497
+ // Tell output that there is no data left for it.
17498
+ let samples = new Float32Array(0);
17499
+ this.output.addSamples(samples);
17500
+ }
17466
17501
  });
17467
17502
  this.output.samplesPlayed.on(this.onSamplesPlayed.bind(this));
17468
17503
  this.output.open(bufferTimeInMilliseconds);
@@ -17565,7 +17600,7 @@
17565
17600
  Logger.debug('AlphaSynth', 'Starting countin');
17566
17601
  this._sequencer.startCountIn();
17567
17602
  this._synthesizer.setupMetronomeChannel(this._countInVolume);
17568
- this.tickPosition = 0;
17603
+ this.updateTimePosition(0, true);
17569
17604
  }
17570
17605
  this.output.play();
17571
17606
  return true;
@@ -17717,6 +17752,7 @@
17717
17752
  this._sequencer.resetCountIn();
17718
17753
  this.timePosition = this._sequencer.currentTime;
17719
17754
  this.playInternal();
17755
+ this.output.resetSamples();
17720
17756
  }
17721
17757
  else if (this._sequencer.isPlayingOneTimeMidi) {
17722
17758
  Logger.debug('AlphaSynth', 'Finished playback (one time)');
@@ -17968,6 +18004,7 @@
17968
18004
  this.lineHeight = 'normal';
17969
18005
  this.size = '1rem';
17970
18006
  this.families = [];
18007
+ this.parseOnlyFamilies = false;
17971
18008
  this._currentTokenIndex = -1;
17972
18009
  this._input = '';
17973
18010
  this._currentToken = null;
@@ -18005,13 +18042,26 @@
18005
18042
  return;
18006
18043
  }
18007
18044
  }
18008
- this.fontStyleVariantWeight();
18009
- this.fontSizeLineHeight();
18045
+ if (!this.parseOnlyFamilies) {
18046
+ this.fontStyleVariantWeight();
18047
+ this.fontSizeLineHeight();
18048
+ }
18010
18049
  this.fontFamily();
18011
18050
  }
18051
+ static parseFamilies(value) {
18052
+ const parser = new FontParser(value);
18053
+ parser.parseOnlyFamilies = true;
18054
+ parser.parse();
18055
+ return parser.families;
18056
+ }
18012
18057
  fontFamily() {
18013
18058
  if (!this._currentToken) {
18014
- throw new Error(`Missing font list`);
18059
+ if (this.parseOnlyFamilies) {
18060
+ return;
18061
+ }
18062
+ else {
18063
+ throw new Error(`Missing font list`);
18064
+ }
18015
18065
  }
18016
18066
  const familyListInput = this._input.substr(this._currentToken.startPos).trim();
18017
18067
  let pos = 0;
@@ -18187,6 +18237,13 @@
18187
18237
  this._currentTokenIndex = -1;
18188
18238
  this.nextToken();
18189
18239
  }
18240
+ static quoteFont(f) {
18241
+ if (f.indexOf(' ') === -1) {
18242
+ return f;
18243
+ }
18244
+ const escapedQuotes = f.replaceAll('"', '\\"');
18245
+ return `"${escapedQuotes}"`;
18246
+ }
18190
18247
  }
18191
18248
  /**
18192
18249
  * Lists all flags for font styles.
@@ -18229,7 +18286,7 @@
18229
18286
  */
18230
18287
  constructor(family, size, style = FontStyle.Plain, weight = FontWeight.Regular) {
18231
18288
  this._cssScale = 0.0;
18232
- this._family = family;
18289
+ this._families = FontParser.parseFamilies(family);
18233
18290
  this._size = size;
18234
18291
  this._style = style;
18235
18292
  this._weight = weight;
@@ -18240,16 +18297,30 @@
18240
18297
  this._css = this.toCssString();
18241
18298
  }
18242
18299
  /**
18243
- * Gets the font family name.
18300
+ * Gets the first font family name.
18301
+ * @deprecated Consider using {@link families} for multi font family support.
18244
18302
  */
18245
18303
  get family() {
18246
- return this._family;
18304
+ return this._families[0];
18247
18305
  }
18248
18306
  /**
18249
- * Sets the font family name.
18307
+ * Sets the font family list.
18308
+ * @deprecated Consider using {@link families} for multi font family support.
18250
18309
  */
18251
18310
  set family(value) {
18252
- this._family = value;
18311
+ this.families = FontParser.parseFamilies(value);
18312
+ }
18313
+ /**
18314
+ * Gets the font family name.
18315
+ */
18316
+ get families() {
18317
+ return this._families;
18318
+ }
18319
+ /**
18320
+ * Sets the font family name.
18321
+ */
18322
+ set families(value) {
18323
+ this._families = value;
18253
18324
  this.reset();
18254
18325
  }
18255
18326
  /**
@@ -18297,6 +18368,18 @@
18297
18368
  get isItalic() {
18298
18369
  return this.style === FontStyle.Italic;
18299
18370
  }
18371
+ /**
18372
+ * Initializes a new instance of the {@link Font} class.
18373
+ * @param families The families.
18374
+ * @param size The size.
18375
+ * @param style The style.
18376
+ * @param weight The weight.
18377
+ */
18378
+ static withFamilyList(families, size, style = FontStyle.Plain, weight = FontWeight.Regular) {
18379
+ const f = new Font("", size, style, weight);
18380
+ f.families = families;
18381
+ return f;
18382
+ }
18300
18383
  toCssString(scale = 1) {
18301
18384
  if (!this._css || !(Math.abs(scale - this._cssScale) < 0.01)) {
18302
18385
  let buf = '';
@@ -18308,9 +18391,7 @@
18308
18391
  }
18309
18392
  buf += this.size * scale;
18310
18393
  buf += 'px ';
18311
- buf += "'";
18312
- buf += this.family;
18313
- buf += "'";
18394
+ buf += this.families.map(f => FontParser.quoteFont(f)).join(', ');
18314
18395
  this._css = buf;
18315
18396
  this._cssScale = scale;
18316
18397
  }
@@ -18322,21 +18403,17 @@
18322
18403
  return null;
18323
18404
  case 'object': {
18324
18405
  const m = v;
18325
- let family = m.get('family');
18406
+ let families = m.get('families');
18326
18407
  // tslint:disable-next-line: no-unnecessary-type-assertion
18327
18408
  let size = m.get('size');
18328
18409
  let style = JsonHelper.parseEnum(m.get('style'), FontStyle);
18329
18410
  let weight = JsonHelper.parseEnum(m.get('weight'), FontWeight);
18330
- return new Font(family, size, style, weight);
18411
+ return Font.withFamilyList(families, size, style, weight);
18331
18412
  }
18332
18413
  case 'string': {
18333
18414
  const parser = new FontParser(v);
18334
18415
  parser.parse();
18335
- let family = parser.families[0];
18336
- if ((family.startsWith("'") && family.endsWith("'")) ||
18337
- (family.startsWith('"') && family.endsWith('"'))) {
18338
- family = family.substr(1, family.length - 2);
18339
- }
18416
+ let families = parser.families;
18340
18417
  let fontSizeString = parser.size.toLowerCase();
18341
18418
  let fontSize = 0;
18342
18419
  // as per https://websemantics.uk/articles/font-size-conversion/
@@ -18399,7 +18476,7 @@
18399
18476
  fontWeight = FontWeight.Bold;
18400
18477
  break;
18401
18478
  }
18402
- return new Font(family, fontSize, fontStyle, fontWeight);
18479
+ return Font.withFamilyList(families, fontSize, fontStyle, fontWeight);
18403
18480
  }
18404
18481
  default:
18405
18482
  return null;
@@ -18407,7 +18484,7 @@
18407
18484
  }
18408
18485
  static toJson(font) {
18409
18486
  const o = new Map();
18410
- o.set('family', font.family);
18487
+ o.set('families', font.families);
18411
18488
  o.set('size', font.size);
18412
18489
  o.set('style', font.style);
18413
18490
  o.set('weight', font.weight);
@@ -18491,8 +18568,8 @@
18491
18568
  this.scoreInfoColor = new Color(0, 0, 0, 0xff);
18492
18569
  }
18493
18570
  }
18494
- RenderingResources.sansFont = 'Arial';
18495
- RenderingResources.serifFont = 'Georgia';
18571
+ RenderingResources.sansFont = 'Arial, sans-serif';
18572
+ RenderingResources.serifFont = 'Georgia, serif';
18496
18573
 
18497
18574
  /**
18498
18575
  * The display settings control how the general layout and display of alphaTab is done.
@@ -21058,9 +21135,17 @@
21058
21135
  FontSizes.FontSizeLookupTables.set(family, new Uint8Array([8]));
21059
21136
  }
21060
21137
  }
21061
- static measureString(s, family, size, style, weight) {
21138
+ static measureString(s, families, size, style, weight) {
21062
21139
  let data;
21063
21140
  let dataSize = 11;
21141
+ let family = families[0]; // default to first font
21142
+ // find a font which is maybe registered already
21143
+ for (let i = 0; i < families.length; i++) {
21144
+ if (FontSizes.FontSizeLookupTables.has(families[i])) {
21145
+ family = families[i];
21146
+ break;
21147
+ }
21148
+ }
21064
21149
  if (!FontSizes.FontSizeLookupTables.has(family)) {
21065
21150
  FontSizes.generateFontLookup(family);
21066
21151
  }
@@ -24359,6 +24444,10 @@
24359
24444
  * Applies any changes that were done to the settings object and informs the {@link renderer} about any new values to consider.
24360
24445
  */
24361
24446
  updateSettings() {
24447
+ const score = this.score;
24448
+ if (score) {
24449
+ ModelUtils.applyPitchOffsets(this.settings, score);
24450
+ }
24362
24451
  this.renderer.updateSettings(this.settings);
24363
24452
  // enable/disable player if needed
24364
24453
  if (this.settings.player.enablePlayer) {
@@ -24440,8 +24529,8 @@
24440
24529
  }
24441
24530
  }
24442
24531
  internalRenderTracks(score, tracks) {
24532
+ ModelUtils.applyPitchOffsets(this.settings, score);
24443
24533
  if (score !== this.score) {
24444
- ModelUtils.applyPitchOffsets(this.settings, score);
24445
24534
  this.score = score;
24446
24535
  this.tracks = tracks;
24447
24536
  this._trackIndexes = [];
@@ -25733,11 +25822,12 @@
25733
25822
  * @target web
25734
25823
  */
25735
25824
  class FontLoadingChecker {
25736
- constructor(family) {
25825
+ constructor(families) {
25737
25826
  this._isStarted = false;
25738
25827
  this.isFontLoaded = false;
25739
25828
  this.fontLoaded = new EventEmitterOfT();
25740
- this._family = family;
25829
+ this._originalFamilies = families;
25830
+ this._families = families;
25741
25831
  }
25742
25832
  checkForFontAvailability() {
25743
25833
  if (Environment.isRunningInWorker) {
@@ -25751,30 +25841,62 @@
25751
25841
  this._isStarted = true;
25752
25842
  let failCounter = 0;
25753
25843
  let failCounterId = window.setInterval(() => {
25754
- failCounter++;
25755
- Logger.warning('Rendering', `Could not load font '${this._family}' within ${failCounter * 5} seconds`, null);
25844
+ Logger.warning('Rendering', `Could not load font '${this._families[0]}' within ${(failCounter + 1) * 5} seconds`, null);
25845
+ // try loading next font if there are more than 1 left
25846
+ if (this._families.length > 1) {
25847
+ this._families.shift();
25848
+ failCounter = 0;
25849
+ }
25850
+ else {
25851
+ failCounter++;
25852
+ }
25756
25853
  }, 5000);
25757
- Logger.debug('Font', `Start checking for font availablility: ${this._family}`);
25758
- Logger.debug('Font', `[${this._family}] Font API available`);
25854
+ Logger.debug('Font', `Start checking for font availablility: ${this._families.join(', ')}`);
25855
+ let errorHandler = () => {
25856
+ if (this._families.length > 1) {
25857
+ Logger.debug('Font', `[${this._families[0]}] Loading Failed, switching to ${this._families[1]}`);
25858
+ this._families.shift();
25859
+ window.setTimeout(() => {
25860
+ checkFont();
25861
+ }, 0);
25862
+ }
25863
+ else {
25864
+ Logger.error('Font', `[${this._originalFamilies.join(',')}] Loading Failed, rendering cannot start`);
25865
+ window.clearInterval(failCounterId);
25866
+ }
25867
+ };
25868
+ let successHandler = (font) => {
25869
+ Logger.debug('Rendering', `[${font}] Font API signaled available`);
25870
+ this.isFontLoaded = true;
25871
+ window.clearInterval(failCounterId);
25872
+ this.fontLoaded.trigger(this._families[0]);
25873
+ };
25759
25874
  let checkFont = () => {
25760
- document.fonts.load(`1em ${this._family}`).then(() => {
25761
- Logger.debug('Font', `[${this._family}] Font API signaled loaded`);
25762
- if (document.fonts.check('1em ' + this._family)) {
25763
- Logger.debug('Rendering', `[${this._family}] Font API signaled available`);
25764
- this.isFontLoaded = true;
25765
- window.clearInterval(failCounterId);
25766
- this.fontLoaded.trigger(this._family);
25875
+ // Fast Path: check if one of the specified fonts is already available.
25876
+ for (const font of this._families) {
25877
+ if (document.fonts.check('1em ' + font)) {
25878
+ successHandler(font);
25879
+ return;
25880
+ }
25881
+ }
25882
+ // Slow path: Wait for fonts to be loaded sequentially
25883
+ const promise = document.fonts.load(`1em ${this._families[0]}`);
25884
+ promise.then(() => {
25885
+ Logger.debug('Font', `[${this._families[0]}] Font API signaled loaded`);
25886
+ if (document.fonts.check('1em ' + this._families[0])) {
25887
+ successHandler(this._families[0]);
25767
25888
  }
25768
25889
  else {
25769
- Logger.debug('Font', `[${this._family}] Font API loaded reported, but font not available, checking later again`, null);
25770
- window.setTimeout(() => {
25771
- checkFont();
25772
- }, 250);
25890
+ errorHandler();
25773
25891
  }
25774
25892
  return true;
25893
+ }, reason => {
25894
+ errorHandler();
25775
25895
  });
25776
25896
  };
25777
- checkFont();
25897
+ document.fonts.ready.then(() => {
25898
+ checkFont();
25899
+ });
25778
25900
  }
25779
25901
  }
25780
25902
 
@@ -26899,9 +27021,9 @@
26899
27021
  this.registerFontChecker(settings.display.resources.subTitleFont);
26900
27022
  }
26901
27023
  registerFontChecker(font) {
26902
- if (!this._fontCheckers.has(font.family)) {
26903
- let checker = new FontLoadingChecker(font.family);
26904
- this._fontCheckers.set(font.family, checker);
27024
+ if (!this._fontCheckers.has(font.families.join(', '))) {
27025
+ let checker = new FontLoadingChecker(font.families);
27026
+ this._fontCheckers.set(font.families.join(', '), checker);
26905
27027
  checker.fontLoaded.on(this.onFontLoaded.bind(this));
26906
27028
  checker.checkForFontAvailability();
26907
27029
  }
@@ -27876,7 +27998,7 @@
27876
27998
  if (!text) {
27877
27999
  return 0;
27878
28000
  }
27879
- return FontSizes.measureString(text, this.font.family, this.font.size, this.font.style, this.font.weight);
28001
+ return FontSizes.measureString(text, this.font.families, this.font.size, this.font.style, this.font.weight);
27880
28002
  }
27881
28003
  onRenderFinished() {
27882
28004
  // nothing to do
@@ -31368,7 +31490,7 @@
31368
31490
  renderTriplet(cx, cy, canvas) {
31369
31491
  cy += 2 * this.scale;
31370
31492
  let font = this.renderer.resources.effectFont;
31371
- canvas.font = new Font(font.family, font.size * 0.8, font.style);
31493
+ canvas.font = Font.withFamilyList(font.families, font.size * 0.8, font.style);
31372
31494
  let rightX = cx + TripletFeelGlyph.NoteSeparation * this.scale + 3 * this.scale;
31373
31495
  canvas.beginPath();
31374
31496
  canvas.moveTo(cx, cy + 3 * this.scale);
@@ -32881,7 +33003,7 @@
32881
33003
  let size = 12 * this.renderer.settings.display.scale;
32882
33004
  let height = Math.floor(size * 2);
32883
33005
  const e = new RenderFinishedEventArgs();
32884
- const font = new Font(resources.copyrightFont.family, size, FontStyle.Plain, FontWeight.Bold);
33006
+ const font = Font.withFamilyList(resources.copyrightFont.families, size, FontStyle.Plain, FontWeight.Bold);
32885
33007
  this.renderer.canvas.font = font;
32886
33008
  const centered = Environment.getLayoutEngineFactory(this.renderer.settings.display.layoutMode).vertical;
32887
33009
  e.width = this.renderer.canvas.measureText(msg);
@@ -38392,8 +38514,8 @@
38392
38514
  }
38393
38515
  paint(cx, cy, canvas) {
38394
38516
  let tabBarRenderer = this.renderer;
38395
- let startY = cy + this.x + (tabBarRenderer.getNoteY(this._beat.maxNote, NoteYPosition.Top));
38396
- let endY = cy + this.y + tabBarRenderer.getNoteY(this._beat.minNote, NoteYPosition.Bottom);
38517
+ let startY = cy + this.x + (tabBarRenderer.getNoteY(this._beat.maxStringNote, NoteYPosition.Top));
38518
+ let endY = cy + this.y + tabBarRenderer.getNoteY(this._beat.minStringNote, NoteYPosition.Bottom);
38397
38519
  let arrowX = (cx + this.x + this.width / 2) | 0;
38398
38520
  let arrowSize = 8 * this.scale;
38399
38521
  if (this._beat.brushType !== BrushType.None) {
@@ -40765,6 +40887,11 @@
40765
40887
  Document.prototype.replaceChildren = Element.prototype.replaceChildren;
40766
40888
  DocumentFragment.prototype.replaceChildren = Element.prototype.replaceChildren;
40767
40889
  }
40890
+ if (!('replaceAll' in String.prototype)) {
40891
+ String.prototype.replaceAll = function (str, newStr) {
40892
+ return this.replace(new RegExp(str, 'g'), newStr);
40893
+ };
40894
+ }
40768
40895
  }
40769
40896
  }
40770
40897
  /**
@@ -40839,7 +40966,7 @@
40839
40966
  /**
40840
40967
  * @target web
40841
40968
  */
40842
- Environment.bravuraFontChecker = new FontLoadingChecker('alphaTab');
40969
+ Environment.bravuraFontChecker = new FontLoadingChecker(['alphaTab']);
40843
40970
  Environment.renderEngines = Environment.createDefaultRenderEngines();
40844
40971
  Environment.layoutEngines = Environment.createDefaultLayoutEngines();
40845
40972
  Environment.staveProfiles = Environment.createDefaultStaveProfiles();
@@ -40984,8 +41111,8 @@
40984
41111
  // </auto-generated>
40985
41112
  class VersionInfo {
40986
41113
  }
40987
- VersionInfo.version = '1.3.0-alpha.355';
40988
- VersionInfo.date = '2022-08-09T00:56:55.506Z';
41114
+ VersionInfo.version = '1.3.0-alpha.374';
41115
+ VersionInfo.date = '2022-08-28T00:56:29.356Z';
40989
41116
 
40990
41117
  var index$5 = /*#__PURE__*/Object.freeze({
40991
41118
  __proto__: null,
@@ -44049,13 +44176,18 @@
44049
44176
  var index = /*#__PURE__*/Object.freeze({
44050
44177
  __proto__: null,
44051
44178
  AlphaSynth: AlphaSynth,
44179
+ CircularSampleBuffer: CircularSampleBuffer,
44052
44180
  PlaybackRange: PlaybackRange,
44053
44181
  get PlayerState () { return PlayerState; },
44054
44182
  PlayerStateChangedEventArgs: PlayerStateChangedEventArgs,
44055
44183
  PlaybackRangeChangedEventArgs: PlaybackRangeChangedEventArgs,
44056
44184
  PositionChangedEventArgs: PositionChangedEventArgs,
44185
+ MidiEventsPlayedEventArgs: MidiEventsPlayedEventArgs,
44057
44186
  ActiveBeatsChangedEventArgs: ActiveBeatsChangedEventArgs,
44058
- AlphaSynthWebWorkerApi: AlphaSynthWebWorkerApi
44187
+ AlphaSynthWebWorkerApi: AlphaSynthWebWorkerApi,
44188
+ AlphaSynthWebAudioOutputBase: AlphaSynthWebAudioOutputBase,
44189
+ AlphaSynthScriptProcessorOutput: AlphaSynthScriptProcessorOutput,
44190
+ AlphaSynthAudioWorkletOutput: AlphaSynthAudioWorkletOutput
44059
44191
  });
44060
44192
 
44061
44193
  exports.AlphaTabApi = AlphaTabApi;