ni.com is currently experiencing unexpected issues.

Some services may be unavailable at this time.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How can you crossfade (fade in/out) arrays?

Hi
 
Does anybody know how can you crossfade (fade in/out) arrays that represent a sound signal?
 
i have a series of segments/arrays that represent my signal after been broken down, and i want to crossfade these arrays for further processing. i am multiplying each segment with a uniform window (Hanning) but i think the correct way to crossfade them is to have a window of twice the length of the segment instead of just being equal to it.
Has anybody done that before, or be able to give me some pointers/tips about this task?Any help is appreciated.
 
Regards
Madgreek 
0 Kudos
Message 1 of 85
(5,536 Views)

Madgreek:

I have never done crossfading signals, however I will be able to help you if you provide me with more information about what you are trying to do. Are you just referring to doing array manipulation/multiplication?

Regards,

Rudi N.

0 Kudos
Message 2 of 85
(5,461 Views)
Hello Rudi
 
basically yes its about array manipulation im referring to. what i want is to overlap arrays (crossfade) by a  certain portion of them (lets say 50%).
 
regards
madgreek
0 Kudos
Message 3 of 85
(5,457 Views)
If I understand your question correctly, then you want to do the following:

Create a window array
    This array should have the same number of elements as each signal you are trying to crossfade
    You probably want it to ramp up (if it is not the first component of the soundtrack), then go flat, then ramp down.
    The durations of the ramp segments will be however long you want the crossfade to take, starting from 0 and building up to 1 (with a similar, but opposite downramp at the end)

Then multiply the the signal and the window element-by-element

Then you need to add the two signal arrays together (mostly a concatenation, but the ramped segments will be added to each other element-by-element)

At the end of that process you should have the first signal fading right into the other.

Does that make sense?  The window-making algorithm, and the signal-adding method are the fun parts, so I will leave you with those 🙂

Best of luck,
~milq

p.s. if I were doing it, I might piggyback the window array with the signal (2D array) so I could use indexing to determine whether or not a certain portion of the signal was a ramp section or not (would be useful information while performing the "add" operation)
0 Kudos
Message 4 of 85
(5,445 Views)

Hello milq.

I am sorry but i am not 100% sure about what you are saying. Can you please make it a lil more simple than that (i am a lil slow sometimes Smiley Happy)...

In the attached file i am showing what i have done up to now (basically i am feeding my code with the voiced/unvoiced segments, then i re-segment again the voiced ones according to the pitch period present in them and multiplying each one with a Hanning window. The thing is i am not able to concatenate them but just window them. Thats where my problem is.)

Thank you for your time and help

madgreek

Download All
0 Kudos
Message 5 of 85
(5,427 Views)
Attaching code is easier than attaching the pictures, then I can mess with it a bit and see what is up.

But I am not exactly sure what you mean by the following:

"then i re-segment again the voiced ones according to the pitch period present in them and multiplying each one with a Hanning window."

Crossfading can be done completely in the time domain, there is no need to do any spectral analysis, or really anything in the frequency domain.  So I guess I am not quite sure why you are using that windowing function.

What exactly do you mean by "resegment again the voiced ones according to the pitch period"?

I don't understand how that relates to crossfading.  I thought you wanted to do this:
        ____________________ _______________
^      /                                 / \                            \
|      /                                /    \                            \
|     /                                /      \                             \
|    /                                /        \                             \
| Begin A                 Fade         Fade                    End B
                              in B             out A        
   Time ------------->

Am I right?  Is there something else you are doing that requires spectral fiddling?

Sorry I can't be of more help,
~milq

Message Edited by Milqman on 03-23-2007 02:28 PM

0 Kudos
Message 6 of 85
(5,422 Views)
milq
 
Sorry if i was not quite clear about what i needed. Perhaps crossfading was the wrong term to use.
 
My final goal is to be able to time/pitch scale my sound signal using the TD-PSOLA (time domain pitch synchronized overlap add ) algorithm. As a reference, TD-PSOLA segments the signal according to the pitch periods (this is what i meant "resegment the voiced ones, its just the way i have built my code), then concatenates the segments by using a Hanning window of length twice the segments to fade them in/out, with each segment being centered in the window, basically 50% overlap between them.
 
In a few words what i have done up to now is this,1) initially i segmented the sound into segments of 512 samples long each, 2) found whice ones are voiced and which are unvoiced, 3) estimated the pitch period in the voiced ones and  4) i "resegmented" the voiced ones of length 512 into smaller segments of length equal to the pitch period in that specific segment (if the pitch period was lets say 64 samples in any voiced segment, i broke down that segment into pieces of length 64 therefore got 8 segments). You can see this procedure into the 2D array in my code.
 
Now i would like to concatenate the voiced segments (fade them in/out) this is what i meant by crossfade, as i said maybe it was the wrong term to use. I have attached my code with the sound file if you would like to give it a look and get an idea of what i am doing.
 
If i was not clear about something i am sorry and  please feel free to ask me.
 
kind regards
madgreek
Download All
0 Kudos
Message 7 of 85
(5,408 Views)
Ok, I just read up a little bit on what you are trying to do here. (<--- link)

I am leaving work right now (and would normally leave my computer here and ignore LV for the weekend) but this sounds like a fun problem.

I have to run now, but I have my thinking cap on, and we are on the same page.

Enjoy your weekend,
~milq


0 Kudos
Message 8 of 85
(5,399 Views)
You have a great weekend also Smiley Happy
 
Hope to talk to you soon
 
 
0 Kudos
Message 9 of 85
(5,395 Views)
What are you using to pull out the optimum marker locations on your orginal voiced signals?

How long are the signals and how much are you shifting the pitch by?

This is how I would walk through it:

Take in a signal
Determine whether it is voiced or not (from what I have read you basically ignore non-voiced segments)

Voiced signals should probably be broken down into smaller portions each with a smaller bandwidth (so your marking algorithm does not need to do much thinking).  This way you can use the constant pitch assumption later without it biting you too hard.

(just to be clear, I am going to use the word "portions" to describe a chunk of segments/periods that are all of approximately the same pitch, and use "periods" and "segments" interchangably)

A voiced signal needs to be marked (I would do this by giving the array another dimension and using 1's and 0's to determine your marks and spot between marks).  Now you should have a 2xn matrix/array where one column/row is signal and the other is mostly 0's but has 1's cooresponding to the spots on the signal portion where you are at highest power periodic point in the signal. 

Each portion then get passed to a loop (this loop needs a portion, the new desired pitch, the new desired portion length, and the sampling frequency).  I would pass these in by initializing a desired/target 2D array with markers where you want them and all 0's for the signal row/column.

Then that loop iterates through the desired portion/array until it find a marker (1 in the second row/column) when it sees that, it goes into a nested loop
that loop will look through the original/marked/voiced portion and find the 2 periods/segments that "line up with" the current target position.  That inner loop then pops out the starting and ending indexes of those 2 periods.  The bigger loop will grab those segments, hanning window it, and make sure it is of proper length to fit where it needs to go in the target.  Then you add it right in to your target array.  This is the end of that loop, so on the next iteration, it will be searching through the desired array again for the next marker.  You should be able to continue this until there are no more markers in the desired array (aka done).

After you make this and see how it works, you can make a quick chunk of code that will programatically initialize the "desired array template" (with markers and such).

Are we still on the same page?

~milq
0 Kudos
Message 10 of 85
(5,381 Views)