DSPRelated.com
Forums

Cepstrum problems

Started by VelociChicken April 6, 2008
Hello, I'm getting a lot of noise on my cepstum plots, and I wondered if I'm 
creating them correctly. Even when I play a simple sinusoidal sound, I'm 
getting spikes at certain places, but unstable at other note pitches. I 
can't currently see how anyone could track pitch if it's right. I tried all 
combinations of step and FFT point sizes, plus different windowing 
functions.
Also, from the docs on the web it seems 80% have it as   FFT > Log  >  IFFT 
which confused the heck out of me for a while. I'm guessing it actually 
really is 'spectrum of a spectrum' - here's what I do in dodgy fake code:-

NPOINTS = 2048

Hann window signal at NPOINTS width, with step of 1024

spectrum = FFT (signal, NPOINTS)

Of  'spectrum'
{
    magnitude = 2.0f * sqrtf(real*real + imag*imag)
    mag_signal = 10.0f * log10f(magnitude)
}

// divide by two because it's a half  NPOINTS (0 - nyquist) of magnitudes

cepstrum = FFT (mag_signal, NPOINTS / 2)

Of  'cepstrum'  0 - NPOINTS/2
{
    magnitude = 2.0f * sqrtf(real*real + imag*imag)
    plot (binNum, magnitude)
}

Cheers, hopefully somebody understands the above and easily set's me right!

Thanks,
VC






On Apr 6, 4:13 pm, "VelociChicken" <b...@yahoob.com> wrote:
> Hello, I'm getting a lot of noise on my cepstum plots, and I wondered if I'm > creating them correctly. Even when I play a simple sinusoidal sound, I'm > getting spikes at certain places, but unstable at other note pitches. I > can't currently see how anyone could track pitch if it's right. I tried all > combinations of step and FFT point sizes, plus different windowing > functions. > Also, from the docs on the web it seems 80% have it as FFT > Log > IFFT > which confused the heck out of me for a while. I'm guessing it actually > really is 'spectrum of a spectrum' - here's what I do in dodgy fake code:- > > NPOINTS = 2048 > > Hann window signal at NPOINTS width, with step of 1024 > > spectrum = FFT (signal, NPOINTS) > > Of 'spectrum' > { > magnitude = 2.0f * sqrtf(real*real + imag*imag) > mag_signal = 10.0f * log10f(magnitude) > > } > > // divide by two because it's a half NPOINTS (0 - nyquist) of magnitudes > > cepstrum = FFT (mag_signal, NPOINTS / 2) > > Of 'cepstrum' 0 - NPOINTS/2 > { > magnitude = 2.0f * sqrtf(real*real + imag*imag) > plot (binNum, magnitude) > > } > > Cheers, hopefully somebody understands the above and easily set's me right! > > Thanks, > VC
VC It is difficult to respond to your posting because: 1) You haven't told us just what you are trying to achieve. 2) You haven't told us just what you have done. 3) You haven't told us just what the inputs you have used are, what were the results and why you think they are wrong. I have some questions: Why did you choose real as opposed to complex cepstrum? What reference suggested decreasing the transform size in the process? Some things you might do to get a more useful response: 1) Instead of collecting many references and calculating a vote, develop an approach to picking a good reference and stick with it, then tell us what you picked and why it matched your goals. 2)Try writing consistent readable code. its hard enough to get people to review code, even harder when you insist on 'dodgy' and 'fake' code. 3) Tell us some specifics of the things in the first list. If you have picked an accessible reference, it may make this easier. Good luck Dale B. Dalrymple http://dbdimages.com
On Apr 6, 3:13 pm, "VelociChicken" <b...@yahoob.com> wrote:
> Hello, I'm getting a lot of noise on my cepstum plots, and I wondered if I'm > creating them correctly. Even when I play a simple sinusoidal sound, I'm > getting spikes at certain places, but unstable at other note pitches.
A cepstrum reports the spacing of any harmonic overtone series found. But a pure sinusoid should have no overtones (nor any visible formant envelope). Try a more complicated waveform, say a sinusoid plus 10 or so harmonics. You also might want to try zero-padding the 2nd FFT to retain some quefrency resolution. IMHO. YMMV. -- rhn A.T nicholson d.0.t C-o-M http://www.nicholson.com/rhn/dsp.html
"Ron N." <rhnlogic@yahoo.com> wrote in message 
news:bc199e3b-c32e-453a-8dbf-78379c952b13@l28g2000prd.googlegroups.com...
> On Apr 6, 3:13 pm, "VelociChicken" <b...@yahoob.com> wrote: >> Hello, I'm getting a lot of noise on my cepstum plots, and I wondered if >> I'm >> creating them correctly. Even when I play a simple sinusoidal sound, I'm >> getting spikes at certain places, but unstable at other note pitches. > > A cepstrum reports the spacing of any harmonic overtone > series found. But a pure sinusoid should have no overtones > (nor any visible formant envelope). Try a more complicated > waveform, say a sinusoid plus 10 or so harmonics. You also > might want to try zero-padding the 2nd FFT to retain some > quefrency resolution.
Hi, thanks for your reply. I have it doing two forward then two backward transforms, and it reproduces the signal perfectly, so I guess it's working. I'm actually using the Fast Hartlley Transform (proposed by an ieee doc that definately speeds things up), so I'm guess I've got my scales all wrong for the log calculation somewhere. I've tried zero padding the 2nd transform, but of course it's all log of the values, so it creates a notch down at the padded part, do I pad with a very small number like log(1e-30) ? Cheers, Dave
> IMHO. YMMV. > -- > rhn A.T nicholson d.0.t C-o-M > http://www.nicholson.com/rhn/dsp.html
On Apr 6, 7:13&#4294967295;pm, "VelociChicken" <b...@yahoob.com> wrote:
> Hello, I'm getting a lot of noise on my cepstum plots, and I wondered if I'm > creating them correctly. Even when I play a simple sinusoidal sound, I'm > getting spikes at certain places, but unstable at other note pitches. I > can't currently see how anyone could track pitch if it's right. I tried all > combinations of step and FFT point sizes, plus different windowing > functions. > Also, from the docs on the web it seems 80% have it as &#4294967295; FFT > Log &#4294967295;> &#4294967295;IFFT > which confused the heck out of me for a while. I'm guessing it actually > really is 'spectrum of a spectrum' - here's what I do in dodgy fake code:- > > NPOINTS = 2048 > > Hann window signal at NPOINTS width, with step of 1024 > > spectrum = FFT (signal, NPOINTS) > > Of &#4294967295;'spectrum' > { > &#4294967295; &#4294967295; magnitude = 2.0f * sqrtf(real*real + imag*imag) > &#4294967295; &#4294967295; mag_signal = 10.0f * log10f(magnitude) > > } > > // divide by two because it's a half &#4294967295;NPOINTS (0 - nyquist) of magnitudes > > cepstrum = FFT (mag_signal, NPOINTS / 2) > > Of &#4294967295;'cepstrum' &#4294967295;0 - NPOINTS/2 > { > &#4294967295; &#4294967295; magnitude = 2.0f * sqrtf(real*real + imag*imag) > &#4294967295; &#4294967295; plot (binNum, magnitude) > > } > > Cheers, hopefully somebody understands the above and easily set's me right! > > Thanks, > VC
Having a lot of frequency components with magnitude near zero and taking the logarithm of those cannot be helping your calculation. Also, you realize that you are doing a "real" cepstrum as opposed to a "complex" cepstrum? Dirk
On Apr 8, 5:44 am, "VelociChicken" <b...@yahoob.com> wrote:
> "Ron N." <rhnlo...@yahoo.com> wrote in message > > news:bc199e3b-c32e-453a-8dbf-78379c952b13@l28g2000prd.googlegroups.com... > > > On Apr 6, 3:13 pm, "VelociChicken" <b...@yahoob.com> wrote: > >> Hello, I'm getting a lot of noise on my cepstum plots, and I wondered if > >> I'm > >> creating them correctly. Even when I play a simple sinusoidal sound, I'm > >> getting spikes at certain places, but unstable at other note pitches. > > > A cepstrum reports the spacing of any harmonic overtone > > series found. But a pure sinusoid should have no overtones > > (nor any visible formant envelope). Try a more complicated > > waveform, say a sinusoid plus 10 or so harmonics. You also > > might want to try zero-padding the 2nd FFT to retain some > > quefrency resolution. > > Hi, thanks for your reply. I have it doing two forward then two backward > transforms, and it reproduces the signal perfectly, so I guess it's working.
In general the real cepstrum is not invertible, since it throws away all the phase information (and even the complex cepstrum has possible ambiguity in the phase unwrapping).
> I've tried zero padding the 2nd transform, but of course it's all log of the > values, so it creates a notch down at the padded part, do I pad with a very > small number like log(1e-30) ?
Since the zero-padding is only used to interpolate more quefrency sample points, it could be zero (and after the log operation, obviously). Before taking the log, you might want to clamp any zeros in the spectrum to just below the noise floor (and any windowing artifacts may render that noise of significantly non-zero magnitude) to bound the total energy of the cepstrum resulting from the 2nd fft.
> > IMHO. YMMV. > > -- > > rhn A.T nicholson d.0.t C-o-M > >http://www.nicholson.com/rhn/dsp.html