Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 26 additions & 8 deletions source/funkin/play/PlayState.hx
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,24 @@ class PlayState extends MusicBeatSubState
*/
public var playbackRate:Float = 1.0;

/**
* The volume of the instrumental track.
* @default `1.0` for 100%.
*/
public var instrumentalVolume:Float = 1.0;

/**
* The volume of the player vocals track.
* @default `1.0` for 100%.
*/
public var playerVocalsVolume:Float = 1.0;

/**
* The volume of the opponent vocals track.
* @default `1.0` for 100%.
*/
public var opponentVocalsVolume:Float = 1.0;

/**
* An empty FlxObject contained in the scene.
* The current gameplay camera will always follow this object. Tween its position to move the camera smoothly.
Expand Down Expand Up @@ -1028,16 +1046,15 @@ class PlayState extends MusicBeatSubState
}
}

if (FlxG.sound.music != null) FlxG.sound.music.volume = 1;
if (FlxG.sound.music != null) FlxG.sound.music.volume = instrumentalVolume;

if (vocals != null)
{
vocals.pause();
vocals.time = startTimestamp - Conductor.instance.instrumentalOffset;

vocals.volume = 1;
vocals.playerVolume = 1;
vocals.opponentVolume = 1;
vocals.playerVolume = playerVocalsVolume;
vocals.opponentVolume = opponentVocalsVolume;
}

if (!fromDeathState)
Expand Down Expand Up @@ -2512,7 +2529,7 @@ class PlayState extends MusicBeatSubState
}

// Prevent the volume from being wrong.
FlxG.sound.music.volume = 1.0;
FlxG.sound.music.volume = instrumentalVolume;
if (FlxG.sound.music.fadeTween != null) FlxG.sound.music.fadeTween.cancel();

if (vocals != null)
Expand All @@ -2522,7 +2539,8 @@ class PlayState extends MusicBeatSubState

vocals.time = startTimestamp - Conductor.instance.instrumentalOffset;
vocals.pitch = playbackRate;
vocals.volume = 1.0;
vocals.playerVolume = playerVocalsVolume;
vocals.opponentVolume = opponentVocalsVolume;

// trace('STARTING SONG AT:');
// trace('${FlxG.sound.music.time}');
Expand Down Expand Up @@ -2986,7 +3004,7 @@ class PlayState extends MusicBeatSubState
playerStrumline.hitNote(note, !event.isComboBreak);
if (event.doesNotesplash) playerStrumline.playNoteSplash(note.noteData.getDirection());
if (note.isHoldNote && note.holdNoteSprite != null) playerStrumline.playNoteHoldCover(note.holdNoteSprite);
if (vocals != null) vocals.playerVolume = 1;
if (vocals != null) vocals.playerVolume = playerVocalsVolume;

// Display the combo meter and add the calculation to the score.
if (note.scoreable)
Expand Down Expand Up @@ -3225,7 +3243,7 @@ class PlayState extends MusicBeatSubState
comboPopUps.displayRating(daRating);
if (combo >= 10) comboPopUps.displayCombo(combo);

if (vocals != null) vocals.playerVolume = 1;
if (vocals != null) vocals.playerVolume = playerVocalsVolume;
}

/**
Expand Down
24 changes: 24 additions & 0 deletions source/funkin/save/Save.hx
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,7 @@ class Save implements ConsoleClass
chartEditorLiveInputStyle: ChartEditorLiveInputStyle.None,
theme: ChartEditorTheme.Light,
playtestStartTime: false,
playtestAudioSettings: false,
downscroll: false,
showNoteKinds: true,
metronomeVolume: 1.0,
Expand Down Expand Up @@ -413,6 +414,23 @@ class Save implements ConsoleClass
return data.optionsChartEditor.playtestStartTime;
}

public var chartEditorPlaytestAudioSettings(get, set):Bool;

function get_chartEditorPlaytestAudioSettings():Bool
{
if (data.optionsChartEditor.playtestAudioSettings == null) data.optionsChartEditor.playtestAudioSettings = false;

return data.optionsChartEditor.playtestAudioSettings;
}

function set_chartEditorPlaytestAudioSettings(value:Bool):Bool
{
// Set and apply.
data.optionsChartEditor.playtestAudioSettings = value;
flush();
return data.optionsChartEditor.playtestAudioSettings;
}

public var chartEditorTheme(get, set):ChartEditorTheme;

function get_chartEditorTheme():ChartEditorTheme
Expand Down Expand Up @@ -1933,6 +1951,12 @@ typedef SaveDataChartEditorOptions =
*/
var ?playtestStartTime:Bool;

/**
* If true, playtest songs with the current audio settings in the Chart Editor.
* @default `false`
*/
var ?playtestAudioSettings:Bool;

/**
* Theme music in the Chart Editor.
* @default `true`
Expand Down
18 changes: 17 additions & 1 deletion source/funkin/ui/debug/charting/ChartEditorState.hx
Original file line number Diff line number Diff line change
Expand Up @@ -604,6 +604,11 @@ class ChartEditorState extends UIState // UIState derives from MusicBeatState
*/
var playtestBotPlayMode:Bool = false;

/**
* If true, playtesting a chart will use the audio settings that were set here.
*/
var playtestAudioSettings:Bool = false;

/**
* Enables or disables the "debugger" popup that appears when you run into a flixel error.
*/
Expand Down Expand Up @@ -2486,6 +2491,7 @@ class ChartEditorState extends UIState // UIState derives from MusicBeatState
showNoteKindIndicators = save.chartEditorShowNoteKinds;
showSubtitles = save.chartEditorShowSubtitles;
playtestStartTime = save.chartEditorPlaytestStartTime;
playtestAudioSettings = save.chartEditorPlaytestAudioSettings;
currentTheme = save.chartEditorTheme;
metronomeVolume = save.chartEditorMetronomeVolume;
hitsoundVolumePlayer = save.chartEditorHitsoundVolumePlayer;
Expand Down Expand Up @@ -2516,6 +2522,7 @@ class ChartEditorState extends UIState // UIState derives from MusicBeatState
save.chartEditorDownscroll = isViewDownscroll;
save.chartEditorShowNoteKinds = showNoteKindIndicators;
save.chartEditorPlaytestStartTime = playtestStartTime;
save.chartEditorPlaytestAudioSettings = playtestAudioSettings;
save.chartEditorTheme = currentTheme;
save.chartEditorMetronomeVolume = metronomeVolume;
save.chartEditorHitsoundVolumePlayer = hitsoundVolumePlayer;
Expand Down Expand Up @@ -6268,7 +6275,16 @@ class ChartEditorState extends UIState // UIState derives from MusicBeatState

Cursor.hide();

LoadingState.loadPlayState(targetStateParams, false, true, function(targetState) {
LoadingState.loadPlayState(targetStateParams, false, true, function(targetState)
{
// Apply volume settings.
if (playtestAudioSettings)
{
targetState.instrumentalVolume = (menubarItemVolumeInstrumental.value / 100.0) ?? 1.0;
targetState.playerVocalsVolume = (menubarItemVolumeVocalsPlayer.value / 100.0) ?? 1.0;
targetState.opponentVocalsVolume = (menubarItemVolumeVocalsOpponent.value / 100.0) ?? 1.0;
}

targetState.vocals = audioVocalTrackGroup;
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,17 @@ class ChartEditorToolboxHandler
state.playtestSongScripts = checkboxSongScripts.selected;
};

var checkboxAudioSettings:Null<CheckBox> = toolbox.findComponent('playtestAudioSettingsCheckbox', CheckBox);

if (checkboxAudioSettings == null)
throw 'ChartEditorToolboxHandler.buildToolboxPlaytestPropertiesLayout() - Could not find playtestAudioSettingsCheckbox component.';

state.playtestAudioSettings = checkboxAudioSettings.selected;

checkboxAudioSettings.onClick = _ -> {
state.playtestAudioSettings = checkboxAudioSettings.selected;
};

return toolbox;
}

Expand Down