[Open Assets] Sound Channels (Music Layers)

This content may be freely modified and/or maintained by anyone.
Status
Not open for further replies.

Varren

Top 50 In #FortniteMostWanted
Sonic Team Junior
I was asked to release this so

This is basically a sound streaming script that allows you to emulate music channels (brstm, aax, etc) and then play whichever, whenever. (think white world from sonic generations)


Function:
Code:
S_StartSoundChannel(player_t player, table{chan1}, table{chan2}, 
int secs, int looppoint, int channel)

[B]player[/B] = player affected
[B]table{chan1}[/B] = the defined table storing the channel1 sounds in LUA_LIBR
[B]table{chan2}[/B] = the defined table storing the channel2 sounds in LUA_LIBR
[B]secs[/B] = seconds to loop through (1*TICRATE = 1 second of files to loop through)
[B]looppoint[/B] = the number of your soundfile where the song loops
[B]channel[/B] = channel to play (0 - First | 1 - Second | 2 - Both)
Sound tables which can be copied or renamed are in the library file (LUA_LIBR)

Some examples of usage:
-------------
Flag triggers
Boss Phase triggers
-------------

The example included uses a flag trigger that changes what layer of music plays when you enter water

Music Files:
--------------------------
If you want to insert your own soundfiles, then you need audacity and a tiny batch file renamer that can increment numbers. (try Bulk Rename Utility)

First you need to set up your loop point in seconds (so if your song ends at 1:20 and loops at 35 seconds your loop point value will be 35. If your loop point is 35.80 then it would be 36. If the music doesn't sound right with looping you might have to edit it a bit to get it to loop properly. This will be input in the looppoint part of the function, keep it for when you use it

Run Audacity and turn off show metadata editor in options under Import/Export. After that, import the track and go to Analyze > Regular Interval Labels... and inside that dialogue, set Label Interval [seconds] to how many seconds you want to split the files into.
4PY5Vpu.png


When audacity finishes creating labels, go to File > Export Multiple... select the sound format and export it into a separate folder. I Recommend setting file name prefix as DSEXP (replacing exp as the sound name), and using .ogg with a quality of 4 or less so the file size is low
FuSm8VX.png

Do these steps for for both tracks (except the looping)
--------------------------

Importing/Adding to game:
--------------------------
Import all split sounds into a new wad file (keep it organized with a marker between both sets if you need to) and save it separately as something you can recognize

Replace the content before [ //-- Length of files (# of files) ] with your own name and number of files from the tracks (not the combined total) and replace the table names, etc, with your own names for organization

Change the lines with the sfx_ prefix to your own for both tables (excluding the number extensions)

To use it in-game, just use the function wherever you want it to be used, just make sure you set the music volume to 0 or switch to a silent musiclump. (or tweak it however you want, I don't know)
--------------------------


I also don't suggest adding a bunch of files/musics to your projects since it does take up freeslots. Use it wisely I guess

If you have any questions feel free to ask
 

Attachments

  • lua_soundchannels.zip
    2.8 MB · Views: 453
Last edited:
Barring a few bugs like the audible gaps between the segments in the example wad, this is pretty neat. With this, we can finally have the Phantasy Star Online soundtrack as it was intended to be used!
 
Barring a few bugs like the audible gaps between the segments in the example wad ...

Sorry about that...
This was literally not an issue before I converted it into a function, and I'm not sure why it does this (rarely)

EDIT: It looks like this is an issue with the sdl2(?) version. It works fine with srb2dd for me
 
Last edited:
Status
Not open for further replies.

Who is viewing this thread (Total: 1, Members: 0, Guests: 1)

Back
Top