Author Topic: Normalize sound while channel is playing  (Read 711 times)

MoHamMad

  • Posts: 7
Normalize sound while channel is playing
« on: 6 Nov '23 - 07:45 »
Hi. I am using bass with c#. I want to normalize the volume of currently playing music in the bass channel.
Some parts of my song are low and some parts are too loud. I am looking for a way to play all parts of my file at the same volume. I just found loudmax VST but it was only for windows. Is there a way that can be used in both Windows and Linux?
I know that many things have been opened in this form with the same title, but I could not find my answer in them.

Ian @ un4seen

  • Administrator
  • Posts: 26178
Re: Normalize sound while channel is playing
« Reply #1 on: 6 Nov '23 - 14:54 »
You could first try the BASS_FX add-on's BASS_FX_BFX_DAMP effect via BASS_ChannelSetFX. That will normalize based on the peak level. If you would prefer to normalize based on loudness instead, then there is also a new BASSLOUD add-on that you could use for that:

   www.un4seen.com/forum/?topic=20129.0

It doesn't include a ready-made BASS_ChannelSetFX option (like BASS_FX_BFX_DAMP), but you could use a BASS_FX_VOLUME effect and have the loudness measurements control that.

MoHamMad

  • Posts: 7
Re: Normalize sound while channel is playing
« Reply #2 on: 7 Nov '23 - 03:40 »
Thanks for the answer. Can you please tell me how to get the peak while playing the channel? The examples I have seen so far all use another stream which is the only decoder. While I want to do this at the same time as playing the file. Changing the file itself is not important for me, only the sound coming out of the bass is important for me.

Ian @ un4seen

  • Administrator
  • Posts: 26178
Re: Normalize sound while channel is playing
« Reply #3 on: 7 Nov '23 - 12:08 »
You can get the current peak level during playback from BASS_ChannelGetLevel(Ex). Please see their documentation for details.

MoHamMad

  • Posts: 7
Re: Normalize sound while channel is playing
« Reply #4 on: 7 Nov '23 - 13:43 »
What is the difference between getting peak by ChannelGetLevel or bassloud add on as BASSLoudnessGetLevel(loudHandle, BASS_LOUDNESS_CURRENT, *v)?

Ian @ un4seen

  • Administrator
  • Posts: 26178
Re: Normalize sound while channel is playing
« Reply #5 on: 7 Nov '23 - 16:05 »
BASS_ChannelGetLevel(Ex) gives a peak sample level, while BASS_Loudness_GetLevel with BASS_LOUDNESS_CURRENT gives a loudness level. You can read about the difference between peak and loudness normalization here:

   https://www.wikipedia.org/wiki/Audio_normalization

If you would like to know the gory details of loudness measurement, that's here:

   https://www.itu.int/dms_pubrec/itu-r/rec/bs/R-REC-BS.1770-4-201510-I!!PDF-E.pdf

MoHamMad

  • Posts: 7
Re: Normalize sound while channel is playing
« Reply #6 on: 7 Nov '23 - 17:52 »
Thanks for your good answers and sorry for my more questions.
I got the peak level by channelGetLevel and get the correct peak from left and right numbers. Now what I have to do? What effect is better to I use for it? Immagin that I want to normalize the playing file volume to -2db, and I want to all parse of my file to be play at this volume. I'm getting channel's level every 20ms, the peak is between 0 to 32767 (I think), my good parse of file is around 8000-12000 peak, but bad places are at 1000-4000. What effect should I use with what values? I saw someone was using DSPGain, but here We have two properties from 0 to 1024 and 0 to 100, That I dont know how to convert 8000 or 1000 to their values :).
Sorry, I'm a little bad in these subjects.