utils¶
Utility functions for the matching submodule.
remap
¶
remap(
x: float,
o_min: float,
o_max: float,
n_min: float,
n_max: float,
) -> float
Linearly map one range to another. For example, if the original range is 0 to 10 and the new range is 0 to 5,
and x value of 5 will result in an output of 2.5.
This function can handle negative values and inverted ranges. If the input is -10 to 0 and the new range is 5 to 10, the output will still be valid.
| PARAMETER | DESCRIPTION |
|---|---|
|
The value inside the old range to be remapped.
TYPE:
|
|
Minimum value of the old range.
TYPE:
|
|
Maximum value of the old range.
TYPE:
|
|
Minimum value of the new range.
TYPE:
|
|
Maximum value of the new range.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
result
|
TYPE:
|
Source code in src/downmixer/matching/utils.py
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 | |
ease
¶
ease(x: float, falloff: float = 4.8) -> float
Returns \(y\) according to the equation \(y=1-(f*x^2)\), where \(f\) is an arbitrary "falloff" value.
| PARAMETER | DESCRIPTION |
|---|---|
|
The value to be placed in the curve.
TYPE:
|
|
An arbitrary value that determines how sharply the value for \(y\) decreases as \(x\) increases. Default is 4.8, picked simply because it gave fairly good results.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
y
|
The value placed in the curve.
TYPE:
|
Source code in src/downmixer/matching/utils.py
46 47 48 49 50 51 52 53 54 55 56 57 | |