Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Memory Leak in playing Wave sounds

Status
Not open for further replies.

tedsmith

Programmer
Nov 23, 2000
1,762
AU
I get a slight memory leak using the MMControl or using the Wave API calls. Just setting up a simple form to play a 2k beep looses available physical memory bit by bit. I used the standard as per the example, stoping and closing the MMControl. I even set the MMControl to a variable and set it to nothing each time it ends using the Sub Done and it still looses memory. About 4k each time I play the beep. Eventually the computer freezes up as though the stack has run out. I tried it on 3 different computers and get the same result.
The VB Beep control doesnt do it even when I set the default wave file to the same beep.wav in the control panel!
Is there a better third party audio activeX control?
Any suggestions?
 
Yes, use the ActiveX control called Activemovie. You can do a lot more with it and it bypasses all the old software and uses DirectX directly. However, I think that your problem is arising out of the creation and killing of an object under program control. You will find that windows, by nature does not show that the resources are released for certain objects until the next time you create one-Its weird, its microsoft... You can use an activemovie control running in an ap for months at a time, just don't kill it and recreate the object using VB in runtime. You should recycle the function of the object, unless you have to dispose of maybe 40 activemovie objects while keeping the app alive. The only thing I would seriously use MMControl for is a simple audio recorder. Even then you can use MCISendStringA in MMSystem.DLL, which allows you to set sample rates, etc. A good resource is VB Developers Guide to the Win32 API, ISBN 0-7821-2559-X. This book has a good example of using MMSystem.DLL to play and record audio.
 
Thanks Audioplayer!
With a nickname like yours, perhaps you might know the answer to this one?
I want to select and play two wave files (a voice introduction to a tune followed by the tune itself).
The second files starts immediately after the first one finishes but I also want to be able to continue with other input etc immediately the first file starts playing.
If I use API calls I either can't input anything else while the first file is playing or else the second one immediately stops and overides the first one so you don't even hear it. I can do it with the MMcontrol using the "done" thingy but not with any Wave Apis I can find. Is it possible somehow with the MMSystem.DLL?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top