#sound.lua & sound API for Steamodded
132 messages · Page 1 of 1 (latest)
Should have done this sooner
@west badger I didn't quite understand what you wanted to be like the base game for the music ?
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
Hmmmmm I see
I could maybe play the music on repeat and only activate it's sound when it's called
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
Yeah but in that case all sound are the same length no ?
yea, if that's a requirement for that system to work then i don't mind
In the base game, are all the music the same length ?
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
yea they are the same length so that shouldn't be an issue
Should be doable, I'll see what I can do to make it simple
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
That's what I'll do yes 😉
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
awesome thank you!! i'll check it out when i get home
Also send me your mod when you finish it !
I'm hyped
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?
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
alright sounds good
yeah I recommend you to target a modloader unless you specifically need the power
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"
Ill see for the volume slider, shouldn't be too hard
Hmm... I'll see what I can do for ya
Music volume problem is done
There still seems to be flame problems...
Should be good now
Only thing left is smooth transition between music
like a fadeout
And some bugfixes and code optimization
thank you so much
Thank you too for using what I do
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
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 ?
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
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
i'll try that
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
that would be awesome
Btw, is the API easy to use or not ?
I tried my best to make it as easy to use as possible
I'm gonna make stop_previous_instance false by default
And l'm working on the temporary stop sounds and replace sounds
@west badger temporary sounds done
nice nice
Created a pull request on main Steamodded branch
@west badger it has been merged into main branch ^^
Soon there'll be a release imo
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^^
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
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.
it's possible
They have several track
They're called musicX and goes from 1 to 5
Thanks! Looking into it now. Converting those 5 to their minor keys for a spookier feel. I'm dubbing it: "Balatrick-or-Treat" 
Fyi
Will need to update some instructions and change things for Steamodded 1.0
But the core of the mod wont change
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
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
Wdym same sort of format ?
Like only a table ?
They could always directly do what they want since all vars are stored in a SMODS.TABLE var
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
@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
https://github.com/Steamopollys/Steamodded/blob/main/core/game_object.lua#L257
https://github.com/Steamopollys/Steamodded/blob/main/lovely/sound.toml
Seems good to me, it's nice and clean
Created a pull request for the used G.settings.Sound
that was inversed in the logic
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?
it's included in steamodded
yes
cool
The files don't even work rn, it's more for issues and how to create things in a more detailed way
Just use Steamodded API directly
Happy to see SMODS.Sound given a section in the Steamodded API :)
Yeah, I spent some time creating it and doing it well
even if Aurelius did a great job porting it and adding some features
ty, getting it working with music and everything was a good bit more work since I had to actually use the sound manager
Did my way not work ? or was incompatible to how the game handles the sound and lua patching ?
I remember trying things with the sound manager and just banging my head against a wall
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
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)
basically to modulate and sync the music, I needed to have access to the vanilla sound objects
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 !
🫡
yeah maybe it could have been done without the thread, but imo that would be more headaches so I just went ahead and switched to patching the thread
ty
Yeah I didn't want to tamper it since I didn't want my mod to have problem with another one or Steamodded