Spaces:
Running on Zero
Running on Zero
Commit ·
ffdea96
1
Parent(s): d03f31e
add utility functions
Browse files- plot_utils.py → utils.py +32 -1
plot_utils.py → utils.py
RENAMED
|
@@ -1,7 +1,8 @@
|
|
| 1 |
-
import numpy as np
|
| 2 |
import torch
|
|
|
|
| 3 |
from scipy.signal import freqz
|
| 4 |
from typing import Iterable
|
|
|
|
| 5 |
|
| 6 |
from modules import fx
|
| 7 |
from modules.functional import (
|
|
@@ -39,3 +40,33 @@ def get_log_mags_from_eq(eq: Iterable, worN=1024, sr=44100):
|
|
| 39 |
|
| 40 |
log_mags = list(map(f, eq))
|
| 41 |
return log_mags[0][0], [x for _, x in log_mags]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
import torch
|
| 2 |
+
import numpy as np
|
| 3 |
from scipy.signal import freqz
|
| 4 |
from typing import Iterable
|
| 5 |
+
from functools import reduce
|
| 6 |
|
| 7 |
from modules import fx
|
| 8 |
from modules.functional import (
|
|
|
|
| 40 |
|
| 41 |
log_mags = list(map(f, eq))
|
| 42 |
return log_mags[0][0], [x for _, x in log_mags]
|
| 43 |
+
|
| 44 |
+
|
| 45 |
+
jsonparse2hydra = lambda d: (
|
| 46 |
+
(
|
| 47 |
+
{"_target_": d["class_path"]}
|
| 48 |
+
| (
|
| 49 |
+
{k: jsonparse2hydra(v) for k, v in d["init_args"].items()}
|
| 50 |
+
if "init_args" in d
|
| 51 |
+
else {}
|
| 52 |
+
)
|
| 53 |
+
if "class_path" in d
|
| 54 |
+
else {k: jsonparse2hydra(v) for k, v in d.items()}
|
| 55 |
+
)
|
| 56 |
+
if isinstance(d, dict)
|
| 57 |
+
else (list(map(jsonparse2hydra, d)) if isinstance(d, list) else d)
|
| 58 |
+
)
|
| 59 |
+
|
| 60 |
+
remove_window_fn = lambda d: (
|
| 61 |
+
{k: remove_window_fn(v) for k, v in d.items() if k != "window_fn"}
|
| 62 |
+
if isinstance(d, dict)
|
| 63 |
+
else (list(map(remove_window_fn, d)) if isinstance(d, list) else d)
|
| 64 |
+
)
|
| 65 |
+
|
| 66 |
+
|
| 67 |
+
def chain_functions(*functions):
|
| 68 |
+
return lambda *initial_args: reduce(
|
| 69 |
+
lambda xs, f: f(*xs) if isinstance(xs, tuple) else f(xs),
|
| 70 |
+
functions,
|
| 71 |
+
initial_args,
|
| 72 |
+
)
|