FM: fix "clicks"

Signed-off-by: Ivan Bushchik <ivabus@ivabus.dev>
This commit is contained in:
Ivan Bushchik 2024-01-19 09:59:52 +03:00
parent 1aff34a06a
commit 26fcf5741b
No known key found for this signature in database
GPG key ID: 2F16FBF3262E090C

View file

@ -16,7 +16,7 @@ pub struct ModulationFreq(f32);
#[derive(Copy, Clone)] #[derive(Copy, Clone)]
pub struct FrequencyDeviation(f32); pub struct FrequencyDeviation(f32);
const FIGHT_CLICKS: usize = 128; const FIGHT_CLICKS: usize = 256;
impl Synth for FM { impl Synth for FM {
fn from_channel(channel: Channel, bpm: u16) -> Self fn from_channel(channel: Channel, bpm: u16) -> Self
@ -84,9 +84,8 @@ impl Synth for FM {
// This makes a little linear fade-in-out so we don't get "clicks" // This makes a little linear fade-in-out so we don't get "clicks"
* if k <= FIGHT_CLICKS { * if k <= FIGHT_CLICKS {
k as f32 / FIGHT_CLICKS as f32 k as f32 / FIGHT_CLICKS as f32
} else if k } else if samples - k
>= samples <= FIGHT_CLICKS
- FIGHT_CLICKS
{ {
(samples (samples
- k) as f32 / FIGHT_CLICKS as f32 - k) as f32 / FIGHT_CLICKS as f32