On Tue, Nov 30, 2010 at 12:58 PM, robert bristow-johnson
<r...@audioimagination.com> wrote:
>
> On Nov 29, 2010, at 8:50 PM, Element Green wrote:
>>
>> It seems like the algorithm I came up with independently is very
>> similar.  The absolute value of the difference of the sample points is
>> taken as with AMDF.  Prior to summing the values together though, I'm
>> multiplying by the window I described before (with a peak in the
>> center where the loop point is), giving samples closer to the loop
>> point more weight.
>
> it's AMDF (with a more window).  that link above shows the AMDF with a
> rectangular window.  usually "no window" means "rectangular window".  and
> usually we think that rectangular ain't the best kind of window.
>
> you can also square the difference (which is the same thing as squaring the
> abs value).  i might call this the ASDF.  a continuous-time representation
> (used for pitch detection) is depicted as Eq. (1) in the Wavetable-101.pdf
> paper you can find at the music-dsp site.  in fact, you can raise the abs
> value of the difference to any power that's a positive number.  this is
> really the Lp norm where AMDF with be the L1 norm and ASDF would be the L2
> norm.  the higher the power, the more it emphasizes the bigger errors
> (de-emphasizing the little errors).
>
> one more thing about the L2 norm and ASDF is that it can be related directly
> to a form of autocorrelation.  the ASDF is really an upside-down
> autocorrelation (with an offset).  so the ASDF will have nulls or valleys
> precisely where the autocorrelation has peaks.
>


Now I know what I'm working with.  Thanks for that.


>
> Olli has responded with the two particular end-points.  if the two loop
> points are well correlated, you want to use the linear crossfading you
> planned (where the fade-in and fade-out functions always add to 1, that's
> what i call a "constant voltage" crossfade).  but if the two loop points are
> completely uncorrelated (like you would get for white noise), then you want
> crossfade envelopes that are the sqrt() of your constant voltage crossfade
> (you want the square of your envelopes to add to 1, i call that a "constant
> power" crossfade).
>
> you should always be able to find loop points that have correlation of at
> least 0 (completely uncorrelated).  even if it's real crap that you are
> splicing to other real crap, assuming both signals have the DC removed, the
> correlation function will have no DC component and both negative values and
> positive values (with different lags).  you will always want to choose a lag
> with the largest correlation (a normalized correlation as close to 1 as
> possible).  so your correlation will be better than what you would get if it
> was completely uncorrelated white noise.
>

Fortunately this algorithm is usually going to be used on Instruments
which already have a periodic nature.  Seldom will there be a case
where looping white noise is desirable and then the user probably
doesn't need assistance figuring out the optimal location (manually
setting a loop and listening to the result should suffice).

> a few years ago i was investigating this and was considering writing a paper
> for the AES about it.  there is a theory that you can design (on the fly)
> optimal crossfade envelopes for any normalized correlation between 0 and 1.
>  if you want, i can dig up the notes and equations about it.
>

That certainly sounds interesting.  So ultimately a cross fade
function curve could be picked based on the output of the AMDF
algorithm.  I would definitely be interested in the relevant equation
:-)

>> Its a sample/instrument editor, so its all non-realtime.
>
> then what you should do is have your editor test a variety of loop-end times
> and for each of those, find the best loop-begin point (according to your
> AMDF or ASDF measure).  so you would have a list of loop-end candidates,
> each with their optimal loop-begin point (where the begin point and end
> point match the best) and you would choose the loop-end candidate that has
> the best match to its associated loop-begin.
>
> if this is for a simple sampler, and if your sampler can more simply "jump"
> from the loop-end to loop-begin point without the crossfade in real-time,
> then you can *pre*-crossfade the audio data so that the jump is as seamless
> as it would be if it were crossfaded.  that's an old sampling keyboard trick
> (from the 1980s).  it works very well for good matches (well correlated).
>  not sure it would be very good for poor matches, but splices around poor
> matches sound like crap anyway.

Yes, my application (Swami) currently exhaustively searches two ranges
(set by the user) of where to search for start and end loop points.  A
list of results is generated, which are sorted by default by relative
"quality" which is the number obtained from the AMDF algorithm.  There
are also some other parameters for filtering what sort of results end
up in the final list.  This includes the idea of loop groups, where
loops with similar lengths and start positions are considered to be a
part of the same group and only the best result from that group is
used.

The underlying synthesizer is FluidSynth, which does interpolation
around the loop, so it is at least making an attempt to smooth out any
major inconsistencies.  I like the idea of doing on the fly cross
fading though.  At least for auditioning the effect prior to applying
it.

>
> --
>
> r b-j                  ...@audioimagination.com
>
> "Imagination is more important than knowledge."
>

Seems like this topic is getting close to being exhausted for now.
Thank you all for your very detailed and helpful responses.

Best regards,
Element Green
--
dupswapdrop -- the music-dsp mailing list and website:
subscription info, FAQ, source code archive, list archive, book reviews, dsp 
links
http://music.columbia.edu/cmc/music-dsp
http://music.columbia.edu/mailman/listinfo/music-dsp

Reply via email to