summaryrefslogtreecommitdiff
path: root/2d
diff options
context:
space:
mode:
authorDavid Thompson <dthompson2@worcester.edu>2014-01-23 20:19:28 -0500
committerDavid Thompson <dthompson2@worcester.edu>2014-01-23 20:19:28 -0500
commit8b9f05a2c0a32b8d2970f5c0e5f0cf7bd9d25160 (patch)
tree1717b5f6ec37f55170144507c7865f615579dd95 /2d
parent6a8777e4d920b299b1efd49ab7152a409200bb3f (diff)
Return unspecified value for void audio functions.
* 2d/audio.scm (ignore-value): New macro. (set-sample-volume, play-sample, pause-music, resume-music) (rewind-music, stop-music): Ignore return value. (music-playing?, music-paused?): Add docstrings.
Diffstat (limited to '2d')
-rw-r--r--2d/audio.scm86
1 files changed, 55 insertions, 31 deletions
diff --git a/2d/audio.scm b/2d/audio.scm
index 84b7a99..034f1b9 100644
--- a/2d/audio.scm
+++ b/2d/audio.scm
@@ -24,10 +24,35 @@
(define-module (2d audio)
#:use-module (srfi srfi-9)
#:use-module (srfi srfi-2)
- #:use-module ((sdl mixer) #:prefix SDL:))
+ #:use-module ((sdl mixer) #:prefix SDL:)
+ #:export (load-sample
+ sample?
+ sample-audio
+ sample-volume
+ set-sample-volume
+ play-sample
+ load-music
+ music?
+ music-audio
+ music-volume
+ play-music
+ set-music-volume
+ pause-music
+ resume-music
+ rewind-music
+ stop-music
+ music-paused?
+ music-playing?))
(SDL:open-audio)
+;; Used to wrap SDL audio functions whose return values should be
+;; ignored.
+(define-syntax-rule (ignore-value body ...)
+ (begin
+ body ...
+ *unspecified*))
+
;; Wrapper over SDL audio objects.
(define-record-type <sample>
(make-sample audio)
@@ -46,20 +71,11 @@ loaded"
(define (set-sample-volume volume)
"Set the volume that all samples are played at to VOLUME."
- (SDL:volume volume)
- *unspecified*)
+ (ignore-value (SDL:volume volume)))
(define (play-sample sample)
"Play the given audio SAMPLE."
- (SDL:play-channel (sample-audio sample))
- *unspecified*)
-
-(export load-sample
- sample?
- sample-audio
- sample-volume
- set-sample-volume
- play-sample)
+ (ignore-value (SDL:play-channel (sample-audio sample))))
;; Wrapper over SDL music objects.
(define-record-type <music>
@@ -78,25 +94,33 @@ loaded."
(SDL:music-volume))
(define (set-music-volume volume)
- "Set the volume that music is played at."
- (SDL:volume volume)
- *unspecified*)
+ "Set the volume that music is played at to VOLUME."
+ (ignore-value (SDL:volume volume)))
(define (play-music music)
"Play the given MUSIC."
- (SDL:play-music (music-audio music))
- *unspecified*)
-
-(export load-music
- music?
- music-audio
- music-volume
- play-music
- set-music-volume)
-
-(re-export (SDL:pause-music . pause-music)
- (SDL:resume-music . resume-music)
- (SDL:rewind-music . rewind-music)
- (SDL:halt-music . stop-music)
- (SDL:paused-music? . music-paused?)
- (SDL:playing-music? . music-playing?))
+ (ignore-value (SDL:play-music (music-audio music))))
+
+(define (pause-music)
+ "Pause the current music track."
+ (ignore-value (SDL:pause-music)))
+
+(define (resume-music)
+ "Resume the current music track."
+ (ignore-value (SDL:resume-music)))
+
+(define (rewind-music)
+ "Restart the current music track."
+ (ignore-value (SDL:rewind-music)))
+
+(define (stop-music)
+ "Stop playing the current music track."
+ (ignore-value (SDL:halt-music)))
+
+(define (music-playing?)
+ "Return #t if music is currently playing, otherwise return #f."
+ (SDL:playing-music?))
+
+(define (music-paused?)
+ "Return #t if music is currently paused, otherwise return #f."
+ (SDL:paused-music?))