Author Topic: BGM Folder  (Read 3625 times)

bananaguy12

  • Guest
BGM Folder
« on: August 05, 2015, 02:58:43 PM »
In games like 'kill the needle games 2' or 'kamilia 3'  :denKamilia_v2: I noticed there is a separate folder where all the bgm is stored, and the bgm is not stored in the gamemaker file. Somehow the game pulls the music from the folder or something. I was wondering how do I do this? Thanks.

Katz

  • Cherry Eater
  • Posts: 71
  • OS:
  • Windows 8.1/Server 2013 Windows 8.1/Server 2013
  • Browser:
  • Chrome 44.0.2403.130 Chrome 44.0.2403.130
    • View Profile
  • Playstyle: Keyboard
Re: BGM Folder
« Reply #1 on: August 05, 2015, 03:25:08 PM »
Either external .ogg loaders (FMOD, SuperSound) or sound_add();

Derf

  • Guest
Re: BGM Folder
« Reply #2 on: August 05, 2015, 07:58:00 PM »
This method only works for GM8/8.1:

Code: [Select]
bgm = sound_add(working_directory+"\BGM\song.mp3",3,0);

if(!sound_isplaying(bgm)){
     sound_loop(bgm);
}

Obviously change the first line to match your folder name + song name, but if it's inside the folder where the game is you should be set. Might need a little tweaking to get it to work with your specific sound engine though.

klazen108

  • Administrator
  • The Kid
  • Posts: 286
  • your a kid now your a squid now
  • OS:
  • Windows 8.1/Server 2013 Windows 8.1/Server 2013
  • Browser:
  • Chrome 44.0.2403.125 Chrome 44.0.2403.125
    • View Profile
    • Delicious-Fruit
  • Playstyle: Keyboard
Re: BGM Folder
« Reply #3 on: August 06, 2015, 09:00:54 AM »
Note that if you're doing sound_add, you should only do this once in your game, say at game start (and it will take time, so you should only load one song per step, otherwise the game will look like it's freezing). This is what's happening during that loading bar at the beginning of K3 - it's adding one sound, then ticking the loading bar, adding another sound, ticking the loading bar, until it's done.

Never load sounds elsewhere! If, for example, you tried to load the sound on room start in the room you want to play the music in, it's going to create a new copy of the sound every time you load that room! You'll notice the slow restart time, and it probably wouldn't take long for the game to crash from memory errors due to the memory being full of the songs you loaded. (Note that this advice doesn't apply to you if you're advanced enough to understand the tradeoffs and always release any allocated memory)

tl;dr only use sound_add at the start of your game, never anywhere else

Derf

  • Guest
Re: BGM Folder
« Reply #4 on: August 06, 2015, 09:30:15 AM »
Yeah I really should have clarified a lot of that when I wrote my response, thank you Klazen :~)

klazen108

  • Administrator
  • The Kid
  • Posts: 286
  • your a kid now your a squid now
  • OS:
  • Windows 8.1/Server 2013 Windows 8.1/Server 2013
  • Browser:
  • Chrome 44.0.2403.125 Chrome 44.0.2403.125
    • View Profile
    • Delicious-Fruit
  • Playstyle: Keyboard
Re: BGM Folder
« Reply #5 on: August 06, 2015, 10:08:49 AM »
no problem, just want to save everyone the pain I've had to go through :Kappa:

bananaguy12

  • Guest
Re: BGM Folder
« Reply #6 on: August 08, 2015, 02:27:27 AM »
no problem, just want to save everyone the pain I've had to go through :Kappa:

Are there any benefits to using the sound folder outside of gm. Because in my last game i just put all the music in the .exe.

BBF

  • Cherry Eater
  • Posts: 95
  • OS:
  • Windows 7/Server 2008 R2 Windows 7/Server 2008 R2
  • Browser:
  • Chrome 44.0.2403.130 Chrome 44.0.2403.130
    • View Profile
  • Playstyle: Keyboard
Re: BGM Folder
« Reply #7 on: August 08, 2015, 06:10:07 AM »
Players can replace the music with something else, or choose to not load it at all to lower startup time (like K3 does with FMOD)

Also keeps your .exe file much smaller and (probably?) makes it easier to switch out music during development.

Derf

  • Guest
Re: BGM Folder
« Reply #8 on: August 08, 2015, 03:21:34 PM »
In my experience if you set it up right (as Klazen was suggesting), the game does run noticeably faster, in the sense that it doesn't lag when loading the music.

Also on a purely aesthetic side note, it make me feel special when I see my game has folders within the game folder. It feels like a proper product to me for some reason.

Sephalos

  • Spike Dodger
  • Posts: 228
  • OS:
  • Windows Vista/Server 2008 Windows Vista/Server 2008
  • Browser:
  • Chrome 44.0.2403.130 Chrome 44.0.2403.130
    • View Profile
  • Playstyle: Gamepad
Re: BGM Folder
« Reply #9 on: August 08, 2015, 03:41:36 PM »
no problem, just want to save everyone the pain I've had to go through :Kappa:
Are there any benefits to using the sound folder outside of gm. Because in my last game i just put all the music in the .exe.
The biggest benefit to loading music externally is memory management. If you intend to make a very large game and you don't manage your memory usage, you're going to run into a lot of problems. GameMaker by default will load everything you put in the GMK into the memory when starting the game. If the memory overloads this can cause bugs, missing music or sounds, surfaces or particles not loading properly and more.