首页 > 解决方案 > Dr-Racket 中的背景声音 [lang #r5rs]

问题描述

我正在尝试在游戏中使用一些背景声音。如果我使用我目前拥有的循环,它不会返回或者它会分层声音。有没有办法测试 ui 中是否有声音播放,或者 Rsound 是声音的必备工具?


(define play-asynchronously #f)

(define sound-test #t)
(define (sound-test!)
  (if sound-test
      #f
      #t))



(define (in-game-loop)
  (if sound-test
      (if (play-sound "flight_of_the_bumblebee.mp3" play-asynchronously)
          ;Geschreven in 1899-1900 door Nikolaj Rimski-Korsakov
          ;Gedownload op 16/05/2018 van https://ia802606.us.archive.org/19/items/FlightOfTheBumblebee/flight_of_the_bumblebee_2.mp3
          (in-game-loop)
          'done)
      (begin
        (in-menu-loop)
        (set! sound-test #t))))

(define (in-menu-loop)
  (if sound-test
      (if (play-sound "Gymnopedie-No-1.mp3" play-asynchronously)
          ;Geschreven in 1888 door Erik Satie
          ;Gedownload op 16/05/018 van https://incompetech.com/music/royalty-free/?keywords=gymnopedie
          (in-menu-loop)
          'done)
      (begin
        (in-game-loop)
        (set! sound-test #t))))

标签: loopsaudioschemeracket

解决方案


推荐阅读