stk:: sininewave如何计算正弦?

How does stk::SineWave calculate a sine?

本文关键字:计算 sininewave 何计算 stk      更新时间:2023-10-16

我是c++的新手,我正试图从合成工具包中理解sininewave类。描述说:

This class computes and saves a static sine "table" that can be shared by multiple instances. It has an interface similar to the WaveLoop class but inherits from the Generator class. Output values are computed using linear interpolation.

所以我猜它根本不计算sin ?如果在正弦波的高点和低点之间使用线性插值,那不是一个三角波吗?有人能解释一下这个计算是做什么的吗?

如果您看一下实现,您将看到构造函数在1.0 / TABLE_SIZE的步骤中在0.01.0范围内计算sin,其中TABLE_SIZE默认为2048。然后在这些值之间进行线性插值。这与正弦函数非常接近