#Boombox volume goes up to 11

1 messages · Page 1 of 1 (latest)

tired forge
#

Make the volume on the Boombox go up past 10 to 11! Boombox is even louder, maybe twice as loud as at 10 and can be heard even further away.

tired forge
#

So I'm trying to work out where the method that controls the volume is. I think its part of VolumeAndInterferenceController

#
    {
        if (!interferenceAudioSource.isPlaying)
        {
            musicAudioSource.volume = volume;
            return;
        }
        float num = volume * signalStrength;
        float num2 = Mathf.Clamp01(volume * (1f - signalStrength / 0.7f) * interferenceSoundVolumeMultiplier);
        if (num2 < 0.01f)
        {
            num2 = 0f;
        }
        musicAudioSource.volume = num;
        interferenceAudioSource.volume = num2;
    }```
#

I think it takes the original audio and if the volume is set below whatever is defined as 10 it reduces the volume

jolly plume
#

Internally, the control is also just 0 to 1. 10 is what's shown because showing 0.7 as volume instead of 7 makes no sense.

#

You cannot go above 1, you'd need to alter the original source to go any higher.

tired forge
#

It could apply a limiter effect above 1 to cause that. I wonder if unity has an audio limiter built in.

jolly plume
#

You'd probably want to change the gains in the audio mixer the boombox uses, it might be able to boost the volume.

tired forge
#

I don't think 0.7 is related to the volume I think that's specifically for the radio mode where it simulates signal loss if the antenna isn't up or you're in a tunnel etc.

jolly plume
#

It's literally there.

musicAudioSource.volume = volume;

tired forge
#

it returns after if (!interferenceAudioSource.isPlaying) which I'm assuming is when a tape is used

jolly plume
#

The volume is also clamped to [0..1] by the method that takes the control's values.

#

Interference is the static you hear in tunnels.

#

So the audio volume is decreased if the interference audio is playing.

tired forge
#

Yeah I think tackling with the cassettes would be best first. Or it just needs to apply a limiter effect to both the radio and tape audio that's probably simpler. And then the static effect will still work.

#

Something like this maybe

jolly plume
#

But a limiter would just lower the volume?

tired forge
#

No limiters increase volume

jolly plume
#

Isn't your objective to increase it?

tired forge
#

They're not intuitively named

#

I suppose its because it limits the dynamic range. It increases the overall perceived loudness by raising the quietest parts of the audio.

A limiter catches the highest peaks of an audio source and applies “brick wall” compression that prevents them from exceeding the digital clipping point of 0 dBFS – or any other threshold you set. Limiters are often used to increase perceived loudness by raising the quietest parts of an audio signal while preventing the peaks from clipping. Limiting is also the final, and perhaps the most easily recognizable, step in mastering a song, allowing you to turn up the master to commercial loudness without unintentionally clipping.

#

From skimming that unity discussion thread unity has a compressor but the ratios it offers wont work for this application

jolly plume
#

But it seems that it won't go over the highest peaks anyway. Though I guess the perception of the lower parts could help make it feel louder.

tired forge
#

it does make quite a difference

#

I'm also not sure if the source audio peaks at 0dB I'd have to check. It could be the loudest parts can be boosted too. And after that I think applying a distortion effect would be cool.

jolly plume
#

It still all goes through a chain of audio mixers, which control the final volume in relation to eachother.

#

You could increase the dB gain of the one the boombox uses, though I'm not sure what the code to do that would be.

tired forge
#

Digging through the code to see if I can find that. I'm also trying to find where it maps the values 1-10 to actual volume level internally

jolly plume
#

But still, wouldn't most audio already be "limited" when you listen to it?

tired forge
#

I'm not sure it depends what the devs chose to do with the audio afaik

jolly plume
#

That 0-10 is just the display. All controls work in the [0..1] range.

#

Just like throttle notches show 0-11, it's just 0-1 internally.

#

0 to 100%.

tired forge
#

Yeah but it has to map that somewhere to know what 1 and 10 is

#

unless it just truncates the value on the display

jolly plume
#

11 notches, so 0.0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1.0.

tired forge
#

I found it here I think bottomText.text = $"Volume: {volumeX10} - Station: {radioStationIndex + 1} - Signal strength: {(int)Mathf.Clamp(radioSignal * 100f, 0f, 100f)}";

#

volumeX10 is this though private int volumeX10 = 4; 🤔

jolly plume
#

That's the default...

tired forge
#

That's interesting because it has public float spawnVolume = 0.5f; so it appears it spawns at 0.5 🤔

jolly plume
#

Anything that is public and in a MonoBehaviour cannot be trusted, as the editor will override the value.

#

In any case:

tired forge
#

Are you looking at this in the unity editor?

jolly plume
#

You can get the mixer from the audio source, IDK how to change the values.

#

Yes.

tired forge
#

Alright I'll check it out in there later thanks. I've been looking at it with ilspy

jolly plume
#

I'm really not sure if it's possible to change this stuff.

kind dragon
#

@lilac pilot there's a few but this is the one where people talk about the files and stuff, I can't understand code but it should help you a bit

lilac pilot
#

ay thanks!

pseudo pelican
#

Making audio louder is the most difficult thing to do. Especially in VR where everything is even quieter

#

I just had to increase dB on all my audio files with some clipping

#

Don't understand the reason to restrict volume beyond 1.0, if it just multiples the audio wave. Sure, it will cause clipping and audio quality loss, but it's not that bad

jolly plume
#

Just a 1dB increase adds too much static if the volume is already normalised.

pseudo pelican
#

Also AudioMixers are hard to change from code for no reason. They don't have a proper class to set values on, can't be added at runtime, you have to have the editor open to do anything with it

jolly plume
#

Mixers are usually a thing you set in the project and should never change in realtime TBH.

pseudo pelican
jolly plume
#

You can however multiply all master volumes of locomotives to a lower value, but that's a terrible idea.

pseudo pelican
#

Some sounds turn out louder then others even at the same normalized level, and yeah locomotive engine is one of them

pseudo pelican
#

Even without volume increases

#

I missed how old this thread was 😅

lilac pilot
pseudo pelican