@@ -37,17 +37,17 @@ import { TripletFeel } from '@coderline/alphatab/model/TripletFeel';
3737import { VibratoType } from '@coderline/alphatab/model/VibratoType' ;
3838import { Voice } from '@coderline/alphatab/model/Voice' ;
3939
40- import { Logger } from '@coderline/alphatab/Logger' ;
41- import { ModelUtils } from '@coderline/alphatab/model/ModelUtils' ;
4240import type { IWriteable } from '@coderline/alphatab/io/IWriteable' ;
43- import { FadeType } from '@coderline/alphatab/model/FadeType ' ;
44- import { Rasgueado } from '@coderline/alphatab/model/Rasgueado ' ;
41+ import { Logger } from '@coderline/alphatab/Logger ' ;
42+ import { AccidentalType } from '@coderline/alphatab/model/AccidentalType ' ;
4543import { Direction } from '@coderline/alphatab/model/Direction' ;
46- import { BeamDirection } from '@coderline/alphatab/rendering/utils/BeamDirection' ;
44+ import { FadeType } from '@coderline/alphatab/model/FadeType' ;
45+ import { ModelUtils } from '@coderline/alphatab/model/ModelUtils' ;
4746import { Ottavia } from '@coderline/alphatab/model/Ottavia' ;
48- import { WahPedal } from '@coderline/alphatab/model/WahPedal' ;
49- import { AccidentalType } from '@coderline/alphatab/model/AccidentalType' ;
47+ import { Rasgueado } from '@coderline/alphatab/model/Rasgueado' ;
5048import { TremoloPickingEffect } from '@coderline/alphatab/model/TremoloPickingEffect' ;
49+ import { WahPedal } from '@coderline/alphatab/model/WahPedal' ;
50+ import { BeamDirection } from '@coderline/alphatab/rendering/utils/BeamDirection' ;
5151
5252/**
5353 * @internal
@@ -434,6 +434,11 @@ export class Gp3To5Importer extends ScoreImporter {
434434 }
435435 }
436436
437+ /**
438+ * Guitar Pro 3-6 changes to a bass clef if any string tuning is below B2;
439+ */
440+ private static readonly _bassClefTuningThreshold = ModelUtils . parseTuning ( 'B2' ) ! . realValue ;
441+
437442 public readTrack ( ) : void {
438443 const newTrack : Track = new Track ( ) ;
439444 newTrack . ensureStaveCount ( 1 ) ;
@@ -527,10 +532,10 @@ export class Gp3To5Importer extends ScoreImporter {
527532
528533 // `12` for all tunings which have bass clefs
529534 const clefMode = IOHelper . readInt32LE ( this . data ) ;
530- if ( clefMode === 12 ) {
531- this . _clefsPerTrack . set ( index , Clef . F4 ) ;
535+ if ( clefMode === 12 || tuning [ tuning . length - 1 ] < Gp3To5Importer . _bassClefTuningThreshold ) {
536+ this . _clefsPerTrack . set ( newTrack . index , Clef . F4 ) ;
532537 } else {
533- this . _clefsPerTrack . set ( index , Clef . G2 ) ;
538+ this . _clefsPerTrack . set ( newTrack . index , Clef . G2 ) ;
534539 }
535540
536541 // Unknown, no UI setting seem to affect this
@@ -570,10 +575,10 @@ export class Gp3To5Importer extends ScoreImporter {
570575 GpBinaryHelpers . gpReadStringIntByte ( this . data , this . settings . importer . encoding ) ;
571576 }
572577 } else {
573- if ( GeneralMidi . isBass ( newTrack . playbackInfo . program ) ) {
574- this . _clefsPerTrack . set ( index , Clef . F4 ) ;
578+ if ( tuning [ tuning . length - 1 ] < Gp3To5Importer . _bassClefTuningThreshold ) {
579+ this . _clefsPerTrack . set ( newTrack . index , Clef . F4 ) ;
575580 } else {
576- this . _clefsPerTrack . set ( index , Clef . G2 ) ;
581+ this . _clefsPerTrack . set ( newTrack . index , Clef . G2 ) ;
577582 }
578583 }
579584 }
0 commit comments