LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Sound Merging in Music Instrument tones

Solved!
Go to solution

Hello, I am a LabView fresh learner and I am doing a project call Sound Merger.

This project goal is merge 2 (or more) music instrument tones, and get the averaged tones.

 

Capture.PNG

https://en.wikipedia.org/wiki/Piano_key_frequencies

 

Lets take the example of Piano, it has 88 keys which mean 88 tones, each tone has it own frequency.

For my project, if the user chosse the input tones of Key88(4186.01Hz) and Key86(3729.31Hz),

then the expected output of averaged tones should be ( (4186.01Hz + 3729.31Hz) / 2 = 3957.66Hz ) ,

which mean the output tone is close to Key87(3951.07Hz).

 

My piano tones files are download from freesound.org

https://freesound.org/people/pinkyfinger/packs/4409

 

I use the  "File Path Control" to read the tone files and wire it to simple read

 

                                  Capture1.PNG                    Capture2.PNG                    Capture3.PNG

 

                                           Sound files(wav)                                                                  Front Panel                                                               Block diagram

 

 

 

I was studying the output of simple read, because the information tell me the data is an array of waveforms, so I guess to get the averaged tone,

maybe I should do the way

a) put them in wavefomrs, average the 2 waveforms, play the averaged wavefomrs

b) put them in array, average the 2 arrays , convert back to sound data and play it

 

By the way, I do not know implement both the ways, and I am not sure wheter the ways are correct.

 

Capture4.PNG

 

I hope you guys can guide me,  I will very appreciate about that.

0 Kudos
Message 1 of 7
(4,989 Views)
Solution
Accepted by topic author Raydivine

Not a bad project, and it will teach you something about sound, waves, etc.  [Have you had physics?  Do you have a familiarity with music, i.e. have you played an instrument, especially the piano?]

 

Here's an experiment to try.  Consider middle C on the piano (roughly 256Hz).  Consider the C an octave above it (roughly 512 Hz).  Play both at the same time.  What notes do you hear?  If you know music, you'll know that you only hear the note "C" (though it may be tricky to figure out which octave(s)).  Yet the average of 256 and 512 is 384, which is close to a G.  Hmm, maybe averaging sounds is a little more complicated than averaging their frequencies ...

 

Bob Schor

0 Kudos
Message 2 of 7
(4,969 Views)

Thanks for reply, I studied physics but my foundation is not strong and I actually know nothing about music instrument. 

I was use the  "+" operator collect the 2 data together and play it, it is just the 2 sounds mixed together, doesn't generate averaged sound.

 

So I think I should do the average in waveforms or average in array way, would you mind to teach me implement one of them?

 

I also seen the virtual piano project in Labview, the tones are generated by sound simulator, which input certain frequency value,

may be the third way should get the 2 frequency values of the 2 sounds,  averaged them then input to simulator, is there any labview block can collect sound frequency?

 

 

0 Kudos
Message 3 of 7
(4,942 Views)
Solution
Accepted by topic author Raydivine

@Raydivine wrote:

I also seen the virtual piano project in Labview, the tones are generated by sound simulator, which input certain frequency value,

may be the third way should get the 2 frequency values of the 2 sounds,  averaged them then input to simulator, is there any labview block can collect sound frequency?

 

 


 

Hi!

 

There is this promising Multitone Generator VI:

 

 

http://zone.ni.com/reference/en-XX/help/371361K-01/lvwave/multitone_generator/

 

 

...but I have never used it.

 

 

 

Thanks for reply, I studied physics but my foundation is not strong and I actually know nothing about music instrument. 

 

Maybe this online course from Ed Doering is a good start for you:

Musical Signal Processing with LabVIEW

 

 

I would be interested in your progress, so don't hesitate to post some of your code

 

 

Regards,
Alex

Message 4 of 7
(4,919 Views)
Solution
Accepted by topic author Raydivine

As Bob_Schor said, playing two notes together has NOTHING to do with averaging them.  

 

It's called MIXING, and doesn't work like you're thinking.

 

If the tones are pure (sinusoidal), and if the mixer is perfectly linear, then the mixed result is simply a waveform with TWO frequencies in it.

 

But piano (or any other musical instrument besides a whistle) tones are NOT pure - they have harmonics, which are other frequencies, related (mathematically) to the fundamental.

 

And if your mixer is non-linear, then it will produce spurious frequencies: the SUM (F1+F2) and the DIFFERENCE(F1-F2) frequencies, and the sums and diffs of various harmonics, making a large ugly mess.

 

If you want to hear what two keys sound like together, just add the two waveforms.  That's good enough for a first go.

 

You have to be careful about headroom, though - if you add a full loudness C and a full-loudness F, then there will be parts of the result that are clipped (that's a non-linear mixer right there), and it will sound like a broken speaker.

 

So, generally, if your individual tones are full loudness (+/- 1.0), then you want to divide them down by 8 or 10 before mixing, so as to avoid clipping.   Then provide a master volume control to adjust the mixed output level.

Steve Bird
Culverson Software - Elegant software that is a pleasure to use.
Culverson.com


LinkedIn

Blog for (mostly LabVIEW) programmers: Tips And Tricks

Message 5 of 7
(4,904 Views)
Ya, thanks for giving me the guide
0 Kudos
Message 6 of 7
(4,879 Views)

I build the first protoType,  the way is using convolution.

 

Based on my tested, the result tone is not so much averaged.

( I choose toneA and toneC as my inputs, its wont exactly come out toneB but a fusion)

 

May be convultion is not best way for my purpose, but I was gain something new about that.

Anyway , thanks for you guys giving me guide , as promised I post my protoType here.

0 Kudos
Message 7 of 7
(4,753 Views)