@@ -542,10 +542,10 @@ export class AlphaTexImporter extends ScoreImporter implements IAlphaTexImporter
542542 // Note value
543543 let isDead : boolean = false ;
544544 let isTie : boolean = false ;
545- let numericValue : number = - 1 ;
545+ let numericValue : number = Number . NaN ;
546546 let articulationValue : string = '' ;
547- let octave : number = - 1 ;
548- let tone : number = - 1 ;
547+ let octave : number = Number . NaN ;
548+ let tone : number = Number . NaN ;
549549 let accidentalMode = NoteAccidentalMode . Default ;
550550 const noteValue = node . noteValue as AlphaTexAstNode ;
551551 let detectedNoteKind : AlphaTexStaffNoteKind | undefined = undefined ;
@@ -570,7 +570,7 @@ export class AlphaTexImporter extends ScoreImporter implements IAlphaTexImporter
570570 isTie = str === '-' ;
571571 if ( isTie || isDead ) {
572572 numericValue = 0 ;
573- if ( node . noteStringDot && node . noteString ) {
573+ if ( node . noteStringSeparator && node . noteString ) {
574574 detectedNoteKind = AlphaTexStaffNoteKind . Fretted ;
575575 } else {
576576 detectedNoteKind = undefined ; // don't know on those notes
@@ -668,19 +668,19 @@ export class AlphaTexImporter extends ScoreImporter implements IAlphaTexImporter
668668 return ;
669669 }
670670
671- const noteString : number = node . noteString ! . value ;
672- if ( noteString < 1 || noteString > this . _state . currentStaff ! . tuning . length ) {
671+ const frettedNoteString : number = node . noteString ! . value ;
672+ if ( frettedNoteString < 1 || frettedNoteString > this . _state . currentStaff ! . tuning . length ) {
673673 this . addSemanticDiagnostic ( {
674674 code : AlphaTexDiagnosticCode . AT208 ,
675675 message : `Note string is out of range. Available range: 1-${ this . _state . currentStaff ! . tuning . length } ` ,
676676 severity : AlphaTexDiagnosticsSeverity . Error ,
677- start : noteValue . end ,
678- end : noteValue . end
677+ start : node . noteString . start ,
678+ end : node . noteString . end
679679 } ) ;
680680 return ;
681681 }
682682
683- note . string = this . _state . currentStaff ! . tuning . length - ( noteString - 1 ) ;
683+ note . string = this . _state . currentStaff ! . tuning . length - ( frettedNoteString - 1 ) ;
684684 if ( ! isTie ) {
685685 note . fret = numericValue ;
686686 }
@@ -716,6 +716,34 @@ export class AlphaTexImporter extends ScoreImporter implements IAlphaTexImporter
716716 this . _state . articulationUniqueIdToIndex . set ( articulationValue , articulationIndex ) ;
717717 }
718718 note . percussionArticulation = articulationIndex ;
719+
720+ if ( node . noteString ) {
721+ const percussionNoteString : number = node . noteString ! . value ;
722+ if ( percussionNoteString < 1 || percussionNoteString > this . _state . currentStaff ! . tuning . length ) {
723+ this . addSemanticDiagnostic ( {
724+ code : AlphaTexDiagnosticCode . AT208 ,
725+ message : `Note string is out of range. Available range: 1-${ this . _state . currentStaff ! . tuning . length } ` ,
726+ severity : AlphaTexDiagnosticsSeverity . Error ,
727+ start : node . noteString . start ,
728+ end : node . noteString . end
729+ } ) ;
730+ return ;
731+ }
732+ note . string = this . _state . currentStaff ! . tuning . length - ( percussionNoteString - 1 ) ;
733+ } else {
734+ // find free string
735+ for ( let i = 0 ; i < this . _state . currentStaff ! . tuning . length ; i ++ ) {
736+ const s = this . _state . currentStaff ! . tuning . length - i ;
737+ if ( ! beat . noteStringLookup . has ( s ) ) {
738+ note . string = s ;
739+ break ;
740+ }
741+ }
742+ if ( Number . isNaN ( note . string ) ) {
743+ note . string = this . _state . currentStaff ! . tuning . length ;
744+ }
745+ }
746+
719747 break ;
720748 }
721749 }
@@ -742,6 +770,7 @@ export class AlphaTexImporter extends ScoreImporter implements IAlphaTexImporter
742770 switch ( staffNoteKind ) {
743771 case AlphaTexStaffNoteKind . Pitched :
744772 staff . isPercussion = false ;
773+ staff . showTablature = false ;
745774 staff . stringTuning . reset ( ) ;
746775 if ( ! this . _state . staffHasExplicitDisplayTransposition . has ( staff ) ) {
747776 staff . displayTranspositionPitch = 0 ;
@@ -755,6 +784,7 @@ export class AlphaTexImporter extends ScoreImporter implements IAlphaTexImporter
755784 case AlphaTexStaffNoteKind . Articulation :
756785 staff . isPercussion = true ;
757786 staff . stringTuning . reset ( ) ;
787+ staff . stringTuning . tunings = [ 0 , 0 , 0 , 0 , 0 , 0 ] ;
758788 if ( ! this . _state . staffHasExplicitDisplayTransposition . has ( staff ) ) {
759789 staff . displayTranspositionPitch = 0 ;
760790 }
@@ -813,7 +843,9 @@ export class AlphaTexImporter extends ScoreImporter implements IAlphaTexImporter
813843 // reset to defaults
814844 staff . stringTuning . reset ( ) ;
815845
816- if ( program === 15 ) {
846+ if ( staff . isPercussion ) {
847+ staff . stringTuning . tunings = [ 0 , 0 , 0 , 0 , 0 , 0 ] ;
848+ } else if ( program === 15 ) {
817849 // dulcimer E4 B3 G3 D3 A2 E2
818850 staff . stringTuning . tunings = Tuning . getDefaultTuningFor ( 6 ) ! . tunings ;
819851 } else if ( program >= 24 && program <= 31 ) {
@@ -1097,7 +1129,6 @@ export class AlphaTexImporter extends ScoreImporter implements IAlphaTexImporter
10971129
10981130 public applyPercussionStaff ( staff : Staff ) {
10991131 staff . isPercussion = true ;
1100- staff . showTablature = false ;
11011132 staff . track . playbackInfo . program = 0 ;
11021133 }
11031134
0 commit comments