Author Topic: Wav playing file in LISP  (Read 5854 times)

0 Members and 1 Guest are viewing this topic.

Andrea

  • Water Moccasin
  • Posts: 2372
Wav playing file in LISP
« 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")
Keep smile...

GDF

  • Water Moccasin
  • Posts: 2081
Re: Wav playing file in LISP
« Reply #1 on: September 19, 2008, 11:31:18 AM »
I think I can use this somewhere....
Why is there never enough time to do it right, but always enough time to do it over?
BricsCAD 2020x64 Windows 10x64

GDF

  • Water Moccasin
  • Posts: 2081
Re: Wav playing file in LISP
« Reply #2 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")))
Why is there never enough time to do it right, but always enough time to do it over?
BricsCAD 2020x64 Windows 10x64

ronjonp

  • Needs a day job
  • Posts: 7526
Re: Wav playing file in LISP
« Reply #3 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)
    )
  )
)
« Last Edit: September 19, 2008, 12:03:35 PM by ronjonp »

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

Andrea

  • Water Moccasin
  • Posts: 2372
Re: Wav playing file in LISP
« Reply #4 on: September 19, 2008, 12:06:00 PM »
nice catch ronjonp !  :-)
Keep smile...

Jan ter Aij

  • Guest
Re: Wav playing file in LISP
« Reply #5 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.

ronjonp

  • Needs a day job
  • Posts: 7526
Re: Wav playing file in LISP
« Reply #6 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.

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

deegeecees

  • Guest
Re: Wav playing file in LISP
« Reply #7 on: October 21, 2008, 01:05:24 PM »

Ben Clark

  • Newt
  • Posts: 94
Re: Wav playing file in LISP
« Reply #8 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?