#sound.lua & sound API for Steamodded

132 messages · Page 1 of 1 (latest)

strange prairie
#

Should have done this sooner

#

@west badger I didn't quite understand what you wanted to be like the base game for the music ?

west badger
#

i apologize if i explain this poorly but in the base game, the ost seems to work in a way where, once the song switches, the new song picks up at the same point the previous song ended
since they are all variants of the same song with different instrumentation, this allows for them to transition smoothly between each other
i'm not quite sure how it works in the code, though

strange prairie
#

Hmmmmm I see

#

I could maybe play the music on repeat and only activate it's sound when it's called

west badger
#

ex. if you're in a shop and open an arcana pack...
if the shop theme is at the timestamp 1:23 at that exact moment, the tarot theme will be at 1:23 as well, rather than the song starting from the beginning

strange prairie
#

Yeah but in that case all sound are the same length no ?

west badger
#

yea, if that's a requirement for that system to work then i don't mind

strange prairie
#

In the base game, are all the music the same length ?

west badger
#

i believe so

#

i can't check atm

strange prairie
#

lemme check

#

all 2:53 yes

#

so you'll need all your music to be the same length if ya want the same effect

#

I'll implement that rn

west badger
#

yea they are the same length so that shouldn't be an issue

strange prairie
#

Should be doable, I'll see what I can do to make it simple

west badger
#

you could make it a toggle if you wanted, so people who don't care about the songs starting from the beginning can use whatever they want in their own packs

strange prairie
strange prairie
#

I cooked something I'll see if it works

#

I've got the playing & switch correct

#

rn I'm checking if it loops corrctly

#

I have a techno and chill music it's really funny when it switches XD

#

PERFECTION

#

When you code and it works 1st time

#

Okay

#

I have a side effect rn : no flame when you oneshot a blind

#

I'll see what I can do

#

Okay easy

#

@west badger updated to add the feature you wanted (just update and it should work without changing anything)

  • a bugfix
west badger
#

awesome thank you!! i'll check it out when i get home

strange prairie
#

Also send me your mod when you finish it !
I'm hyped

west badger
#

i'm curious how i would go about sharing it when the time comes, do i just make it lovely exclusive and tell people to download this custom sound.lua?

strange prairie
#

I'll update the mod so that it can work without being lovely injector

#

It's just simpler for me to mod that way and then convert it

#
  • it should soon be on base Steamodded
west badger
#

alright sounds good

solid latch
#

yeah I recommend you to target a modloader unless you specifically need the power

west badger
#

this is almost perfect

#

i do think it'd be great if the songs could fade between each other on transition instead of cutting abruptly but that's it

#

otherwise it's exactly what i was hoping for

#

there's also the fact that the music is controlled by the "game volume" slider instead of "music volume"

strange prairie
#

Ill see for the volume slider, shouldn't be too hard

strange prairie
strange prairie
#

Music volume problem is done

strange prairie
#

Should be good now

#

Only thing left is smooth transition between music

#

like a fadeout

#

And some bugfixes and code optimization

west badger
#

thank you so much

strange prairie
#

Thank you too for using what I do

west badger
#

i am very curious if it's possible to undo a sound replacement that was done with this api

#

in a mod unrelated to the music one, i want a sound to replace multhit2 in a specific situation but i want it to go back to normal afterwards

strange prairie
#

It's possible but you'll need to hook it yourself and call the Custom_Play_Sound yourself

#

what's the specific situation mayeb I could help ?

west badger
#

this is the code i have right now

local cest_ref = card_eval_status_text
function card_eval_status_text(card, eval_type, amt, percent, dir, extra)
    if (eval_type == 'extra' or eval_type == 'jokers') and extra.Xmult_mod then
        if extra.Xmult_mod < 1 then
            Add_Custom_Replace_Sound{multhit2= {
                sound_code = "xmult_lose",
                pitch = 0.8+percent*0.2
            }}
        end
    end
    cest_ref(card, eval_type, amt, percent, dir, extra)
end
#

i'd just like to set the sound back to normal if either of those ifs are false

strange prairie
#

All the sounds, stop sound, replace sounds are stocked in
SMODS.SOUND_SOURCES , SMODS.STOP_SOUNDS, SMODS.REPLACE_SOUND_PLAYED

#

so you could do SMODS.REPLACE_SOUND_PLAYED[multhit2] = nil

#

or a table.remove (if that exists)

#

@west badger

west badger
#

i'll try that

strange prairie
#

I could add some temporary stop sounds and replace sounds also

#

with a number of time it needs to trigger

#

before disappearing

#

It shouldn't even be that hard if you want

west badger
#

that would be awesome

strange prairie
#

Btw, is the API easy to use or not ?

#

I tried my best to make it as easy to use as possible

west badger
#

it is pretty easy to use imo

#

as long as you know the basics of making a mod

strange prairie
#

I'm gonna make stop_previous_instance false by default

strange prairie
#

And l'm working on the temporary stop sounds and replace sounds

strange prairie
#

@west badger temporary sounds done

west badger
#

nice nice

strange prairie
#

Created a pull request on main Steamodded branch

strange prairie
#

@west badger it has been merged into main branch ^^
Soon there'll be a release imo

languid halo
#

yep, a 1.0 release is underway

#

I'll repackage a few things to integrate this with the new API framework if that's fine by you^^

strange prairie
#

Sure, idk how you'll do it if you change my codes x) but no problem w you changing it, if you have any question do not hesitate

livid pond
#

Is it possible to use this or a similar mod to change/replace the background music? I heard it's "all one track" but it definitely changes up tempo etc. at certain points (like booster packs). Not sure if the game files have just one track or several already but I'd like to replace them if possible.

strange prairie
#

They have several track

#

They're called musicX and goes from 1 to 5

livid pond
strange prairie
#

Fyi

#

Will need to update some instructions and change things for Steamodded 1.0

#

But the core of the mod wont change

languid halo
#

the core as in the code itself or the interface?

#

Ideally I'd want this to be integrated with the rest of the Steamodded APIs, following the same sort of format

strange prairie
#

The core as in the code itself for updating to 1.0 sound API

#

Unless of course you change the functions how They behave etc

strange prairie
#

Like only a table ?

#

They could always directly do what they want since all vars are stored in a SMODS.TABLE var

languid halo
#

I'll give a shot at a port in the way I imagine it to be and I can show you. Then we can decide to keep that or do something else

#

it's just that the time for breaking changes is now, there might not be another major version like this

languid halo
#

@strange prairie I just finished porting the sound API to a Steamodded 1.0 compliant format. Wanna have a look and see if things are fine with you this way. I've made it so there's less separate functions to achieve the same set of features, and I'm fine adjusting the docs to reflect this

#
GitHub

A Balatro ModLoader. Contribute to Steamopollys/Steamodded development by creating an account on GitHub.

GitHub

A Balatro ModLoader. Contribute to Steamopollys/Steamodded development by creating an account on GitHub.

strange prairie
#

Created a pull request for the used G.settings.Sound

#

that was inversed in the logic

celest haven
#

so to use this in a mod do i include it in my mod's files itself or do i just put it in as a seperate mod and tell people to download it as well?

celest haven
#

oh by default???

#

is it in 0.9.8?

languid halo
#

yes

celest haven
#

cool

strange prairie
strange prairie
#

Just use Steamodded API directly

agile briar
#

Happy to see SMODS.Sound given a section in the Steamodded API :)

strange prairie
#

even if Aurelius did a great job porting it and adding some features

languid halo
#

ty, getting it working with music and everything was a good bit more work since I had to actually use the sound manager

strange prairie
#

I remember trying things with the sound manager and just banging my head against a wall

languid halo
#

your way didn't work for music because it's handled in a thread, which you were bypassing, plus the API did not yet have a way to tell the game to even play music

strange prairie
#

Yeah I bypassed the thread because trying things with the thread was a real headache and I just saw that this way worked

#

what doesn't work with my way ?

#

(and in the commits I can see you really spent some time on this)

#

I really thought I did a great job, I guess not x)

languid halo
strange prairie
#

yeah to modulate the music forsure you needed that XD

I tried to implement it but gave up because it was too complicated

But music syncing was good

#

Unless maybe, only part of the music was replaced, then maybe problem there idk

#

Anyway, GL Aurelius and great work !

#

🫡

languid halo
languid halo
strange prairie