Skip to content

Commit

Permalink
Switch to numpy-minmax for max abs calculations
Browse files Browse the repository at this point in the history
  • Loading branch information
iver56 committed Sep 3, 2024
1 parent 50b1ef0 commit d752231
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 3 deletions.
6 changes: 3 additions & 3 deletions audiomentations/core/utils.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import math
import os
from functools import lru_cache
from pathlib import Path
from typing import List, Union, Tuple

import math
import numpy as np
import numpy_minmax
import numpy_rms
from numpy.typing import NDArray

Expand Down Expand Up @@ -213,7 +214,6 @@ def get_crossfade_mask_pair(


def get_max_abs_amplitude(samples: NDArray):
min_amplitude = np.amin(samples)
max_amplitude = np.amax(samples)
min_amplitude, max_amplitude = numpy_minmax.minmax(samples)
max_abs_amplitude = max(abs(min_amplitude), abs(max_amplitude))
return max_abs_amplitude
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ librosa==0.10.0.post2
matplotlib>=3.0.0,<4
numba==0.57.0
numpy==1.23.0
numpy-minmax>=0.3.0,<1
numpy-rms>=0.4.2,<1
pydub==0.23.1
pyloudnorm==0.1.0
Expand Down
1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ def find_version(*file_paths):
packages=find_packages(exclude=["demo", "tests"]),
install_requires=[
"numpy>=1.21.0,<2",
"numpy-minmax>=0.3.0,<1",
"numpy-rms>=0.4.2,<1",
"librosa>=0.8.0,!=0.10.0,<0.11.0",
"scipy>=1.4,<1.13",
Expand Down

0 comments on commit d752231

Please sign in to comment.