@@ -556,6 +556,7 @@ export class AlphaTexImporter extends ScoreImporter {
556556 private _currentStaff ! : Staff ;
557557 private _barIndex : number = 0 ;
558558 private _voiceIndex : number = 0 ;
559+ private _initialTempo = Automation . buildTempoAutomation ( false , 0 , 120 , 0 ) ;
559560
560561 // Last known position that had valid syntax/symbols
561562 private _currentDuration : Duration = Duration . QuadrupleWhole ;
@@ -768,8 +769,6 @@ export class AlphaTexImporter extends ScoreImporter {
768769 */
769770 private createDefaultScore ( ) : void {
770771 this . _score = new Score ( ) ;
771- this . _score . tempo = 120 ;
772- this . _score . tempoLabel = '' ;
773772 this . newTrack ( ) ;
774773 }
775774
@@ -1073,13 +1072,13 @@ export class AlphaTexImporter extends ScoreImporter {
10731072 case 'tempo' :
10741073 this . sy = this . newSy ( true ) ;
10751074 if ( this . sy === AlphaTexSymbols . Number ) {
1076- this . _score . tempo = this . syData as number ;
1075+ this . _initialTempo . value = this . syData as number ;
10771076 } else {
10781077 this . error ( 'tempo' , AlphaTexSymbols . Number , true ) ;
10791078 }
10801079 this . sy = this . newSy ( ) ;
10811080 if ( this . sy === AlphaTexSymbols . String ) {
1082- this . _score . tempoLabel = this . syData as string ;
1081+ this . _initialTempo . text = this . syData as string ;
10831082 this . sy = this . newSy ( ) ;
10841083 }
10851084 anyTopLevelMeta = true ;
@@ -1878,6 +1877,8 @@ export class AlphaTexImporter extends ScoreImporter {
18781877 master . timeSignatureDenominator = master . previousMasterBar ! . timeSignatureDenominator ;
18791878 master . timeSignatureNumerator = master . previousMasterBar ! . timeSignatureNumerator ;
18801879 master . tripletFeel = master . previousMasterBar ! . tripletFeel ;
1880+ } else {
1881+ master . tempoAutomations . push ( this . _initialTempo ) ;
18811882 }
18821883 }
18831884 const anyBarMeta = this . barMeta ( bar ) ;
@@ -2367,8 +2368,19 @@ export class AlphaTexImporter extends ScoreImporter {
23672368 } else if ( syData === 'tempo' ) {
23682369 // NOTE: playbackRatio is calculated on score finish when playback positions are known
23692370 const tempoAutomation = this . readTempoAutomation ( false ) ;
2371+
2372+ if ( beat . index === 0 ) {
2373+ const existing = beat . voice . bar . masterBar . tempoAutomations . find ( a => a . ratioPosition === 0 ) ;
2374+ if ( existing ) {
2375+ existing . value = tempoAutomation . value ;
2376+ existing . text = tempoAutomation . text ;
2377+ beat . automations . push ( existing ) ;
2378+ return true ;
2379+ }
2380+ }
23702381 beat . automations . push ( tempoAutomation ) ;
23712382 beat . voice . bar . masterBar . tempoAutomations . push ( tempoAutomation ) ;
2383+
23722384 return true ;
23732385 } else if ( syData === 'volume' ) {
23742386 // NOTE: playbackRatio is calculated on score finish when playback positions are known
@@ -3326,7 +3338,14 @@ export class AlphaTexImporter extends ScoreImporter {
33263338 } else if ( syData === 'tempo' ) {
33273339 const tempoAutomation = this . readTempoAutomation ( true ) ;
33283340
3329- master . tempoAutomations . push ( tempoAutomation ) ;
3341+ const existing = master . tempoAutomations . find ( a => a . ratioPosition === tempoAutomation . ratioPosition ) ;
3342+ if ( existing ) {
3343+ existing . value = tempoAutomation . value ;
3344+ existing . text = tempoAutomation . text ;
3345+ existing . isVisible = tempoAutomation . isVisible ;
3346+ } else {
3347+ master . tempoAutomations . push ( tempoAutomation ) ;
3348+ }
33303349 } else if ( syData === 'section' ) {
33313350 this . sy = this . newSy ( ) ;
33323351 if ( this . sy !== AlphaTexSymbols . String ) {
@@ -3624,7 +3643,7 @@ export class AlphaTexImporter extends ScoreImporter {
36243643 tempoAutomation . isLinear = false ;
36253644 tempoAutomation . type = AutomationType . Tempo ;
36263645
3627- if ( this . sy === AlphaTexSymbols . LBrace && withPosition ) {
3646+ if ( this . sy === AlphaTexSymbols . LParensis && withPosition ) {
36283647 this . sy = this . newSy ( true ) ;
36293648 if ( this . sy !== AlphaTexSymbols . Number ) {
36303649 this . error ( 'tempo' , AlphaTexSymbols . Number , true ) ;
@@ -3644,8 +3663,13 @@ export class AlphaTexImporter extends ScoreImporter {
36443663 tempoAutomation . ratioPosition = this . syData as number ;
36453664 this . sy = this . newSy ( ) ;
36463665
3647- if ( this . sy !== AlphaTexSymbols . RBrace ) {
3648- this . error ( 'tempo' , AlphaTexSymbols . RBrace , true ) ;
3666+ if ( this . sy === AlphaTexSymbols . String && ( this . syData as string ) === 'hide' ) {
3667+ tempoAutomation . isVisible = false ;
3668+ this . sy = this . newSy ( ) ;
3669+ }
3670+
3671+ if ( this . sy !== AlphaTexSymbols . RParensis ) {
3672+ this . error ( 'tempo' , AlphaTexSymbols . RParensis , true ) ;
36493673 }
36503674 this . sy = this . newSy ( ) ;
36513675 } else if ( this . sy === AlphaTexSymbols . Number ) {
0 commit comments