docstr: Check that we avoid wrap distortion if input is too loud
docstr_tok: ["Check","that","we","avoid","wrap","distortion","if","input","is","too","loud"]
code: def test_too_loud_input(self):
      """Check that we avoid wrap distortion if input is too loud"""
      samples_in, sample_rate = load_sound_file(
          os.path.join(DEMO_DIR, "perfect-alley1.ogg"),
          sample_rate=None,
          mono=True,
      )
      samples_in = samples_in[..., 0:196000]
      samples_in *= 10
      augmenter = Mp3Compression(
          min_bitrate=320, max_bitrate=320, backend="lameenc", p=1.0
      )
  
      samples_out = augmenter(
          samples=samples_in, sample_rate=sample_rate
      )
      samples_out = samples_out[..., 0 : samples_in.shape[-1]]
      assert samples_out.dtype == np.float32
  
      # Apply delay compensation, so we can compare output with input sample by sample
      delay = calculate_delay(
          samples_in,
          samples_out,
          min_lag_in_samples=0,
          max_lag_in_samples=3100,
      )
      snippet_length = 42000
      delay_compensated_samples_out = samples_out[
          ..., delay : delay + snippet_length
      ]
      samples_in = samples_in[..., :snippet_length]
      mse_value = mse(samples_in, delay_compensated_samples_out)
  
      assert mse_value < 0.00001
  
file_path: audiomentations/tests/test_mp3_compression.py
imports: import os
  import matplotlib.pyplot
  import numpy
  import pytest
  from audiomentations import Mp3Compression
  from audiomentations.core.audio_loading_utils import load_sound_file
  from demo.demo import DEMO_DIR
label_desc: Use image node_id 4 for calling the TestMp3Compression obj's underlying member method code with example usage: obj.test_too_loud_input() without return types