sox-users@lists.sourceforge.net unofficial mirror
 help / color / mirror / code / Atom feed
* frequency detection
@ 2021-12-09 11:36 Mikko Olkkonen
  0 siblings, 0 replies; only message in thread
From: Mikko Olkkonen @ 2021-12-09 11:36 UTC (permalink / raw)
  To: sox-users@lists.sourceforge.net


[-- Attachment #1.1: Type: text/plain, Size: 1000 bytes --]

Hello,
I want to detect a frequency of my signal. My signal is "well behaving",
therefore variable "freq" at stat.c line 285 seems to contain a correct and
highly precise value of the frequency of my signal. However, on the next
line (stat.c line 286) type conversion (int) rounds that frequency down
resulting in one Hertz too little value in half of the cases. e.g.
> sox -n /tmp/tmp.wav synth 1 sine 100.01 stat   // gives 100Hz. OK.
> sox -n /tmp/tmp.wav synth 1 sine 99.99 stat    // gives 99Hz. should be
100Hz, right

Line 285 in stat.c
is   freq = sqrt(stat->dsum2/stat->sum2)*effp->in_signal.rate/(M_PI*2);
should be:   freq = 0.5 +
sqrt(stat->dsum2/stat->sum2)*effp->in_signal.rate/(M_PI*2);

Or, more preferrably line 286 in stat.c
is    fprintf(stderr, "Rough   frequency: %12d\n", (int)freq);
should be    fprintf(stderr, "Rough   frequency: %14.2f\n", freq);

Or is the some other effect in sox that could be used for "high precision"
frequency detection of a signal?
regards, Mikko O.

[-- Attachment #1.2: Type: text/html, Size: 1175 bytes --]

[-- Attachment #2: Type: text/plain, Size: 0 bytes --]



[-- Attachment #3: Type: text/plain, Size: 158 bytes --]

_______________________________________________
Sox-users mailing list
Sox-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sox-users

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2021-12-09 11:38 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-12-09 11:36 frequency detection Mikko Olkkonen

Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/sox.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).