From 38eee24832fe6da4f135cae455881ab97953b23a Mon Sep 17 00:00:00 2001 From: Gene Pasquet Date: Sat, 18 Apr 2026 02:47:10 +0100 Subject: Refresh docs and re-indent --- sound.scm | 88 +++++++++++++++++++++++++++++++-------------------------------- 1 file changed, 44 insertions(+), 44 deletions(-) (limited to 'sound.scm') diff --git a/sound.scm b/sound.scm index 983386f..c78f6e7 100644 --- a/sound.scm +++ b/sound.scm @@ -1,45 +1,45 @@ (module downstroke-sound * - (import scheme - (chicken base) - (only srfi-1 for-each) - downstroke-mixer) - - (define *sound-registry* '()) - (define *music* #f) - - (define (init-audio!) - (mix-open-audio! 44100 mix-default-format 2 512)) - - (define (load-sounds! sound-alist) - (set! *sound-registry* - (map (lambda (pair) - (cons (car pair) (mix-load-chunk (cdr pair)))) - sound-alist))) - - (define (play-sound sym) - (let ((entry (assq sym *sound-registry*))) - (when (and entry (cdr entry)) - (mix-play-channel -1 (cdr entry) 0)))) - - (define (load-music! path) - (set! *music* (mix-load-mus path))) - - (define (play-music! volume) - (when *music* - (mix-play-music *music* -1) - (mix-volume-music (inexact->exact (round (* volume 128)))))) - - (define (stop-music!) (mix-halt-music)) - - (define (set-music-volume! volume) - (mix-volume-music (inexact->exact (round (* volume 128))))) - - (define (cleanup-audio!) - (when *music* - (mix-halt-music) - (mix-free-music! *music*) - (set! *music* #f)) - (for-each (lambda (pair) (mix-free-chunk! (cdr pair))) - *sound-registry*) - (set! *sound-registry* '()) - (mix-close-audio!))) +(import scheme + (chicken base) + (only srfi-1 for-each) + downstroke-mixer) + +(define *sound-registry* '()) +(define *music* #f) + +(define (init-audio!) + (mix-open-audio! 44100 mix-default-format 2 512)) + +(define (load-sounds! sound-alist) + (set! *sound-registry* + (map (lambda (pair) + (cons (car pair) (mix-load-chunk (cdr pair)))) + sound-alist))) + +(define (play-sound sym) + (let ((entry (assq sym *sound-registry*))) + (when (and entry (cdr entry)) + (mix-play-channel -1 (cdr entry) 0)))) + +(define (load-music! path) + (set! *music* (mix-load-mus path))) + +(define (play-music! volume) + (when *music* + (mix-play-music *music* -1) + (mix-volume-music (inexact->exact (round (* volume 128)))))) + +(define (stop-music!) (mix-halt-music)) + +(define (set-music-volume! volume) + (mix-volume-music (inexact->exact (round (* volume 128))))) + +(define (cleanup-audio!) + (when *music* + (mix-halt-music) + (mix-free-music! *music*) + (set! *music* #f)) + (for-each (lambda (pair) (mix-free-chunk! (cdr pair))) + *sound-registry*) + (set! *sound-registry* '()) + (mix-close-audio!))) -- cgit v1.2.3