Fix a bug where title music starts blaringly loud.

This commit is contained in:
EliteMasterEric 2024-03-15 21:53:07 -04:00
parent ea491e57a0
commit e4eb543fa7
2 changed files with 14 additions and 7 deletions

View file

@ -241,10 +241,16 @@ class FunkinSound extends FlxSound implements ICloneable<FunkinSound>
@:allow(flixel.sound.FlxSoundGroup) @:allow(flixel.sound.FlxSoundGroup)
override function updateTransform():Void override function updateTransform():Void
{ {
_transform.volume = #if FLX_SOUND_SYSTEM ((FlxG.sound.muted || this.muted) ? 0 : 1) * FlxG.sound.volume * #end if (_transform != null)
(group != null ? group.volume : 1) * _volume * _volumeAdjust; {
_transform.volume = #if FLX_SOUND_SYSTEM ((FlxG.sound.muted || this.muted) ? 0 : 1) * FlxG.sound.volume * #end
(group != null ? group.volume : 1) * _volume * _volumeAdjust;
}
if (_channel != null) _channel.soundTransform = _transform; if (_channel != null)
{
_channel.soundTransform = _transform;
}
} }
public function clone():FunkinSound public function clone():FunkinSound
@ -270,11 +276,12 @@ class FunkinSound extends FlxSound implements ICloneable<FunkinSound>
* Creates a new `FunkinSound` object and loads it as the current music track. * Creates a new `FunkinSound` object and loads it as the current music track.
* *
* @param key The key of the music you want to play. Music should be at `music/<key>/<key>.ogg`. * @param key The key of the music you want to play. Music should be at `music/<key>/<key>.ogg`.
* @param startingVolume The volume you want the music to start at.
* @param overrideExisting Whether to override music if it is already playing. * @param overrideExisting Whether to override music if it is already playing.
* @param mapTimeChanges Whether to check for `SongMusicData` to update the Conductor with. * @param mapTimeChanges Whether to check for `SongMusicData` to update the Conductor with.
* Data should be at `music/<key>/<key>-metadata.json`. * Data should be at `music/<key>/<key>-metadata.json`.
*/ */
public static function playMusic(key:String, overrideExisting:Bool = false, mapTimeChanges:Bool = true):Void public static function playMusic(key:String, startingVolume:Float = 1.0, overrideExisting:Bool = false, mapTimeChanges:Bool = true):Void
{ {
if (!overrideExisting && FlxG.sound.music?.playing) return; if (!overrideExisting && FlxG.sound.music?.playing) return;
@ -292,7 +299,7 @@ class FunkinSound extends FlxSound implements ICloneable<FunkinSound>
} }
} }
FlxG.sound.music = FunkinSound.load(Paths.music('$key/$key')); FlxG.sound.music = FunkinSound.load(Paths.music('$key/$key'), startingVolume);
// Prevent repeat update() and onFocus() calls. // Prevent repeat update() and onFocus() calls.
FlxG.sound.list.remove(FlxG.sound.music); FlxG.sound.list.remove(FlxG.sound.music);

View file

@ -222,9 +222,9 @@ class TitleState extends MusicBeatState
{ {
var shouldFadeIn = (FlxG.sound.music == null); var shouldFadeIn = (FlxG.sound.music == null);
// Load music. Includes logic to handle BPM changes. // Load music. Includes logic to handle BPM changes.
FunkinSound.playMusic('freakyMenu', false, true); FunkinSound.playMusic('freakyMenu', 0.0, false, true);
// Fade from 0.0 to 0.7 over 4 seconds // Fade from 0.0 to 0.7 over 4 seconds
if (shouldFadeIn) FlxG.sound.music.fadeIn(4, 0, 0.7); if (shouldFadeIn) FlxG.sound.music.fadeIn(4.0, 0.0, 1.0);
} }
function getIntroTextShit():Array<Array<String>> function getIntroTextShit():Array<Array<String>>