Discussion:
[SoX-devel] Modification to spectrogram.c for log frequency axis and setting lower/upper chart frequency
Joe Desbonnet
2014-02-17 00:21:59 UTC
Permalink
My modifications to spectrogram.c to plot frequency on log axis and also to
limit upper and lower plotted frequency are close to being complete.

I'm not very familiar with sox, and my C a bit rusty, so if any seasoned
sox developers have the time to review my code, that would be great. The
log axis on its own didn't require much code change, but I found the
frequency limits needed a fair bit of new parsing code. Specifying
frequency limits (at least a lower bound) is necessary in log plots else a
good part of the screen will be wasted in frequencies 1 - 100 Hz which is
not the most useful for audio.

I've documented the changes at this blog post:
http://jdesbonnet.blogspot.ie/2014/02/sox-spectrogram-log-frequency-axis-and.html

And the code is here:
https://github.com/jdesbonnet/joe-desbonnet-blog/tree/master/projects/sox-log-spectrogram

If this code is worth contributing please advise what are the next steps
(if any). Consider this code contributed under whatever terms that are
required to have it added to the project.

Regards,

Joe Desbonnet.
Eric Wong
2014-02-17 06:14:47 UTC
Permalink
Post by Joe Desbonnet
If this code is worth contributing please advise what are the next steps
(if any). Consider this code contributed under whatever terms that are
required to have it added to the project.
You mentioned there was already an open feature request? uploading the
patch to the bugtracker should be a start. AFAIK, most of the sox
developers are busy at the moment with real-life stuff.

I just cloned your blog and looked at it (a diff/cloned sox.git repo
would've been better), and it looks mostly OK...
Did you make sure log10_high_freq != log10_low_freq anywhere? Otherwise
you might divide by zero:

float log_scale = (float)p->rows/(log10_high_freq - log10_low_freq);

I'm only a simple C programmer and don't know the math behind
spectrograms, though.

(*) not sure how pick sox devs are about trailing whitespace,
but other projects I work tend to be very picky :)
Joe Desbonnet
2014-02-17 11:36:35 UTC
Permalink
Eric,

Thanks for the feedback. Ya, good point re the low==high /0 problem. Forced
low<high when parsing cmd line opts. Added diff to my git repository and
updated ticket with link to the patch.

Regards,

Joe.
Post by Eric Wong
Post by Joe Desbonnet
If this code is worth contributing please advise what are the next steps
(if any). Consider this code contributed under whatever terms that are
required to have it added to the project.
You mentioned there was already an open feature request? uploading the
patch to the bugtracker should be a start. AFAIK, most of the sox
developers are busy at the moment with real-life stuff.
I just cloned your blog and looked at it (a diff/cloned sox.git repo
would've been better), and it looks mostly OK...
Did you make sure log10_high_freq != log10_low_freq anywhere? Otherwise
float log_scale = (float)p->rows/(log10_high_freq - log10_low_freq);
I'm only a simple C programmer and don't know the math behind
spectrograms, though.
(*) not sure how pick sox devs are about trailing whitespace,
but other projects I work tend to be very picky :)
------------------------------------------------------------------------------
Android apps run on BlackBerry 10
Introducing the new BlackBerry 10.2.1 Runtime for Android apps.
Now with support for Jelly Bean, Bluetooth, Mapview and more.
Get your Android app in front of a whole new audience. Start now.
http://pubads.g.doubleclick.net/gampad/clk?id=124407151&iu=/4140/ostg.clktrk
_______________________________________________
SoX-devel mailing list
https://lists.sourceforge.net/lists/listinfo/sox-devel
Loading...