LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

how can I get good performance in LabVIEW while playing .WAV files?

I have been using the LabVIEW "play sound VI" for some time, but have noticed that if I have multiple threads running, the performance on other threads is very slow. Is there anything I can do to improve performance, other than not playing the sound?
0 Kudos
Message 1 of 4
(2,397 Views)
Try to use PlaySound from Windows API ...
you can find it in "winmm.dll" and its description (from MSDN, where you can find details about parameters) is

PlaySound
The PlaySound function plays a sound specified by the given filename, resource, or system event.

BOOL PlaySound(
LPCSTR pszSound,
HMODULE hmod,
DWORD fdwSound
);

Let me know if you need details ...
0 Kudos
Message 2 of 4
(2,397 Views)
I'm sorry, I don't know how to use this information.

I have the vague feeling that I need to use the LabVIEW "Call Library Function" to call this function, but I have no idea how to specify the calling convention or parameters.

I looked around the MSDN to try to figure out what LPCSTR means in terms of the available parameters under the LabVIEW Call Library Function Parameter Type values that are available (i.e., the available selections are:
C String pointer
Pascal String Pointer
), but the web site seems too huge for an amateur like me to figure out where to go.

I gave things a shot by looking at the "play sound" example VI in "Examples...", which was rather helpful.

(Exact path for this VI was:
C:\Program Files\National Instruments\LabVIEW 6
\examples\Dll\sound\playsnd.llb\Play Sound.vi)

However, when I ran my VI, it crashed LabVIEW.
So obviously, I don't know what I'm doing & I'm feeling like I'm out of my league here.
0 Kudos
Message 3 of 4
(2,397 Views)
Hi,
It seems that I forgot some details ... so:
1. I assumed that you are using sound related functions from LV palette ... I'm saying this because I noticed that the name of the LV built in function is "Snd Play Wave File".
2. Those data types involved are :
LPCSTR - Pointer to a constant null-terminated string of 8-bit Windows (ANSI) characters.
DWORD - 32-bit unsigned integer.
HMODULE - Handle to a module. (this one is somehow complicated to explain, so let's say it's a LONG pointer)
For LV data types used when calling a library function, there are some Knowledge Base articles.
3. I thought that calling a Windows API functions could be a chance to an improvement. Thus, Windows API contains 2 functions to play a wave file: Pla
ySound and sndPlaySound. I suggested PlaySound because is more powerful. I mentioned MSDN for details thinking that you may need to use some of those flags. (if you need them, find attached document including their descriptions)
4. The example that you mentioned, I tried it and is working properly. It uses sndPlaySound. You can find in LV TOOLv18 [http://hamiltondesign-consulting.com/Utils.htm] another one (using PlaySound) along with some other useful VIs.

Let me know if you still have problems.
0 Kudos
Message 4 of 4
(2,397 Views)