@@ -13,7 +13,6 @@ namespace MuConvert.chu;
1313public class SusGenerator : IGenerator < IChuChart >
1414{
1515 private const int SusTpb = 480 ;
16- private const int C2sRsl = 384 ;
1716
1817 public ( string , List < Alert > ) Generate ( IChuChart chart )
1918 {
@@ -33,26 +32,27 @@ private static SusChart ConvertToSus(IChuChart chart, List<Alert> alerts)
3332 if ( chart is C2sChart c2s )
3433 {
3534 bpm = c2s . BpmEvents . Count > 0 ? c2s . BpmEvents [ 0 ] . Bpm : c2s . DefBpm ;
35+ int c2sTpb = c2s . Resolution / 4 ;
3636 var result = new SusChart { Bpm = bpm , TicksPerBeat = SusTpb , Title = title , Artist = artist } ;
37- foreach ( var n in c2s . Notes ) result . Notes . Add ( ScaleUp ( n ) ) ;
37+ foreach ( var n in c2s . Notes ) result . Notes . Add ( ScaleUp ( n , c2sTpb ) ) ;
3838 return result ;
3939 }
4040
4141 if ( chart is UgcChart ugc )
4242 {
4343 bpm = ugc . BpmEvents . Count > 0 ? ugc . BpmEvents [ 0 ] . Bpm : 120.0 ;
4444 var result = new SusChart { Bpm = bpm , TicksPerBeat = SusTpb , Title = ugc . Title , Artist = ugc . Artist } ;
45- foreach ( var n in ugc . Notes ) result . Notes . Add ( MapLaneOnly ( n ) ) ;
45+ foreach ( var n in ugc . Notes ) result . Notes . Add ( ScaleUp ( n , ugc . TicksPerBeat ) ) ;
4646 return result ;
4747 }
4848
49- alerts . Add ( new Alert ( Warning , string . Format ( Locale . ChuGeneratorUnsupported , "→ SUS" ) ) ) ;
50- return new SusChart ( ) ;
49+ alerts . Add ( new Alert ( Error , string . Format ( Locale . ChuGeneratorUnsupported , "→ SUS" ) ) ) ;
50+ throw new ConversionException ( alerts ) ;
5151 }
5252
53- private static ChuNote ScaleUp ( ChuNote n )
53+ private static ChuNote ScaleUp ( ChuNote n , int sourceTicksPerBeat )
5454 {
55- int s ( int v ) => ( int ) ( ( long ) v * SusTpb / ( C2sRsl / 4 ) ) ;
55+ int s ( int v ) => ( int ) ( ( long ) v * SusTpb / sourceTicksPerBeat ) ;
5656 return new ChuNote
5757 {
5858 Type = n . Type , Measure = n . Measure , Offset = s ( n . Offset ) ,
@@ -63,15 +63,6 @@ private static ChuNote ScaleUp(ChuNote n)
6363 } ;
6464 }
6565
66- private static ChuNote MapLaneOnly ( ChuNote n ) => new ( )
67- {
68- Type = n . Type , Measure = n . Measure , Offset = n . Offset ,
69- Cell = n . Cell * 2 , Width = n . Width * 2 ,
70- HoldDuration = n . HoldDuration , SlideDuration = n . SlideDuration ,
71- EndCell = n . EndCell * 2 , EndWidth = n . EndWidth * 2 ,
72- Extra = n . Extra , TargetNote = n . TargetNote , AirHoldDuration = n . AirHoldDuration ,
73- } ;
74-
7566 private static string Serialize ( SusChart sus )
7667 {
7768 var sb = new StringBuilder ( ) ;
0 commit comments