sound_paths bug?

This forum is for the Lua scriptable clone of DM/CSB called Dungeon Strikes Back by Sophia. Use DSB to build your own highly customised games.

Moderator: Sophia

Forum rules
Please read the Forum rules and policies before posting.
Post Reply
User avatar
meadwarrior
Journeyman
Posts: 91
Joined: Sat Dec 01, 2018 1:02 am

sound_paths bug?

Post by meadwarrior »

Hello!

It may not be a bug but instead me missing something.

When I make a trigger to start a music theme, it only works when the music is in the main folder (like before 0.7.0).
Creating a sound.cfg and describing sound_paths doesn't help, the music is not recognized.

:?: How would I go about implementing music that's in a different folder?

Thanks!
User avatar
Gambit37
Should eat more pies
Posts: 13715
Joined: Wed May 31, 2000 1:57 pm
Location: Location, Location
Contact:

Re: sound_paths bug?

Post by Gambit37 »

To access music from a subfolder, edit the music exvar in your ambient sound object so that it points to the folder, eg:

Code: Select all

music = "folder/filename_without_extension"
no_loop = true
That works for me, do you get a different result?

The sound.cfg file is a new feature that only works for the existing sound effects. You'd only use that if you want to override those built-in sounds with filenames in a different subfolder, eg, in sound.cfg you'd need something like this:

Code: Select all

sound_paths = {
  BUZZ = "sfx_remaster/dungeon_teleport.ogg",
  CLICK = "sfx_remaster/dungeon_click.ogg",
  DINK = "sfx_remaster/dungeon_dink.ogg",
  [..etc..]
}
I've not yet tested that new feature, but in theory that's how it should work. Note that DSB built in sounds have some funny names, but you need to refer to them exactly. You can get the existing names from base/graphics.lua near the bottom of the file. You just need the bit after the "snd." definition.
User avatar
meadwarrior
Journeyman
Posts: 91
Joined: Sat Dec 01, 2018 1:02 am

Re: sound_paths bug?

Post by meadwarrior »

I see, so it's for sounds only.
Thanks, Gambit! Pointing the exvar to the folder worked perfectly.

As a bonus, it seems to be loading the music much faster than from the main folder. At least there's no 'slowdown' when the music starts :)
User avatar
Sophia
Concise and Honest
Posts: 4240
Joined: Thu Sep 12, 2002 9:50 pm
Location: Nowhere in particular
Contact:

Re: sound_paths bug?

Post by Sophia »

Actually, no, sound_paths works for dsb_music as well. If it isn't working for you, then you've done something wrong.

Post your relevant code and I'll try to help.
User avatar
meadwarrior
Journeyman
Posts: 91
Joined: Sat Dec 01, 2018 1:02 am

Re: sound_paths bug?

Post by meadwarrior »

Okay, this is awkward. After trying again, it worked as advertised :oops:
Sorry for the false alarm.

Is there an advantage to doing it this away vs the other one?
I get a slowdown when the music starts with both methods (except for one trigger that magically has none :D)

Thanks!
User avatar
Sophia
Concise and Honest
Posts: 4240
Joined: Thu Sep 12, 2002 9:50 pm
Location: Nowhere in particular
Contact:

Re: sound_paths bug?

Post by Sophia »

The main advantage is you have all of your file paths in one place so if you need to move things around you don't have to edit a bunch of code. DSB will also load (very slightly) faster, but the difference isn't significant.

The slowdown is caused more by FMOD (the sound library used by DSB) and your filesystem than anything DSB is doing, and unfortunately there isn't much I can do about it.
User avatar
meadwarrior
Journeyman
Posts: 91
Joined: Sat Dec 01, 2018 1:02 am

Re: sound_paths bug?

Post by meadwarrior »

I see, thanks!
Don't worry about the slowdown, it doesn't really bother that much ;)
User avatar
Gambit37
Should eat more pies
Posts: 13715
Joined: Wed May 31, 2000 1:57 pm
Location: Location, Location
Contact:

Re: sound_paths bug?

Post by Gambit37 »

Sorry for any misinformation on my part! :oops:

I had thought the .cfg files were only for re-pathing existing DSB named assets? Is that not the case? I did try defining new named graphics in the graphics.cfg, but that didn't work, so I'm still using my graphics.lua for new stuff. What is the right way to do this? I'm getting a bit confused to be honest!
User avatar
Sophia
Concise and Honest
Posts: 4240
Joined: Thu Sep 12, 2002 9:50 pm
Location: Nowhere in particular
Contact:

Re: sound_paths bug?

Post by Sophia »

All graphics.cfg does is specify a path to use when trying to load a certain bitmap. It doesn't actually try to load anything. That is, you still need a call to dsb_get_bitmap to actually load an image, but you can just use a short symbolic name (like in base/graphics.lua) and it will pull the long path out of graphics.cfg.

There are other methods for specifying a path, such as putting it directly in the dsb_get_bitmap call, but they are less flexible.
User avatar
meadwarrior
Journeyman
Posts: 91
Joined: Sat Dec 01, 2018 1:02 am

Re: sound_paths bug?

Post by meadwarrior »

No worries, I appreciate your help either way, Gambit :)

What I do is to specify a pathname in the graphics.cfg

Code: Select all

graphics_paths = {
DEADSKULLTIST_FRONT1 = "gfx/floor_flats/deco/deadskulltist_front1.png",
}
and then I do the thing in the graphics.lua

Code: Select all

gfx.deadskulltist_front1 = dsb_get_bitmap("DEADSKULLTIST_FRONT1")
which I can then use for new objects.

The gfx folder is inside the main folder.

--EDIT: Oops, Sophia beat me there ;)
User avatar
Gambit37
Should eat more pies
Posts: 13715
Joined: Wed May 31, 2000 1:57 pm
Location: Location, Location
Contact:

Re: sound_paths bug?

Post by Gambit37 »

Doh! Right. OK, thanks both! :)

Sophia, is there any difference in startup loading speed between adding a short named file in the CFG and then loading it in graphics.lua, versus just loading it in graphics.lua without a short name?
User avatar
Sophia
Concise and Honest
Posts: 4240
Joined: Thu Sep 12, 2002 9:50 pm
Location: Nowhere in particular
Contact:

Re: sound_paths bug?

Post by Sophia »

A file should always have a short name, but something like this is also perfectly valid:

Code: Select all

gfx.some_image = dsb_get_bitmap("SOMEIMAGE", "gfx/someimage.png")
Both doing it this way and adding a "SOMEIMAGE" entry in graphics.cfg are pretty much the same speed, and both methods are ever so slightly faster than just having a short name by itself because DSB doesn't have to try to load every single format it supports. Without a file extension DSB just has to try each file extension it supports in turn.
User avatar
Gambit37
Should eat more pies
Posts: 13715
Joined: Wed May 31, 2000 1:57 pm
Location: Location, Location
Contact:

Re: sound_paths bug?

Post by Gambit37 »

Sophia wrote: Wed Dec 19, 2018 2:05 amA file should always have a short name
Hmmm. I've never bothered with short names for my new graphics, I don't see the point of them. As I'm only ever referring to things by their "gfx.name" in my code, having a short name makes no difference. So I've been doing it like this for years which seems to work fine:

Code: Select all

gfx.ui_background_only = dsb_get_bitmap(path .. "ui_background_only")
However, given your explanation, perhaps I might get a loading speed increase by going back and using the short name and filename.extension format instead! My startup *is* pretty slow now and I'm still only 20% through replacing all these graphics!
Post Reply