Author Topic: Wav File Playing...  (Read 6852 times)

0 Members and 1 Guest are viewing this topic.

Columbia

  • Guest
Wav File Playing...
« 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.

SMadsen

  • Guest
Wav File Playing...
« Reply #1 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

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

ImaJayhawk

  • Guest
Wav File Playing...
« Reply #3 on: October 13, 2004, 11:26:10 AM »
Out of curiosity how would you do it using doslib?

--ImaJayhawk

Columbia

  • Guest
Wav File Playing...
« Reply #4 on: October 13, 2004, 11:32:44 AM »
Really, really simple...
Code: [Select]

(dos_wav "filename.wav")

Columbia

  • Guest
Wav File Playing...
« Reply #5 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?

Keith™

  • Villiage Idiot
  • Seagull
  • Posts: 16899
  • Superior Stupidity at its best
Wav File Playing...
« Reply #6 on: October 13, 2004, 03:40:53 PM »
Have you tried using Rundll32 to play the file through the winmm.dll ?
Proud provider of opinion and arrogance since November 22, 2003 at 09:35:31 am
CadJockey Militia Field Marshal

Find me on https://parler.com @kblackie

Columbia

  • Guest
Wav File Playing...
« Reply #7 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.

Keith™

  • Villiage Idiot
  • Seagull
  • Posts: 16899
  • Superior Stupidity at its best
Wav File Playing...
« Reply #8 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.
Proud provider of opinion and arrogance since November 22, 2003 at 09:35:31 am
CadJockey Militia Field Marshal

Find me on https://parler.com @kblackie

Dommy2Hotty

  • Swamp Rat
  • Posts: 1127
Re: Wav File Playing...
« Reply #9 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?

Bob Wahr

  • Guest
Re: Wav File Playing...
« Reply #10 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

Dommy2Hotty

  • Swamp Rat
  • Posts: 1127
Re: Wav File Playing...
« Reply #11 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?

Bob Wahr

  • Guest
Re: Wav File Playing...
« Reply #12 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

deegeecees

  • Guest
Re: Wav File Playing...
« Reply #13 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

Dommy2Hotty

  • Swamp Rat
  • Posts: 1127
Re: Wav File Playing...
« Reply #14 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:

Swift

  • Swamp Rat
  • Posts: 596
Re: Wav File Playing...
« Reply #15 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


Dommy2Hotty

  • Swamp Rat
  • Posts: 1127
Re: Wav File Playing...
« Reply #16 on: October 11, 2005, 02:45:46 PM »
That works!  Thanks...now to put that with the Erase reactor...after work...

Andrea

  • Water Moccasin
  • Posts: 2372
Re: Wav File Playing...
« Reply #17 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..
Keep smile...

MP

  • Seagull
  • Posts: 17750
  • Have thousands of dwgs to process? Contact me.
Re: Wav File Playing...
« Reply #18 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'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.
« Last Edit: October 11, 2005, 03:15:13 PM by MP »
Engineering Technologist • CAD Automation Practitioner
Automation ▸ Design ▸ Drafting ▸ Document Control ▸ Client
cadanalyst@gmail.comhttp://cadanalyst.slack.comhttp://linkedin.com/in/cadanalyst

deegeecees

  • Guest
Re: Wav File Playing...
« Reply #19 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.

Keith™

  • Villiage Idiot
  • Seagull
  • Posts: 16899
  • Superior Stupidity at its best
Re: Wav File Playing...
« Reply #20 on: October 11, 2005, 04:55:54 PM »
Proud provider of opinion and arrogance since November 22, 2003 at 09:35:31 am
CadJockey Militia Field Marshal

Find me on https://parler.com @kblackie

MP

  • Seagull
  • Posts: 17750
  • Have thousands of dwgs to process? Contact me.
Re: Wav File Playing...
« Reply #21 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
Engineering Technologist • CAD Automation Practitioner
Automation ▸ Design ▸ Drafting ▸ Document Control ▸ Client
cadanalyst@gmail.comhttp://cadanalyst.slack.comhttp://linkedin.com/in/cadanalyst

Andrea

  • Water Moccasin
  • Posts: 2372
Re: Wav File Playing...
« Reply #22 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'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.
Keep smile...