File tree Expand file tree Collapse file tree 1 file changed +5
-5
lines changed Expand file tree Collapse file tree 1 file changed +5
-5
lines changed Original file line number Diff line number Diff line change @@ -583,8 +583,8 @@ impl Executor {
583
583
584
584
// Play sound from frequency
585
585
"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 ;
588
588
589
589
let num_samples = ( duration_secs * sample_rate) as usize ;
590
590
let samples: Vec < f32 > = ( 0 ..num_samples)
@@ -600,15 +600,15 @@ impl Executor {
600
600
for _ in samples {
601
601
sink. append (
602
602
rodio:: source:: SineWave :: new ( frequency as f32 )
603
- . take_duration ( Duration :: from_secs ( duration_secs) ) ,
603
+ . take_duration ( Duration :: from_secs_f64 ( duration_secs) ) ,
604
604
) ;
605
605
}
606
606
607
607
sink. play ( ) ;
608
- std:: thread:: sleep ( Duration :: from_secs ( duration_secs) ) ;
608
+ std:: thread:: sleep ( Duration :: from_secs_f64 ( duration_secs) ) ;
609
609
}
610
610
611
- let duration_secs = self . pop_stack ( ) . get_number ( ) as u64 ;
611
+ let duration_secs = self . pop_stack ( ) . get_number ( ) ;
612
612
let frequency = self . pop_stack ( ) . get_number ( ) ;
613
613
614
614
play_sine_wave ( frequency, duration_secs) ;
You can’t perform that action at this time.
0 commit comments