TheSwamp

Code Red => AutoLISP (Vanilla / Visual) => Topic started by: Andrea on September 19, 2008, 11:16:06 AM

Title: Wav playing file in LISP
Post by: Andrea on September 19, 2008, 11:16:06 AM
Hi all,..

I'm curious to see your code to play wav file.

ther's mine.
Code: [Select]
(defun PlayWav (wavfile / WAV)
  (vl-load-com)
  (setq WAV (vlax-create-object "Wscript.Shell"))
(vlax-invoke
   WAV
   "run"
   (strcat "sndrec32 /play /close \"\" " wavfile) T)
(vlax-release-object WAV)

)

(playwav "c:\\windows\\media\\tada.wav")
Title: Re: Wav playing file in LISP
Post by: GDF on September 19, 2008, 11:31:18 AM
I think I can use this somewhere....
Title: Re: Wav playing file in LISP
Post by: GDF on September 19, 2008, 11:38:50 AM
(defun ARCH:assWAV () (dos_wav (strcat ARCH#SUPF "gerbil_ass.wav")))
(defun ARCH:dumassWAV  ()
  (dos_wav (strcat ARCH#SUPF "frog_dumbass.wav")))
(defun ARCH:lookinWAV () (dos_wav (strcat ARCH#SUPF "frog_lookin.wav")))
Title: Re: Wav playing file in LISP
Post by: ronjonp on September 19, 2008, 11:48:39 AM
Andrea,

That's the code route I'd take too.

Here's a different version that won't error if the wav file is not found.

Code: [Select]
(defun playwav (wavfile / WAV)
  (vl-load-com)
  (if (and (findfile wavfile)
   (= (strcase (vl-filename-extension wavfile)) ".WAV")
   (setq WAV (vlax-create-object "Wscript.Shell"))
      )
    (progn
      (vlax-invoke
WAV
"run"
(strcat "sndrec32 /play /close \"\" " wavfile)
T
      )
      (vlax-release-object WAV)
    )
  )
)
Title: Re: Wav playing file in LISP
Post by: Andrea on September 19, 2008, 12:06:00 PM
nice catch ronjonp !  :-)
Title: Re: Wav playing file in LISP
Post by: Jan ter Aij on October 20, 2008, 07:27:41 AM
Dear Andrea and Ronjonp,
The sndrec32 command does not seem to be available in Vista.
Is there an equivalent
I can use in Vista??

Greetings.
Title: Re: Wav playing file in LISP
Post by: ronjonp on October 21, 2008, 12:43:23 PM
Dear Andrea and Ronjonp,
The sndrec32 command does not seem to be available in Vista.
Is there an equivalent
I can use in Vista??

Greetings.

From what I've read, the easiest solution is to copy the sndrec32.exe from an XP computer to your Vista computer %windir%\System32.
Title: Re: Wav playing file in LISP
Post by: deegeecees on October 21, 2008, 01:05:24 PM
There are more examples here:

http://www.theswamp.org/index.php?topic=14549.0
Title: Re: Wav playing file in LISP
Post by: Ben Clark on May 14, 2019, 04:47:44 PM
These don't work anymore. Anyone have an idea why?

Does "Wscript.Shell" work differently now perhaps?