快捷方式

torchaudio.prototype.functional.extend_pitch

torchaudio.prototype.functional.extend_pitch(base: Tensor, pattern: Union[int, List[float], Tensor])[源代码]

将给定的时间序列值与其乘数进行扩展。

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

给定一系列基频(音高),此函数会追加其泛音(harmonic overtones)或非谐波分音(inharmonic partials)。

参数
  • base (torch.Tensor) – 基时间序列,例如基频(Hz)。形状:(…, 时间, 1)

  • pattern (int, python:floats 列表torch.Tensor) –

    如果为 int,则表示操作后的音高序列数量。pattern - 1 个音调被添加,从而生成的 Tensor 包含给定序列的最多 pattern 泛音。

    如果为 float 列表或 torch.Tensor,它必须是一维的,表示基频的自定义乘数。

返回

振荡器频率(Hz)。形状:(…, 时间, num_tones)

返回类型

Tensor

示例
>>> # fundamental frequency
>>> f0 = torch.linspace(1, 5, 5).unsqueeze(-1)
>>> f0
tensor([[1.],
        [2.],
        [3.],
        [4.],
        [5.]])
>>> # Add harmonic overtones, up to 3rd.
>>> f = extend_pitch(f0, 3)
>>> f.shape
torch.Size([5, 3])
>>> f
tensor([[ 1.,  2.,  3.],
        [ 2.,  4.,  6.],
        [ 3.,  6.,  9.],
        [ 4.,  8., 12.],
        [ 5., 10., 15.]])
>>> # Add custom (inharmonic) partials.
>>> f = extend_pitch(f0, torch.tensor([1, 2.1, 3.3, 4.5]))
>>> f.shape
torch.Size([5, 4])
>>> f
tensor([[ 1.0000,  2.1000,  3.3000,  4.5000],
        [ 2.0000,  4.2000,  6.6000,  9.0000],
        [ 3.0000,  6.3000,  9.9000, 13.5000],
        [ 4.0000,  8.4000, 13.2000, 18.0000],
        [ 5.0000, 10.5000, 16.5000, 22.5000]])
使用 extend_pitch 的教程
Additive Synthesis

加法合成

加法合成

文档

获取 PyTorch 的完整开发者文档

查看文档

教程

获取面向初学者和高级开发者的深度教程

查看教程

资源

查找开发资源并获得问题解答

查看资源