audio - How to play a song on repeat in Racket/gui? -


i'm making slideshow using racket , want short song play on loop behind slide show. i'm using (play-sound) racket crashes segfault towards end of song, @ different slide. if run show without sound code not segfault.

i think song ending causing racket/gui crash , looping might prevent this. playing song in main function of show such

(define (run)  (play-sound "path" #t)  (slide (...)  (run)) 

causes song continuously cut out, playing first 2 seconds or before repeating. have play-sound line outside of main function, crash towards end, @ end. i've tried increasing drracket's memory didn't help. advice appreciated.

you might interested in rsound package (cf. http://pkgs.racket-lang.org). package have both advantages , disadvantages on current approach. obvious disadvantage will require convert song wav. here's code:

#lang racket  (require rsound)  (define ishmael (rs-read "/users/clements/desktop/call-me-ishmael.wav"))  (define lead-time (* 1/10 44100))  (define (play-forever sound)   (define p (make-pstream))   (define len (rs-frames sound))   (let loop ([t 0])     (pstream-queue p sound (+ t lead-time))     (define next-t (+ t len))     (sleep (* 1/44100 (- next-t (pstream-current-frame p))))     (loop next-t)))  (play-forever ishmael) 

Comments

Popular posts from this blog

shopping cart - Page redirect not working PHP -

php - How to modify a menu to show sub-menus -

python - Installing PyDev in eclipse is failed -