descriptinc / audiotools

Object-oriented handling of audio data, with GPU-powered augmentations, and more.
https://descriptinc.github.io/audiotools/
MIT License
234 stars 39 forks source link

signal.loudness() fails for signals with channels > 5 #98

Open hugofloresgarcia opened 1 year ago

hugofloresgarcia commented 1 year ago
>>> import audiotools as at
>>> sig = AudioSignal.wave(100, 1.0, 44100, num_channels=6, shape='sine')
>>> sig = at.AudioSignal.wave(100, 1.0, 44100, num_channels=6, shape='sine')
/home/hugo/descript/audiotools/audiotools/core/audio_signal.py:376: UserWarning: To copy construct from a tensor, it is recommended to use sourceTensor.clone().detach() or sourceTensor.clone().detach().requires_grad_(True), rather than torch.tensor(sourceTensor).
  wave_data = torch.tensor(wave_data, dtype=torch.float32)
>>> sig.loudness()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/hugo/descript/audiotools/audiotools/core/loudness.py", line 313, in loudness
    loudness = meter.integrated_loudness(self.audio_data.permute(0, 2, 1))
  File "/home/hugo/descript/audiotools/audiotools/core/loudness.py", line 215, in integrated_loudness
    l = -0.691 + 10.0 * torch.log10((G[None, :nch, None] * z).sum(1, keepdim=True))
RuntimeError: The size of tensor a (5) must match the size of tensor b (6) at non-singleton dimension 1