#!/usr/bin/newlisp # # How to play a WAV file with MikMod. # # Developed with newLisp 8.8.0 in Slackware Linux using libMikMod 3.1.10. # Does not work with Win32 platforms. # # April 23, 2006 - PvE. # #-------------------------------------------------------------------------------------------------- # Remarks: # # The MikMod variable 'md_mode' should be set to "DMODE_SOFT_SNDFX". The default value for this # variable is: DMODE_STEREO | DMODE_SURROUND | DMODE_16BITS | DMODE_SOFT_MUSIC | DMODE_SOFT_SNDFX. # # So we're d*** lucky here, since there is no way to set this variable in an interpreted way. :-) #-------------------------------------------------------------------------------------------------- # Load MIKMOD context (load "MIKMOD.lsp") (MIKMOD:MikMod_RegisterAllDrivers) # initialize the library (if (> (MIKMOD:MikMod_Init) 0) (println "Could not initialize sound.")) # Load file (set 'sfx1 (MIKMOD:Sample_Load "click.wav")) (if (= sfx1 0) (println "Could not load sound.")) # Set voices (MIKMOD:MikMod_SetNumVoices -1 1) # Enable output (MIKMOD:MikMod_EnableOutput) # Start playing (set 'v1 (MIKMOD:Sample_Play sfx1 0 0)) # We're playing (do-until (> (MIKMOD:Voice_Stopped v1) 0) (MIKMOD:MikMod_Update) (sleep 50) ) (MIKMOD:MikMod_DisableOutput) (MIKMOD:Sample_Free sfx1) (MIKMOD:MikMod_Exit) # Exit newLisp (exit)