torchaudio.prototype.functional.oscillator_bank¶
- torchaudio.prototype.functional.oscillator_bank(frequencies: Tensor, amplitudes: Tensor, sample_rate: float, reduction: str = 'sum', dtype: Optional[dtype] = torch.float64) Tensor [source]¶
从给定的瞬时频率和幅度合成波形。
注意
输出波形的相位信息是通过对给定的瞬时频率 (
frequencies
) 进行累积求和得到的。当数据类型精度不足时,这会产生舍入误差。使用torch.float64
可以解决这个问题。下图显示了当以 8000 [Hz] 采样率生成恒定频率和幅度的正弦波时,torch.float32 和 torch.float64 之间的差异。请注意,torch.float32 版本显示了 torch.float64 版本中看不到的伪影。
- 参数:
- 返回值:
生成的波形。
如果
reduction
为"none"
,则形状为 (…, time, N),否则形状为 (…, time)。- 返回类型:
Tensor
- 使用
oscillator_bank
的教程