Page 1 of 1

Add API for mods to change volume/radius of sound effects

Posted: Wed Sep 06, 2017 3:03 pm
by Sachertorte
TL;DR
Add API for mods to change the volume and radius of sound effects.

What?
The volume of sound effects can currently be changed manually by the user by replacing game files with louder versions of those game files. Mods can also replace sound files.
What mods cannot do is adjust the volume of those sounds in-game, or adjust the radius from which they can be heard.
Why?
Sounds can be heard from different distances - for example, inserters can be heard from a few tiles away, whereas belts can only be heard if you're very close to them - after all, you wouldn't want your eardrums pierced every time you crossed your main bus.

However, I'm not happy with the distribution of sound volumes and sound radii in-game. Take trains for example. When riding a train, I struggle to hear the thrum of the engine, and yet the clack-clack of traversing the track is very loud. I would like to increase the volume of the train engine, and also increase the radius from which the train can be heard - I want to be able to hear these massive engines even when they're off screen!

Currently, mods offer no way to do this, hence my suggestion.

Re: Add API for mods to change volume/radius of sound effects

Posted: Wed Sep 06, 2017 4:54 pm
by Rseding91
All of that is defined through the prototypes for a given sound :)

The fast transport belt for example has this defined:

Code: Select all

    working_sound =
    {
      sound =
      {
        filename = "__base__/sound/fast-transport-belt.ogg",
        volume = 0.4
      },
      max_sounds_per_type = 3
    },
Additionally the working_sound property supports the following settings:
  • float: apparent_volume
  • uint8: max_sounds_per_type
  • bool: match_progress_to_activity
  • bool: match_volume_to_activity
  • bool: match_speed_to_activity
  • double: audible_distance_modifier

Re: Add API for mods to change volume/radius of sound effects

Posted: Wed Sep 06, 2017 6:14 pm
by Bilka
Rseding91 wrote: Additionally the working_sound property supports the following settings:
  • float: apparent_volume
  • uint8: max_sounds_per_type
  • bool: match_progress_to_activity
  • bool: match_volume_to_activity
  • bool: match_speed_to_activity
  • double: audible_distance_modifier
What about probability and idle_sound? And are those properties only possible for the working_sound, or also for other sounds, such as vehicle_impact_sound?

To me it seems like there is a "generic" sound that can be defined, like his:

Code: Select all

vehicle_impact_sound =  { filename = "__base__/sound/car-metal-impact.ogg", volume = 0.65 },
--or
sound = { filename = "__base__/sound/substation.ogg" },
--or
sound =
{
 filename = "__base__/sound/accumulator-working.ogg",
  volume = 1
},
idle_sound = {
  filename = "__base__/sound/accumulator-idle.ogg",
  volume = 0.4
},
Working_sound uses that "generic" sound, and other properties can only be defined there, right? Or can I use filename directly inside working_sound?

And what volume does this use?

Code: Select all

   
 working_sound =
    {
      sound =
      {
        filename = "__base__/sound/electric-furnace.ogg",
        volume = 0.7
      },
      apparent_volume = 1.5
    },

Re: Add API for mods to change volume/radius of sound effects

Posted: Thu May 14, 2020 7:04 pm
by Sachertorte
Apologies for taking so long to reply, I was trying to work out how to exit Vim.

I've just created a mod that adjusts the audible_distance_modifier for locomotives. I set it to 8 just to see what that sounded like, but upon booting the game (0.18.24), I was informed that the audible_distance_modifier can only be used to reduce distances and therefore cannot be set to a value above 1.

That's particularly disappointing for this application, as the end goal of my mod is to increase that distance and that's pretty much it. Just increasing the volume of the working_sound is not good - I don't want to deafen myself, and the sound still appears and fades away almost instantly as a train goes past.

I found a simple sound-based mod (Uranium Geiger by ikornaselur) that plays a sound even at distances by playing the sound from the player. I'd really like to avoid this, if possible - I want the train to feel like it's making the noise.

Weirdly enough, Googling "factorio audible_distance_modifier" leads only to API documentation, FFF341 where Val was playing with pipe attenuation, and this very thread. So it doesn't look like this has been a problem for anyone else. It's entirely possible that the scope of this property has changed since I made this thread three years ago, but is there some way for me to overcome it? If not, may I ask why this hard restriction is in place?

Re: Add API for mods to change volume/radius of sound effects

Posted: Thu May 14, 2020 8:13 pm
by Rseding91
It works that way because the way sounds work in the game: every frame the game looks around your player for sounds to play. Then using the properties I mentioned before it plays the sound(s) it finds.

Since the area it searches is limited, you can't say "search outside that area" by increasing the range modifier > 1. Every tile increase in that area it has to search is quadratic in the total area it has to search.

Re: Add API for mods to change volume/radius of sound effects

Posted: Thu May 14, 2020 8:39 pm
by Sachertorte
That makes sense. Thank you for your response.

I suppose the next best option would be to attempt to duplicate the train's sound. I have a few ideas but they're beyond the scope of a feature request (which it looks like I originally posted in the wrong subforum anyway).

Lots of noise

Posted: Sun May 17, 2020 3:52 am
by Phil
I just recently read the Friday Facts where you said that the game had a 15 active sound cap and when you raised it you found it very noisy. I think you should put an option in the settings to allow the game to play every sound within range of your character, or just let you set your own limit if you want the sounds but your computer can't run all of them well, because there's a fascination with how an industrial environment, even light industry, is a cacophony of sounds that dull the senses or become so familiar that you can start to recognize regular sounds within that cacophony. Needless to say, it'd be a fun effect to be able to turn on at will if you want to get a real grasp of the scale of the moving parts around tightly packed factories since the game generally doesn't give players the experience of that sort of audible bombardment you'd get in an actual industrial environment. Just something fun to throw at the senses.

Re: Add API for mods to change volume/radius of sound effects

Posted: Sun May 17, 2020 7:07 am
by ssilk
moved to nearly similar topic - ssilk

See also answer from rseding: there are restrictions.

Re: Lots of noise

Posted: Sun May 17, 2020 8:52 am
by Klonan
Phil wrote: Sun May 17, 2020 3:52 am I just recently read the Friday Facts where you said that the game had a 15 active sound cap and when you raised it you found it very noisy. I think you should put an option in the settings to allow the game to play every sound within range of your character, or just let you set your own limit if you want the sounds but your computer can't run all of them well, because there's a fascination with how an industrial environment, even light industry, is a cacophony of sounds that dull the senses or become so familiar that you can start to recognize regular sounds within that cacophony. Needless to say, it'd be a fun effect to be able to turn on at will if you want to get a real grasp of the scale of the moving parts around tightly packed factories since the game generally doesn't give players the experience of that sort of audible bombardment you'd get in an actual industrial environment. Just something fun to throw at the senses.
Its already an option, you can change it in the config files

Re: Add API for mods to change volume/radius of sound effects

Posted: Sun May 17, 2020 1:07 pm
by ssilk
Nice. So I think we can call this implemented, because I think this is no option, that only should be available to more experienced users.