flamo 0.1.7__py3-none-any.whl → 0.1.9__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
flamo/auxiliary/reverb.py CHANGED
@@ -67,7 +67,18 @@ class inverse_map_gamma(torch.nn.Module):
67
67
  return y
68
68
  else:
69
69
  return y**(1/self.delays)
70
-
70
+
71
+ class map_gfdn_gamma(torch.nn.Module):
72
+ def __init__(self, delays: torch.Tensor, n_groups: int, fs: int):
73
+ super().__init__()
74
+ self.delays = delays
75
+ self.n_groups = n_groups
76
+ self.fs = fs
77
+
78
+ def forward(self, x: torch.Tensor) -> torch.Tensor:
79
+ """Map input to grouped RT values."""
80
+ gamma = torch.mul(rt2slope(x, self.fs).unsqueeze(-1), self.delays.unsqueeze(0))
81
+ return gamma
71
82
 
72
83
  class HomogeneousFDN:
73
84
  r"""
@@ -281,7 +292,7 @@ class HomogeneousFDN:
281
292
  rt60, self.config_dict.sample_rate, torch.tensor(self.delays)
282
293
  ).squeeze()
283
294
  return 10 ** (gdB / 20)
284
-
295
+
285
296
 
286
297
  class parallelFDNAccurateGEQ(dsp.parallelAccurateGEQ):
287
298
  r"""
@@ -371,6 +382,69 @@ class parallelFDNAccurateGEQ(dsp.parallelAccurateGEQ):
371
382
  self.input_channels = len(self.delays)
372
383
  self.output_channels = len(self.delays)
373
384
 
385
+ class parallelGFDNAccurateGEQ(parallelFDNAccurateGEQ):
386
+ # TODO
387
+ def __init__(
388
+ self,
389
+ octave_interval: int = 1,
390
+ n_groups: int = 2,
391
+ nfft: int = 2**11,
392
+ fs: int = 48000,
393
+ delays: torch.Tensor = None,
394
+ alias_decay_db: float = 0.0,
395
+ start_freq: float = 31.25,
396
+ end_freq: float = 16000.0,
397
+ device=None
398
+ ):
399
+ assert (delays is not None), "Delays must be provided"
400
+ self.delays = delays
401
+ map = map_gfdn_gamma(delays, n_groups, fs)
402
+ super().__init__(
403
+ octave_interval=octave_interval,
404
+ nfft=nfft,
405
+ delays=delays,
406
+ fs=fs,
407
+ map=map,
408
+ alias_decay_db=alias_decay_db,
409
+ start_freq=start_freq,
410
+ end_freq=end_freq,
411
+ device=device
412
+ )
413
+ self.n_gains = self.size[0]
414
+ self.size = (n_groups * self.size[0], len(delays))
415
+ self.param = param = torch.nn.Parameter(
416
+ torch.empty(self.size, device=self.device), requires_grad=self.requires_grad
417
+ )
418
+
419
+ def get_poly_coeff(self, param):
420
+ r"""
421
+ Computes the polynomial coefficients for the SOS section.
422
+ """
423
+ a = torch.zeros((3, self.size[0]+1, len(self.delays)), device=self.device)
424
+ b = torch.zeros((3, self.size[0]+1, len(self.delays)), device=self.device)
425
+ for n_i in range(len(self.delays)):
426
+ for i_group in range(self.n_gains):
427
+ (
428
+ b[:, i_group * (self.n_gains) : (i_group + 1) * self.n_gains, n_i],
429
+ a[:, i_group * (self.n_gains) : (i_group + 1) * self.n_gains, n_i],
430
+ ) = accurate_geq(
431
+ target_gain=param[
432
+ i_group * self.n_gains : (i_group + 1) * self.n_gains, n_i
433
+ ],
434
+ center_freq=self.center_freq,
435
+ shelving_crossover=self.shelving_crossover,
436
+ fs=self.fs,
437
+ device=self.device,
438
+ )
439
+
440
+ b_aa = torch.einsum('p, pon -> pon', self.alias_envelope_dcy.to(torch.double), b.to(torch.double))
441
+ a_aa = torch.einsum('p, pon -> pon', self.alias_envelope_dcy.to(torch.double), a.to(torch.double))
442
+ B = torch.fft.rfft(b_aa, self.nfft, dim=0)
443
+ A = torch.fft.rfft(a_aa, self.nfft, dim=0)
444
+ H_temp = torch.prod(B, dim=1) / (torch.prod(A, dim=1))
445
+ H = torch.where(torch.abs(torch.prod(A, dim=1)) != 0, H_temp, torch.finfo(H_temp.dtype).eps*torch.ones_like(H_temp))
446
+ H_type = torch.complex128 if param.dtype == torch.float64 else torch.complex64
447
+ return H.to(H_type), B, A
374
448
 
375
449
  class parallelFDNGEQ(dsp.parallelGEQ):
376
450
  r"""
@@ -721,7 +795,6 @@ class parallelFDNPEQ(Filter):
721
795
  self.output_channels = len(self.delays)
722
796
 
723
797
 
724
-
725
798
  class parallelFirstOrderShelving(dsp.parallelFilter):
726
799
 
727
800
  def __init__(
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: flamo
3
- Version: 0.1.7
3
+ Version: 0.1.9
4
4
  Summary: An Open-Source Library for Frequency-Domain Differentiable Audio Processing
5
5
  Project-URL: Homepage, https://github.com/gdalsanto/flamo
6
6
  Project-URL: Issues, https://github.com/gdalsanto/flamo/issues
@@ -5,7 +5,7 @@ flamo/auxiliary/__init__.py,sha256=7lVNh8OxHloZ4KPmp-iTUJnUbi8XbuRzGaQ3Z-NKXio,4
5
5
  flamo/auxiliary/eq.py,sha256=eIWMIq0ggizXLhTdeWWbgBXWUFXCJyoEbkBH7Gzasao,6779
6
6
  flamo/auxiliary/filterbank.py,sha256=02w8dI8HoNDtKpdVhSJkIkd-h-KNXvZtivf3l4_ozzU,9866
7
7
  flamo/auxiliary/minimize.py,sha256=fMTAAAk9yD7Y4luKS4XA1-HTq44xo2opq_dRPRrhlIY,2474
8
- flamo/auxiliary/reverb.py,sha256=9iKSuyuqRiHGGvaj0eizqVpu2V7plsX13OWiB6o1whU,31636
8
+ flamo/auxiliary/reverb.py,sha256=CZgdw2MQtakAjE_hQhhgaTpUfXFPnHyNAmMzhCBPw4c,34715
9
9
  flamo/auxiliary/scattering.py,sha256=qlK8cynrpde56yLlbPuScC0Y1VmsPb0SFXl6Xisv6hA,9420
10
10
  flamo/auxiliary/velvet.py,sha256=B4pYEnhaQPkh02pxqiGdAhLRX2g-eWtHezphi0_h4Qs,4201
11
11
  flamo/auxiliary/config/config.py,sha256=CxXj-8sLq0_m9KyLg1a6NwLoK1UvTz3i0jZOLraq14I,2893
@@ -18,7 +18,7 @@ flamo/optimize/utils.py,sha256=R5-KoZagRho3eykY88pC3UB2mc5SsE4Yv9X-ogskXdA,1610
18
18
  flamo/processor/__init__.py,sha256=paGdxGVZgA2VAs0tBwRd0bobzGxeyK79DS7ZGO8drkI,41
19
19
  flamo/processor/dsp.py,sha256=n92YJPrES-ydwHgXmZ9RkFevIC3n-Wh4X8I1QNZqcV0,126378
20
20
  flamo/processor/system.py,sha256=9XwLtaGEVs9glVOFvyiPnQpsnR_Wjrv6k1i1qCs8D1Q,42516
21
- flamo-0.1.7.dist-info/METADATA,sha256=l7iOHLTNu4f4znfkj4uOFiAIMvFFo0gQKYycvQFpfZ0,7825
22
- flamo-0.1.7.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
23
- flamo-0.1.7.dist-info/licenses/LICENSE,sha256=smMocRH7xdPT5RvFNqSLtbSNzohXJM5G_rX1Qaej6vg,1120
24
- flamo-0.1.7.dist-info/RECORD,,
21
+ flamo-0.1.9.dist-info/METADATA,sha256=JcCP6I_T2SHTbtiIuIIWfHoVOrTcBZ7TLed3MwHZoN4,7825
22
+ flamo-0.1.9.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
23
+ flamo-0.1.9.dist-info/licenses/LICENSE,sha256=smMocRH7xdPT5RvFNqSLtbSNzohXJM5G_rX1Qaej6vg,1120
24
+ flamo-0.1.9.dist-info/RECORD,,
File without changes