From e4fac71b14ab42e0769e0df02402bf0fb7e85760 Mon Sep 17 00:00:00 2001 From: Pander Date: Wed, 17 Sep 2014 15:29:32 +0200 Subject: [PATCH] implement scaling frequency with debuging, stuck at segfault --- INSTALL.md | 9 +- MANUAL.md | 6 ++ man/spek.1 | 10 ++ po/spek.pot | 212 ---------------------------------------- src/spek-spectrogram.cc | 57 ++++++++++- src/spek-spectrogram.h | 2 + web/man-0.8.2.html | 46 +++++---- 7 files changed, 104 insertions(+), 238 deletions(-) delete mode 100644 po/spek.pot diff --git a/INSTALL.md b/INSTALL.md index 206d7781..fee8d1fb 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -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: diff --git a/MANUAL.md b/MANUAL.md index 917ff9a8..874c419e 100644 --- a/MANUAL.md +++ b/MANUAL.md @@ -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* diff --git a/man/spek.1 b/man/spek.1 index fda470d9..89428b33 100644 --- a/man/spek.1 +++ b/man/spek.1 @@ -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[] diff --git a/po/spek.pot b/po/spek.pot deleted file mode 100644 index b17ef599..00000000 --- a/po/spek.pot +++ /dev/null @@ -1,212 +0,0 @@ -# SOME DESCRIPTIVE TITLE. -# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER -# This file is distributed under the same license as the PACKAGE package. -# FIRST AUTHOR , YEAR. -# -#, fuzzy -msgid "" -msgstr "" -"Project-Id-Version: PACKAGE VERSION\n" -"Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2014-03-29 13:05-0700\n" -"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" -"Last-Translator: FULL NAME \n" -"Language-Team: LANGUAGE \n" -"Language: \n" -"MIME-Version: 1.0\n" -"Content-Type: text/plain; charset=CHARSET\n" -"Content-Transfer-Encoding: 8bit\n" -"Plural-Forms: nplurals=INTEGER; plural=EXPRESSION;\n" - -#: ../data/spek.desktop.in.in.h:1 -msgid "Spek" -msgstr "" - -#: ../data/spek.desktop.in.in.h:2 -msgid "Spectrum Analyser" -msgstr "" - -#: ../data/spek.desktop.in.in.h:3 -msgid "View spectrograms of your audio files" -msgstr "" - -#: ../data/spek.desktop.in.in.h:4 -msgid "Spek Spectrum Analyser" -msgstr "" - -#: ../src/spek-pipeline.cc:197 -#, c-format -msgid "%d kbps" -msgstr "" - -#: ../src/spek-pipeline.cc:202 -#, c-format -msgid "%d Hz" -msgstr "" - -#: ../src/spek-pipeline.cc:209 -#, c-format -msgid "%d bit" -msgid_plural "%d bits" -msgstr[0] "" -msgstr[1] "" - -#: ../src/spek-pipeline.cc:217 -#, c-format -msgid "%d channel" -msgid_plural "%d channels" -msgstr[0] "" -msgstr[1] "" - -#: ../src/spek-pipeline.cc:234 -msgid "Cannot open input file" -msgstr "" - -#: ../src/spek-pipeline.cc:237 -msgid "Cannot find stream info" -msgstr "" - -#: ../src/spek-pipeline.cc:240 -msgid "The file contains no audio streams" -msgstr "" - -#: ../src/spek-pipeline.cc:243 -msgid "Cannot find decoder" -msgstr "" - -#: ../src/spek-pipeline.cc:246 -msgid "Unknown duration" -msgstr "" - -#: ../src/spek-pipeline.cc:249 -msgid "No audio channels" -msgstr "" - -#: ../src/spek-pipeline.cc:252 -msgid "Cannot open decoder" -msgstr "" - -#: ../src/spek-pipeline.cc:255 -msgid "Unsupported sample format" -msgstr "" - -#. TRANSLATORS: first %s is the error message, second %s is stream description. -#: ../src/spek-pipeline.cc:267 -#, c-format -msgid "%s: %s" -msgstr "" - -#: ../src/spek-preferences-dialog.cc:67 -msgid "Preferences" -msgstr "" - -#: ../src/spek-preferences-dialog.cc:72 -msgid "(system default)" -msgstr "" - -#. TRANSLATORS: The name of a section in the Preferences dialog. -#: ../src/spek-preferences-dialog.cc:79 -msgid "General" -msgstr "" - -#: ../src/spek-preferences-dialog.cc:88 -msgid "Language:" -msgstr "" - -#: ../src/spek-preferences-dialog.cc:104 -msgid "Check for &updates" -msgstr "" - -#: ../src/spek-spectrogram.cc:191 -#, c-format -msgid "%d kHz" -msgstr "" - -#: ../src/spek-spectrogram.cc:196 -#, c-format -msgid "%d dB" -msgstr "" - -#. TRANSLATORS: keep "00" unchanged, it's used to calc the text width -#: ../src/spek-spectrogram.cc:302 -msgid "00 kHz" -msgstr "" - -#. TRANSLATORS: keep "-00" unchanged, it's used to calc the text width -#: ../src/spek-spectrogram.cc:333 -msgid "-00 dB" -msgstr "" - -#: ../src/spek-window.cc:75 -msgid "Spek - Acoustic Spectrum Analyser" -msgstr "" - -#: ../src/spek-window.cc:91 -msgid "&File" -msgstr "" - -#: ../src/spek-window.cc:97 -msgid "&Edit" -msgstr "" - -#: ../src/spek-window.cc:101 ../src/spek-window.cc:106 -msgid "&Help" -msgstr "" - -#: ../src/spek-window.cc:128 -msgid "Help" -msgstr "" - -#: ../src/spek-window.cc:141 -msgid "A new version of Spek is available, click to download." -msgstr "" - -#. TRANSLATORS: window title, %s is replaced with the file name -#: ../src/spek-window.cc:179 -#, c-format -msgid "Spek - %s" -msgstr "" - -#: ../src/spek-window.cc:226 -msgid "All files" -msgstr "" - -#: ../src/spek-window.cc:228 -msgid "Audio files" -msgstr "" - -#: ../src/spek-window.cc:242 -msgid "Open File" -msgstr "" - -#: ../src/spek-window.cc:264 -msgid "PNG images" -msgstr "" - -#: ../src/spek-window.cc:270 -msgid "Save Spectrogram" -msgstr "" - -#. Suggested name is .png -#: ../src/spek-window.cc:278 -msgid "Untitled" -msgstr "" - -#. TRANSLATORS: Add your name here -#: ../src/spek-window.cc:325 -msgid "translator-credits" -msgstr "" - -#: ../src/spek-window.cc:331 -msgid "Copyright (c) 2010-2013 Alexander Kojevnikov and contributors" -msgstr "" - -#: ../src/spek-window.cc:334 -msgid "Spek Website" -msgstr "" - -#. TRANSLATORS: the %s is the package version. -#: ../src/spek.cc:94 -#, c-format -msgid "Spek version %s" -msgstr "" diff --git a/src/spek-spectrogram.cc b/src/spek-spectrogram.cc index e1379ab9..8ee0afd8 100644 --- a/src/spek-spectrogram.cc +++ b/src/spek-spectrogram.cc @@ -16,6 +16,8 @@ * along with Spek. If not, see . */ +using namespace std;//needed for debugging with cout, FIXME remove all lines with cout after implementing scaling frequency range + #include #include @@ -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); } diff --git a/src/spek-spectrogram.h b/src/spek-spectrogram.h index cf0a37fe..48759c62 100644 --- a/src/spek-spectrogram.h +++ b/src/spek-spectrogram.h @@ -58,6 +58,8 @@ class SpekSpectrogram : public wxWindow int prev_width; int urange; int lrange; + int ufreq; + int lfreq; DECLARE_EVENT_TABLE() }; diff --git a/web/man-0.8.2.html b/web/man-0.8.2.html index 506bb92f..ed6f07ef 100644 --- a/web/man-0.8.2.html +++ b/web/man-0.8.2.html @@ -1,11 +1,11 @@ - + Spek 0.8.2 manual @@ -16,21 +16,21 @@

Spek 0.8.2 manual

SYNOPSIS

-       spek [OPTION...]	[FILE]
+       spek [OPTION...] [FILE]
 
 
 

DESCRIPTION

-       Spek generates a	spectrogram for	the input audio	file.
+       Spek generates a spectrogram for the input audio file.
 
 
 

OPTIONS

        -h, --help
-	      Output the help message then quit.
+          Output the help message then quit.
 
        -V, --version
-	      Output version information then quit.
+          Output version information then quit.
 
 
 
@@ -45,39 +45,45 @@

KEYBINDINGS

 
        Ctrl-E Show the preferences dialog.
 
-       F1     Open online manual in the	browser.
+       F1     Open online manual in the browser.
 
        Shift-F1
-	      Show the about dialog.
+          Show the about dialog.
 
    Spectrogram
-       Ctrl-up,	Ctrl-down
-	      Change the lower limit of	the dynamic range in dBFS.
+       Ctrl-up, Ctrl-down
+          Change the lower limit of the dynamic range in dBFS.
 
        Ctrl-Shift-up, Ctrl-Shift-down
-	      Change the upper limit of	the dynamic range in dBFS.
+          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
-	      The  configuration file for Spek,	stored in a simple INI format.
+          The configuration file for Spek, stored in a simple INI format.
 
 
 

AUTHORS

-       Alexander Kojevnikov <alexander@kojevnikov.com>.	Other contributors are
-       listed in the LICENCE.md	file distributed with the source code.
+       Alexander Kojevnikov <alexander@kojevnikov.com>. Other contributors are
+       listed in the LICENCE.md file distributed with the source code.
 
 
 

DISTRIBUTION

-       The    latest	version	   of	 Spek	 may	be   downloaded	  from
+       The latest version of Spek may be downloaded from
        http://spek.cc.
 
 
 
-Spek 0.8.2			  2013-02-24			       SPEK(1)
+Spek 0.8.2              2013-02-24                   SPEK(1)