oscillators: fix

This commit is contained in:
veclav talica 2024-06-15 14:30:50 +05:00
parent b06759de76
commit 12b32acb2b

View File

@ -51,12 +51,16 @@ struct sqrtwave {
uint32_t u; uint32_t u;
} v; } v;
} init_sqrtwave(float frequency, float phase, float amplitude) { } init_sqrtwave(float frequency, float phase, float amplitude) {
struct sqrtwave r; struct sqrtwave r;
r.w = init_sinewave(frequency, phase, 1.f); union {
v.f = r.w.s; float f;
a.f = amplitude; uint32_t u;
r.v.u = (a.u & 0x7fffffff) | (v.u & 0x80000000); } v, a;
return r; r.w = init_sinewave(frequency, phase, 1.f);
v.f = r.w.s;
a.f = amplitude;
r.v.u = (a.u & 0x7fffffff) | (v.u & 0x80000000);
return r;
} }
/* Use floating point bit representation to infer sign, all other bits are set to amplitude */ /* Use floating point bit representation to infer sign, all other bits are set to amplitude */