Re: fir allpass filters for phase-alignment



On Dec 11, 2:43 pm, "banton" <bant...@xxxxxx> wrote:
Fred wrote:

....
It seems to me that tweaking the splice is a better idea.  I've done some
of this in generating continous loops from short samples.

One artifact of generating loops from short samples is that the output will
have a discrete spectrum associated with the length of the sample.  Is that
tolerable?  If not, you have a serious problem.  While that's not exactly
what you describe, it may suggest a type of difficulty.

I understand what you describe, and it's definitely not tolerable for
my purpose.  Basically is is exactly what I want to avoid (The influence
of segment length on the periodicity of the output material).


it's not so much the segment *length* that Fred's method (if i do not
misunderstand him) "tweaks", but it is the precise placement of where
the segment is being extracted.

the way i would present this is that Fred's method deliberately adds
an amount of jitter in the new segment location (that is limited to a
specified number of milliseconds) where the segment that is ending is
most correlated to the new segment. this is what is done in simple
time-scaling or pitch-shifting (the WSOLA method). the jitter is
enough to make your splices sound better, but not so much as to screw
up the overall beat or tempo of what you are listening to.

If the waveform is a general one then let's split it into two types:
1) periodic
2) aperiodic

- For a periodic waveform, a splicing approach would be to have a FIR filter
with a single nonzero coefficient.  Here I'm assuming that the sample rate
is very high or that we're talking about an analog delay line as the FIR
filter.  All you have to do is set the delay to an appropriate value and
there will be no splice transient - the delay (or the skipped part of the
record) is an integer number of periods.

That's simple, and you don't even need a very high sampling rate, if
you use fractional delay filters (e.g use lagrange to generate the
kernel)

or linearly interpolate to get fractional delay. or upsample a little
and linearly interpolate. (you have bigger issues with artifacts,
like bad splices.)

- For an aperiodic waveform there is *no* theoretical solution.  But, as has
been observed here many times (I credit Jerry with this idea) one can come
arbitrarily close as the delay time is increased.  Example:  The signal is
the sum of a 1 Hz sinusoid and a PI Hz sinusoid.  It is not periodic because
the two constituent frequencies aren't rationally related.  But, the longer
you're willing to wait, the closer they *appear* to be periodic - at some
point the difference is lost in the noise.

well, if it isn't "white" noise, what happens is that you can find
some splice displacement where the energy of the difference is at a
local minimum and less than the energy of the signal. but if the
"periodicity" is very low (more noise-like)

This is also clear to me and I have done some sound synthesis things
related to what you describe.





How does this apply to your application?  I'm not sure what you're trying to
accomplish overall.  What I will observe is that the approach of using a
"filter" has long time implications while the approach of using a pure
"delay line" has no long time implications.  A delay line is a *perfect* all
pass and the phase matching is as good as you can accomplish as above
(... I think).

The challenge seems to be to find an appropriate delay.  What if you did a
short-term correlation between the signals to find a likely splice point?

or Average Magnitude Difference Function (AMDF) or Squared difference
(ASDF).

I am already doing that to localize the splice points.
The allpass filtering comes afterwards to do phase correction.

phase correction of *what*?? phase and delay, while not exactly the
same concept, are almost the same thing. at least they are not
independent.if i do not misunderstand you, you have already adjusted
the phase to get the least amount of "glitch" in the splice. now, if
due to non-periodicity, you want to adjust the phases of different
sinusoidal components independently, you need to do either a multiband
"time-domain" splicing scheme, or something like the phase vocoder to
lose the glitches in the non-periodic portions.


Then, don't filter at all - just splice the raw signals (which is an
implementation of the delay line approach).  In fact, that's implied by
your all-pass

....

All the things you mention are closely related to synthesis
methods that I am using and in fact I have played around with
all of this ideas.
The keypoint is that I am now looking for a way to shift the
internal phase relations of the material around to create improved
matches.  It smears out some signal contents in time and shifts
components out of their original phase relation. But limited by
the size of the applied allpass filter; so as long as
the filter is small, say 256 .. 512 samples, not a problem for me.

The filters, simply created by measuring
the phase differences in 2 frames around the transition point
_do_ allready significantly improve the correlation of the
two signals.  But I am certain that I can improve the way,
I create the filters.

Maybe, it helps if I relate the method to phase-vocoding.
A phase-vocoder estimates sinusoidal bins and as long as
those are distant enough to be identified in the spectrum,
the phase-vocoder doesn't care if components have rational
frequency relations or not (in other words: if the signal is
periodic).  In the resynthesis the phases of the components
are continuous.  So you can for example time-stretch an
inharmonic sound.
This comes with the expense of blurred spectra and other
artifacts through the difficulty to estimate the time-varying
sinusoids from fourier frames.

the "blurred spectra and other artifacts" that come from the p-voc is
due to the fact that, in an inharmonic sound, no single amount of
delay lag will perfectly match for all frequency components. but for
harmonic (or "quasi-periodic") sounds, the cross-correlation or AMDF
*will* find a lag that *does* make all harmonics happy. the amount of
phase shift that this results for the 2nd harmonic is exactly twice
that of the 1st. for each harmonic, in a time-scaling application,
you are splice in or out an integer number (call it M) of cycles of
your periodic waveform. so, for the first harmonic, you are splicing
in or out M sinusoidal cycles. for the 2nd harmonic it's 2M, for the
3rd it's 3M and so on. now for the inharmonic (or "nonperiodic")
sound, a time-domain WSOLA-like technique might splice some sinusoidal
components happily, but another that is, say, at 4.5 times the
reciprocal of the splice displacement time, that component will be 180
degrees out of phase in the splice and you get a glitch. but, for
periodic sounds, at least the waveshape is preserved.

the p-voc method gets *all* sinusoidal components spliced in phase (by
disassembling the sound into individual sinusoidal components), but at
the expense of sacrificing waveshape since some sinusoidal components
are delayed a different amount of time than others to accomplish
glitch-free splicing for all.

What I am doing works in the time domain and there clearly is
a relation to WSOLA and similar techniques. However, I do
not aim at timescale modification, but rather at "jumping
around" in the wave,

that is only a *generalization* of the jumping around that a WSOLA
timescaler does. you should still be able to add a little jitter
(within a specified limit) and hunt around for the best match for a
splice and get this to sound good for most sounds. what are you
doing? asynchronous granular synthesis?

but you can see the relation since, time-domain
timescalers jump around as well,

well that will teach me for not reading ahead (to the bottom of your
post).

just in a very specific manner.
Even though it is not my original goal (which is simply to synthesize
interesting sounds with experimental methods), I'll pretend from
now on that the goal of what I am doing is to time-stretch chords.

major chords will sound good. minor chords less good. diminished
chords will sound bad.

First I identify points which show correlate.  Then I compare
the phase differences at two selected points and create
a phase-aligning filter which is applied to the next segment.
And so on.. for every jump (or cut or segment boundary, however
you call it) a new filter is created to achieve approximate phase
continuity.
Needless to say, it creates its own kind of artefacts; but
different ones than the pvoc or SOLA based stuff.

i think what you're trying to do is similar to the pvoc, but with
fewer degrees of freedom. if your APF has only a couple of knobs to
tweak, there are only two degrees of freedom. the pvoc will have an
independent degree of freedom for each sinusoid it identifies and
isolates.

Sorry, for the long post, but every reply idicated that
people are puzzled why I want to find a method to create
allpass fir filters that will align-phase values of 2 signals
around a given time-point.

well, first of all, other than simple delays (or less simple
fractional-sample delays), you can't do a general APF with an FIR
because, while you can put your zeros wherever you like in an FIR, the
poles of an FIR remain at the origin. a general (non-pure delay) APF
has the poles and zeros mirrored (as reciprocals) about the unit
circle.

i think i understand what you want to do. some sorta Acid or similar
or an async granular synthesis thingie. the best i can recommend is
jitter your segment locations a little to get the best match for
splicing. another thing is to use splicing functions that can
gracefully vary between "constant-voltage" crossfades (for splicing
completely correlated sound segments) to "constant-power" crossfades
(for splicing completely uncorrelated sound segments). this is what i
was thinking about back in 1998 when i posted this:

http://groups.google.com/group/comp.dsp/browse_frm/thread/b332e8223828f222/befae9679b77ec96

note that we came up with a nice answer. if i had pursued this more,
it would be worthy of publication IMO.

r b-j
.



Relevant Pages

  • Re: adaptive sine-wave cancellation
    ... Since he is using a sinusoid for the test signal, ... that will work - depending on the length of the filter. ... For a finite-length filter that's not "infinite" but I get the ... delay and a particular amplitude. ...
    (comp.dsp)
  • Re: Even order of Hilbert Filter
    ... delay is integral. ... ANY filter that has odd symmetry and zero real part in the frequency ... at and near Fs/2. ...
    (comp.dsp)
  • Re: Regarding DC removal filter.
    ... moving-average filter to determine a DC component, and subtracting ... moving average filter is both linear-phase and low-computation. ... is cheap and long throughput delay is acceptable, ... a DC blocker is an HPF (with at least one zero at z=1 ...
    (comp.dsp)
  • Re: automated FSL tests
    ... zeros at 999 and 1001 kHz. ... a group delay of 10 s at 1 kHz, ... You are describing a particular incident pulse and a filter transfer ... at least for an ideal phase conjugation process. ...
    (comp.lang.forth)
  • Re: strange behaviour of ntp peerstats entries.
    ... But the filter goes well ... The procedure does drastically reduce the variance of the delay, ... meaning that ntp suddenly has no data to do anything with for many many ...
    (comp.protocols.time.ntp)