fork/m-overlay
git clone https://git.julia.blue/fork/m-overlay
a8034e9
v2.1.1
1local music ={ 2PLAYLIST ={} , 3SONGS ={} , 4PLAYLIST_ID =- 1 , 5PLAYING =nil , 6FINISHED =true , 7LOOP =false , 8TRACK_ID ={} , 9RNG_SEED =nil , 10PROBABILITY_FILE ="probability.json" , 11PROBABILITY_SETTINGS ={ 12global ={} , 13states ={} , 14} , 15MUTED =false 16} 17 18local MUTED_TEXTURE =love . graphics . newImage ( "textures/gui/muted.png" ) 19 20local log =require ( "log" ) 21local melee =require ( "melee" ) 22local memory =require ( "memory" ) 23local notification =require ( "notification" ) 24local overlay =require ( "overlay" ) 25local wav =require ( "wav" ) 26local json =require ( "serializer.json" ) 27local fs =require ( "util.filesystem" ) 28 29require ( "extensions.math" ) 30 31-- Given a list of {element, weight} pairs, do a weighted random sample 32-- of the elements (returns an index, not the element itself) 33local function weightedRandomChoice ( list ) 34if not list or # list == 0 then return nil end 35if # list == 1 then return 1 end 36 37local sum =0 38for _ , weight in pairs ( list ) do 39sum =sum + weight 40end 41 42if sum <= 0 then return nil end 43 44local choice =math . random ( 1 , sum ) 45for k , weight in pairs ( list ) do 46choice =choice - weight 47if choice <= 0 then 48return k 49end 50end 51return choice 52end 53 54local function moveFolderContentsTo ( from , to ) 55local info =love . filesystem . getInfo ( from ) 56 57if info and info . type == "directory" then 58-- Upgrade to new folder layout 59local configdir =love . filesystem . getSaveDirectory () 60 61local files =love . filesystem . getDirectoryItems ( from ) 62for k , file in ipairs ( files ) do 63os . rename (( "%s/%s/%s" ): format ( configdir , from , file ), ( "%s/%s/%s" ): format ( configdir , to , file )) 64end 65 66love . filesystem . remove ( from ) 67end 68end 69 70function music . update () 71if not music . PLAYING or music . FINISHED then return end 72 73local duration =music . PLAYING . STREAM : getDuration ( "samples" ) 74local position =music . PLAYING . STREAM : tell ( "samples" ) 75 76if music . LOOP then 77local finished =not music . PLAYING . STREAM : isPlaying () 78 79if finished then 80-- If the song is no longer playing, that means it reached the end 81-- Immediately play it again 82log . debug ( "[MUSIC] End of song reached, replaying" ) 83music . PLAYING . STREAM : play () 84end 85 86local info =music . PLAYING . WAV 87 88if info then 89for k , loop in pairs ( info . loops ) do 90if finished or position >= loop . sample_end then 91log . debug ( "[MUSIC] Loop point reached, seeking to %d" , loop . sample_start ) 92-- If the song finished playing or reached the looping point, loop back to the start? 93music . PLAYING . STREAM : seek ( loop . sample_start , "samples" ) 94break -- Only handle the first loop for now.. 95end 96end 97end 98else 99if not music . PLAYING . STREAM : isPlaying () or position >= duration then 100-- We mark that the song has completed, allowing the next game frame hook to play the next song in the playlist 101music . FINISHED =true 102end 103end 104end 105 106function music . init () 107love . filesystem . createDirectory ( "Melee" ) 108 109local info =love . filesystem . getInfo ( "Stage Music" ) 110 111if info and info . type == "directory" then 112-- Upgrade to new folder layout 113local configdir =love . filesystem . getSaveDirectory () 114os . rename (( "%s/Stage Music" ): format ( configdir ), ( "%s/Melee/Stage Music" ): format ( configdir )) 115end 116 117local info =love . filesystem . getInfo ( "Melee/Stage Music/Menu" ) 118 119if info and info . type == "directory" then 120-- Upgrade to new folder layout 121local configdir =love . filesystem . getSaveDirectory () 122os . rename (( "%s/Melee/Stage Music/Menu" ): format ( configdir ), ( "%s/Melee/Menu Music" ): format ( configdir )) 123else 124love . filesystem . createDirectory ( "Melee/Menu Music" ) 125end 126 127-- VS mode folders 128 129for stageid , name in pairs ( melee . getAllStages ()) do 130love . filesystem . createDirectory (( "Melee/Stage Music/%s" ): format ( name )) 131end 132moveFolderContentsTo ( "Melee/Stage Music/All" , "Melee/Stage Music" ) 133 134-- Single player folders 135 136love . filesystem . createDirectory ( "Melee/Single Player Music" ) 137 138for stageid , name in pairs ( melee . getSinglePlayerStages ()) do 139love . filesystem . createDirectory (( "Melee/Single Player Music/%s" ): format ( name )) 140end 141 142-- Series folders 143 144for stageid , series in pairs ( melee . getAllStageSeries ()) do 145love . filesystem . createDirectory (( "Melee/Series Music/%s" ): format ( series )) 146end 147moveFolderContentsTo ( "Melee/Series Music/All" , "Melee/Series Music" ) 148 149love . filesystem . createDirectory ( "Melee/Single Player Music/Break the Targets" ) 150 151for stageid , name in pairs ( melee . getAkaneiaStages ()) do 152love . filesystem . createDirectory (( "Melee/Akaneia Stage Music/%s" ): format ( name )) 153end 154for stageid , name in pairs ( melee . getBeyondMeleeStages ()) do 155love . filesystem . createDirectory (( "Melee/Beyond Melee Stage Music/%s" ): format ( name )) 156end 157 158music . loadProbablitities () 159end 160 161function music . kill () 162if music . PLAYING then 163if music . PLAYING . STREAM then 164if music . PLAYING . STREAM : isPlaying () then 165log . debug ( "[MUSIC] Killed music" ) 166music . PLAYING . STREAM : stop () 167music . FINISHED =true 168end 169music . PLAYING . STREAM : release () 170end 171music . PLAYING =nil 172end 173end 174 175-- Set to true when the announcer says 'GAME!' 176local MATCH_SOFT_END =false 177 178function music . shouldPlayMusic () 179return melee . isInMenus () or ( melee . isInGame () and not melee . matchFinsihed () and not MATCH_SOFT_END ) 180end 181 182function music . onLoopChange ( mode ) 183if music . PLAYING and music . PLAYING . STREAM : isPlaying () then 184music . LOOP =music . shouldLoop () 185end 186end 187 188function music . getVolume () 189return PANEL_SETTINGS : GetVolume () 190end 191 192function music . getPlaylist () 193local playlist =table . copy ( music . PLAYLIST ) 194table . sort ( playlist , function ( a , b ) 195return a . FILEPATH < b . FILEPATH 196end ) 197return playlist 198end 199 200function music . getPlaylistTree () 201local playlist =music . getPlaylist () 202local tree ={} 203for k , entry in ipairs ( playlist ) do 204local directory =string . getFilePath ( entry . FILEPATH ) 205if not tree [ directory ] then tree [ directory ] ={} end 206table . insert ( tree [ directory ], entry ) 207end 208return tree 209end 210 211local LOADED =false 212local ALLOW_INGAME_VOLUME =false 213 214memory . hook ( "OnGameClosed" , "Set state unloaded" , function () 215LOADED =false 216end ) 217 218memory . hook ( "scene.major" , "Load Initial Volume" , function ( menu ) 219if memory . isMelee () and ALLOW_INGAME_VOLUME and not LOADED and menu == SCENE_MAIN_MENU then 220LOADED =true 221-- Set the games music value to our value 222music . setVolume ( music . getVolume ()) 223end 224end ) 225 226memory . hook ( "volume.slider" , "Ingame Volume Adjust" , function ( volume ) 227if memory . isMelee () and ALLOW_INGAME_VOLUME and LOADED then 228PANEL_SETTINGS : SetVolume ( 100 - volume ) 229end 230end ) 231 232function music . refreshRNGseed () 233local getSeed =function () 234if not music . RNG_SEED or not memory . isMelee () then return os . time (), "the system time" end 235if melee . isInMenus () then return music . RNG_SEED + 1 , "the previous seed" end 236if melee . isNetplayGame () then return memory . online . rng_offset , "Slippi" end 237return memory . rng . seed , "Melee" 238end 239 240local seed , source =getSeed () 241math . randomseed ( seed ) 242music . RNG_SEED =seed 243log . debug ( "[RANDOM] Obtained seed \"0x%X\" from %s" , seed , source ) 244end 245 246function music . setVolume ( vol ) 247if ALLOW_INGAME_VOLUME and memory . isMelee () then 248-- Melee's slider goes in increments of 5 249-- It seems to add +5 or -5 no matter what, but it can actually take numbers in between and still work 250--local nearest5 = math.round((100-vol) / 5)*5 251 252-- volume.slider adjust (0-100) 253memory . writeByte ( 0x8045C384 , math . round ( 100 - vol )) 254 255-- volume.music adjust (0-127) 256memory . writeByte ( 0x804D3887 , ( vol / 100 ) * 127 ) 257end 258 259if music . PLAYING then 260if music . MUTED then 261vol =0 262end 263music . PLAYING . STREAM : setVolume (( vol / 100 ) * ( melee . isPaused () and 0.35 or 1 )) 264end 265end 266 267do 268local LOOPING_NONE =0 269local LOOPING_MENU =1 270local LOOPING_STAGE_TIMED =2 271local LOOPING_STAGE_ENDLESS =4 272function music . shouldLoop () 273local loop =PANEL_SETTINGS : GetMusicLoopMode () 274 275if music . PLAYLIST_ID == 0 then 276return bit . band ( loop , LOOPING_MENU ) == LOOPING_MENU 277elseif melee . isCountdownTimer () then 278return bit . band ( loop , LOOPING_STAGE_TIMED ) == LOOPING_STAGE_TIMED 279else 280return bit . band ( loop , LOOPING_STAGE_ENDLESS ) == LOOPING_STAGE_ENDLESS 281end 282 283return false 284end 285end 286 287do 288local function getWeightTable ( songs ) 289local tbl ={} 290local useWeights =false 291local firstValue 292for k , song in pairs ( songs ) do 293tbl [ k ] =music . getFileProbability ( song . FILEPATH ) 294if not firstValue then 295firstValue =tbl [ k ] 296elseif firstValue ~= tbl [ k ] then 297useWeights =true 298end 299end 300return tbl , useWeights 301end 302 303local function getNextTrack ( songs ) 304local weightTable , useWeights =getWeightTable ( songs ) 305 306if useWeights then 307local track_id =weightedRandomChoice ( getWeightTable ( songs )) 308return track_id , track_id 309end 310 311music . TRACK_ID [ music . PLAYLIST_ID ] =(( music . TRACK_ID [ music . PLAYLIST_ID ] or - 1 ) + 1 ) % # songs 312local track_id =music . TRACK_ID [ music . PLAYLIST_ID ] + 1 313 314-- Only shuffle if we have more than 2 songs.. 315if # songs > 2 then 316-- Every time we play a song, we randomly place it towards the start of the playlist 317-- This keeps the playlist in a constantly shuffled order 318local track =table . remove ( songs , track_id ) 319local newpos =math . random ( 1 , track_id ) 320table . insert ( songs , newpos , track ) 321return track_id , newpos 322end 323 324return track_id , track_id 325end 326 327local function loadTrack ( songs , index ) 328local track_info =songs [ index ] 329 330local filepath =track_info . FILEPATH 331 332local success , source =pcall ( love . audio . newSource , filepath , "stream" ) 333if not ( success and source ) then 334log . error ( "[MUSIC] invalid music file %q" , filepath ) 335notification . error ( "invalid music file %q" , filepath ) 336table . remove ( songs , index ) 337return nil 338end 339 340return { STREAM =source , WAV =track_info . IS_WAV and wav . parse ( filepath ) or nil , INFO =track_info } 341end 342 343function music . playNextTrack () 344if not memory . isMelee () or not PANEL_SETTINGS : PlayStageMusic () then return end 345if music . PLAYING ~= nil and not music . FINISHED then return end 346if not music . PLAYLIST_ID then return end 347if not music . shouldPlayMusic () then return end 348 349local songs =music . PLAYLIST 350 351if # songs > 0 then 352local track_id , track_index =getNextTrack ( songs ) 353 354if not track_index then return end 355 356music . PLAYING =loadTrack ( songs , track_index ) 357 358if music . PLAYING then 359local path =music . PLAYING . INFO . FILEPATH 360if music . PLAYLIST_ID == 0x0 then 361log . info ( "[MUSIC] Playing track #%d for menu (%q)" , track_id , path ) 362else 363log . info ( "[MUSIC] Playing track #%d for stage %q (%q)" , track_id , melee . getStageName ( music . PLAYLIST_ID ), path ) 364end 365music . setVolume ( PANEL_SETTINGS : GetVolume ()) 366music . LOOP =music . shouldLoop () 367music . PLAYING . STREAM : play () 368music . FINISHED =false 369end 370end 371end 372end 373 374function music . onStateChange () 375if melee . isInGame () then 376music . loadForStage ( memory . stage . id ) 377elseif melee . isInMenus () then 378music . loadForStage ( 0 ) 379end 380end 381 382function music . draw () 383if music . MUTED then 384love . graphics . setColor ( 255 , 255 , 255 , 255 ) 385love . graphics . easyDraw ( MUTED_TEXTURE , 256 - 16 , 256 - 68 , 0 , 32 , 32 ) 386end 387end 388 389memory . hook ( "frame" , "Melee - Music Think" , music . playNextTrack ) 390 391memory . hook ( "OnGameClosed" , "Dolphin - Game closed" , function () 392music . kill () 393end ) 394 395memory . hook ( "scene.major" , "Melee - Menu state" , function ( menu ) 396if melee . isInMenus () then 397music . loadForStage ( 0 ) 398elseif not melee . isInGame () then 399music . kill () 400end 401end ) 402 403memory . hook ( "scene.minor" , "Melee - Menu state" , function ( menu ) 404if melee . isInMenus () then 405music . loadForStage ( 0 ) 406elseif melee . isInGame () then 407MATCH_SOFT_END =false 408music . loadForStage ( memory . stage . id ) 409else 410music . kill () 411end 412end ) 413 414memory . hook ( "stage.id" , "Melee - Stage loaded" , function ( stage ) 415if melee . isInGame () then 416music . loadForStage ( stage ) 417end 418end ) 419 420memory . hook ( "match.info.playing" , "Melee - Classic Mode Master Hand Fix?" , function ( playing ) 421-- In classic mode, when you kill masterhand the match result is never set, but the "playing" flag is set to false. 422-- Mute the music right when masterhand is killed. 423if not playing and ( memory . scene . major == SCENE_CLASSIC_MODE and memory . stage . id == 0x25 ) then 424MATCH_SOFT_END =true 425music . kill () 426end 427end ) 428 429memory . hook ( "match.info.paused" , "Melee - Pause volume" , function ( paused ) 430music . setVolume ( music . getVolume ()) 431end ) 432 433memory . hook ( "match.info.finished" , "Melee - GAME kill music" , function ( finished ) 434if finished then 435-- The match ended, so no matter what the music should be killed 436music . kill () 437end 438end ) 439 440memory . hook ( "match.info.result" , "Melee - GAME kill music" , function ( result ) 441-- LRAB+Start/Saltyrunback causes a result of MATCH_NO_CONTEST.. We don't want to end the music in this case only. 442-- The match.finished hook will end the music instead when actually exiting the match using normal LRA+Start. 443-- If the match actually ends normally, we kill the music early when it announces the end of the game. 444 445if result ~= MATCH_NO_RESULT and ( memory . scene . major ~= SCENE_VS_MODE or ( memory . scene . major == SCENE_VS_MODE and result ~= MATCH_NO_CONTEST )) then 446MATCH_SOFT_END =true 447music . kill () 448end 449end ) 450 451memory . hook ( "controller.*.buttons.pressed" , "Melee - Music skipper" , function ( port , pressed ) 452if not memory . isMelee () or PANEL_SETTINGS : IsBinding () or PANEL_SETTINGS : IsSlippiReplay () then return end -- Don't skip when the user is setting a button combination or when watching a replay 453local skipMask =PANEL_SETTINGS : GetMusicSkipMask () 454local muteMask =PANEL_SETTINGS : GetMusicMuteMask () 455if port == overlay . getPort () then 456if pressed == skipMask and # music . PLAYLIST > 1 then 457log . debug ( "[MUSIC] [MASK = 0x%X] Skip combo pressed, stopping music." , skipMask ) 458music . kill () 459end 460if pressed == muteMask then 461music . MUTED =not music . MUTED 462music . setVolume ( music . getVolume ()) 463log . debug ( "[MUSIC] [MASK = 0x%X] Mute combo pressed, %s music." , skipMask , music . MUTED and "muting" or "unmuting" ) 464end 465end 466end ) 467 468local valid_music_ext ={ 469[ "mp3" ] =true , 470[ "ogg" ] =true , 471[ "wav" ] =true , 472[ "flac" ] =true 473} 474 475function music . isValidMusicExt ( ext ) 476return valid_music_ext [ ext ] 477end 478 479function music . loadPlaylistForStage ( stageid , name ) 480local found =0 481local files =love . filesystem . getDirectoryItems ( name ) 482table . sort ( files ) -- Sort our list of files alphabetically, giving our table a deterministic state 483for k , file in ipairs ( files ) do 484local filepath =( "%s/%s" ): format ( name , file ) 485local info =love . filesystem . getInfo ( filepath ) 486if info then 487if info . type == "file" then 488local ext =string . getFileExtension ( file ): lower () 489 490if music . isValidMusicExt ( ext ) then 491found =found + 1 492 493-- Insert the newly found track into a random position in the playlist 494local pos =math . random ( 1 , # music . PLAYLIST ) 495local prob =music . PROBABILITY_SETTINGS [ "global" ][ filepath ] or tonumber ( string . match ( filepath , ".-_(%d+)%.%w+$" )) or 100 496 497if prob > 100 then 498log . warn ( "[MUSIC] Song %q has a probability greater than 100%%" , filepath ) 499end 500 501music . PROBABILITY_SETTINGS [ "global" ][ filepath ] =prob 502 503table . insert ( music . PLAYLIST , pos , { FILEPATH =filepath , FILENAME =file , WEIGHT =prob , IS_WAV =ext == "wav" } ) 504end 505end 506else 507log . warn ( "[MUSIC] Unable to get file information for file %q" , filepath ) 508end 509end 510if found > 0 then 511log . info ( "[MUSIC] Found %d songs in %q" , found , name ) 512end 513end 514 515function music . loadProbablitities () 516music . PROBABILITY_SETTINGS ={ 517global ={} , 518states ={} , 519} 520 521local probFile =music . PROBABILITY_FILE 522 523local f =love . filesystem . newFile ( probFile , "r" ) 524if f then 525local settings =music . PROBABILITY_SETTINGS 526local success , decoded =pcall ( json . decode , f : read ()) 527f : close () 528if not success then 529-- If we failed decoding, decoded is an error string. 530-- Get the last bit of text after the file name and line number. 531-- Error format: "filename.lua:1: (OUR ERROR STRING HERE)" 532local err =string . match ( decoded , "^.*:%s*(.*)$" ) or decoded 533log . error ( "[MUSIC] Failed parsing %s: ('%s')" , probFile , err ) 534notification . error ( "Failed parsing %s: ('%s')" , probFile , err ) 535elseif decoded . global and decoded . states then 536if decoded . global then 537for file , prob in pairs ( decoded . global ) do 538settings [ "global" ][ file ] =prob 539end 540end 541if decoded . states then 542for stateid , files in pairs ( decoded . states ) do 543stateid =tonumber ( stateid ) 544settings [ "states" ][ stateid ] =files 545end 546end 547else 548-- OLD SAVE FORMAT 549for file , prob in pairs ( decoded ) do 550settings [ "global" ][ file ] =prob 551end 552end 553end 554end 555 556function music . updateGlobalProbabilities ( tbl ) 557local settings =music . PROBABILITY_SETTINGS 558 559for file , prob in pairs ( tbl ) do 560settings [ "global" ][ file ] =prob 561end 562end 563 564function music . updateStateProbabilities ( tbl ) 565local state =music . PLAYLIST_ID 566local settings =music . PROBABILITY_SETTINGS 567 568for file , prob in pairs ( tbl ) do 569if not settings [ "states" ][ state ] then settings [ "states" ][ state ] ={} end 570settings [ "states" ][ state ][ file ] =prob 571end 572end 573 574function music . getFileProbability ( file ) 575local stateP =music . getStateFileProbability ( file ) 576 577if stateP < 100 then 578return stateP 579end 580 581return music . getGlobalFileProbability ( file ) 582end 583 584function music . getGlobalFileProbability ( file ) 585local settings =music . PROBABILITY_SETTINGS 586if settings [ "global" ] and settings [ "global" ][ file ] then 587return settings [ "global" ][ file ] 588end 589return 100 -- Default to 100% chance 590end 591 592function music . getStateFileProbability ( file ) 593local state =music . PLAYLIST_ID 594local settings =music . PROBABILITY_SETTINGS 595if settings [ "states" ] and settings [ "states" ][ state ] and settings [ "states" ][ state ][ file ] then 596return settings [ "states" ][ state ][ file ] 597end 598return 100 -- Default to 100% chance 599end 600 601function music . getProbabilitySaveTable () 602local tbl ={ 603global ={} , 604states ={} , 605} 606 607-- Only get files that have a custom prob. set 608for file , prob in pairs ( music . PROBABILITY_SETTINGS [ "global" ]) do 609if prob < 100 then 610tbl [ "global" ][ file ] =prob 611end 612end 613for stateid , files in pairs ( music . PROBABILITY_SETTINGS [ "states" ]) do 614stateid =tostring ( stateid ) -- JSON objects can only use strings as keys 615for file , prob in pairs ( files ) do 616if prob < 100 then 617if not tbl [ "states" ][ stateid ] then tbl [ "states" ][ stateid ] ={} end 618tbl [ "states" ][ stateid ][ file ] =prob 619end 620end 621end 622return tbl 623end 624 625function music . saveProbabilities () 626local probFile =music . PROBABILITY_FILE 627 628local f , err =love . filesystem . newFile ( probFile , "w" ) 629if f then 630log . warn ( "Writing to %s" , probFile ) 631notification . warning ( "Writing to %s" , probFile ) 632f : write ( json . encode ( music . getProbabilitySaveTable (), true )) 633f : flush () 634else 635log . error ( "Failed writing to %s: %s" , probFile , err ) 636notification . error ( "Failed writing to %s: %s" , probFile , err ) 637end 638end 639 640function music . loadForStage ( stageid ) 641if music . PLAYLIST_ID == stageid then return end 642 643music . kill () 644if not memory . isMelee () or not PANEL_SETTINGS : PlayStageMusic () then return end 645 646music . PLAYLIST_ID =stageid 647music . PLAYLIST ={} 648 649music . refreshRNGseed () 650 651music . loadPlaylistForStage ( stageid , "Melee" ) 652 653if stageid == 0x0 then 654music . loadPlaylistForStage ( stageid , "Melee/Menu Music" ) 655return 656elseif melee . isBTTStage ( stageid ) then 657music . loadPlaylistForStage ( stageid , "Melee/Single Player Music/Break the Targets" ) 658return 659end 660 661local name =melee . getStageName ( stageid ) 662local series =melee . getStageSeries ( stageid ) 663local sp =melee . isSinglePlayerStage ( stageid ) 664local aka =melee . isAkaneiaStage ( stageid ) 665local bm =melee . isBeyondMeleeStage ( stageid ) 666 667if not name then music . PLAYLIST_ID =nil return end 668 669if sp then 670music . loadPlaylistForStage ( stageid , ( "Melee/Single Player Music/%s" ): format ( name )) -- Load everything in the stage specific folder 671music . loadPlaylistForStage ( stageid , "Melee/Single Player Music" ) -- Load everything that's not in a stage folder as well 672elseif aka then 673music . loadPlaylistForStage ( stageid , ( "Melee/Akaneia Stage Music/%s" ): format ( name )) -- Load everything in the stage specific folder 674music . loadPlaylistForStage ( stageid , "Melee/Akaneia Stage Music" ) -- Load everything in the akaneia folder 675music . loadPlaylistForStage ( stageid , "Melee/Stage Music" ) -- Load everything in the stage folder 676elseif bm then 677music . loadPlaylistForStage ( stageid , ( "Melee/Beyond Melee Stage Music/%s" ): format ( name )) -- Load everything in the stage specific folder 678music . loadPlaylistForStage ( stageid , "Melee/Beyond Melee Stage Music" ) -- Load everything in the akaneia folder 679music . loadPlaylistForStage ( stageid , "Melee/Stage Music" ) -- Load everything in the stage folder 680else 681music . loadPlaylistForStage ( stageid , ( "Melee/Stage Music/%s" ): format ( name )) -- Load everything in the stage specific folder 682music . loadPlaylistForStage ( stageid , "Melee/Stage Music" ) -- Load everything in the stage folder 683end 684 685if series then 686music . loadPlaylistForStage ( stageid , ( "Melee/Series Music/%s" ): format ( series )) -- Load everything in the series folder 687music . loadPlaylistForStage ( stageid , "Melee/Series Music" ) -- Load everything that's not in a stage folder as well 688end 689end 690 691return music