Skip to content

Commit

Permalink
[SCD] clamp quintic-interpolated sample values to the range that actu…
Browse files Browse the repository at this point in the history
…al hardware can generate
  • Loading branch information
jsgroth committed Jan 10, 2025
1 parent 249d40e commit 9288c02
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion backend/segacd-core/src/rf5c164.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,8 @@ fn interpolate_quintic(samples: [i8; 6], x: f64) -> f64 {
eighthym2 - 7.0 / 12.0 * ym1 + 13.0 / 12.0 * y0 - y1 + eleventwentyfourthy2 - twelfthy3;
let c5 = 1.0 / 24.0 * (y3 - ym2) + 5.0 / 24.0 * (ym1 - y2) + 5.0 / 12.0 * (y1 - y0);

((((c5 * x + c4) * x + c3) * x + c2) * x + c1) * x + c0
let result = ((((c5 * x + c4) * x + c3) * x + c2) * x + c1) * x + c0;
result.clamp(-127.0, 126.0)
}

#[derive(Debug, Clone, Default, Encode, Decode)]
Expand Down

0 comments on commit 9288c02

Please sign in to comment.