[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Traverso-commit] traverso/src plugins/native/SpectralMeter.cpp p...
From: |
Nicola Doebelin |
Subject: |
[Traverso-commit] traverso/src plugins/native/SpectralMeter.cpp p... |
Date: |
Thu, 07 Feb 2008 12:52:57 +0000 |
CVSROOT: /sources/traverso
Module name: traverso
Changes by: Nicola Doebelin <n_doebelin> 08/02/07 12:52:57
Modified files:
src/plugins/native: SpectralMeter.cpp SpectralMeter.h
src/traverso : SpectralMeterWidget.cpp SpectralMeterWidget.h
Log message:
fixes bug #21952: "Correlation meter and FFT spectrometer 'falloff'"
for the FFT meter
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/traverso/src/plugins/native/SpectralMeter.cpp?cvsroot=traverso&r1=1.6&r2=1.7
http://cvs.savannah.gnu.org/viewcvs/traverso/src/plugins/native/SpectralMeter.h?cvsroot=traverso&r1=1.4&r2=1.5
http://cvs.savannah.gnu.org/viewcvs/traverso/src/traverso/SpectralMeterWidget.cpp?cvsroot=traverso&r1=1.50&r2=1.51
http://cvs.savannah.gnu.org/viewcvs/traverso/src/traverso/SpectralMeterWidget.h?cvsroot=traverso&r1=1.23&r2=1.24
Patches:
Index: plugins/native/SpectralMeter.cpp
===================================================================
RCS file: /sources/traverso/traverso/src/plugins/native/SpectralMeter.cpp,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -b -r1.6 -r1.7
--- plugins/native/SpectralMeter.cpp 5 Nov 2007 15:49:31 -0000 1.6
+++ plugins/native/SpectralMeter.cpp 7 Feb 2008 12:52:57 -0000 1.7
@@ -16,7 +16,7 @@
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
-$Id: SpectralMeter.cpp,v 1.6 2007/11/05 15:49:31 r_sijrier Exp $
+$Id: SpectralMeter.cpp,v 1.7 2008/02/07 12:52:57 n_doebelin Exp $
*/
@@ -34,12 +34,14 @@
#include "Debugger.h"
#define PI 3.141592653589
+#define BUFFER_READOUT_TOLERANCE 2 // recommended: 1-10
SpectralMeter::SpectralMeter()
: Plugin()
{
m_frlen = 2048;
m_windowingFunction = 1;
+ m_bufferreadouts = 0;
(int) init();
@@ -165,10 +167,30 @@
int readcount = m_databufferL->read_space();
// If there is not enough new data for an FFT window in the ringbuffer,
- // leave it alone and return zero
+ // decide if the cycle should be ignored or if the fft spectrum should
+ // be filled with 0. Ignore it as long as the number of readouts is
+ // below the BUFFER_READOUT_TOLERANCE.
if (readcount < m_frlen) {
+ // add another 'if' to avoid unlimited growth of the variable
+ if (m_bufferreadouts <= BUFFER_READOUT_TOLERANCE) {
+ m_bufferreadouts++;
+ }
+
+ if (m_bufferreadouts >= BUFFER_READOUT_TOLERANCE) {
+ // return spectra filled with 0
+ specl.clear();
+ specr.clear();
+ for (int i = 1; i < m_frlen/2 + 1; ++i) {
+ specl.push_back(0.0);
+ specr.push_back(0.0);
+ }
+ return -1; // return -1 to inform the receiver about
silence
+ } else {
return 0;
}
+ } else {
+ m_bufferreadouts = 0;
+ }
specl.clear();
specr.clear();
Index: plugins/native/SpectralMeter.h
===================================================================
RCS file: /sources/traverso/traverso/src/plugins/native/SpectralMeter.h,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -b -r1.4 -r1.5
--- plugins/native/SpectralMeter.h 5 Feb 2007 17:10:09 -0000 1.4
+++ plugins/native/SpectralMeter.h 7 Feb 2008 12:52:57 -0000 1.5
@@ -17,7 +17,7 @@
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
-$Id: SpectralMeter.h,v 1.4 2007/02/05 17:10:09 r_sijrier Exp $
+$Id: SpectralMeter.h,v 1.5 2008/02/07 12:52:57 n_doebelin Exp $
*/
@@ -62,6 +62,7 @@
private:
int m_frlen;
int m_windowingFunction;
+ int m_bufferreadouts;
// FFTW globals
fftw_plan pfegl, pfegr;
Index: traverso/SpectralMeterWidget.cpp
===================================================================
RCS file: /sources/traverso/traverso/src/traverso/SpectralMeterWidget.cpp,v
retrieving revision 1.50
retrieving revision 1.51
diff -u -b -r1.50 -r1.51
--- traverso/SpectralMeterWidget.cpp 24 Jan 2008 18:06:26 -0000 1.50
+++ traverso/SpectralMeterWidget.cpp 7 Feb 2008 12:52:57 -0000 1.51
@@ -149,6 +149,7 @@
lower_freq_log = log10(lower_freq);
sample_rate = audiodevice().get_sample_rate();
show_average = false;
+ update_average = true;
sample_weight = 1;
QFontMetrics fm(themer()->get_font("FFTMeter:fontscale:label"));
@@ -326,7 +327,18 @@
// if no data was available, return, so we _only_ update the widget when
// it needs to be!
- if (m_meter->get_data(specl, specr) == 0) {
+
+ int ret = m_meter->get_data(specl, specr);
+
+ // switch off the update of the average curve if silence is played back.
+ if (ret == -1) {
+ update_average = false;
+ } else {
+ update_average = true;
+ }
+
+ // do nothing if the buffer is not ready.
+ if (ret == 0) {
return;
}
@@ -437,18 +449,18 @@
}
// fill the average sample curve
- if (show_average) {
+ if (show_average && update_average) {
for (int i = 0; i < m_avg_db.size(); ++i) {
float val = 5.0 * (log10(specl.at(i) * specr.at(i)) +
xfactor);
float v = val * sweight + m_avg_db.at(i) * oweight;
m_avg_db[i] = v;
}
- }
// progress the sample weighting for the average curve
- if ((show_average) && (sample_weight < (MAX_SAMPLES - 1))) {
+ if (sample_weight < (MAX_SAMPLES - 1)) {
++sample_weight;
}
+ }
}
// call this function if the size, number of bands, ranges etc. changed.
Index: traverso/SpectralMeterWidget.h
===================================================================
RCS file: /sources/traverso/traverso/src/traverso/SpectralMeterWidget.h,v
retrieving revision 1.23
retrieving revision 1.24
diff -u -b -r1.23 -r1.24
--- traverso/SpectralMeterWidget.h 21 Jan 2008 16:22:17 -0000 1.23
+++ traverso/SpectralMeterWidget.h 7 Feb 2008 12:52:57 -0000 1.24
@@ -137,6 +137,7 @@
float freq_step;
int bar_offset;
bool show_average;
+ bool update_average;
void reduce_bands();
void update_layout();
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Traverso-commit] traverso/src plugins/native/SpectralMeter.cpp p...,
Nicola Doebelin <=