From 78c23526d227dc14b3380988562be7ea5fd0010e Mon Sep 17 00:00:00 2001 From: David Thompson Date: Wed, 9 Jan 2019 21:25:42 -0500 Subject: Integrate new audio module into game loop. * chickadee.scm (run-game): Replace SDL mixer with OpenAL audio system. --- chickadee.scm | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'chickadee.scm') diff --git a/chickadee.scm b/chickadee.scm index 0a9b0b3..876c59e 100644 --- a/chickadee.scm +++ b/chickadee.scm @@ -22,6 +22,7 @@ ;;; Code: (define-module (chickadee) + #:use-module (chickadee audio) #:use-module (chickadee config) #:use-module (chickadee game-loop) #:use-module (chickadee math matrix) @@ -41,7 +42,6 @@ #:use-module ((sdl2 input keyboard) #:prefix sdl2:) #:use-module ((sdl2 input mouse) #:prefix sdl2:) #:use-module (sdl2 input text) - #:use-module (sdl2 mixer) #:use-module ((sdl2 video) #:prefix sdl2:) #:use-module (srfi srfi-9) #:export (current-window @@ -227,9 +227,8 @@ border is disabled, otherwise it is enabled.") (controller-move (const #t)) error) (sdl-init) - (false-if-exception (mixer-init)) - (open-audio) (start-text-input) + (init-audio) (let* ((window (sdl2:make-window #:opengl? #t #:title window-title #:size (list window-width window-height) @@ -311,6 +310,9 @@ border is disabled, otherwise it is enabled.") (define (update-sdl dt) (input-sdl) (update dt) + ;; Update audio after updating game state so that any sounds + ;; that were queued to play this frame start playing immediately. + (update-audio) ;; Free any GPU resources that have been GC'd. (gpu-reap!)) (define (render-sdl-opengl alpha) @@ -343,5 +345,6 @@ border is disabled, otherwise it is enabled.") #:time sdl-ticks #:update-hz update-hz))) (lambda () + (quit-audio) (sdl2:delete-gl-context! gl-context) (sdl2:close-window! window))))) -- cgit v1.2.3