@coderline/alphatab 1.3.0-alpha.849 → 1.3.0-alpha.856
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.d.ts +24 -0
- package/dist/alphaTab.js +321 -143
- package/dist/alphaTab.min.js +1 -1
- package/dist/alphaTab.min.mjs +1 -1
- package/dist/alphaTab.mjs +321 -143
- package/package.json +2 -2
package/dist/alphaTab.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* alphaTab v1.3.0-alpha.
|
|
2
|
+
* alphaTab v1.3.0-alpha.856 (develop, build 856)
|
|
3
3
|
*
|
|
4
4
|
* Copyright © 2023, Daniel Kuschny and Contributors, All rights reserved.
|
|
5
5
|
*
|
|
@@ -2029,6 +2029,7 @@
|
|
|
2029
2029
|
this.maxBendPoint = null;
|
|
2030
2030
|
/**
|
|
2031
2031
|
* Gets or sets the fret on which this note is played on the instrument.
|
|
2032
|
+
* 0 is the nut.
|
|
2032
2033
|
*/
|
|
2033
2034
|
this.fret = -1;
|
|
2034
2035
|
/**
|
|
@@ -2376,28 +2377,43 @@
|
|
|
2376
2377
|
return 0;
|
|
2377
2378
|
}
|
|
2378
2379
|
get realValue() {
|
|
2379
|
-
|
|
2380
|
-
if (this.isStringed) {
|
|
2381
|
-
if (this.harmonicType === HarmonicType.Natural) {
|
|
2382
|
-
realValue = this.harmonicPitch + this.stringTuning - this.beat.voice.bar.staff.transpositionPitch;
|
|
2383
|
-
}
|
|
2384
|
-
else {
|
|
2385
|
-
realValue += this.harmonicPitch;
|
|
2386
|
-
}
|
|
2387
|
-
}
|
|
2388
|
-
return realValue;
|
|
2380
|
+
return this.calculateRealValue(true, true);
|
|
2389
2381
|
}
|
|
2390
2382
|
get realValueWithoutHarmonic() {
|
|
2391
|
-
|
|
2392
|
-
|
|
2393
|
-
|
|
2394
|
-
|
|
2395
|
-
|
|
2383
|
+
return this.calculateRealValue(true, false);
|
|
2384
|
+
}
|
|
2385
|
+
/**
|
|
2386
|
+
* Calculates the real note value of this note as midi key respecting the given options.
|
|
2387
|
+
* @param applyTranspositionPitch Whether or not to apply the transposition pitch of the current staff.
|
|
2388
|
+
* @param applyHarmonic Whether or not to apply harmonic pitches to the note.
|
|
2389
|
+
* @returns The calculated note value as midi key.
|
|
2390
|
+
*/
|
|
2391
|
+
calculateRealValue(applyTranspositionPitch, applyHarmonic) {
|
|
2392
|
+
const transpositionPitch = applyTranspositionPitch ? this.beat.voice.bar.staff.transpositionPitch : 0;
|
|
2393
|
+
if (applyHarmonic) {
|
|
2394
|
+
let realValue = this.calculateRealValue(applyTranspositionPitch, false);
|
|
2395
|
+
if (this.isStringed) {
|
|
2396
|
+
if (this.harmonicType === HarmonicType.Natural) {
|
|
2397
|
+
realValue = this.harmonicPitch + this.stringTuning - transpositionPitch;
|
|
2398
|
+
}
|
|
2399
|
+
else {
|
|
2400
|
+
realValue += this.harmonicPitch;
|
|
2401
|
+
}
|
|
2402
|
+
}
|
|
2403
|
+
return realValue;
|
|
2396
2404
|
}
|
|
2397
|
-
|
|
2398
|
-
|
|
2405
|
+
else {
|
|
2406
|
+
if (this.isPercussion) {
|
|
2407
|
+
return this.percussionArticulation;
|
|
2408
|
+
}
|
|
2409
|
+
if (this.isStringed) {
|
|
2410
|
+
return this.fret + this.stringTuning - transpositionPitch;
|
|
2411
|
+
}
|
|
2412
|
+
if (this.isPiano) {
|
|
2413
|
+
return this.octave * 12 + this.tone - transpositionPitch;
|
|
2414
|
+
}
|
|
2415
|
+
return 0;
|
|
2399
2416
|
}
|
|
2400
|
-
return 0;
|
|
2401
2417
|
}
|
|
2402
2418
|
get harmonicPitch() {
|
|
2403
2419
|
if (this.harmonicType === HarmonicType.None || !this.isStringed) {
|
|
@@ -13323,6 +13339,7 @@
|
|
|
13323
13339
|
this.ensureVoices(bar);
|
|
13324
13340
|
}
|
|
13325
13341
|
}
|
|
13342
|
+
let chordsByIdForTrack = new Map();
|
|
13326
13343
|
if (masterBar) {
|
|
13327
13344
|
let attributesParsed = false;
|
|
13328
13345
|
for (let c of element.childNodes) {
|
|
@@ -13344,7 +13361,7 @@
|
|
|
13344
13361
|
}
|
|
13345
13362
|
break;
|
|
13346
13363
|
case 'harmony':
|
|
13347
|
-
this.parseHarmony(c, track);
|
|
13364
|
+
this.parseHarmony(c, track, chordsByIdForTrack);
|
|
13348
13365
|
break;
|
|
13349
13366
|
case 'sound':
|
|
13350
13367
|
// TODO
|
|
@@ -13484,127 +13501,23 @@
|
|
|
13484
13501
|
staff.tuning[staff.tuning.length - line] = tuning;
|
|
13485
13502
|
}
|
|
13486
13503
|
}
|
|
13487
|
-
parseHarmony(element, track) {
|
|
13488
|
-
let
|
|
13489
|
-
let
|
|
13490
|
-
|
|
13491
|
-
|
|
13492
|
-
for (let c of element.childNodes) {
|
|
13493
|
-
if (c.nodeType === XmlNodeType.Element) {
|
|
13494
|
-
switch (c.localName) {
|
|
13504
|
+
parseHarmony(element, track, chordsByIdForTrack) {
|
|
13505
|
+
let chord = new Chord();
|
|
13506
|
+
for (let childNode of element.childNodes) {
|
|
13507
|
+
if (childNode.nodeType === XmlNodeType.Element) {
|
|
13508
|
+
switch (childNode.localName) {
|
|
13495
13509
|
case 'root':
|
|
13496
|
-
|
|
13497
|
-
|
|
13498
|
-
|
|
13499
|
-
|
|
13500
|
-
|
|
13501
|
-
|
|
13502
|
-
|
|
13503
|
-
switch (parseInt(c.innerText)) {
|
|
13504
|
-
case -2:
|
|
13505
|
-
rootAlter = ' bb';
|
|
13506
|
-
break;
|
|
13507
|
-
case -1:
|
|
13508
|
-
rootAlter = ' b';
|
|
13509
|
-
break;
|
|
13510
|
-
case 0:
|
|
13511
|
-
rootAlter = '';
|
|
13512
|
-
break;
|
|
13513
|
-
case 1:
|
|
13514
|
-
rootAlter = ' #';
|
|
13515
|
-
break;
|
|
13516
|
-
case 2:
|
|
13517
|
-
rootAlter = ' ##';
|
|
13518
|
-
break;
|
|
13519
|
-
}
|
|
13520
|
-
break;
|
|
13521
|
-
}
|
|
13522
|
-
}
|
|
13523
|
-
}
|
|
13510
|
+
chord.name = this.parseHarmonyRoot(childNode);
|
|
13511
|
+
break;
|
|
13512
|
+
case 'kind':
|
|
13513
|
+
chord.name = chord.name + this.parseHarmonyKind(childNode);
|
|
13514
|
+
break;
|
|
13515
|
+
case 'frame':
|
|
13516
|
+
this.parseHarmonyFrame(childNode, chord);
|
|
13524
13517
|
break;
|
|
13525
13518
|
}
|
|
13526
13519
|
}
|
|
13527
13520
|
}
|
|
13528
|
-
let chord = new Chord();
|
|
13529
|
-
chord.name = rootStep + rootAlter;
|
|
13530
|
-
// TODO: find proper names for the rest
|
|
13531
|
-
// switch (kind)
|
|
13532
|
-
// {
|
|
13533
|
-
// // triads
|
|
13534
|
-
// case "major":
|
|
13535
|
-
// break;
|
|
13536
|
-
// case "minor":
|
|
13537
|
-
// chord.Name += "m";
|
|
13538
|
-
// break;
|
|
13539
|
-
// // Sevenths
|
|
13540
|
-
// case "augmented":
|
|
13541
|
-
// break;
|
|
13542
|
-
// case "diminished":
|
|
13543
|
-
// break;
|
|
13544
|
-
// case "dominant":
|
|
13545
|
-
// break;
|
|
13546
|
-
// case "major-seventh":
|
|
13547
|
-
// chord.Name += "7M";
|
|
13548
|
-
// break;
|
|
13549
|
-
// case "minor-seventh":
|
|
13550
|
-
// chord.Name += "m7";
|
|
13551
|
-
// break;
|
|
13552
|
-
// case "diminished-seventh":
|
|
13553
|
-
// break;
|
|
13554
|
-
// case "augmented-seventh":
|
|
13555
|
-
// break;
|
|
13556
|
-
// case "half-diminished":
|
|
13557
|
-
// break;
|
|
13558
|
-
// case "major-minor":
|
|
13559
|
-
// break;
|
|
13560
|
-
// // Sixths
|
|
13561
|
-
// case "major-sixth":
|
|
13562
|
-
// break;
|
|
13563
|
-
// case "minor-sixth":
|
|
13564
|
-
// break;
|
|
13565
|
-
// // Ninths
|
|
13566
|
-
// case "dominant-ninth":
|
|
13567
|
-
// break;
|
|
13568
|
-
// case "major-ninth":
|
|
13569
|
-
// break;
|
|
13570
|
-
// case "minor-ninth":
|
|
13571
|
-
// break;
|
|
13572
|
-
// // 11ths
|
|
13573
|
-
// case "dominant-11th":
|
|
13574
|
-
// break;
|
|
13575
|
-
// case "major-11th":
|
|
13576
|
-
// break;
|
|
13577
|
-
// case "minor-11th":
|
|
13578
|
-
// break;
|
|
13579
|
-
// // 13ths
|
|
13580
|
-
// case "dominant-13th":
|
|
13581
|
-
// break;
|
|
13582
|
-
// case "major-13th":
|
|
13583
|
-
// break;
|
|
13584
|
-
// case "minor-13th":
|
|
13585
|
-
// break;
|
|
13586
|
-
// // Suspended
|
|
13587
|
-
// case "suspended-second":
|
|
13588
|
-
// break;
|
|
13589
|
-
// case "suspended-fourth":
|
|
13590
|
-
// break;
|
|
13591
|
-
// // Functional sixths
|
|
13592
|
-
// case "Neapolitan":
|
|
13593
|
-
// break;
|
|
13594
|
-
// case "Italian":
|
|
13595
|
-
// break;
|
|
13596
|
-
// case "French":
|
|
13597
|
-
// break;
|
|
13598
|
-
// case "German":
|
|
13599
|
-
// break;
|
|
13600
|
-
// // Other
|
|
13601
|
-
// case "pedal":
|
|
13602
|
-
// break;
|
|
13603
|
-
// case "power":
|
|
13604
|
-
// break;
|
|
13605
|
-
// case "Tristan":
|
|
13606
|
-
// break;
|
|
13607
|
-
// }
|
|
13608
13521
|
// var degree = element.GetElementsByTagName("degree");
|
|
13609
13522
|
// if (degree.Length > 0)
|
|
13610
13523
|
// {
|
|
@@ -13621,9 +13534,199 @@
|
|
|
13621
13534
|
// }
|
|
13622
13535
|
// }
|
|
13623
13536
|
this._currentChord = ModelUtils.newGuid();
|
|
13537
|
+
const chordKey = chord.uniqueId;
|
|
13538
|
+
if (chordsByIdForTrack.has(chordKey)) {
|
|
13539
|
+
// check if the chord is already present
|
|
13540
|
+
chord.showDiagram = false;
|
|
13541
|
+
}
|
|
13624
13542
|
for (let staff of track.staves) {
|
|
13625
13543
|
staff.addChord(this._currentChord, chord);
|
|
13626
13544
|
}
|
|
13545
|
+
chordsByIdForTrack.set(chordKey, chord);
|
|
13546
|
+
}
|
|
13547
|
+
parseHarmonyRoot(xmlNode) {
|
|
13548
|
+
let rootStep = '';
|
|
13549
|
+
let rootAlter = '';
|
|
13550
|
+
for (let rootChild of xmlNode.childNodes) {
|
|
13551
|
+
if (rootChild.nodeType === XmlNodeType.Element) {
|
|
13552
|
+
switch (rootChild.localName) {
|
|
13553
|
+
case 'root-step':
|
|
13554
|
+
rootStep = rootChild.innerText;
|
|
13555
|
+
break;
|
|
13556
|
+
case 'root-alter':
|
|
13557
|
+
switch (parseInt(xmlNode.innerText)) {
|
|
13558
|
+
case -2:
|
|
13559
|
+
rootAlter = 'bb';
|
|
13560
|
+
break;
|
|
13561
|
+
case -1:
|
|
13562
|
+
rootAlter = 'b';
|
|
13563
|
+
break;
|
|
13564
|
+
case 0:
|
|
13565
|
+
rootAlter = '';
|
|
13566
|
+
break;
|
|
13567
|
+
case 1:
|
|
13568
|
+
rootAlter = '#';
|
|
13569
|
+
break;
|
|
13570
|
+
case 2:
|
|
13571
|
+
rootAlter = '##';
|
|
13572
|
+
break;
|
|
13573
|
+
}
|
|
13574
|
+
break;
|
|
13575
|
+
}
|
|
13576
|
+
}
|
|
13577
|
+
}
|
|
13578
|
+
return rootStep + rootAlter;
|
|
13579
|
+
}
|
|
13580
|
+
parseHarmonyKind(xmlNode) {
|
|
13581
|
+
const kindText = xmlNode.getAttribute('text');
|
|
13582
|
+
let resultKind = '';
|
|
13583
|
+
if (kindText) {
|
|
13584
|
+
// the abbreviation is already provided
|
|
13585
|
+
resultKind = kindText;
|
|
13586
|
+
}
|
|
13587
|
+
else {
|
|
13588
|
+
const kindContent = xmlNode.innerText;
|
|
13589
|
+
switch (kindContent) {
|
|
13590
|
+
// triads
|
|
13591
|
+
case 'major':
|
|
13592
|
+
resultKind = '';
|
|
13593
|
+
break;
|
|
13594
|
+
case 'minor':
|
|
13595
|
+
resultKind = 'm';
|
|
13596
|
+
break;
|
|
13597
|
+
// Sevenths
|
|
13598
|
+
case 'augmented':
|
|
13599
|
+
resultKind = '+';
|
|
13600
|
+
break;
|
|
13601
|
+
case 'diminished':
|
|
13602
|
+
resultKind = '\u25CB';
|
|
13603
|
+
break;
|
|
13604
|
+
case 'dominant':
|
|
13605
|
+
resultKind = '7';
|
|
13606
|
+
break;
|
|
13607
|
+
case 'major-seventh':
|
|
13608
|
+
resultKind = '7M';
|
|
13609
|
+
break;
|
|
13610
|
+
case 'minor-seventh':
|
|
13611
|
+
resultKind = 'm7';
|
|
13612
|
+
break;
|
|
13613
|
+
case 'diminished-seventh':
|
|
13614
|
+
resultKind = '\u25CB7';
|
|
13615
|
+
break;
|
|
13616
|
+
case 'augmented-seventh':
|
|
13617
|
+
resultKind = '+7';
|
|
13618
|
+
break;
|
|
13619
|
+
case 'half-diminished':
|
|
13620
|
+
resultKind = '\u2349';
|
|
13621
|
+
break;
|
|
13622
|
+
case 'major-minor':
|
|
13623
|
+
resultKind = 'mMaj';
|
|
13624
|
+
break;
|
|
13625
|
+
// Sixths
|
|
13626
|
+
case 'major-sixth':
|
|
13627
|
+
resultKind = 'maj6';
|
|
13628
|
+
break;
|
|
13629
|
+
case 'minor-sixth':
|
|
13630
|
+
resultKind = 'm6';
|
|
13631
|
+
break;
|
|
13632
|
+
// Ninths
|
|
13633
|
+
case 'dominant-ninth':
|
|
13634
|
+
resultKind = '9';
|
|
13635
|
+
break;
|
|
13636
|
+
case 'major-ninth':
|
|
13637
|
+
resultKind = 'maj9';
|
|
13638
|
+
break;
|
|
13639
|
+
case 'minor-ninth':
|
|
13640
|
+
resultKind = 'm9';
|
|
13641
|
+
break;
|
|
13642
|
+
// 11ths
|
|
13643
|
+
case 'dominant-11th':
|
|
13644
|
+
resultKind = '11';
|
|
13645
|
+
break;
|
|
13646
|
+
case 'major-11th':
|
|
13647
|
+
resultKind = 'maj11';
|
|
13648
|
+
break;
|
|
13649
|
+
case 'minor-11th':
|
|
13650
|
+
resultKind = 'm11';
|
|
13651
|
+
break;
|
|
13652
|
+
// 13ths
|
|
13653
|
+
case 'dominant-13th':
|
|
13654
|
+
resultKind = '13';
|
|
13655
|
+
break;
|
|
13656
|
+
case 'major-13th':
|
|
13657
|
+
resultKind = 'maj13';
|
|
13658
|
+
break;
|
|
13659
|
+
case 'minor-13th':
|
|
13660
|
+
resultKind = 'm13';
|
|
13661
|
+
break;
|
|
13662
|
+
// Suspended
|
|
13663
|
+
case 'suspended-second':
|
|
13664
|
+
resultKind = 'sus2';
|
|
13665
|
+
break;
|
|
13666
|
+
case 'suspended-fourth':
|
|
13667
|
+
resultKind = 'sus4';
|
|
13668
|
+
break;
|
|
13669
|
+
// TODO: find proper names for the rest
|
|
13670
|
+
// Functional sixths
|
|
13671
|
+
// case "Neapolitan":
|
|
13672
|
+
// break;
|
|
13673
|
+
// case "Italian":
|
|
13674
|
+
// break;
|
|
13675
|
+
// case "French":
|
|
13676
|
+
// break;
|
|
13677
|
+
// case "German":
|
|
13678
|
+
// break;
|
|
13679
|
+
// // Other
|
|
13680
|
+
// case "pedal":
|
|
13681
|
+
// break;
|
|
13682
|
+
// case "power":
|
|
13683
|
+
// break;
|
|
13684
|
+
// case "Tristan":
|
|
13685
|
+
// break;
|
|
13686
|
+
}
|
|
13687
|
+
}
|
|
13688
|
+
return resultKind;
|
|
13689
|
+
}
|
|
13690
|
+
parseHarmonyFrame(xmlNode, chord) {
|
|
13691
|
+
for (let frameChild of xmlNode.childNodes) {
|
|
13692
|
+
if (frameChild.nodeType === XmlNodeType.Element) {
|
|
13693
|
+
switch (frameChild.localName) {
|
|
13694
|
+
case 'frame-strings':
|
|
13695
|
+
const stringsCount = parseInt(frameChild.innerText);
|
|
13696
|
+
chord.strings = new Array(stringsCount);
|
|
13697
|
+
for (let i = 0; i < stringsCount; i++) {
|
|
13698
|
+
// set strings unplayed as default
|
|
13699
|
+
chord.strings[i] = -1;
|
|
13700
|
+
}
|
|
13701
|
+
break;
|
|
13702
|
+
case 'first-fret':
|
|
13703
|
+
chord.firstFret = parseInt(frameChild.innerText);
|
|
13704
|
+
break;
|
|
13705
|
+
case 'frame-note':
|
|
13706
|
+
let stringNo = null;
|
|
13707
|
+
let fretNo = null;
|
|
13708
|
+
for (let noteChild of frameChild.childNodes) {
|
|
13709
|
+
switch (noteChild.localName) {
|
|
13710
|
+
case 'string':
|
|
13711
|
+
stringNo = parseInt(noteChild.innerText);
|
|
13712
|
+
break;
|
|
13713
|
+
case 'fret':
|
|
13714
|
+
fretNo = parseInt(noteChild.innerText);
|
|
13715
|
+
if (stringNo && fretNo >= 0) {
|
|
13716
|
+
chord.strings[stringNo - 1] = fretNo;
|
|
13717
|
+
}
|
|
13718
|
+
break;
|
|
13719
|
+
case 'barre':
|
|
13720
|
+
if (stringNo && fretNo && noteChild.getAttribute('type') === 'start') {
|
|
13721
|
+
chord.barreFrets.push(fretNo);
|
|
13722
|
+
}
|
|
13723
|
+
break;
|
|
13724
|
+
}
|
|
13725
|
+
}
|
|
13726
|
+
break;
|
|
13727
|
+
}
|
|
13728
|
+
}
|
|
13729
|
+
}
|
|
13627
13730
|
}
|
|
13628
13731
|
parseBarline(element, masterBar) {
|
|
13629
13732
|
for (let c of element.childNodes) {
|
|
@@ -13890,9 +13993,9 @@
|
|
|
13890
13993
|
if (!slurNumber) {
|
|
13891
13994
|
slurNumber = '1';
|
|
13892
13995
|
}
|
|
13893
|
-
// slur numbers are unique in the way that they have the same ID across
|
|
13894
|
-
// staffs/tracks etc. as long they represent the logically same slur.
|
|
13895
|
-
// but in our case it must be globally unique to link the correct notes.
|
|
13996
|
+
// slur numbers are unique in the way that they have the same ID across
|
|
13997
|
+
// staffs/tracks etc. as long they represent the logically same slur.
|
|
13998
|
+
// but in our case it must be globally unique to link the correct notes.
|
|
13896
13999
|
// adding the staff ID should be enough to achieve this
|
|
13897
14000
|
slurNumber = beat.voice.bar.staff.index + '_' + slurNumber;
|
|
13898
14001
|
switch (c.getAttribute('type')) {
|
|
@@ -18928,6 +19031,14 @@
|
|
|
18928
19031
|
* at a given midi tick position.
|
|
18929
19032
|
*/
|
|
18930
19033
|
this.tickLookup = new MidiTickLookup();
|
|
19034
|
+
/**
|
|
19035
|
+
* Gets or sets whether transposition pitches should be applied to the individual midi events or not.
|
|
19036
|
+
*/
|
|
19037
|
+
this.applyTranspositionPitches = true;
|
|
19038
|
+
/**
|
|
19039
|
+
* Gets the transposition pitches for the individual midi channels.
|
|
19040
|
+
*/
|
|
19041
|
+
this.transpositionPitches = new Map();
|
|
18931
19042
|
this._currentTripletFeel = null;
|
|
18932
19043
|
this.vibratoResolution = 16;
|
|
18933
19044
|
this._score = score;
|
|
@@ -18939,6 +19050,7 @@
|
|
|
18939
19050
|
* Starts the generation of the midi file.
|
|
18940
19051
|
*/
|
|
18941
19052
|
generate() {
|
|
19053
|
+
this.transpositionPitches.clear();
|
|
18942
19054
|
// initialize tracks
|
|
18943
19055
|
for (const track of this._score.tracks) {
|
|
18944
19056
|
this.generateTrack(track);
|
|
@@ -18984,7 +19096,22 @@
|
|
|
18984
19096
|
this._programsPerChannel.set(channel, program);
|
|
18985
19097
|
}
|
|
18986
19098
|
}
|
|
19099
|
+
static buildTranspositionPitches(score, settings) {
|
|
19100
|
+
const transpositionPitches = new Map();
|
|
19101
|
+
for (const track of score.tracks) {
|
|
19102
|
+
const transpositionPitch = track.index < settings.notation.transpositionPitches.length
|
|
19103
|
+
? settings.notation.transpositionPitches[track.index]
|
|
19104
|
+
: 0;
|
|
19105
|
+
transpositionPitches.set(track.playbackInfo.primaryChannel, transpositionPitch);
|
|
19106
|
+
transpositionPitches.set(track.playbackInfo.secondaryChannel, transpositionPitch);
|
|
19107
|
+
}
|
|
19108
|
+
return transpositionPitches;
|
|
19109
|
+
}
|
|
18987
19110
|
generateChannel(track, channel, playbackInfo) {
|
|
19111
|
+
const transpositionPitch = track.index < this._settings.notation.transpositionPitches.length
|
|
19112
|
+
? this._settings.notation.transpositionPitches[track.index]
|
|
19113
|
+
: 0;
|
|
19114
|
+
this.transpositionPitches.set(channel, transpositionPitch);
|
|
18988
19115
|
let volume = MidiFileGenerator.toChannelShort(playbackInfo.volume);
|
|
18989
19116
|
let balance = MidiFileGenerator.toChannelShort(playbackInfo.balance);
|
|
18990
19117
|
this._handler.addControlChange(track.index, 0, channel, ControllerType.VolumeCoarse, volume);
|
|
@@ -19204,7 +19331,7 @@
|
|
|
19204
19331
|
generateNote(note, beatStart, beatDuration, brushInfo) {
|
|
19205
19332
|
const track = note.beat.voice.bar.staff.track;
|
|
19206
19333
|
const staff = note.beat.voice.bar.staff;
|
|
19207
|
-
let noteKey = note.
|
|
19334
|
+
let noteKey = note.calculateRealValue(this.applyTranspositionPitches, true);
|
|
19208
19335
|
if (note.isPercussion) {
|
|
19209
19336
|
const articulation = PercussionMapper.getArticulation(note);
|
|
19210
19337
|
if (articulation) {
|
|
@@ -19482,7 +19609,7 @@
|
|
|
19482
19609
|
case SlideOutType.Shift:
|
|
19483
19610
|
playedBendPoints.push(new BendPoint(shiftSlideDurationOffset, 0));
|
|
19484
19611
|
// normal note values are in 1/2 tones, bends are in 1/4 tones
|
|
19485
|
-
const dy = (note.slideTarget.
|
|
19612
|
+
const dy = (note.slideTarget.calculateRealValue(this.applyTranspositionPitches, true) - note.calculateRealValue(this.applyTranspositionPitches, true)) * 2;
|
|
19486
19613
|
playedBendPoints.push(new BendPoint(BendPoint.MaxPosition, dy));
|
|
19487
19614
|
break;
|
|
19488
19615
|
case SlideOutType.OutDown:
|
|
@@ -20021,6 +20148,7 @@
|
|
|
20021
20148
|
this._mutedChannels = new Map();
|
|
20022
20149
|
this._soloChannels = new Map();
|
|
20023
20150
|
this._isAnySolo = false;
|
|
20151
|
+
this._transpositionPitches = new Map();
|
|
20024
20152
|
this.currentTempo = 0;
|
|
20025
20153
|
this.timeSignatureNumerator = 0;
|
|
20026
20154
|
this.timeSignatureDenominator = 0;
|
|
@@ -20082,8 +20210,30 @@
|
|
|
20082
20210
|
resetChannelStates() {
|
|
20083
20211
|
this._mutedChannels = new Map();
|
|
20084
20212
|
this._soloChannels = new Map();
|
|
20213
|
+
this.applyTranspositionPitches(new Map());
|
|
20085
20214
|
this._isAnySolo = false;
|
|
20086
20215
|
}
|
|
20216
|
+
applyTranspositionPitches(transpositionPitches) {
|
|
20217
|
+
// dynamically adjust actively playing voices to the new pitch they have.
|
|
20218
|
+
// we are not updating the used preset and regions though.
|
|
20219
|
+
const previousTransposePitches = this._transpositionPitches;
|
|
20220
|
+
for (const voice of this._voices) {
|
|
20221
|
+
if (voice.playingChannel >= 0 && voice.playingChannel !== 9 /*percussion*/) {
|
|
20222
|
+
let pitchDifference = 0;
|
|
20223
|
+
if (previousTransposePitches.has(voice.playingChannel)) {
|
|
20224
|
+
pitchDifference -= previousTransposePitches.get(voice.playingChannel);
|
|
20225
|
+
}
|
|
20226
|
+
if (transpositionPitches.has(voice.playingChannel)) {
|
|
20227
|
+
pitchDifference += transpositionPitches.get(voice.playingChannel);
|
|
20228
|
+
}
|
|
20229
|
+
voice.playingKey += pitchDifference;
|
|
20230
|
+
if (this._channels) {
|
|
20231
|
+
voice.updatePitchRatio(this._channels.channelList[voice.playingChannel], this.outSampleRate);
|
|
20232
|
+
}
|
|
20233
|
+
}
|
|
20234
|
+
}
|
|
20235
|
+
this._transpositionPitches = transpositionPitches;
|
|
20236
|
+
}
|
|
20087
20237
|
dispatchEvent(synthEvent) {
|
|
20088
20238
|
this._midiEventQueue.enqueue(synthEvent);
|
|
20089
20239
|
}
|
|
@@ -20498,6 +20648,9 @@
|
|
|
20498
20648
|
if (!this._channels || channel > this._channels.channelList.length) {
|
|
20499
20649
|
return;
|
|
20500
20650
|
}
|
|
20651
|
+
if (this._transpositionPitches.has(channel)) {
|
|
20652
|
+
key += this._transpositionPitches.get(channel);
|
|
20653
|
+
}
|
|
20501
20654
|
this._channels.activeChannel = channel;
|
|
20502
20655
|
this.noteOn(this._channels.channelList[channel].presetIndex, key, vel);
|
|
20503
20656
|
}
|
|
@@ -20507,6 +20660,9 @@
|
|
|
20507
20660
|
* @param key note value between 0 and 127 (60 being middle C)
|
|
20508
20661
|
*/
|
|
20509
20662
|
channelNoteOff(channel, key) {
|
|
20663
|
+
if (this._transpositionPitches.has(channel)) {
|
|
20664
|
+
key += this._transpositionPitches.get(channel);
|
|
20665
|
+
}
|
|
20510
20666
|
const matches = [];
|
|
20511
20667
|
let matchFirst = null;
|
|
20512
20668
|
let matchLast = null;
|
|
@@ -20695,6 +20851,9 @@
|
|
|
20695
20851
|
* @param pitchWheel pitch wheel position 0 to 16383 (default 8192 unpitched)
|
|
20696
20852
|
*/
|
|
20697
20853
|
channelSetPerNotePitchWheel(channel, key, pitchWheel) {
|
|
20854
|
+
if (this._transpositionPitches.has(channel)) {
|
|
20855
|
+
key += this._transpositionPitches.get(channel);
|
|
20856
|
+
}
|
|
20698
20857
|
const c = this.channelInit(channel);
|
|
20699
20858
|
if (c.perNotePitchWheel.has(key) && c.perNotePitchWheel.get(key) === pitchWheel) {
|
|
20700
20859
|
return;
|
|
@@ -21492,6 +21651,9 @@
|
|
|
21492
21651
|
this.midiLoadFailed.trigger(e);
|
|
21493
21652
|
}
|
|
21494
21653
|
}
|
|
21654
|
+
applyTranspositionPitches(transpositionPitches) {
|
|
21655
|
+
this._synthesizer.applyTranspositionPitches(transpositionPitches);
|
|
21656
|
+
}
|
|
21495
21657
|
setChannelMute(channel, mute) {
|
|
21496
21658
|
this._synthesizer.channelSetMute(channel, mute);
|
|
21497
21659
|
}
|
|
@@ -23180,6 +23342,9 @@
|
|
|
23180
23342
|
cmd: 'alphaSynth.destroyed'
|
|
23181
23343
|
});
|
|
23182
23344
|
break;
|
|
23345
|
+
case 'alphaSynth.applyTranspositionPitches':
|
|
23346
|
+
this._player.applyTranspositionPitches(new Map(JSON.parse(data.transpositionPitches)));
|
|
23347
|
+
break;
|
|
23183
23348
|
}
|
|
23184
23349
|
}
|
|
23185
23350
|
onPositionChanged(e) {
|
|
@@ -24969,6 +25134,7 @@
|
|
|
24969
25134
|
* Applies any changes that were done to the settings object and informs the {@link renderer} about any new values to consider.
|
|
24970
25135
|
*/
|
|
24971
25136
|
updateSettings() {
|
|
25137
|
+
var _a;
|
|
24972
25138
|
const score = this.score;
|
|
24973
25139
|
if (score) {
|
|
24974
25140
|
ModelUtils.applyPitchOffsets(this.settings, score);
|
|
@@ -24977,6 +25143,9 @@
|
|
|
24977
25143
|
// enable/disable player if needed
|
|
24978
25144
|
if (this.settings.player.enablePlayer) {
|
|
24979
25145
|
this.setupPlayer();
|
|
25146
|
+
if (score) {
|
|
25147
|
+
(_a = this.player) === null || _a === void 0 ? void 0 : _a.applyTranspositionPitches(MidiFileGenerator.buildTranspositionPitches(score, this.settings));
|
|
25148
|
+
}
|
|
24980
25149
|
}
|
|
24981
25150
|
else {
|
|
24982
25151
|
this.destroyPlayer();
|
|
@@ -25347,10 +25516,13 @@
|
|
|
25347
25516
|
let midiFile = new MidiFile();
|
|
25348
25517
|
let handler = new AlphaSynthMidiFileHandler(midiFile);
|
|
25349
25518
|
let generator = new MidiFileGenerator(this.score, this.settings, handler);
|
|
25519
|
+
// we pass the transposition pitches separately to alphaSynth.
|
|
25520
|
+
generator.applyTranspositionPitches = false;
|
|
25350
25521
|
generator.generate();
|
|
25351
25522
|
this._tickCache = generator.tickLookup;
|
|
25352
25523
|
this.onMidiLoad(midiFile);
|
|
25353
25524
|
this.player.loadMidiFile(midiFile);
|
|
25525
|
+
this.player.applyTranspositionPitches(generator.transpositionPitches);
|
|
25354
25526
|
}
|
|
25355
25527
|
/**
|
|
25356
25528
|
* Changes the volume of the given tracks.
|
|
@@ -27024,6 +27196,12 @@
|
|
|
27024
27196
|
midi: JsonConverter.midiFileToJsObject(midi)
|
|
27025
27197
|
});
|
|
27026
27198
|
}
|
|
27199
|
+
applyTranspositionPitches(transpositionPitches) {
|
|
27200
|
+
this._synth.postMessage({
|
|
27201
|
+
cmd: 'alphaSynth.applyTranspositionPitches',
|
|
27202
|
+
transpositionPitches: JSON.stringify(Array.from(transpositionPitches.entries()))
|
|
27203
|
+
});
|
|
27204
|
+
}
|
|
27027
27205
|
setChannelMute(channel, mute) {
|
|
27028
27206
|
this._synth.postMessage({
|
|
27029
27207
|
cmd: 'alphaSynth.setChannelMute',
|
|
@@ -42321,8 +42499,8 @@
|
|
|
42321
42499
|
// </auto-generated>
|
|
42322
42500
|
class VersionInfo {
|
|
42323
42501
|
}
|
|
42324
|
-
VersionInfo.version = '1.3.0-alpha.
|
|
42325
|
-
VersionInfo.date = '2023-12-
|
|
42502
|
+
VersionInfo.version = '1.3.0-alpha.856';
|
|
42503
|
+
VersionInfo.date = '2023-12-12T01:25:35.593Z';
|
|
42326
42504
|
|
|
42327
42505
|
var index$5 = /*#__PURE__*/Object.freeze({
|
|
42328
42506
|
__proto__: null,
|