TheSwamp

Code Red => AutoLISP (Vanilla / Visual) => Topic started by: Columbia on October 13, 2004, 10:02:39 AM

Title: Wav File Playing...
Post by: Columbia on October 13, 2004, 10:02:39 AM
This is for all you guru's among geeks   :P

I want to play a *.wav file from my VisualLISP function.  How does one go about doing that.  I'm already familiar with the DOSLib coolness, however I want to be able to ship this out to another user who may or may not have DOSLib, and I don't want to ship the DOSLib arx to them.

Any and all help here would be appreciated.   Thanks.
Title: Wav File Playing...
Post by: SMadsen on October 13, 2004, 10:23:35 AM
All I have is a VBA thingie:
Code: [Select]
Private Declare Function PlaySound Lib "winmm.dll" (ByVal lpszName As String, ByVal hModule As Long, ByVal dwFlags As Long) As Long

Private Const SND_ASYNC = &H1         '  play asynchronously
Private Const SND_FILENAME = &H20000  '  file name
Private Const NO_ERROR = 0


Private Sub PlayItSam()
  PlaySound "D:\WINNT\Media\notify.wav", ByVal 0&, SND_FILENAME Or SND_ASYNC
End Sub
Title: Wav File Playing...
Post by: CAB on October 13, 2004, 11:00:51 AM
http://theswamp.org/phpBB2/viewtopic.php?t=993&highlight=wav+file
and
http://theswamp.org/phpBB2/viewtopic.php?t=370&highlight=wav+file
Title: Wav File Playing...
Post by: ImaJayhawk on October 13, 2004, 11:26:10 AM
Out of curiosity how would you do it using doslib?

--ImaJayhawk
Title: Wav File Playing...
Post by: Columbia on October 13, 2004, 11:32:44 AM
Really, really simple...
Code: [Select]

(dos_wav "filename.wav")
Title: Wav File Playing...
Post by: Columbia on October 13, 2004, 02:06:21 PM
Stig, CAB, Thanks.  I appreciate the info.

...But (there's always a "but", isn't there?) what I really wanted was a method of interacting with Win32API through VLISP to play it.  I would still have to ship this file VBA file along with the vlx.

Any thoughts?
Title: Wav File Playing...
Post by: Keith™ on October 13, 2004, 03:40:53 PM
Have you tried using Rundll32 to play the file through the winmm.dll ?
Title: Wav File Playing...
Post by: Columbia on October 13, 2004, 03:43:56 PM
Ummm..... Keith you've caught me completely ignorant.  I don't even know what Rundll32 is, nevermind trying to use it.
Title: Wav File Playing...
Post by: Keith™ on October 13, 2004, 04:23:13 PM
rundll32 is a program that you can use to run exported dll functions (typically C and/or C++ functions) winmm.dll is the dll that contains the function to play multimedia files. I have not explored how to make it happen, but I am quite sure given the correct syntax it would be possible.
Title: Re: Wav File Playing...
Post by: Dommy2Hotty on October 11, 2005, 12:59:14 PM
All I have is a VBA thingie:
Code: [Select]
Private Declare Function PlaySound Lib "winmm.dll" (ByVal lpszName As String, ByVal hModule As Long, ByVal dwFlags As Long) As Long

Private Const SND_ASYNC = &H1         '  play asynchronously
Private Const SND_FILENAME = &H20000  '  file name
Private Const NO_ERROR = 0


Private Sub PlayItSam()
  PlaySound "D:\WINNT\Media\notify.wav", ByVal 0&, SND_FILENAME Or SND_ASYNC
End Sub

Pardon my ignorance, but how do I get that to run?
Title: Re: Wav File Playing...
Post by: Bob Wahr on October 11, 2005, 01:06:47 PM
type VBAMAN , click NEW then click VBA EDITOR.  Paste that code into the IDE put your cursor somewhere in the sub portion of it and press F5
Title: Re: Wav File Playing...
Post by: Dommy2Hotty on October 11, 2005, 01:14:04 PM
Okay...now what if I wanted to put this in as part of a reactor?  Particularly when an object is erased?
Title: Re: Wav File Playing...
Post by: Bob Wahr on October 11, 2005, 01:16:03 PM
Code: [Select]
Private Declare Function PlaySound Lib "winmm.dll" (ByVal lpszName As String, ByVal hModule As Long, ByVal dwFlags As Long) As Long

Private Const SND_ASYNC = &H1         '  play asynchronously
Private Const SND_FILENAME = &H20000  '  file name
Private Const NO_ERROR = 0


Private Sub AcadDocument_ObjectErased(ByVal ObjectID As Long)
 PlaySound "D:\WINNT\Media\notify.wav", ByVal 0&, SND_FILENAME Or SND_ASYNC
End Sub
Title: Re: Wav File Playing...
Post by: deegeecees on October 11, 2005, 01:19:58 PM
Code: [Select]
Private Sub AcadDocument_EndCommand(ByVal CommandName As String)
    If (VBA.UCase$(CommandName) = "ERASE") Then
        Call PlayItSam
    End If
End Sub
Title: Re: Wav File Playing...
Post by: Dommy2Hotty on October 11, 2005, 02:34:59 PM
Even when I tried the original code, I never got a macro to execute.  I'm not familiar with VBA, so I apologize in advance.  But I followed the procedure Bob outlined, but when I hit F5, I don't have anyt macro to select to run.  :dummy:
Title: Re: Wav File Playing...
Post by: Swift on October 11, 2005, 02:41:31 PM
try inserting this in a new module in the vbaide

Code: [Select]
Option Explicit
Private Declare Function PlaySound Lib "winmm.dll" (ByVal lpszName As String, ByVal hModule As Long, ByVal dwFlags As Long) As Long

Private Const SND_ASYNC = &H1         '  play asynchronously
Private Const SND_FILENAME = &H20000  '  file name
Private Const NO_ERROR = 0

Public Sub MakeANoise()
PlaySound "c:\windows\media\ding", ByVal 0&, SND_FILENAME Or SND_ASYNC

End Sub

Title: Re: Wav File Playing...
Post by: Dommy2Hotty on October 11, 2005, 02:45:46 PM
That works!  Thanks...now to put that with the Erase reactor...after work...
Title: Re: Wav File Playing...
Post by: Andrea on October 11, 2005, 02:46:34 PM
if you try to use simple beep sound..

you can use  (acet-sys-beep Yoursoundhere)

or

(startapp "c:/windows/system32/sndrec32.exe /play /close"  "C:/windows/media/tada.wav")

but this will show the soundrecorder...
maybe it have a switch / to play background...but i don't know..
Title: Re: Wav File Playing...
Post by: MP on October 11, 2005, 02:58:16 PM
One more time ... ACET* = Evil.

If you don't want to roll your own functions use DOSLIB (http://www.mcneel.com/cgi-bin/download.cgi?doslib)'s (dos_wav filename) function, but please don't use the ACET* crap, you're just begging for problems down the road and your users are the ones that will pay.
Title: Re: Wav File Playing...
Post by: deegeecees on October 11, 2005, 03:14:00 PM
Code: [Select]
Private Sub AcadDocument_EndCommand(ByVal CommandName As String)
 If (VBA.UCase$(CommandName) = "ERASE") Then
 Call PlayItSam
 End If
End Sub

This will not work the way it should, so please disregard.
Title: Re: Wav File Playing...
Post by: Keith™ on October 11, 2005, 04:55:54 PM
See this thread ....
http://www.theswamp.org/forum/index.php?topic=993.0
Title: Re: Wav File Playing...
Post by: MP on October 11, 2005, 05:31:38 PM
lol, this thread reminds me that I used to have the sound of a toilet flush everytime members of Microstation / PDS group changed projects (I had written a project management utility to map the network, modify the registry etc). I didn't keep the code active very long but it was funny while it was enabled.

 :-D
Title: Re: Wav File Playing...
Post by: Andrea on October 11, 2005, 09:17:59 PM
One more time ... ACET* = Evil.

If you don't want to roll your own functions use DOSLIB (http://www.mcneel.com/cgi-bin/download.cgi?doslib)'s (dos_wav filename) function, but please don't use the ACET* crap, you're just begging for problems down the road and your users are the ones that will pay.

MP could you explain exactly why ACET* is crap ?
I'm new with it...and for my own...seem to work.