massung / r-cade

Retro Game Engine for Racket
https://r-cade.io
Other
273 stars 13 forks source link

Crash and sound corruption on play-music #15

Closed DexterLagan closed 4 years ago

DexterLagan commented 4 years ago

DrRacket 7.6, Windows 10 64 bits, libsndfile 1.0.28

Running these notes crashes DrRacket right after the first few notes play :

lang racket

(require r-cade)

;; create a song (define theme (music "E2-E2-E2-E2."

:tempo 280

     #:instrument sine-wave))

(define (game-loop) (text 2 2 "Playing few notes.") (when (= (frame) 1) (play-music theme)))

(run game-loop 128 128)


I also had garbled sound after the first few notes of "E1-E1-E1-E1." or "E1-E1-E1-E1".

massung commented 4 years ago

Ugh. Well. Thanks. I'll see if I can track this down... :-)

massung commented 4 years ago

Fixed (finally) with db8988d7e5cc4d4c1805baff80e4773d42ef90d9.

DexterLagan commented 4 years ago

Awesome! Thanks!

Dex

On May 12, 2020, at 8:30 PM, Jeffrey Massung notifications@github.com wrote:

 Fixed (finally) with db8988d.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or unsubscribe.

massung commented 4 years ago

If curious, this was because the garbage collector was moving the underlying memory for the music out from under the music thread. If the sample data was long enough, it'd never move it (or very, very rarely). The memory is now allocated to a fixed location that the collector won't relocate.

If you happen upon this again, I'd be very surprised, but definitely re-open the issue.

DexterLagan commented 4 years ago

Sounds good. I’ll keep you posted.

Cheers,

Dex

On May 12, 2020, at 11:56 PM, Jeffrey Massung notifications@github.com wrote:

 If curious, this was because the garbage collector was moving the underlying memory for the music out from under the music thread. If the sample data was long enough, it'd never move it (or very, very rarely). The memory is now allocated to a fixed location that the collector won't relocate.

If you happen upon this again, I'd be very surprised, but definitely re-open the issue.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or unsubscribe.