Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

implement scaling frequency with debuging, stuck at segfault #71

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion INSTALL.md
Original file line number Diff line number Diff line change
@@ -40,7 +40,14 @@ terminal:

To build you will need wxWidgets and FFmpeg packages. On Debian/Ubuntu you also
need development packages: libwxgtk2.8-dev, wx-common, libavcodec-dev and
libavformat-dev.
libavformat-dev. These can be installed with the command:

sudo apt-get install build-essential autoconf intltool libtool \
libwxgtk3.0-dev libavformat-dev

The configure script can be generated by running:

./autogen.sh

To start Spek, run:

6 changes: 6 additions & 0 deletions MANUAL.md
Original file line number Diff line number Diff line change
@@ -53,6 +53,12 @@ On OS X use the Command key instead of Ctrl.
`Ctrl-Shift-up`, `Ctrl-Shift-down`
: Change the upper limit of the dynamic range in dBFS.

`Ctrl-left`, `Ctrl-right`
: Change the lower limit of the frequency range in Hz.

`Ctrl-Shift-left`, `Ctrl-Shift-right`
: Change the upper limit of the frequency range in Hz.

# FILES

*~/.config/spek/preferences*
10 changes: 10 additions & 0 deletions man/spek.1
Original file line number Diff line number Diff line change
@@ -60,6 +60,16 @@ Change the lower limit of the dynamic range in dBFS.
Change the upper limit of the dynamic range in dBFS.
.RS
.RE
.TP
.B \f[C]Ctrl\-left\f[], \f[C]Ctrl\-right\f[]
Change the lower limit of the frequency range in Hz.
.RS
.RE
.TP
.B \f[C]Ctrl\-Shift\-left\f[], \f[C]Ctrl\-Shift\-right\f[]
Change the upper limit of the frequency range in Hz.
.RS
.RE
.SH FILES
.TP
.B \f[I]~/.config/spek/preferences\f[]
212 changes: 0 additions & 212 deletions po/spek.pot

This file was deleted.

57 changes: 52 additions & 5 deletions src/spek-spectrogram.cc
Original file line number Diff line number Diff line change
@@ -16,6 +16,8 @@
* along with Spek. If not, see <http://www.gnu.org/licenses/>.
*/

using namespace std;//needed for debugging with cout, FIXME remove all lines with cout after implementing scaling frequency range

#include <cmath>

#include <wx/dcbuffer.h>
@@ -42,6 +44,8 @@ enum
{
MAX_RANGE = 0,
MIN_RANGE = -140,
MAX_FREQ = 48000,
MIN_FREQ = 0,
URANGE = -20,
LRANGE = -120,
FFT_BITS = 11,
@@ -71,7 +75,9 @@ SpekSpectrogram::SpekSpectrogram(wxFrame *parent) :
image(1, 1),
prev_width(-1),
urange(URANGE),
lrange(LRANGE)
lrange(LRANGE),
ufreq(MAX_FREQ),
lfreq(MIN_FREQ)
{
SetBackgroundStyle(wxBG_STYLE_CUSTOM);
SetFocus();
@@ -115,15 +121,55 @@ void SpekSpectrogram::on_char(wxKeyEvent& evt)
bool CS = evt.GetModifiers() == (wxMOD_CONTROL | wxMOD_SHIFT);
bool dn = evt.GetKeyCode() == WXK_DOWN;
bool up = evt.GetKeyCode() == WXK_UP;
bool lf = evt.GetKeyCode() == WXK_LEFT;
bool rg = evt.GetKeyCode() == WXK_RIGHT;

if (C && up) {
// increasing lower limit of dynamic range
this->lrange = spek_min(this->lrange + 1, this->urange - 1);
} else if (C && dn) {
// decreasing lower limit of dynamic range
this->lrange = spek_max(this->lrange - 1, MIN_RANGE);
} else if (CS && up) {
// increasing upper limit of dynamic range
this->urange = spek_min(this->urange + 1, MAX_RANGE);
} else if (CS && dn) {
// decreasing upper limit of dynamic range
this->urange = spek_max(this->urange - 1, this->lrange + 1);
} else if (C && rg) {
// increasing lower limit frequency range
cout << "Crg" << this->lfreq << " " << this->ufreq << "\n";//FIXME
if (this->lfreq == MIN_FREQ) {
this->lfreq = 1; // because two times zero is still zero
} else {
this->lfreq = spek_min(this->lfreq * 2, this->ufreq / 2);
}
cout << this->lfreq << "\n";//FIXME
} else if (C && lf) {
// decreasing lower limit frequency range
cout << "Clf" << this->lfreq << " " << this->ufreq << "\n";//FIXME
if (this->lfreq == MIN_FREQ) {
// do nothing
} else if (this->lfreq == 1) {
this->lfreq = MIN_FREQ; // to avoid going into rounding
} else {
this->lfreq = this->lfreq / 2;
}
cout << this->lfreq << "\n";//FIXME
} else if (CS && rg) {
// increasing upper limit frequency range
cout << "CSrg" << this->lfreq << " " << this->ufreq << "\n";//FIXME
if (this->ufreq == MAX_FREQ) {
// do nothing
} else {
this->ufreq = spek_min(this->ufreq * 2, MAX_FREQ);
}
cout << this->ufreq << "\n";//FIXME
} else if (CS && lf) {
// decreasing upper limit frequency range
cout << "CSlf" << this->lfreq << " " << this->ufreq << "\n";//FIXME
this->ufreq = spek_max(this->ufreq / 2, this->lfreq * 2);
cout << this->ufreq << "\n";//FIXME
} else {
evt.Skip();
return;
@@ -301,11 +347,11 @@ void SpekSpectrogram::render(wxDC& dc)
// TRANSLATORS: keep "00" unchanged, it's used to calc the text width
_("00 kHz"),
freq_factors,
0,
freq,
0,//FIXME replace with this->lfreq?
freq,//FIXME replace with this->ufreq?
3.0,
(h - TPAD - BPAD) / (double)freq,
0.0,
(h - TPAD - BPAD) / (double)freq,//FIXME replace with (double)this->ufreq
0.0,//FIXME replace with (double)this->lfreq ?
freq_formatter
);
freq_ruler.draw(dc);
@@ -377,6 +423,7 @@ void SpekSpectrogram::start()
this->desc = wxString::FromUTF8(spek_pipeline_desc(this->pipeline).c_str());
this->duration = spek_pipeline_duration(this->pipeline);
this->sample_rate = spek_pipeline_sample_rate(this->pipeline);
this->ufreq = this->sample_rate / 2;
} else {
this->image.Create(1, 1);
}
2 changes: 2 additions & 0 deletions src/spek-spectrogram.h
Original file line number Diff line number Diff line change
@@ -58,6 +58,8 @@ class SpekSpectrogram : public wxWindow
int prev_width;
int urange;
int lrange;
int ufreq;
int lfreq;

DECLARE_EVENT_TABLE()
};
46 changes: 26 additions & 20 deletions web/man-0.8.2.html
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
<HTML>
<HEAD>
<style type="text/css">
body {font-size: 11pt;}
h1, h2 {font-weight: bold;}
h1 {font-size: 16pt;}
h2 {font-size: 12pt;}
</style>
<style type="text/css">
body {font-size: 11pt;}
h1, h2 {font-weight: bold;}
h1 {font-size: 16pt;}
h2 {font-size: 12pt;}
</style>
<TITLE>Spek 0.8.2 manual</TITLE>
</HEAD>
<BODY>
@@ -16,21 +16,21 @@ <H1>Spek 0.8.2 manual</H1>

</PRE>
<H2>SYNOPSIS</H2><PRE>
<B>spek</B> [OPTION...] [FILE]
<B>spek</B> [OPTION...] [FILE]


</PRE>
<H2>DESCRIPTION</H2><PRE>
<B>Spek</B> generates a spectrogram for the input audio file.
<B>Spek</B> generates a spectrogram for the input audio file.


</PRE>
<H2>OPTIONS</H2><PRE>
<B>-h</B>, <B>--help</B>
Output the help message then quit.
Output the help message then quit.

<B>-V</B>, <B>--version</B>
Output version information then quit.
Output version information then quit.


</PRE>
@@ -45,39 +45,45 @@ <H2>KEYBINDINGS</H2><PRE>

<B>Ctrl-E</B> Show the preferences dialog.

<B>F1</B> Open online manual in the browser.
<B>F1</B> Open online manual in the browser.

<B>Shift-F1</B>
Show the about dialog.
Show the about dialog.

<B>Spectrogram</B>
<B>Ctrl-up</B>, <B>Ctrl-down</B>
Change the lower limit of the dynamic range in dBFS.
<B>Ctrl-up</B>, <B>Ctrl-down</B>
Change the lower limit of the dynamic range in dBFS.

<B>Ctrl-Shift-up</B>, <B>Ctrl-Shift-down</B>
Change the upper limit of the dynamic range in dBFS.
Change the upper limit of the dynamic range in dBFS.

<B>Ctrl-left</B>, <B>Ctrl-right</B>
Change the lower limit of the frequency range in Hz.

<B>Ctrl-Shift-left</B>, <B>Ctrl-Shift-right</B>
Change the upper limit of the frequency range in Hz.


</PRE>
<H2>FILES</H2><PRE>
<I>~/.config/spek/preferences</I>
The configuration file for Spek, stored in a simple INI format.
The configuration file for Spek, stored in a simple INI format.


</PRE>
<H2>AUTHORS</H2><PRE>
Alexander Kojevnikov &lt;alexander@kojevnikov.com&gt;. Other contributors are
listed in the LICENCE.md file distributed with the source code.
Alexander Kojevnikov &lt;alexander@kojevnikov.com&gt;. Other contributors are
listed in the LICENCE.md file distributed with the source code.


</PRE>
<H2>DISTRIBUTION</H2><PRE>
The latest version of <B>Spek</B> may be downloaded from
The latest version of <B>Spek</B> may be downloaded from
<I><a href="http://spek.cc">http://spek.cc</a></I>.



Spek 0.8.2 2013-02-24 <B>SPEK(1)</B>
Spek 0.8.2 2013-02-24 <B>SPEK(1)</B>
</PRE>
<HR>
<ADDRESS>