Skip to content

Shorten precomputed_sine_table #309

@orottier

Description

@orottier
let table: Vec<f32> = (0..TABLE_LENGTH_USIZE)
    .map(|x| ((x as f32) * 2.0 * PI * (1. / (TABLE_LENGTH_F32))).sin())
    .collect();

This computes the full sine wave from t=0 to t=2PI.
We can use the symmetries of the sine wave to store only the part of t=0 to t=PI/2 and derive the other ranges from it:
https://www.electronics-notes.com/images/waveform-sine-wave-02.png

This will reduce the general memory usage so we can utilize the caches for other things which may improve the libs performance

Metadata

Metadata

Assignees

Labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions