retrofit repl to use table cosine lookups, so it links with lto="fat"

This commit is contained in:
bunnie 2023-01-02 17:50:06 +08:00
parent 597e24cd99
commit 59f06ff16f
2 changed files with 2 additions and 1 deletions

View file

@ -25,6 +25,7 @@ content-plugin-api = {path = "../../services/content-plugin-api"} # all content
com = {path = "../../services/com"}
llio = {path = "../../services/llio"}
codec = {path = "../../services/codec"}
cos_table = {path = "../../libs/cos_table"}
[features]
default = []

View file

@ -148,7 +148,7 @@ impl<'a> ShellCmdApi<'a> for Audio {
// put the "expensive" f32 comparison outside the cosine wave table computation loop
let omega = self.freq * 2.0 * std::f32::consts::PI / SAMPLE_RATE_HZ;
for sample in frame.iter_mut() {
let raw_sine: i16 = (AMPLITUDE * f32::cos( self.play_sample * omega ) * i16::MAX as f32) as i16;
let raw_sine: i16 = (AMPLITUDE * cos_table::cos( self.play_sample * omega ) * i16::MAX as f32) as i16;
let left = raw_sine as u16;
let right = raw_sine as u16;
*sample = right as u32 | (left as u32) << 16;