Use FunDSP crate for beepboops
This commit is contained in:
parent
784e205357
commit
9219b6c475
4 changed files with 142 additions and 76 deletions
|
|
@ -5,12 +5,15 @@ use bracket_lib::random::RandomNumberGenerator;
|
|||
use crate::resources::sound_output::{SoundOutput, SoundSamples};
|
||||
|
||||
type Frequency = u32;
|
||||
type StartFrequency = u32;
|
||||
type EndFrequency = u32;
|
||||
type MinFrequency = u32;
|
||||
type MaxFrequency = u32;
|
||||
|
||||
pub enum SoundType {
|
||||
Silence,
|
||||
Tone(Frequency),
|
||||
Sweep(StartFrequency, EndFrequency),
|
||||
Noise(MinFrequency, MaxFrequency),
|
||||
}
|
||||
|
||||
|
|
@ -38,13 +41,10 @@ impl SoundEffects {
|
|||
pub fn new(ss: &SoundOutput) -> Self {
|
||||
Self {
|
||||
startup: ss.render_sound_effect(&SoundEffect {
|
||||
sounds: (30..400)
|
||||
.step_by(8)
|
||||
.map(|x| Sound {
|
||||
sound_type: SoundType::Tone(x),
|
||||
duration: Duration::from_millis(24),
|
||||
})
|
||||
.collect(),
|
||||
sounds: vec![Sound {
|
||||
sound_type: SoundType::Sweep(1, 350),
|
||||
duration: Duration::from_secs(1),
|
||||
}],
|
||||
}),
|
||||
step: ss.render_sound_effect(&SoundEffect {
|
||||
sounds: vec![
|
||||
|
|
@ -80,8 +80,8 @@ impl SoundEffects {
|
|||
}),
|
||||
bad_key: ss.render_sound_effect(&SoundEffect {
|
||||
sounds: iter::once(Sound {
|
||||
sound_type: SoundType::Tone(400),
|
||||
duration: Duration::from_millis(20),
|
||||
sound_type: SoundType::Tone(540),
|
||||
duration: Duration::from_millis(40),
|
||||
})
|
||||
.chain((0..4).flat_map(|_| {
|
||||
array::IntoIter::new([
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue