class_docstr: A `scipy.signal.butter`-based generic filter class.
class_docstr_tok: ["A","`","scipy.signal.butter","`","-based","generic","filter","class","."]
code: def randomize_parameters(
      self, samples: NDArray[np.float32], sample_rate: int = None
  ):
      super().randomize_parameters(samples, sample_rate)
      if self.zero_phase:
          random_order = random.randint(
              self.min_rolloff // 12, self.max_rolloff // 12
          )
          self.parameters["rolloff"] = random_order * 12
      else:
          random_order = random.randint(
              self.min_rolloff // 6, self.max_rolloff // 6
          )
          self.parameters["rolloff"] = random_order * 6
  
      if (
          self.filter_type
          in BaseButterworthFilter.ALLOWED_ONE_SIDE_FILTER_TYPES
      ):
          cutoff_mel = np.random.uniform(
              low=convert_frequency_to_mel(self.min_cutoff_freq),
              high=convert_frequency_to_mel(self.max_cutoff_freq),
          )
          self.parameters["cutoff_freq"] = convert_mel_to_frequency(
              cutoff_mel
          )
      elif (
          self.filter_type
          in BaseButterworthFilter.ALLOWED_TWO_SIDE_FILTER_TYPES
      ):
          center_mel = np.random.uniform(
              low=convert_frequency_to_mel(self.min_center_freq),
              high=convert_frequency_to_mel(self.max_center_freq),
          )
          self.parameters["center_freq"] = convert_mel_to_frequency(
              center_mel
          )
  
          bandwidth_fraction = np.random.uniform(
              low=self.min_bandwidth_fraction,
              high=self.max_bandwidth_fraction,
          )
          self.parameters["bandwidth"] = (
              self.parameters["center_freq"] * bandwidth_fraction
          )
  
file_path: audiomentations/audiomentations/augmentations/base_butterword_filter.py
imports: import random
  import numpy
  from numpy.typing import NDArray
  from scipy.signal import butter, sosfilt, sosfiltfilt, sosfilt_zi
  from audiomentations.core.transforms_interface import BaseWaveformTransform
  from audiomentations.core.utils import convert_frequency_to_mel, convert_mel_to_frequency
label_desc: Use image node_id 4 for calling the BaseButterworthFilter obj's underlying member method code with example usage: obj.randomize_parameters(samples, sample_rate) without return types