Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"Audio.music" system with music overriding #77

Open
wants to merge 14 commits into
base: master
Choose a base branch
from

Conversation

SpencerlyEverly
Copy link
Contributor

@SpencerlyEverly SpencerlyEverly commented Jun 22, 2024

I am back with a new pull request! Here's a new addition that goes great with "Audio.sounds": "Audio.music"!

2024-06-22 18-21-12

Basically, the system for SFXs have been ported over to now include music. Below is information on how it works, along with code that will need to be added to SMBX2 itself:

Music Category IDs

  • 1: Special Music
  • 2: World Music
  • 3: Level Music

Track IDs

Depending on the category ID, track IDs are the music IDs located under "music.ini".

New Functions

  • Audio.music[musicCategoryID][trackID]: The new table system used to get or set the music specified. Only one variable exists for the system (music). When changing music, be sure the music you want to use is a filepath string, NOT an "SDL Mixer X" music chunk made with "Audio.MusicOpen". To know how it works, see below:
    • To get the music, just provide the variable with the IDs set: Audio.music[musicCategoryID][trackID].music
    • To change the music, provide the variable with the IDs set, and then specify a filepath to the new music you're changing it to: Audio.music[musicCategoryID][trackID].music = musicFilepath
  • Misc.resolveMusicFile(filepathWithArguments): Like "Misc.resolveSoundFile", this function resolves a music file to see if it exists. If it returns nil, the music specified does not exist. If found, it returns the music you specified. The places that "Misc.resolveMusicFile" looks at is the following:
    • Level Folder (If on a level)
    • Episode directory
    • The SMBX2 root directory ("data/")
  • Audio.MusicCount(categoryID): Returns the number of music IDs that were applied according to what category ID you specified. In the future, this can be used for adding extra music slots to music.ini, to test to see if the count is bigger than it was before.
  • Audio.SfxCount(): Returns the number of sounds that were applied from sounds.ini. In the future (If this happens), this can be used for adding extra sound effect slots to sounds.ini, to test to see if the count is bigger than it was before.

SMBX2 Lua Code to Add

As for what should be added to SMBX2's Lua side for this to work, check out the codes I wrote for "main.lua" and "classexpander.lua" here: https://pastebin.com/v9tb3vGt

Conclusion

This system is useful for changing the Special Music and World Music in Lua, since changing music in those categories are either possible (World Music filepaths, but it needs extra Lua code to make it possible), or actually impossible outside of this pull request (Special Music filepaths, which can't be changed outside of editing music.ini)

So, there's the answer on how useful this will be.

Hopefully, this pull request gets accepted at some point in time!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant