Commit 72f78e9a authored by Aske Simon Christensen's avatar Aske Simon Christensen
Browse files

Rust version of additive core, for documentation

parent 9131032b
#![allow(dead_code)]
use std::{f32, f64};
use std::mem::transmute;
use std::ops::{Index};
......@@ -423,6 +421,28 @@ impl SoundGenerator for OidosSoundGenerator {
}
}
impl OidosSoundGenerator {
/// Functionally equivalent to the vectorized asm versions, but much slower.
#[allow(unused)]
fn additive_core(&mut self) -> f64 {
let mut s = 0f64;
for i in 0..self.n_partials {
let re = self.state_re[i] * self.step_re[i] - self.state_im[i] * self.step_im[i];
let im = self.state_re[i] * self.step_im[i] + self.state_im[i] * self.step_re[i];
self.state_re[i] = re;
self.state_im[i] = im;
let f = self.filter_low[i].min(self.filter_high[i]).min(1.0).max(0.0);
self.filter_low[i] += self.f_add_low;
self.filter_high[i] += self.f_add_high;
s += re * f;
}
s
}
}
extern "cdecl" {
fn supports_avx() -> bool;
fn additive_core_sse2(state_re: *mut f64, state_im: *mut f64, step_re: *const f64, step_im: *const f64,
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment