• Just a reminder that providing specifics on, sharing links to, or naming websites where ROMs can be accessed is against the rules. If your post has any of this information it will be removed.
  • Ever thought it'd be cool to have your art, writing, or challenge runs featured on PokéCommunity? Click here for info - we'd love to spotlight your work!
  • Welcome to PokéCommunity! Register now and join one of the best fan communities on the 'net to talk Pokémon and more! We are not affiliated with The Pokémon Company or Nintendo.

[Audio] Map music will not resume after custom fanfare

  • 222
    Posts
    7
    Years
    • Seen Nov 18, 2023
    I have added a few fanfares to the table in sound.c and they play just fine. However, after they are finished playing, the map music will not resume. This bug will not go away until the player changes map music via warp or map transition.

    Some things I know from debugging so far:
    • m4aMPlayContinue is being called properly after the fanfare ends, but it's not doing anything.
    • sCurrentMapMusic remains unchanged, it's not being reset to MUS_DUMMY or anything.
    • Built-in fanfares still work
    • My .mid files aren't doing anything strange and I can't see any issues with the generated .s build artifacts, it looks valid. Although to be fair I don't have a great knowledge on the internal workings of mid2agb

    Is there some kind of special consideration I'm not seeing to make a fanfare work properly in the engine?
     

    Attachments

    • mus_dex_eval_1.s
      9.3 KB · Views: 1
    • mus_dex_eval_2.s
      8.7 KB · Views: 1
    Last edited:
    Could you provide extra context of the fanfare itself and where/how it's being used? Seeing the .s file could be helpful, as well as whatever event/code that triggers the fanfare.

    I've attached two of the .s files to the original post. As far as how it's being run and used, well, I'm just running the vanilla script command: "playfanfare MUS_DEX_EVAL_1"
    (waitfanfare is for pausing script contexts and doesn't affect the internal system.) Passing in the song name to the command gets crossed referenced by a table that I've edited:

    Code:
    static const struct Fanfare sFanfares[] = {
        [FANFARE_00]        = { MUS_LEVEL_UP,         80 },
        [FANFARE_01]        = { MUS_OBTAIN_ITEM,     160 },
        [FANFARE_02]        = { MUS_EVOLVED,         220 },
        [FANFARE_03]        = { MUS_OBTAIN_TMHM,     220 },
        [FANFARE_04]        = { MUS_HEAL,            160 },
        [FANFARE_05]        = { MUS_OBTAIN_BADGE,    340 },
        [FANFARE_06]        = { MUS_MOVE_DELETED,    180 },
        [FANFARE_07]        = { MUS_OBTAIN_BERRY,    120 },
        [FANFARE_08]        = { MUS_SLOTS_JACKPOT,   250 },
        [FANFARE_09]        = { MUS_SLOTS_WIN,       150 },
        [FANFARE_10]        = { MUS_TOO_BAD,         160 },
        [FANFARE_POKEFLUTE] = { MUS_POKE_FLUTE,      450 },
        [FANFARE_KEY_ITEM]  = { MUS_OBTAIN_KEY_ITEM, 170 },
        [FANFARE_DEX_EVAL]  = { MUS_DEX_RATING,      196 },
        [FANFARE_DEX_EVAL_1]= { MUS_DEX_EVAL_1,      200 },
        [FANFARE_DEX_EVAL_2]= { MUS_DEX_EVAL_2,      180 },
        [FANFARE_DEX_EVAL_3]= { MUS_DEX_EVAL_3,      220 },
        [FANFARE_DEX_EVAL_4]= { MUS_DEX_EVAL_4,      210 },
        [FANFARE_DEX_EVAL_5]= { MUS_DEX_EVAL_5,      210 },
        [FANFARE_DEX_EVAL_6]= { MUS_DEX_EVAL_6,      370 },
    };
    (those last six are what i've added myself.) Nothing else about the fanfare system has been edited to my knowledge. And the vanilla fanfares still resume map music properly, so I'm at a loss.
     
    make clean and make sure MPlayContinue enters that if-statement

    No luck unfortunately. It indeed enters the if statement but isn't working properly. Maybe it's because I'm on pokefirered? Or perhaps something to do with the ipax hq audio mixer.

    Interesting to note is that `IsBGMPausedOrStopped` returns true while "normal" fanfares are played, but returns false while my custom fanfares are played. For that reason I think the bug happens when the fanfare starts instead of ends. It returns true for only one frame then goes back to false, when it's supposed to remain true for the entire fanfare. So when it gets to the end of the fanfare, I'm guessing there's no valid bgm data left to resume...

    Doesn't look like MUSICPLAYER_STATUS_PAUSE is being set properly. But when I try to debug it, it *is* being set and something is messing with the data. I really think there's something wrong with my .s files because I can literally add in random sound effects to the fanfares table and it works perfectly. It's only the stuff I'm inserting.
     
    Last edited:
    Back
    Top