frequency detection

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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.
_______________________________________________
Sox-users mailing list
Sox-users@xxxxxxxxxxxxxxxxxxxxx
https://lists.sourceforge.net/lists/listinfo/sox-users

[Index of Archives]     [Linux Sound]     [ALSA Users]     [ALSA Devel]     [Linux Audio Users]     [Linux Media]     [Kernel]     [Photo Sharing]     [Gimp]     [Yosemite News]     [Linux Media]

  Powered by Linux