Compare seewave::fund and tuneR::FF

61 views
Skip to first unread message

Jeff Oliver

unread,
Aug 26, 2020, 8:12:19 PM8/26/20
to seewave
When using seewave::fund, it always seems to over-estimate the fundamental frequency, while tuneR:FF provides more accurate estimates. I would really like to use the seewave::fund version, because it provides a time series of fundamental frequency values, while tuneR::FF does not. Is this a known bias in seewave::fund?

A comparison of the two approaches is shown below.

# Simulate a 440Hz tuning fork
synth_440 <- seewave::synth(f = 44100,
                            d = 1,
                            cf = 440,
                            output = "Wave")

# Look at the frequency spectrum
f_spec <- seewave::fpeaks(spec = seewave::spec(wave = synth_440),
                          nmax = 2,
                          xlim = c(0, 1),
                          ylim = c(0, 1.1),
                          digits = 3)

# Use seewave::fund to calculate fundamental frequency
synth_fund <- seewave::fund(wave = synth_440,
                         plot = FALSE,
                         fmax = 500)
# Look at mean and median of fundamental frequency values
mean(synth_fund[, 2])
# [1] 0.4445222
median(synth_fund[, 2])
# [1] 0.4454545

# Compare with fundamental frequency calculation from tuneR::FF
synth_period <- tuneR::periodogram(object = synth_440)
synth_ff <- tuneR::FF(object = synth_period)
synth_ff
# [1] 439.9125

Jérôme SUEUR

unread,
Aug 28, 2020, 2:19:53 AM8/28/20
to seewave GROUP
Dear ?,
synth:fund() and tuneR::FF() do not use the same processes. synth:fund() uses a cesptral approach when tuneR::FF() seems to use a peak search heuristic.
The cepstral approach works better for harmonic sounds (not pure tones as in your example). In addition in your example you use a 512 sample window for seewave:fund() (default setting)  but a 65536 sample window for tuneR::FF() (default setting).

Here is another test :

synth_440 <- seewave::synth(f = 44100,
                            d = 1,
                            cf = 440,
                            harmonics=c(1, 0.5, 0.2, 0.1),
                            output = "Wave")
## seewave
synth_fund <- seewave::fund(wave = synth_440,
                         plot = FALSE,
                         fmax = 500)
mean(synth_fund[, 2])
[1] 0.4432127
median(synth_fund[, 2])
[1] 0.441
## tuneR
synth_period <- tuneR::periodogram(object = synth_440, width=512)
synth_ff <- tuneR::FF(object = synth_period)
mean(synth_ff)
[1] 433.2245
median(synth_ff)
[1] 435.8465

I hope this helps a bit.

Best regards,

Jerome


De: "Jeff Oliver" <jeffrey...@gmail.com>
À: "seewave GROUP" <see...@googlegroups.com>
Envoyé: Jeudi 27 Août 2020 02:12:19
Objet: [seewave] Compare seewave::fund and tuneR::FF

--
You received this message because you are subscribed to the Google Groups "seewave" group.
To unsubscribe from this group and stop receiving emails from it, send an email to seewave+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/seewave/2d55ca53-c955-4864-99d5-e24155c2a027n%40googlegroups.com.

Jeff Oliver

unread,
Aug 31, 2020, 6:19:19 PM8/31/20
to seewave
Great to know. The sounds we are ultimately going to be looking at are buzzes created by bees, which have harmonics, so it looks like seewave::fund() is going to be the best approach. We were trying to check our approach with pure (known) sounds from tuning forks, but this does not appear a fair comparison. Thanks again for the explanation.

Cheers,

Jeff

Jérôme SUEUR

unread,
Sep 1, 2020, 10:43:30 AM9/1/20
to seewave GROUP
I can confirm seewave::fund() that works with hymenoptera buzzes.
Enjoy your research,
Best
Jerome


De: "Jeff Oliver" <jeffrey...@gmail.com>
À: "seewave GROUP" <see...@googlegroups.com>
Envoyé: Mardi 1 Septembre 2020 00:19:19
Objet: Re: [seewave] Compare seewave::fund and tuneR::FF

Reply all
Reply to author
Forward
0 new messages