Re: AMDF shortcuts for SOLA time stretching?

View: New views
1 Messages — Rating Filter:   Alert me  

Re: AMDF shortcuts for SOLA time stretching?

by Mattijs Kneppers :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi,

I'm new on this list, and happy to read the interesting discussions that are going on here (although I'll have to acquaint myself with some of the jargon).

I just finished a time stretching implementation, more or less PSOLA, that you might be interested in. I think the quality comes close to the zplane stuff.

You can find it here, it is done in MaxMSP 5 and it's open source: http://www.cycling74.com/twiki/bin/view/Share/MattijsKneppers

Best,
Mattijs

----- Original Message ----

> From: James Chandler Jr <jchandjr@...>
> To: A discussion list for music-related DSP <music-dsp@...>
> Sent: Wednesday, April 23, 2008 7:26:37 AM
> Subject: Re: [music-dsp] AMDF shortcuts for SOLA time stretching?
>
> Hi Ross
>
> I look at all local maxima, both positive and negative. Autocorr of all peaks
> against all other peaks (within the max/min autocorr time limits) seems to give
> 'the very worst matches' along with 'the very best matches'. A very bad score
> might happen when doing correlation between a positive peak and a negative peak
> about 1.5 wave periods distant, or whatever.
>
> Quality-scaling of the array of AMDF values is a simple formula which
> incorporates the very worst score found, so it is nice to find the really bad
> ones along with the good scores.
>
> //high-level check after calculating an array of AMDF scores in a time slice
> BestBeatPeriodicity := (AutoCorrMaxVal - AutoCorrMinVal) / AutoCorrMaxVal;
> if BestBeatPeriodicity < 0.7 then //don't mess with bad periodicity loops
>   goto Skip1; //nothing to see here folks, move along
>
> Using peaks 'seemed like a good idea at the time'. I think the reasons not to
> use zero-crossings, were mostly:
>
> 1. If a file contains low level noise, perhaps the low-level noise would
> modulate the locations of zero crossings more than it would modulate the
> locations of loud peaks.
>
> Viewing wave-animations or oscilloscope traces of some instruments, you see
> higher harmonics 'rippling' or 'slip-sliding' across the tops of lower
> harmonics. This can modulate the peak locations, but I think it is far more
> likely to modulate zero crossing locations.
>
> 2. More importantly, some signals have significant long-duration DC shifts,
> usually near note-on locations. Notorious on Guitar or Electric Bass, though it
> can also be seen in Vocals or Sax, whatever.
>
> For instance, a guitar note can get DC-shifted A LOT for ahile after the
> beginning of the note. This plays hob with zero-crossing locations, but does not
>
> significantly affect the time-location of the local peaks. Even if an aggressive
>
> note-on 'bottom peak' happened to get shifted above the zero line, you still can
>
> detect the time location of a severely-shifted 'bottom peak' by marching thru
> the samples and marking all slope reversals.
>
> Long ago I tried getting rid of transient DC shifts with sharp hipass filters,
> to make zero-crossing detection better. But that didn't help much if at all. If
> anything, it caused note-ons to have a 'double bounce' in DC level, making it
> worse.
>
> ===
>
> The nonrealtime beat detection provides some luxuries that would be difficult in
>
> a realtime plugin that never knows what is coming next.
>
> This code has an analysis option for 'fine-tuning' the short-loop detection,
> once the best 'gross' locations are found. The fine-tune option is used for only
>
> some instrument types. Given the best-scoring 'gross' short-loops, it will do
> AMDF sample-by-sample over a time range of +/- 1 semitone, to find if there is a
>
> better score in the vicinity of that 'best score'.
>
> I expected this fine-tune option to be most useful with instruments using pretty
>
> short autocorr ranges, such as Sax. Strangely enough, the fine-tune short-loop
> discovery was fairly useless for short-autocorr range mono instruments, but a
> noticeable improvement for long-autocorr range chord instruments such as
> acoustic guitar. Not expected, since a short-loop on a chord is several
> milliseconds, and one might not expect a change of a couple of samples' distance
>
> to matter much.
>
> Debug-watching the fine-tune loop, it looked like perhaps 20 percent of short
> loops would get modified from the 'gross detection length', and typically only
> by one or two samples. It seems surprising that the 'gross peaks' distance is so
>
> frequently near optimum.
>
> ===
>
> In previous programs, for time-domain pitch detection or stretching, I would
> start at some anchor point, and do a loop of autocorrelation or AMDF at semitone
>
> distances (to save compute time). Perhaps 24 autocorrelations for a distance of
> 2 octaves. Then I would do a second fine-tune loop for +/- 0.5 semitone,
> sample-by-sample, centered on the best gross score.
>
> That didn't work any better than the current method of just comparing all peaks
> to all other peaks, and the peak cross-correlation perhaps runs faster.
>
> ===
>
> If a note lasts a long time, maybe one second or more, the current
> CompareAllPeaksAgainstAllOtherPeaks, requires a potentially big temporary score
> array.
>
> For instance, if you wanted to accomodate an array of a max of 1001 peak
> locations (lots of peaks in a long note), then a fully-filled out array of
> cross-correlations, I think, would be a triangular number-- (n^2 + n) / 2. So
> for 1001 peaks, a fully-populated cross-correlation array would need 501501
> elements?
>
> But since there are max and min autocorr distance limits, and the
> cross-correlation array doesn't have to be fully populated, it isn't quite that
> bad.
>
> Set some debug values to fire if I ran out of array space, and in practical
> usage, the array of peak locations had to be inched up to 8000 to 'never fail'
> on very long notes. But a cross-correlation array size of 500,000 elements
> turned out big enough to never fail in practice. Perhaps it could be
> significantly smaller than that, but I got tired of fiddling with it.
>
> jcjr
>
> ----- Original Message -----
> From: "Ross Bencina"
> To: "A discussion list for music-related DSP"
> Sent: Tuesday, April 22, 2008 6:41 AM
> Subject: Re: [music-dsp] AMDF shortcuts for SOLA time stretching?
>
>
> > Thanks for your usual generosity in sharing all the interesting details James,
>
> > I didn't find that tedious at all.
> >
> > I found the "Good Short Loops" bit especially interesting.. I'm still not sure
>
> > how you find it easier to find peaks instead of zero crossings for
> > autocorrelation anchor points. When you say 'peaks' do you mean all local
> > maxima? or maximum point between adjacent zero crossings? Is your resoning
> > that the peaks provide a larger set of potential anchor points to work with?
> >
> > Best wishes
> >
> > Ross.
>
> --
> 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

--
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
LightInTheBox - Buy quality products at wholesale price