Funkin icon indicating copy to clipboard operation
Funkin copied to clipboard

cache songs before playing + smoother game over chord

Open vinjcc opened this issue 4 years ago • 13 comments

redoing this too

but anyway, caching the songs prevents a very short freeze right when the song begins to play (especially noticeable on bopeebo at dad's first note). i wasn't sure where to add that paragraph so feel free to move it elsewhere.

  • this time also for game over screen
  • game over music fades out for 0.1 secs instead of immediately stopping, to blend in nicer with the retry chord (love that btw)

tiny changes always

vinjcc avatar Feb 19 '21 06:02 vinjcc

HMMM caching would be useful, I never saw that in the FlxG.sound stuff lolol. I need another good read through of the documentation.

There's a big overhaul to the assets loading that I'm just about to merge, I'm not sure if it addresses the caching stuff, BUT if it doesn't I think this would def be helpful hehehe

ninjamuffin99 avatar Feb 24 '21 04:02 ninjamuffin99

i happened upon it here if you're wondering. i know almost nothing about haxe or flixel, i just like messing with code and burying my face in manuals.

also just noticed songs don't freeze in the web version, maybe because mp3s get decoded much faster than oggs. caching is still useful for download versions though.

vinjcc avatar Feb 28 '21 05:02 vinjcc

Would it even be possible to implement caching into the freeplay menu? A lot of freezes happen there because it plays the song that is selected.

ActualMandM avatar Mar 01 '21 03:03 ActualMandM

it prob would be possible, although I am worried about memory issues on a bit lower end hardware. BUT for now it can prob be implemented and can see if people are running into issues!

ninjamuffin99 avatar Mar 01 '21 04:03 ninjamuffin99

in the freeplay menu it might be better to load songs concurrently somehow, so it doesn't freeze waiting for the song to load every time you change the selection (songs wouldn't play immediately though). i might try caching every song anyway just to see what happens. (ps: pls merge #412)

vinjcc avatar Mar 01 '21 06:03 vinjcc

tried caching the freeplay menu on my end, honestly feels like a no-go to me long load time into the menu and causes a huge memory spike

i added the cache function into addSong if you were curious

	public function addSong(songName:String, weekNum:Int, songCharacter:String)
	{
		songs.push(new SongMetadata(songName, weekNum, songCharacter));
		FlxG.sound.cache(Paths.inst(songName));
	}

https://user-images.githubusercontent.com/15317421/109599989-2a380500-7ad1-11eb-8000-9daa7af486ac.mp4

ActualMandM avatar Mar 02 '21 05:03 ActualMandM

i.hate.file.size.limits.sometimes.mp4

what mod adds the character icons to the freeplay menu

isakube avatar Mar 16 '21 23:03 isakube

i.hate.file.size.limits.sometimes.mp4

what mod adds the character icons to the freeplay menu

this is something in the latest version of the github

aflacc avatar Apr 01 '21 23:04 aflacc

I'm pretty sure this doesn't do anything because FlxG.sound.playMusic doesn't try to use a cached sound, you'd have to swap out playMusic with play for that.

Alternatively, the way superior solution in my opinion is to use FlxG.sound.load on the loadscreen and then play the sound whenever ready. This allows you to take advantage of the OnLoad callback so you can just for example make the game go past the loading screen only after the sound has completely loaded which should eliminate most of the issues with audio on the pc version

SimplyMerlin avatar May 30 '21 23:05 SimplyMerlin

I'm pretty sure this doesn't do anything because FlxG.sound.playMusic doesn't try to use a cached sound, you'd have to swap out playMusic with play for that.

freeplay uses playmusic as well and the caching worked fine there (see video above)

ActualMandM avatar May 31 '21 05:05 ActualMandM

it prob would be possible, although I am worried about memory issues on a bit lower end hardware. BUT for now it can prob be implemented and can see if people are running into issues!

Memory issues are quite a big thing. 5% of issues are black sprites or something

VMGuy23 avatar May 31 '21 09:05 VMGuy23

I'm pretty sure this doesn't do anything because FlxG.sound.playMusic doesn't try to use a cached sound, you'd have to swap out playMusic with play for that.

freeplay uses playmusic as well and the caching worked fine there (see video above)

neither the api nor the code itself show anything that would imply that caching actually does anything when used with playMusic

SimplyMerlin avatar May 31 '21 13:05 SimplyMerlin

tried caching the freeplay menu on my end, honestly feels like a no-go to me long load time into the menu and causes a huge memory spike

i added the cache function into addSong if you were curious

	public function addSong(songName:String, weekNum:Int, songCharacter:String)
	{
		songs.push(new SongMetadata(songName, weekNum, songCharacter));
		FlxG.sound.cache(Paths.inst(songName));
	}

i.hate.file.size.limits.sometimes.mp4

Even though this is 1 year old:

I saw your Task Manager.

600 MB's for a Caching. That's a little scary isn't it?

REALHaydenGaming avatar Sep 25 '22 21:09 REALHaydenGaming