# Get Volume db of an instance

**URL:** <https://qa.fmod.com/t/get-volume-db-of-an-instance/18974>\
**Category:** Unity\
**Created:** [July 4, 2022, 9:10pm UTC](https://qa.fmod.com/t/get-volume-db-of-an-instance/18974 "2022-07-04T21:10:58Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Adrian66](https://avatars.discourse-cdn.com/v4/letter/a/13edae/32.png) [@Adrian66](https://qa.fmod.com/u/Adrian66)\
**Post date:** [July 4, 2022, 9:10pm UTC](https://qa.fmod.com/t/get-volume-db-of-an-instance/18974/1 "2022-07-04T21:10:58Z")

</div>

Hello,

I’ve seen a post that asked something similar but I can’t find the way. I simply want to know the volume in db of any track. Through a bus or the instance itself with getVolume it only returns a float that gives either 0 or 1 (I don’t understand why it asks for a float either)

I hope someone can help me,

Thank you very much.

---

<div class="post-metadata">

**Author:** ![Connor\_FMOD](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/connor_fmod/32/3685_2.png) [@Connor\_FMOD](https://qa.fmod.com/u/Connor_FMOD)\
**Post date:** [July 5, 2022, 11:15pm UTC](https://qa.fmod.com/t/get-volume-db-of-an-instance/18974/2 "2022-07-05T23:15:50Z")

</div>

Hi,  
You definitely can get the decibels of an instance, there are a few API calls you’ll have to make to get the right information.

1. Get the [FMOD.ChannelGroup](https://fmod.com/docs/2.02/api/core-api-channel.html#channel_getchannelgroup) from your bus using [Bus.getChannelGroup](https://fmod.com/docs/2.02/api/studio-api-bus.html#studio_bus_getchannelgroup)
2. Get the `ChannelGroup`’s underlying [DSP](https://fmod.com/docs/2.02/api/core-api-dsp.html) object using [ChannelGroup.getDSP](https://fmod.com/docs/2.02/api/core-api-channelcontrol.html#channelcontrol_getdsp)
3. Enable DSP metering using [DSP.setMeteringEnabled](https://fmod.com/docs/2.02/api/core-api-dsp.html#dsp_setmeteringenabled)
4. Repeatedly query [DSP.getMeteringInfo](https://fmod.com/docs/2.02/api/core-api-dsp.html#dsp_getmeteringinfo) to get the RMS level (average volume) or Peak level (maximum transient volume)

When you want the dB levels use this math’s function to return usable dB numbers

```auto
private float lin2dB(float linear) 
{ 
    return Mathf.Clamp(Mathf.Log10(linear) * 20.0f, -80.0f, 0.0f); 
}

```

Inserting `DSP_METERING_INFO.rmslevel[x]` into the function parameter.  
Note retrieving the `ChannelGroup` will all need to happen on a playing `EventInstance` to ensure the `ChannelGroup` exists. [FMOD.Result](https://fmod.com/docs/2.02/api/core-api-common.html#fmod_result) is a useful tool to debug the code and can be used on most FMOD functions.

Hope this helps!

---

<div class="post-metadata">

**Author:** ![Adrian66](https://avatars.discourse-cdn.com/v4/letter/a/13edae/32.png) [@Adrian66](https://qa.fmod.com/u/Adrian66)\
**Post date:** [July 7, 2022, 4:51pm UTC](https://qa.fmod.com/t/get-volume-db-of-an-instance/18974/3 "2022-07-07T16:51:23Z")

</div>

Thanks a lot! There are no words to thank you for this!! :))

If it’s not too much to ask, two doubts have arisen.

1 - When I do getDPS it asks me for an int to tell it which channel to get. What exactly does that number refer to? To the tracks that are within that channel? And is it just a list?

2 - Then when I get the value of rmslevel, it’s a list of floats. Taking the first value of that list works, but what do the 32 numbers in that list refer to? Why with the first number I can already extract the volume?

Thank you very much again, it’s perfect for what I needed!!!

---

<div class="post-metadata">

**Author:** ![Connor\_FMOD](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/connor_fmod/32/3685_2.png) [@Connor\_FMOD](https://qa.fmod.com/u/Connor_FMOD)\
**Post date:** [July 8, 2022, 12:43am UTC](https://qa.fmod.com/t/get-volume-db-of-an-instance/18974/4 "2022-07-08T00:43:49Z")

</div>

Hi,

Really happy to hear that helped!

1 - The “index” will decide where FMOD will sample the sound from within the buffer. Recommended that you use [FMOD\_CHENNELCONTROL\_DPS\_INDEX](https://fmod.com/docs/2.02/api/core-api-channelcontrol.html#fmod_channelcontrol_dsp_index) to make sure you use a valid `int`.

2 - It is a list of output channels coming from FMOD, with a maximum of 32 explained under [Plugin API Reference DSP](https://fmod.com/docs/2.02/api/plugin-api-dsp.html#fmod_dsp_metering_info). FMOD’s default output configuration is Stero outputting to channels 1 and 2. That is why only the first two indexes of `meteringInfo.rmslevel[x]` have values. If you explicitly tell FMOD to change its output configuration it will populate another index in the array correlating to the new configuration.

Hope this explains things!
