From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Modifying the Sound File to Sound Output VI

Hi there,

 

I am very new to LabVIEW and I am currently making a VI for an electronic drum for a college project. 

 

I was wondering if its possible to modify the Sound File to Sound Output VI so that it has an input which stops and starts the VI.

 

Basically I have the VI within in a case structure. When the drum is hit, the case structure is true, the Sound File to Sound Output VI plays a sample. When false, it does nothing.  The problem is when i hit the drum, the Sound File to Sound Output VI waits for the sound to end before another sound is played again from a hit.

 

I tried adding a boolean switch connecting to a Compund Arithmetic OR box which is then connected to STOP in the while lop within the Sound File to Sound Output VI. Then made the switch an input for a SubVI using the connector pane. But when I run the Sound File to Sound Output VI now I get a sound card error.

 

Any help would be appreciated.

0 Kudos
Message 1 of 8
(3,225 Views)

Zerroth -

 

LabVIEW works in a way that when an action is iniciated, in this case the Sound File to Sound Output VI  the following action (stop sound) will only execute when the Sound File to Sound Output VI has finished.

 

I'm guessing you are trying to work out drum patterns and drum rolls. which is why you would need to receive a new input before it finishes, am I right?

 

The way I see it you are limited by the size of your sound file, and your DAQ card, LV can make acquisitions in speeds in the mille seconds, If your sound is that short you can make drum rolls no problem.

 

As far as I see with some local variables you could make a full drum kit.

 

Again it all depends on how long your sound file lasts;

 

Best Regards

 

Bruno

Bruno Noronha

Certified LabVIEW Associate Developer





Using LabVIEW 8.6
0 Kudos
Message 2 of 8
(3,211 Views)

Hi,

 

It may be beneficial to see the code in this instance. Would that be possible? We can then look at the best way of implementing the sound so that it doesnt wait for the last sound to finish before playing the next one. The application sounds very interesting though!

 

As Bruno said, because LabVIEW is a dataflow development environment, a node will not execute until all the inputs it needs are available. This may be what is happening, where the sound file is a required input for the next node and has to finish before the next one starts.

 

Best Wishes,

Mike W
Applications Engineer
National Instruments UK&Ireland
0 Kudos
Message 3 of 8
(3,190 Views)

Hi there,

 

Thanks for replying. 

 

Using Sound Forge I made the sound shorter the sound sample shorter. It works better but you dont here the sound as well.

 

I have attached the Drum VI to the this post.

 

Again, thanks for the help.

 

Emile

 

 

 

 

0 Kudos
Message 4 of 8
(3,172 Views)
Hi again, I have run into another problem. I plan to add volume to the code as in the harder you hit it the louder it will be. The pictures attached shows the error list and the consumer section of the code. In the code i put in a "convert from dynamic memory to dbl" because i had an error before that saying the source was dynamic and the sink was DBL But I cant solve this current error because i dont know a way of converting a 1D Boolean Array to a Boolean. Thanks again in advance for the help, Emile
Download All
0 Kudos
Message 5 of 8
(3,151 Views)

Emile -

 

I was discussing your application with the guys here at AE department of NI Brazil. After some discussion on what could and could not be done and a couple testes, and analysing your code we came up with an idea.

 

Inside the Sound File to Sound Output.vi you will need a reset button associated to a local variable. Each time the drum pad is hit the local variable will reset the sound. This means that the sound will be played until it receives a reset command so the sound can either play till the end or be cut during the execution. Speed of the reset button will depend on your computer but it should be in the range of a couple milliseconds. 

 

However, analising the VI I noticed that it defines the number of samples per iteration. This means that the sound is split into interations each with a defined number of samples.  If the reset button is pressed, it will only execute at the end of the interation, which means you may have unwanted delay.

 

A way around this problem is using Active X to access the Windows media player to play the sound. With the media player you can stop the sound in the middle without any problems. I have included a simple Active X vi below.

 

The volume can also be adjusted in the Sound File to Sound Output.vi

 

there is subVI called Sound Output set Volume.vi (it is inside the while loop ). This VI determines the sound level of your signal. You are going to have to use some logic here to adjust your signal strength to be a value between 0 and 100 and perhaps again use a local variable as a controle for the volume.

 

I know this isn't the easiest solution but it is the only one that seems plausible to me.

 

 

Best of Luck

 

Bruno

Bruno Noronha

Certified LabVIEW Associate Developer





Using LabVIEW 8.6
Message 6 of 8
(3,137 Views)
Thanks again for the help Bruno. Unfortunately though the version LabVIEW thats installed on this computer is 8.5 and the Windows_Media.vi requires version 8.6 to open. I did however come across this link which las has a Windows Media Player VI which also requires 8.6 but it provides an image of the Block Diagram with it to build it. http://decibel.ni.com/content/docs/DOC-2207 I have put in the code but I am not sure about the settings involved with the Property Node and with Windows Media Player.
0 Kudos
Message 7 of 8
(3,059 Views)

Will this be possible in case of singal generation?

I have a multiple signal and sweep generator and I what to have a stop button to "stop" the current generation in order to star another different.

How can i stpo the current sound output??

regards

 

0 Kudos
Message 8 of 8
(2,467 Views)