Skip to content

Commit 498fb20

Browse files
author
梶塚太智
committed
Update main.rs
1 parent 1384d77 commit 498fb20

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

src/main.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -583,8 +583,8 @@ impl Executor {
583583

584584
// Play sound from frequency
585585
"play-sound" => {
586-
fn play_sine_wave(frequency: f64, duration_secs: u64) {
587-
let sample_rate = 44100;
586+
fn play_sine_wave(frequency: f64, duration_secs: f64) {
587+
let sample_rate = 44100f64;
588588

589589
let num_samples = (duration_secs * sample_rate) as usize;
590590
let samples: Vec<f32> = (0..num_samples)
@@ -600,15 +600,15 @@ impl Executor {
600600
for _ in samples {
601601
sink.append(
602602
rodio::source::SineWave::new(frequency as f32)
603-
.take_duration(Duration::from_secs(duration_secs)),
603+
.take_duration(Duration::from_secs_f64(duration_secs)),
604604
);
605605
}
606606

607607
sink.play();
608-
std::thread::sleep(Duration::from_secs(duration_secs));
608+
std::thread::sleep(Duration::from_secs_f64(duration_secs));
609609
}
610610

611-
let duration_secs = self.pop_stack().get_number() as u64;
611+
let duration_secs = self.pop_stack().get_number();
612612
let frequency = self.pop_stack().get_number();
613613

614614
play_sine_wave(frequency, duration_secs);

0 commit comments

Comments
 (0)