1

Suppose you have the following float32 audio representation loaded from any wav file using the librosa package:

import librosa

wav_x_path = "any_wav_filepath.wav"
wav_source, _ = librosa.load(wav_x_path, sr=16000)

If you then will try to play this audio using, for example, a jupyter notebook, the following snippets sounds in the same way:

from IPython.display import display, Audio

display(Audio(wav_source * 2, rate=sampling_rate))
display(Audio(wav_source * 200, rate=sampling_rate))
display(Audio(wav_source / 200, rate=sampling_rate))

Why does it happen that changing audio aptitude (if I correctly understand what wav_source contains audio amplitude), doesn't affect how the audio sounds?

Dmitry Chebakov
  • 348
  • 3
  • 11

1 Answers1

1

As per the documentation of IPython.display.Audio there is an argument normalize which decides whether to apply automatic scaling of the volume. The default is normalize=True, which is why different amplitude scales is played back at the same level.

Use display(Audio(wav_source * 2, rate=sampling_rate, normalize=False)) and you should be able to hear the difference.

Jon Nordby
  • 5,494
  • 1
  • 21
  • 50
  • Is this how all modern audio players like VLC or QuickTime works? So they are just basically doing normalisation before playing? – Dmitry Chebakov Jun 12 '22 at 13:53
  • 1
    No, most desktop audio players will not normalize the audio by default. But some of the music services do, like Spotify and Apple Music. https://artists.spotify.com/help/article/loudness-normalization Music is generally expected to be mastered to a specific loudness level though. – Jon Nordby Jun 12 '22 at 21:31