[pal-cvs] CVS pal

tneste tneste at common-lisp.net
Fri Sep 7 07:55:16 UTC 2007


Update of /project/pal/cvsroot/pal
In directory clnet:/tmp/cvs-serv13419

Modified Files:
	ffi.lisp package.lisp pal.lisp todo.txt 
Log Message:
Added fading arguments to play-music/halt-music.

--- /project/pal/cvsroot/pal/ffi.lisp	2007/08/30 21:11:23	1.19
+++ /project/pal/cvsroot/pal/ffi.lisp	2007/09/07 07:55:16	1.20
@@ -639,9 +639,15 @@
 
 (cffi:defcfun ("Mix_HaltMusic" halt-music) :int)
 
+(cffi:defcfun ("Mix_FadeOutMusic" fade-out-music) :int
+  (fade :int))
+
 (cffi:defcfun ("Mix_LoadMUS" load-music) :pointer
   (file :string))
 
+(cffi:defcfun ("Mix_FadeInMusic" fade-in-music) :int
+  (music :pointer) (loops :int) (fade :int))
+
 (cffi:defcfun ("Mix_PlayMusic" play-music) :int
   (music :pointer) (loops :int))
 
--- /project/pal/cvsroot/pal/package.lisp	2007/08/30 09:22:19	1.16
+++ /project/pal/cvsroot/pal/package.lisp	2007/09/07 07:55:16	1.17
@@ -4,6 +4,8 @@
   (:use :common-lisp)
   (:export #:+NO-EVENT+
            #:+gl-line-smooth+
+           #:fade-out-music
+           #:fade-in-music
            #:make-font
            #:+gl-pack-alignment+
            #:gl-flush
--- /project/pal/cvsroot/pal/pal.lisp	2007/08/30 21:11:23	1.29
+++ /project/pal/cvsroot/pal/pal.lisp	2007/09/07 07:55:16	1.30
@@ -56,7 +56,7 @@
   (when *pal-running*
     (close-pal))
   (pal-ffi:init (logior pal-ffi:+init-video+ pal-ffi:+init-audio+))
-  (pal-ffi:open-audio 22050 pal-ffi:+audio-s16+ 0 2048)
+  (pal-ffi:open-audio 22050 pal-ffi:+audio-s16+ 0 1024)
   (pal-ffi:gl-set-attribute pal-ffi:+gl-depth-size+ 0)
   (pal-ffi:gl-set-attribute pal-ffi:+gl-doublebuffer+ 1)
   (let ((surface (pal-ffi::set-video-mode
@@ -762,19 +762,26 @@
     (let ((music (pal-ffi::make-music :music music)))
       (pal-ffi:register-resource music))))
 
-(defun play-music (music &key (loops t) (volume 255))
+(defun play-music (music &key (loops t) (volume 255) (fade 0))
   "Volume 0-255. Loops is: t = forever, nil = once, number = number of loops"
   (pal-ffi:volume-music (1+ (truncate volume 2)))
-  (pal-ffi:play-music (pal-ffi:music-music music) (cond ((eq loops t) -1)
-                                                        ((null loops) 0)
-                                                        (t (truncate loops)))))
+  (if (> fade 0)
+      (pal-ffi:fade-in-music (pal-ffi:music-music music) (cond ((eq loops t) -1)
+                                                               ((null loops) 0)
+                                                               (t (truncate loops)))
+                             fade)
+      (pal-ffi:play-music (pal-ffi:music-music music) (cond ((eq loops t) -1)
+                                                            ((null loops) 0)
+                                                            (t (truncate loops))))))
 
 (defun set-music-volume (volume)
   "Volume 0-255"
   (pal-ffi:volume-music (1+ (truncate volume 2))))
 
-(defun halt-music ()
-  (pal-ffi:halt-music))
+(defun halt-music (&optional fade)
+  (if fade
+      (pal-ffi:fade-out-music fade)
+      (pal-ffi:halt-music)))
 
 
 
--- /project/pal/cvsroot/pal/todo.txt	2007/08/30 09:02:24	1.17
+++ /project/pal/cvsroot/pal/todo.txt	2007/09/07 07:55:16	1.18
@@ -4,9 +4,6 @@
 
 - Implement image mirroring, tiles and animation.
 
-- Add more complex sound/music handling functions, channel set volume/dir,
-  fade/etc. music.
-
 - Box/box/line/circle etc. overlap functions, faster v-dist.
 
 - Correct aspect ratio when fullscreen on widescreen displays.




More information about the Pal-cvs mailing list