I Wanna Community

Fangames => Game Design => Programming Questions => Topic started by: xElectricZz on February 08, 2014, 04:38:30 PM

Title: Non-Restarting music only working on one song?
Post by: xElectricZz on February 08, 2014, 04:38:30 PM
the engine I'm using is Yutuuu Edition.

While trying to make my fangame music not restart, i looked around this forum and found some code Seph posted under an older thread, along with instructions to delete a few things in a few objects..

Code: [Select]
if !sound_isplaying(song) { sound_loop(song); }
When i deleted the things, and used this under the creation code of the playMusic object for the default track01, (guy rock), it worked. I pressed R, the music didn't restart. I died, it didn't restart. i switched rooms, it didn't restart.

But, after that testing, i added in some music i found so i didn't have to use guy rock on some rooms. Once i added it, and tried it on a a few rooms, it didn't work. The strange thing is, the rooms with guy rock worked perfectly. The room restarted quickly, and the music didn't ever restart. In the rooms with my music, the room took about a full second to load every time i hit R, and the music restarted. while it was loading, it looked like it was trying to resize itself a bit. before posting this i messed around in game maker for about 60 or so minutes on and off trying to fix it. does anybody have any idea what I'm doing wrong?
Title: Re: Non-Restarting music only working on one song?
Post by: infern0man1 on February 08, 2014, 06:04:49 PM
Well, how big is the music file? Sometimes it can lag the game a bit because music takes up a large amount of memory.
Title: Re: Non-Restarting music only working on one song?
Post by: YoSniper on February 08, 2014, 06:13:08 PM
Is "song" a variable that could represent a variety of sound files in your library? It would help to make sure you are setting the variable "song" correctly before trying to play the sound.

Then again, you may have already considered this. But without seeing the whole code, I can't be sure.
Title: Re: Non-Restarting music only working on one song?
Post by: xElectricZz on February 08, 2014, 06:36:28 PM
The song i'm using is a 6.17MB mp3 file.

The code i'm using is this. I ctrl + right click the playMusic object in a room, and click Creation Code. There, i paste the code i put into the OP. I believe it is a variable of any sounds in the music folder. The name of both show in yellow so i know i got the names correct of what i named them in game maker. If it matters, under the music folder put there for me in yuuutu edition, i made a new folder under that folder entitled "Area 1" to organize my music, and put it in there.

This is the song that won't work for me, and restarts every time.
Code: [Select]
if !sound_isplaying(buttdawgfunk) { sound_loop(buttdawgfunk); }
This is the song that came with Yuuutu edition, guy rock.
Code: [Select]
if !sound_isplaying(track01) { sound_loop(track01); }
If it helps, this is where i got the song. https://chiptuneswin.com/track/buttdawg-funk
Title: Re: Non-Restarting music only working on one song?
Post by: infern0man1 on February 08, 2014, 08:03:08 PM
The song i'm using is a 6.17MB mp3 file.


:PogChamp: You need to compress that sound file. That's probably the main reason why the game is doing that.
Title: Re: Non-Restarting music only working on one song?
Post by: dYnAm1c on February 08, 2014, 09:16:23 PM
.ogg files are probably the best for music in fangames, it has a very good compression but still good audio quality. Also the audio bitrate shouldn't go over 128kb/s as you shouldn't notice a difference anyways to higher bitrates, this saves space and probably better loading times and no lag on restarts.

to compare: a 3 minute song in good mp3 quality is about 4-6mb. A 3 minute song in good ogg quality is about 1,5-2,5mb.
Title: Re: Non-Restarting music only working on one song?
Post by: xElectricZz on February 11, 2014, 02:59:21 PM
.ogg files are probably the best for music in fangames, it has a very good compression but still good audio quality. Also the audio bitrate shouldn't go over 128kb/s as you shouldn't notice a difference anyways to higher bitrates, this saves space and probably better loading times and no lag on restarts.

to compare: a 3 minute song in good mp3 quality is about 4-6mb. A 3 minute song in good ogg quality is about 1,5-2,5mb.

Thanks for the help, After trying to compress it didn't work since its size was still too big, and trying to convert it into an ogg didn't work since it wouldn't play in game maker; i got an idea to convert it like this: 211kbit MP3 (Original File) - 96kbit OGG (From Earlier) - 96kbit MP3 using media.io (https://media.io). It managed to drop to 2.2 or so MB on the OGG, and the exact same size for the MP3 somehow. it works perfectly now.