@@ -520,9 +520,11 @@ public sealed override object VisitSlideDuration(P.SlideDurationContext context)
520520 {
521521 var result = new Duration ( currNote ! ) ;
522522 Duration ? waitTime = null ;
523- isRealExactWaitTime = false ;
523+ isRealExactWaitTime = false ; // 是否通过##,指定了绝对的等待时间值
524+ Rational ? anotherBpm = null ; // 是否通过类似 160#8:3,指定了显式的BPM,且和当前的实际BPM不同
524525 AlertIfMoreParentheses ( context . _lp , context . _rp ) ;
525526
527+ // 解析绝对的等待时间
526528 if ( context . waitTime ( ) != null )
527529 {
528530 waitTime = new Duration ( currNote ! )
@@ -531,19 +533,26 @@ public sealed override object VisitSlideDuration(P.SlideDurationContext context)
531533 } ;
532534 isRealExactWaitTime = true ;
533535 }
536+
537+ // 解析显式的BPM
538+ if ( context . asBpm ( ) != null )
539+ {
540+ var currentBpm = chart . BpmList . Last ( ) . Bpm ;
541+ var bpm = ( decimal ) VisitNumber ( context . asBpm ( ) . number ( ) ) ;
542+ if ( bpm != currentBpm )
543+ {
544+ anotherBpm = ( Rational ) bpm ;
545+ if ( waitTime == null ) // 如果未显式指定绝对的waitTime秒数,则waitTime也要变成该强行指定的bpm下的一拍。不然默认就是currentBpm下的一拍了。
546+ waitTime = new Duration ( currNote ! ) { Seconds = 60 / anotherBpm . Value } ;
547+ }
548+ }
549+
534550 if ( context . number ( ) != null ) result . Seconds = ( Rational ) ( decimal ) VisitNumber ( context . number ( ) ) ;
535551 else
536552 {
537553 var value = ( Rational ) VisitBeats ( context . beats ( ) ) ;
538- if ( context . asBpm ( ) == null ) result . InvariantBar = value ;
539- else
540- {
541- // 根据强行指定的bpm换算为秒数
542- var bpm = ( Rational ) ( decimal ) VisitNumber ( context . asBpm ( ) . number ( ) ) ;
543- result . Seconds = value * ( 240 / bpm ) ;
544- // 如果未显式指定waitTime,则waitTime也要变成强行指定的bpm下的一拍。不然就是音符所在时刻下的一拍了。
545- waitTime ??= new Duration ( currNote ! ) { Seconds = 60 / bpm } ;
546- }
554+ if ( anotherBpm == null ) result . InvariantBar = value ;
555+ else result . Seconds = value * ( 240 / anotherBpm . Value ) ; // 显式指定了bpm的情况,需要根据强行指定的bpm换算为秒数
547556 }
548557 return ( waitTime , result ) ;
549558 }
0 commit comments