use alloc::borrow::Cow;
use serde::{Deserialize, Serialize};
use crate::species::Species;
use crate::voice::CreatureVoice;
#[derive(Debug, Clone, Serialize, Deserialize)]
#[must_use]
pub struct VoicePreset {
pub name: Cow<'static, str>,
pub species: Species,
pub size: f32,
pub f0_offset: f32,
pub breathiness: f32,
}
impl VoicePreset {
#[must_use]
pub fn build(&self) -> CreatureVoice {
CreatureVoice::new(self.species)
.with_size(self.size)
.with_f0_offset(self.f0_offset)
.with_breathiness(self.breathiness)
}
}
pub mod presets {
use super::*;
pub const ALPHA_WOLF: VoicePreset = VoicePreset {
name: Cow::Borrowed("Alpha Wolf"),
species: Species::Wolf,
size: 1.4,
f0_offset: -80.0,
breathiness: 0.03,
};
pub const WOLF_PUP: VoicePreset = VoicePreset {
name: Cow::Borrowed("Wolf Pup"),
species: Species::Wolf,
size: 0.4,
f0_offset: 200.0,
breathiness: 0.12,
};
pub const HOUSE_CAT: VoicePreset = VoicePreset {
name: Cow::Borrowed("House Cat"),
species: Species::Cat,
size: 1.0,
f0_offset: 0.0,
breathiness: 0.08,
};
pub const KITTEN: VoicePreset = VoicePreset {
name: Cow::Borrowed("Kitten"),
species: Species::Cat,
size: 0.4,
f0_offset: 150.0,
breathiness: 0.15,
};
pub const MALE_LION: VoicePreset = VoicePreset {
name: Cow::Borrowed("Male Lion"),
species: Species::Lion,
size: 1.3,
f0_offset: -15.0,
breathiness: 0.12,
};
pub const ANCIENT_DRAGON: VoicePreset = VoicePreset {
name: Cow::Borrowed("Ancient Dragon"),
species: Species::Dragon,
size: 4.0,
f0_offset: -30.0,
breathiness: 0.25,
};
pub const YOUNG_DRAGON: VoicePreset = VoicePreset {
name: Cow::Borrowed("Young Dragon"),
species: Species::Dragon,
size: 0.8,
f0_offset: 50.0,
breathiness: 0.15,
};
pub const BALD_EAGLE: VoicePreset = VoicePreset {
name: Cow::Borrowed("Bald Eagle"),
species: Species::Raptor,
size: 1.2,
f0_offset: -200.0,
breathiness: 0.1,
};
pub const RAVEN: VoicePreset = VoicePreset {
name: Cow::Borrowed("Raven"),
species: Species::Crow,
size: 1.3,
f0_offset: -100.0,
breathiness: 0.2,
};
pub const FIELD_CRICKET: VoicePreset = VoicePreset {
name: Cow::Borrowed("Field Cricket"),
species: Species::Cricket,
size: 1.0,
f0_offset: 0.0,
breathiness: 0.0,
};
pub const ALLIGATOR: VoicePreset = VoicePreset {
name: Cow::Borrowed("American Alligator"),
species: Species::Crocodilian,
size: 1.5,
f0_offset: -10.0,
breathiness: 0.18,
};
#[must_use = "returns the list of all built-in voice presets"]
pub fn all() -> &'static [VoicePreset] {
&[
ALPHA_WOLF,
WOLF_PUP,
HOUSE_CAT,
KITTEN,
MALE_LION,
ANCIENT_DRAGON,
YOUNG_DRAGON,
BALD_EAGLE,
RAVEN,
FIELD_CRICKET,
ALLIGATOR,
]
}
}