zerocoolisgod wrote:Load all of your MP3s into a table when the game or level or whatever starts. Then access them from that table when you need them. It'll move all of your load times to the beginning where timing isn't an issue.
This is a rather bad idea. Since i'm developing a rhythm game, let's say, for an example, a user has
130 songs installed in the game. If i loaded all 130 mp3's file @ startup, besides the fact the
game would take an infinity to load, memory usage would
SKYROCKET.
So, i don't think that's a good idea, it would work fine if the user had something about ~10 songs.
slime wrote:Sulunia wrote:Whenever i load a new .mp3 file, the entire game freezes for almost 1.5 seconds whilst the file loads.
Are you loading the mp3 into a streaming or a static source? How big is the file? Can you post a .love that has the long load time?
I'm loading then into a streaming source. File sizes are about a music size (3.6Mb~4.5Mb), mp3 type.
It's rather hard for me to post the .love here, because this particular section is tied up to a lot of other
spaghetti code.
I could post the entire game here if it's absolutely necessary.. (there is actually no game yet, just UI and splashscreen).
The function i call to load the song follows:
Code: Select all
function loadSong(songLoad)
debugLog("Loading song at filepath "..songLoad, 1, moduleName)
songData = love.sound.newSoundData(songLoad)
songPlay = love.audio.newSource(songLoad, "stream")
debugLog("Done!", 1, moduleName)
debugLog("Information: Sampling rate is "..songData:getSampleRate(), 1, moduleName)
debugLog("Information: Size is "..songData:getSampleCount().." samples", 1, moduleName)
songPlay:setVolume(0.75)
end
(Obs: the reason why i also create a songData is to be able to perform an FFT transformation to get frequency data.)