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
Show file tree
Hide file tree
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
Expand Up @@ -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:

Expand Down
6 changes: 6 additions & 0 deletions MANUAL.md
Original file line number Diff line number Diff line change
Expand Up @@ -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*
Expand Down
10 changes: 10 additions & 0 deletions man/spek.1
Original file line number Diff line number Diff line change
Expand Up @@ -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[]
Expand Down
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
Expand Up @@ -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>
Expand All @@ -42,6 +44,8 @@ enum
{
MAX_RANGE = 0,
MIN_RANGE = -140,
MAX_FREQ = 48000,
MIN_FREQ = 0,
URANGE = -20,
LRANGE = -120,
FFT_BITS = 11,
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
}
Expand Down
2 changes: 2 additions & 0 deletions src/spek-spectrogram.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ class SpekSpectrogram : public wxWindow
int prev_width;
int urange;
int lrange;
int ufreq;
int lfreq;

DECLARE_EVENT_TABLE()
};
Expand Down
Loading