Skip to content

Commit 3fee047

Browse files
committed
Set playspeed after variation load
1 parent 1dba74c commit 3fee047

File tree

2 files changed

+41
-1
lines changed

2 files changed

+41
-1
lines changed

source/funkin/ui/debug/charting/ChartEditorState.hx

Lines changed: 39 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6144,20 +6144,30 @@ class ChartEditorState extends UIState // UIState derives from MusicBeatState
61446144

61456145
fadeInWelcomeMusic(WELCOME_MUSIC_FADE_IN_DELAY, WELCOME_MUSIC_FADE_IN_DURATION);
61466146

6147-
// Reapply the volume.
6147+
// Reapply the volume and playback rate.
61486148
var instTargetVolume:Float = menubarItemVolumeInstrumental.value ?? 1.0;
61496149
var vocalPlayerTargetVolume:Float = menubarItemVolumeVocalsPlayer.value ?? 1.0;
61506150
var vocalOpponentTargetVolume:Float = menubarItemVolumeVocalsOpponent.value ?? 1.0;
61516151

6152+
var playbackRate = ((menubarItemPlaybackSpeed.value ?? 1.0) * 2.0) / 100.0;
6153+
playbackRate = Math.floor(playbackRate / 0.05) * 0.05; // Round to nearest 5%
6154+
playbackRate = Math.max(0.05, Math.min(2.0, playbackRate)); // Clamp to 5% to 200%
6155+
61526156
if (audioInstTrack != null)
61536157
{
61546158
audioInstTrack.volume = instTargetVolume;
6159+
#if FLX_PITCH
6160+
audioInstTrack.pitch = playbackRate;
6161+
#end
61556162
audioInstTrack.onComplete = null;
61566163
}
61576164
if (audioVocalTrackGroup != null)
61586165
{
61596166
audioVocalTrackGroup.playerVolume = vocalPlayerTargetVolume;
61606167
audioVocalTrackGroup.opponentVolume = vocalOpponentTargetVolume;
6168+
#if FLX_PITCH
6169+
audioVocalTrackGroup.pitch = playbackRate;
6170+
#end
61616171
}
61626172
}
61636173

@@ -6311,6 +6321,11 @@ class ChartEditorState extends UIState // UIState derives from MusicBeatState
63116321

63126322
public function postLoadInstrumental():Void
63136323
{
6324+
// Reapply the volume and playback rate.
6325+
var instTargetVolume:Float = menubarItemVolumeInstrumental.value ?? 1.0;
6326+
var playbackRate = ((menubarItemPlaybackSpeed.value ?? 1.0) * 2.0) / 100.0;
6327+
playbackRate = Math.floor(playbackRate / 0.05) * 0.05; // Round to nearest 5%
6328+
playbackRate = Math.max(0.05, Math.min(2.0, playbackRate)); // Clamp to 5% to 200%
63146329
if (audioInstTrack != null)
63156330
{
63166331
// Prevent the time from skipping back to 0 when the song ends.
@@ -6323,6 +6338,10 @@ class ChartEditorState extends UIState // UIState derives from MusicBeatState
63236338
}
63246339
audioVocalTrackGroup.pause();
63256340
};
6341+
audioInstTrack.volume = instTargetVolume;
6342+
#if FLX_PITCH
6343+
audioInstTrack.pitch = playbackRate;
6344+
#end
63266345
}
63276346
else
63286347
{
@@ -6339,6 +6358,25 @@ class ChartEditorState extends UIState // UIState derives from MusicBeatState
63396358
healthIconsDirty = true;
63406359
}
63416360

6361+
public function postLoadVocals():Void
6362+
{
6363+
// Reapply the volume and playback rate.
6364+
var vocalPlayerTargetVolume:Float = menubarItemVolumeVocalsPlayer.value ?? 1.0;
6365+
var vocalOpponentTargetVolume:Float = menubarItemVolumeVocalsOpponent.value ?? 1.0;
6366+
var playbackRate = ((menubarItemPlaybackSpeed.value ?? 1.0) * 2.0) / 100.0;
6367+
playbackRate = Math.floor(playbackRate / 0.05) * 0.05; // Round to nearest 5%
6368+
playbackRate = Math.max(0.05, Math.min(2.0, playbackRate)); // Clamp to 5% to 200%
6369+
6370+
if (audioVocalTrackGroup != null)
6371+
{
6372+
audioVocalTrackGroup.playerVolume = vocalPlayerTargetVolume;
6373+
audioVocalTrackGroup.opponentVolume = vocalOpponentTargetVolume;
6374+
#if FLX_PITCH
6375+
audioVocalTrackGroup.pitch = playbackRate;
6376+
#end
6377+
}
6378+
}
6379+
63426380
function hardRefreshOffsetsToolbox():Void
63436381
{
63446382
var offsetsToolbox:ChartEditorOffsetsToolbox = cast this.getToolbox(CHART_EDITOR_TOOLBOX_OFFSETS_LAYOUT);

source/funkin/ui/debug/charting/handlers/ChartEditorAudioHandler.hx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,8 @@ class ChartEditorAudioHandler
146146
result = playVocals(state, DAD, opponentId, instId);
147147
// if (!result) return false;
148148

149+
state.postLoadVocals();
150+
149151
var perfE:Float = TimerUtil.start();
150152

151153
state.hardRefreshOffsetsToolbox();

0 commit comments

Comments
 (0)