@@ -45,9 +45,6 @@ class PhigrosSimulatorRenderController {
4545 ValueNotifier <int > logMaxCombo = ValueNotifier (0 );
4646 ValueNotifier <double > logScore = ValueNotifier (0 );
4747 ValueNotifier <double > logAccurate = ValueNotifier (0 );
48- ValueNotifier <int > logTapSound = ValueNotifier (0 );
49- ValueNotifier <int > logDragSound = ValueNotifier (0 );
50- ValueNotifier <int > logFlickSound = ValueNotifier (0 );
5148 ValueNotifier <int > logBufferUsage = ValueNotifier (0 );
5249 ValueNotifier <bool > isLoading = ValueNotifier (true );
5350 ValueNotifier <String ?> loadError = ValueNotifier (null );
@@ -61,6 +58,10 @@ class PhigrosSimulatorRenderController {
6158
6259 void setTime (double time) {
6360 _painterController? .setTime (time);
61+ setMusicTime (time);
62+ }
63+
64+ void setMusicTime (double time) {
6465 musicTimeController.add (time);
6566 }
6667
@@ -196,32 +197,39 @@ class _PhigrosSimulatorRenderWidgetState
196197 return ;
197198 }
198199 try {
199- tapSound = await SoLoud .instance.loadAsset (
200+ SoLoud .instance.setMaxActiveVoiceCount (16 * 3 + 2 );
201+ final tapSound = await SoLoud .instance.loadAsset (
200202 "packages/phasetida_flutter/assets/sound/hitSong0.wav" ,
203+ mode: LoadMode .memory,
201204 );
202- dragSound = await SoLoud .instance.loadAsset (
205+ final dragSound = await SoLoud .instance.loadAsset (
203206 "packages/phasetida_flutter/assets/sound/hitSong1.wav" ,
207+ mode: LoadMode .memory,
204208 );
205- flickSound = await SoLoud .instance.loadAsset (
209+ final flickSound = await SoLoud .instance.loadAsset (
206210 "packages/phasetida_flutter/assets/sound/hitSong2.wav" ,
211+ mode: LoadMode .memory,
207212 );
213+ this .tapSound = tapSound;
214+ this .dragSound = dragSound;
215+ this .flickSound = flickSound;
208216 } catch (e) {
209217 widget.controller.soundError.value = "failed to load effect sound: $e " ;
210218 }
211219 try {
212220 final songSource = await SoLoud .instance.loadMem (
213221 "song.ogg" ,
214222 widget.songBuffer,
223+ mode: LoadMode .memory,
215224 );
216225 songLength = SoLoud .instance.getLength (songSource);
217226 musicTotalTime = songLength.inMilliseconds / 1000.0 ;
218227 final songHandle = await SoLoud .instance.play (
219228 songSource,
220- paused: false ,
229+ paused: true ,
221230 looping: true ,
222231 loopingStartAt: songLength,
223232 );
224- SoLoud .instance.setRelativePlaySpeed (songHandle, 0.0000001 );
225233 this .songSource = songSource;
226234 this .songHandle = songHandle;
227235 } catch (e) {
@@ -230,7 +238,7 @@ class _PhigrosSimulatorRenderWidgetState
230238 musicTimeSub = widget.controller.musicTimeController.stream.listen ((time) {
231239 final songHandle = this .songHandle;
232240 if (songHandle != null && songLength != null ) {
233- final lengthInMillisecond = songLength.inMilliseconds - 10 ;
241+ final lengthInMillisecond = songLength.inMilliseconds - 5 ;
234242 SoLoud .instance.setPause (songHandle, false );
235243 SoLoud .instance.seek (
236244 songHandle,
@@ -271,6 +279,13 @@ class _PhigrosSimulatorRenderWidgetState
271279 splashImages: splashImages,
272280 clickImages: clickImages,
273281 offset: offset,
282+ soundTick: (logTapSound, logDragSound, logFlickSound) {
283+ if (widget.controller._enableSound) {
284+ _playSound (tapSound, logTapSound);
285+ _playSound (dragSound, logDragSound);
286+ _playSound (flickSound, logFlickSound);
287+ }
288+ },
274289 );
275290 painterController.setNoteScale (0.25 );
276291 painterController.clickScale = 1.5 ;
@@ -291,21 +306,12 @@ class _PhigrosSimulatorRenderWidgetState
291306 widget.controller.logMaxCombo.value = painterController.logMaxCombo ?? 0 ;
292307 widget.controller.logScore.value = painterController.logScore ?? 0 ;
293308 widget.controller.logAccurate.value = painterController.logAccurate ?? 0 ;
294- widget.controller.logTapSound.value = painterController.logTapSound ?? 0 ;
295- widget.controller.logDragSound.value =
296- painterController.logDragSound ?? 0 ;
297- widget.controller.logFlickSound.value =
298- painterController.logFlickSound ?? 0 ;
299309 widget.controller.logBufferUsage.value =
300310 painterController.logBufferUsage ?? 0 ;
301- if (widget.controller._enableSound) {
302- _playSound (tapSound, painterController.logTapSound);
303- _playSound (dragSound, painterController.logDragSound);
304- _playSound (flickSound, painterController.logFlickSound);
305- }
306311 })..start ();
307312 painterController.setupTime ();
308313 widget.controller.setSpeed (1.0 );
314+ widget.controller.setPaused (false );
309315 this .painterController = painterController;
310316 phasetida.resetNoteState (beforeTimeInSecond: 0 );
311317 setState (() {
0 commit comments