summaryrefslogtreecommitdiff
path: root/chickadee/audio.scm
diff options
context:
space:
mode:
Diffstat (limited to 'chickadee/audio.scm')
-rw-r--r--chickadee/audio.scm21
1 files changed, 12 insertions, 9 deletions
diff --git a/chickadee/audio.scm b/chickadee/audio.scm
index d92ae94..c92eb44 100644
--- a/chickadee/audio.scm
+++ b/chickadee/audio.scm
@@ -77,9 +77,10 @@
(error "cannot load audio sample:" file))))
(define (set-sample-volume! volume)
- "Set the volume that all samples are played at to VOLUME, an integer
-value between 0 and 128."
- (ignore-value (sdl2:set-channel-volume! #f volume)))
+ "Set the volume that all samples are played at to VOLUME, a floating
+point value between 0 and 1."
+ (ignore-value
+ (sdl2:set-channel-volume! #f (inexact->exact (round (* volume 128.0))))))
(define (play-sample sample)
"Play SAMPLE."
@@ -105,14 +106,16 @@ value between 0 and 128."
(make-music (sdl2:load-music file)))
(define (music-volume)
- "Return the volume level for music, an integer value between 0 and
-128."
- (sdl2:music-volume))
+ "Return the volume level for music, a floating point value between
+0 and 1."
+ (/ (sdl2:music-volume) 128.0))
(define (set-music-volume! volume)
- "Set the volume that music is played at to VOLUME, an integer value
-between 0 and 128."
- (ignore-value (sdl2:set-music-volume! volume)))
+ "Set the volume that music is played at to VOLUME, a floating point
+value between 0 and 1."
+ (ignore-value
+ (sdl2:set-music-volume!
+ (inexact->exact (round (* volume 128.0))))))
(define* (play-music music #:key loop?)
"Play MUSIC. If LOOP?, play it over and over and over and over