快捷方式

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]

根據給定的瞬時頻率和幅度合成波形。

This feature supports the following devices: CPU, CUDA This API supports the following properties: Autograd, TorchScript

注意

輸出波形的相位資訊是透過對給定的瞬時頻率 (frequencies) 進行累加求和得到的。當資料型別精度不足時,這會產生舍入誤差。使用 torch.float64 可以避免這個問題。

下圖展示了在使用 8000 [Hz] 取樣率生成恆定頻率和幅度的正弦波時,torch.float32torch.float64 之間的差異。注意,torch.float32 版本顯示了在 torch.float64 版本中未出現的偽影。

https://download.pytorch.org/torchaudio/doc-assets/oscillator_precision.png
引數:
  • frequencies (Tensor) – 按樣本取樣的振盪器頻率 (Hz)。形狀為 (…, time, N)

  • amplitudes (Tensor) – 按樣本取樣的振盪器幅度。形狀為:(…, time, N)

  • sample_rate (float) – 取樣率

  • reduction (str) – 要執行的歸約操作。有效值為 "sum", "mean""none"。預設值:"sum"

  • dtype (torch.dpython:type or None, optional) – 執行累加求和操作的資料型別。預設值:torch.float64。傳入 None 以停用型別轉換。

返回:

合成的波形。

如果 reduction"none",則形狀為 (…, time, N),否則形狀為 (…, time)

返回型別:

Tensor

使用 oscillator_bank 的教程
Additive Synthesis

加法合成

加法合成
Oscillator and ADSR envelope

振盪器和 ADSR 包絡

振盪器和 ADSR 包絡

文件

訪問 PyTorch 的全面開發者文件

檢視文件

教程

獲取面向初學者和高階開發者的深入教程

檢視教程

資源

查詢開發資源並獲得問題解答

檢視資源