LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Layering Sound Waves

Hello,
 
I am working on some Sound Studio subs and I need to know how I would take two individual sound waves (or arrays of Y values) and combine them into one so that when the sound wave is played through computer speakers, it sounds like the two are being played together.  If someone could tell me how to do that, Smiley Happy!!!  Thanks.
 
7J1L1M
0 Kudos
Message 1 of 9
(5,282 Views)
You should be able to just add them; after all that's all an analog audio mixer does.  (The superposition theorem is a marvelous thing!)
 
If your sampling rate is marginal, you might want to make sure you add point-by-point, so as to avoid aliasing artifacts and all that.  In any case, though, sound layeriing is just the algebraic sum of your individual waves.
 
eric
0 Kudos
Message 2 of 9
(5,265 Views)
Here's a really rudimentary wav adder.   (You will want to change the input and output file paths, of course)   
For doing this real time, it will take a little refinement, but this should show how easy it is to add waveforms
 
eric
0 Kudos
Message 3 of 9
(5,264 Views)
And here's a pretty lame real time mixer.  NOT the way to do it, but it shows the principle
 
eric
0 Kudos
Message 4 of 9
(5,257 Views)

Eric,

Thank you for your reply.  I am sorry though that I forgot to mention that I use LabVIEW 7.1, not 8.2.  Since I cannot use the VIs you attached, could you:

 

See if you can save them to LabVIEW 7.1

Illustrate the basic principle behind your idea.

 

I would greatly appreciate further help in this!

7J1L1M

0 Kudos
Message 5 of 9
(5,247 Views)

Hay again,

Just wanted to see if my email got through.  Please check my last reply, as I am getting desperate Smiley Very Happy with my sound mixing.  The best I can do makes it sound like aliens!

7J1L1M

0 Kudos
Message 6 of 9
(5,225 Views)

Hello,

 

I saved the VIs back to LV 7.1 and have attached them to the post. Please keep in mind that the sound libraries changed from 7.1 to 8.0, so once you open these VIs you would find them broken. You would need to replace these VIs with the ones available in the Graphics and Sound sub-palette in LabVIEW 7.1.

 

Regards,

Chetan K

Application Engineering

National Instruments

 

Download All
0 Kudos
Message 7 of 9
(5,202 Views)

Thank you for your reply.

I'm afraid the first VI gives me the same results I had (alien sounding), and while the second one can play two sounds at the same time, what I really need is to be able to combine them into one wave.  Like what Microsoft Sound Recorder does.  In its menu, it has an option where you can mix another sound onto it.  It does not play two files at the same time, but actually puts them together.  That is why I can't use a live mixer, because I need to combine the actual waves into one actual file, so that you could take two wave files and combine them into one, but it would not sound like aliens Smiley Very Happy.  Do you know the method or math for doing this?

7J1L1M

0 Kudos
Message 8 of 9
(5,196 Views)

What is the sampling rate of your sound card?  If you aren't oversampling by quite a bit, you might be getting a lot of aliasing.

Check out:  www.earlevel.com.  It's one of the best sites on general digital audio there is.  (Because the author is my brother-in-law!)

 

eric

0 Kudos
Message 9 of 9
(5,191 Views)