@@ -53,13 +53,15 @@ public class RenderSong : MonoBehaviour
53
53
54
54
public int resolution { get ; set ; } = 192 ;
55
55
56
- public Dictionary < int , int > bpm { get ; set ; }
56
+ public Tempo [ ] bpmChanges { get ; set ; }
57
+
58
+ public TimeSignature [ ] timeSignatureChanges { get ; set ; }
57
59
58
60
public Dictionary < Difficulty , Note [ ] > difficulties { get ; set ; }
59
61
60
62
public Dictionary < int , List < Note > > notesGroupedByHandPosition { get ; set ; }
61
63
62
- public List < BeatBar > beatBars { get ; set ; }
64
+ public BeatBar [ ] beatBars { get ; set ; }
63
65
64
66
private async void Start ( )
65
67
{
@@ -79,12 +81,23 @@ await LoadAudioFileFromPath(
79
81
80
82
resolution = int . Parse ( metadata [ "Resolution" ] ) ;
81
83
82
- bpm = Parsers . ParseBpmFromChartSection ( sections . First ( section => section . Key == NamedSection . SyncTrack )
84
+ bpmChanges = Parsers . ParseBpmFromChartSection ( sections . First ( section => section . Key == NamedSection . SyncTrack )
83
85
. Value ) ;
84
86
85
- var lastTick = Utilities . ConvertSecondsToTicks ( _audioSource . clip . length , resolution , bpm ) ;
87
+ timeSignatureChanges = Parsers . ParseTimeSignaturesFromChartSection ( sections [ NamedSection . SyncTrack ] ) ;
88
+
89
+ var lastTick =
90
+ Utilities . ConvertSecondsToTicks ( _audioSource . clip . length , resolution , bpmChanges , timeSignatureChanges ) ;
86
91
87
- bpm . TryAdd ( Utilities . RoundUpToTheNearestMultiplier ( lastTick , resolution ) , bpm . Last ( ) . Value ) ;
92
+ bpmChanges = bpmChanges . Concat ( new Tempo [ ]
93
+ {
94
+ new ( )
95
+ {
96
+ Position = Utilities . RoundUpToTheNearestMultiplier ( lastTick , resolution ) ,
97
+ BPM = bpmChanges . Last ( ) . BPM
98
+ }
99
+ } )
100
+ . ToArray ( ) ;
88
101
89
102
difficulties = Enum . GetValues ( typeof ( Difficulty ) )
90
103
. Cast < Difficulty > ( )
@@ -98,7 +111,7 @@ await LoadAudioFileFromPath(
98
111
. GroupBy ( note => note . HandPosition )
99
112
. ToDictionary ( group => group . Key , group => group . ToList ( ) ) ;
100
113
101
- beatBars = Utilities . CalculateBeatBars ( bpm , includeHalfNotes : true ) ;
114
+ beatBars = Utilities . CalculateBeatBars ( bpmChanges , includeHalfNotes : true ) ;
102
115
103
116
_audioSource . Play ( ) ;
104
117
}
@@ -154,7 +167,7 @@ private void Update()
154
167
}
155
168
156
169
var tickOffset =
157
- Utilities . ConvertSecondsToTicks ( _audioSource . time , resolution , bpm ) ;
170
+ Utilities . ConvertSecondsToTicks ( _audioSource . time , resolution , bpmChanges , timeSignatureChanges ) ;
158
171
159
172
RenderHitNotes ( notesGroupedByHandPosition ) ;
160
173
@@ -218,13 +231,13 @@ private void RenderNotes(Dictionary<int, List<Note>> notesGroupedByHandPosition,
218
231
}
219
232
}
220
233
221
- private void RenderBeatBars ( List < BeatBar > beatBars , int resolution , int tickOffset )
234
+ private void RenderBeatBars ( BeatBar [ ] beatBars , int resolution , int tickOffset )
222
235
{
223
236
var beatBarMatrix = new List < Matrix4x4 > ( ) ;
224
237
var beatBarHalfMatrix = new List < Matrix4x4 > ( ) ;
225
238
var beatBarQuarterMatrix = new List < Matrix4x4 > ( ) ;
226
239
227
- for ( var x = 0 ; x < beatBars . Count ; x += 1 )
240
+ for ( var x = 0 ; x < beatBars . Length ; x += 1 )
228
241
{
229
242
var position = Utilities . ConvertTickToPosition ( beatBars [ x ] . Position - tickOffset , resolution ) *
230
243
_scale ;
0 commit comments