快捷鍵

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[原始碼]

從給定的瞬時頻率和振幅合成波形。

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.dtypeNone, 可選) – 執行累積總和運算的資料類型。預設值:torch.float64。傳遞 None 以停用轉換。

返回:

產生的波形。

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

返回類型:

Tensor

使用 oscillator_bank 的教學
Additive Synthesis

加法合成

加法合成
Oscillator and ADSR envelope

振盪器和 ADSR 包絡

振盪器和 ADSR 包絡

文件

存取 PyTorch 的完整開發者文件

查看文件

教學

取得初學者和進階開發者的深入教學

查看教學

資源

尋找開發資源並獲得解答

查看資源