LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

To play a part of a wave file

Hello to everyone,
I want to play a part of a wave file in LabWindows/CVI as a part of my project. I tried to make it in LabView and tried to use its dll shared library in LabWindows/CVI, but because of the .net assembly errors (Managed Debug Assistant Loader Lock error) I couldn't achieve to use the dll.
Is there any other method to play a part of a wave file (.wav) in LabWindows/CVI ? Or do I have to code it myself?

Any ideas would be really appreciated,
Thanks,
--
Burcu
0 Kudos
Message 1 of 10
(7,921 Views)
Hi malahuena,
 
Included in CVI 8 there is a sample project called 'sndplay'. From memory this was in CVI 7 too, not sure about earlier versions.
 
C:\Program Files\National Instruments\CVI80\samples\sdk\audio\sndplay.prj
 
Diz.
0 Kudos
Message 2 of 10
(7,910 Views)
Hi,
I investigated the project you mentioned, but it uses Windows SDK functions to play the file. And this function plays the whole wave file.
I have to play a part of a wav file.So I can not use it..:(
Thanks,
--
Burcu
0 Kudos
Message 3 of 10
(7,888 Views)
If you are looking to play the same snippet of a wav file, you can go and rip that portion out of the bigger wav and make your own wav file.  There are many packages to allow that.  I've used Easy CD-DA Extractor to just such a thing.
0 Kudos
Message 4 of 10
(7,855 Views)
You may also be able to use the Windows Media Player ActiveX control to programmatically fast forward to a specific time and stop after an amount of time elapses. I'm not for sure on this, but it could be another solution if editing the wav file is out.

Brandon Vasquez | Software Engineer | Integration Services | National Instruments
0 Kudos
Message 5 of 10
(7,845 Views)
Hi.

I have attached some C code*** which will play a portion of a .wav file. You can test this in CVI's interactive window.

This requires the Windows SDK. If it is not present, and you have access to the LabWindows / CVI setup files, you can repair or modify the installation via Control Panel / Add/Remove Programs.

Good luck,
Colin.

*** copied from here.
Message 6 of 10
(7,828 Views)
We have an ActiveX control for sound recording and playback that is now free to use (with the caveat that there is no support for those who use the free licence).
 
More information here.
--
Martin
Certified CVI Developer
0 Kudos
Message 7 of 10
(7,815 Views)
Hi,
Thanks for your help. I have the samples data, I mean I know the 'start sample and the finish sample'. So how can I calculate the 'seconds' which refer to these samples?
--
Burcu
0 Kudos
Message 8 of 10
(7,782 Views)
Hi,
Thanks a lot for the sample code. I installed the Windows SDK and now I am using this code to play a part of a wav file, and it works fine.

--
Burcu
0 Kudos
Message 9 of 10
(7,765 Views)
You can do the same thing using sample numbers.

Here is the modified code, without error checking:

**************************************************

#include <windows.h>
#include <mmsystem.h>

// Open a Wave Audio device, associating it with a wav file, and wait for the operation to complete
mciSendString("open \"c:\\windows\\media\\Windows XP Startup.wav\" alias mysound wait", 0, 0, 0);

// Set the time format to samples (note: default format is milliseconds)
mciSendString("set mysound time format samples", 0, 0, 0);

// Play the selected part of the waveform and wait for this operation to complete
// (if the sample rate is 22000, this will play from 1000 to 3000 ms)
mciSendString("play mysound from 22000 to 66000 wait", 0, 0, 0);

// Close the device, and wait for this operation to complete
mciSendString("close mysound wait", 0, 0, 0);

**************************************************

(I found the information here)

Regards,
Colin.

0 Kudos
Message 10 of 10
(7,757 Views)