Jump to content
A 2021 backup has been restored. Forums are closed and work in progress. Join our Discord server for more updates! ×
SoaH City Message Board

[Help - MMF2] Music Continuation


Recommended Posts

Let's say I have a certain song playing in the background of my game. After that song is done, I want it to transition immediately into another song, and then have that song loop continuously. Here's an example of what I want to do:

At start of frame: Play Song1 1 time

After Song1 has finished: Play Song2 0 times

By the way, these songs are under sound samples, not music samples. I also want to make it so, after an invincibility jingle has played or something similar to that, the background music starts back at Song1. How would I go about doing this?

Link to comment
Share on other sites

Simple enough. Have a counter set equal to 1 when the level starts. Then, have an event like this...

(No music is playing; counter == 1) --> Play Song2 -1 times; set counter = 0

Similarly, when you hit an invincibility box, set the counter back to 1 and end Song 2. When the invincibility music is finished, it'll revert back to Song2 automatically.

Hope that helps.

(By the way, you should switch the background music to play as music, not samples, as I don't think my method will work if it's samples. Jump noises, ring collecting noises, etc would mess it up)

Link to comment
Share on other sites

It'll revert back to Song2? I want it to go back to Song1. Also, I'm not sure if OGGs will play under music; they will play as samples under a channel, though, so sound effects won't interrupt them.

You may consider having song2 play 0 times based on when song1 reaches a certain position rather than when it finishes in order to eliminate any gaps between transitions.

How would I say, "When Song1 reaches 00:xx"? Would I need to make a separate counter for this?

Link to comment
Share on other sites

EDIT: Oh, I forgot there's a "Specific Sample not playing" option. Well, that makes things easier...

----------------------

Start of level: Play Song1 1 time

(Song1 not playing; counter==1) -> Play Song2 -1 times; set counter = 0

Sonic hits box -> Stop Sample; play Invincibility; set counter = 2

(Invincibility not playing; counter==2) -> Play Song1 -1 times; set counter = 0

-----------------

That should do it.

Link to comment
Share on other sites

Just wondering, but does that double equal-sign in your post mean "equals"?

Anyway, it's not working. Now, whenever I change to invincibility or speed-up, it just plays Song1 again. Also, when I say Song1 isn't playing, instead of setting the counter to 1, it just goes back to playing Song1.

Link to comment
Share on other sites

Yeah, in most programming languages, a single equals sign assigns a value, double equals signs are used to compare two values.

Hmm...well, does the first part work, where it transitions from Song1 to Song2? Do you have the "set counter = 2" before the "play invincible music" event (trust me, it makes a difference sometimes)?

Would you mind posting a picture of the events and conditions the way you have them?

EDIT:

I just wrote a simple version of what you want and noticed a few logic mistakes; try this...

---------------------

Start of level: Play Song1; set counter = 1

(Song1 not playing; counter==1) -> Play Song2 -1 times; set counter = 0

Sonic hits box -> Stop Sample; play Invincibility; set counter = 2

(Invincibility not playing; counter==2) -> Play Song1; set counter = 1

---------------------

This works on mine, so it should work for you now. Sorry about the mistakes earlier.

Link to comment
Share on other sites

No problem. I'm sure I wasn't close to doing this right in the first place. Also, if it helps any, I'm using Sonic Worlds for this.

"vinevalleyintro" is Song1, and "vinevalleypart2" is Song2.

songproblem.png

Also, changing the counter from 0 to 1 still doesn't help; it still goes back to "vinevalleyintro." And now, whenever I hit Invincibility, "vinevalleyintro" plays instead of the invincibility jingle.

[EDIT] You know, I think I'll try something that involves setting a counter to continue increasing and then playing Song2 at a certain point on the counter, which was probably what Lark said in the first place. Otherwise, I'm currently going nowhere.

Link to comment
Share on other sites

Here, I've attached the simple program I made. Maybe you can figure things out better from having a working example...

**To add new types of music (SuperSpeed shoes, Super Sonic, etc), just copy the invincibility code and add 1 to the number. IE: SuperSpeed shoes would set the counter equal to 3, Super Sonic would set it equal to 4, etc. They all have to jump back down to 1, though.***

**However, in your code, I would suggest having the "Stop Sample" conditions ABOVE the "Play Song" ones.***

BlueEmeraldTut.gam

Link to comment
Share on other sites

Thanks, USC. I'll try it out.

[EDIT] Argh, it's still not working. I think the main problem is in Group 1532 in my picture above. I think it's coming from the "vinevalleyintro is not playing," which might be what's causing it to keep playing. But, if I remove it, the song won't play and the framerate in the game slows down. Is there anything I can do to fix that?

[EDIT] Wait, yes! I did it! All I had to do was remove the "Stop any sample" event, and then replace that "vinevalleyintro is not playing" in Group 1532 with "SongCounter is greater than 1." There is kind of a gap in the songs, though. I think I'll try Lark's idea for now.

Link to comment
Share on other sites

If you make a 'compare two general values' condition, you can get the Sample Position value and compare it to a certain amount in milliseconds. So if you wanted the song to transition around 22 seconds, you could retrieve the Sample Position for the top entry and for the bottom you'd input 22000 ( 22 * 1000 ).

Link to comment
Share on other sites

You would replace all the "Song1 is not playing" with the conditions Lark told you about (IE: "Sample Position is greater than 22000 milliseconds").

MMF2 measures in milliseconds instead of seconds, so that's why you have to multiply by 100.

  • Like 1
Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...