I'm new to C++ and I'm trying to understand the SineWave class from the Synthesis Toolkit. The description says:

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.

So I guess it doesn't calculate a sine at all? If it's using linear interpolation between the high and low points on a sine wave, isn't that just a triangle wave? Can someone explain what the calculation does?

有帮助吗?

解决方案

If you take a look at the implementation, you'll see that the constructor calculates sin on the range 0.0 to 1.0 in steps of 1.0 / TABLE_SIZE, where TABLE_SIZE is 2048 by default. The linear interpolation is then done between these values. This closely approximates the sine function.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top