[SCM] calf/master: Merge branch 'master' of ssh://repo.or.cz/srv/git/calf
js at users.alioth.debian.org
js at users.alioth.debian.org
Tue May 7 15:41:12 UTC 2013
Replace calls to memset with functions that work with floats correctly.
Fix memory leak.
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
X-Git-Refname: refs/heads/master
X-Git-Reftype: branch
X-Git-Oldrev: d6a3c1a63a147948535a50da009275278ad5e6a3
X-Git-Newrev: 34569260c452f0fa4c543155ebba174a42a343dc
The following commit has been merged in the master branch:
commit 55e862801746541e3956007e5239ced0306fe0a8
Merge: 1e012bcf523133e009d8f7a064d29fde7b66ab32 250e64e56864a7d17fe51f5c883efb3679cd78c8
Author: Krzysztof Foltman <wdev at foltman.com>
Date: Sat Sep 15 18:41:59 2012 +0100
Merge branch 'master' of ssh://repo.or.cz/srv/git/calf
diff --combined src/modules.cpp
index d7093fe,4361c04..13c72f4
--- a/src/modules.cpp
+++ b/src/modules.cpp
@@@ -699,7 -699,7 +699,7 @@@ void stereo_audio_module::set_sample_ra
// rebuild buffer
buffer_size = (int)(srate * 0.05 * 2.f); // buffer size attack rate multiplied by 2 channels
buffer = (float*) calloc(buffer_size, sizeof(float));
- memset(buffer, 0, buffer_size * sizeof(float)); // reset buffer to zero
+ dsp::zero(buffer, buffer_size); // reset buffer to zero
pos = 0;
}
@@@ -848,7 -848,7 +848,7 @@@ void mono_audio_module::set_sample_rate
// rebuild buffer
buffer_size = (int)srate * 0.05 * 2; // delay buffer size multiplied by 2 channels
buffer = (float*) calloc(buffer_size, sizeof(float));
- memset(buffer, 0, buffer_size * sizeof(float)); // reset buffer to zero
+ dsp::zero(buffer, buffer_size); // reset buffer to zero
pos = 0;
}
@@@ -875,10 -875,9 +875,9 @@@ analyzer_audio_module::analyzer_audio_m
memset(spline_buffer, 0, 200 * sizeof(int)); // reset buffer to zero
phase_buffer = (float*) calloc(max_phase_buffer_size, sizeof(float));
- memset(phase_buffer, 0, max_phase_buffer_size * sizeof(float));
+ dsp::zero(phase_buffer, max_phase_buffer_size);
fft_buffer = (float*) calloc(max_fft_buffer_size, sizeof(float));
- memset(fft_buffer, 0, max_fft_buffer_size * sizeof(float));
fft_inL = (float*) calloc(max_fft_cache_size, sizeof(float));
fft_outL = (float*) calloc(max_fft_cache_size, sizeof(float));
@@@ -887,35 -886,52 +886,52 @@@
fft_smoothL = (float*) calloc(max_fft_cache_size, sizeof(float));
fft_smoothR = (float*) calloc(max_fft_cache_size, sizeof(float));
fft_fallingL = (float*) calloc(max_fft_cache_size, sizeof(float));
fft_fallingR = (float*) calloc(max_fft_cache_size, sizeof(float));
- memset(fft_fallingL, 1.f, max_fft_cache_size * sizeof(float));
- memset(fft_fallingR, 1.f, max_fft_cache_size * sizeof(float));
+ dsp::fill(fft_fallingL, 1.f, max_fft_cache_size);
+ dsp::fill(fft_fallingR, 1.f, max_fft_cache_size);
fft_deltaL = (float*) calloc(max_fft_cache_size, sizeof(float));
fft_deltaR = (float*) calloc(max_fft_cache_size, sizeof(float));
fft_holdL = (float*) calloc(max_fft_cache_size, sizeof(float));
fft_holdR = (float*) calloc(max_fft_cache_size, sizeof(float));
fft_freezeL = (float*) calloc(max_fft_cache_size, sizeof(float));
fft_freezeR = (float*) calloc(max_fft_cache_size, sizeof(float));
- memset(fft_freezeL, 0, max_fft_cache_size * sizeof(float));
- memset(fft_freezeR, 0, max_fft_cache_size * sizeof(float));
- fft_plan = false;
+ fft_plan = NULL;
____analyzer_phase_was_drawn_here = 0;
____analyzer_sanitize = 0;
}
+ analyzer_audio_module::~analyzer_audio_module()
+ {
+ free(fft_freezeR);
+ free(fft_freezeL);
+ free(fft_holdR);
+ free(fft_holdL);
+ free(fft_deltaR);
+ free(fft_deltaL);
+ free(fft_fallingR);
+ free(fft_fallingL);
+ free(fft_smoothR);
+ free(fft_smoothL);
+ free(fft_outR);
+ free(fft_outL);
+ free(fft_inR);
+ free(fft_inL);
+ free(phase_buffer);
+ free(spline_buffer);
+ if (fft_plan)
+ {
+ fftwf_destroy_plan(fft_plan);
+ fft_plan = NULL;
+ }
+ }
+
void analyzer_audio_module::activate() {
active = true;
}
@@@ -958,19 -974,19 +974,19 @@@ void analyzer_audio_module::params_chan
}
if(___sanitize) {
// null the overall buffer
- memset(fft_inL, 1e-20, max_fft_cache_size * sizeof(float));
- memset(fft_inR, 1e-20, max_fft_cache_size * sizeof(float));
- memset(fft_outL, 1e-20, max_fft_cache_size * sizeof(float));
- memset(fft_outR, 1e-20, max_fft_cache_size * sizeof(float));
- memset(fft_holdL, 1e-20, max_fft_cache_size * sizeof(float));
- memset(fft_holdR, 1e-20, max_fft_cache_size * sizeof(float));
- memset(fft_smoothL, 1e-20, max_fft_cache_size * sizeof(float));
- memset(fft_smoothR, 1e-20, max_fft_cache_size * sizeof(float));
- memset(fft_deltaL, 1e-20, max_fft_cache_size * sizeof(float));
- memset(fft_deltaR, 1e-20, max_fft_cache_size * sizeof(float));
+ dsp::zero(fft_inL, max_fft_cache_size);
+ dsp::zero(fft_inR, max_fft_cache_size);
+ dsp::zero(fft_outL, max_fft_cache_size);
+ dsp::zero(fft_outR, max_fft_cache_size);
+ dsp::zero(fft_holdL, max_fft_cache_size);
+ dsp::zero(fft_holdR, max_fft_cache_size);
+ dsp::zero(fft_smoothL, max_fft_cache_size);
+ dsp::zero(fft_smoothR, max_fft_cache_size);
+ dsp::zero(fft_deltaL, max_fft_cache_size);
+ dsp::zero(fft_deltaR, max_fft_cache_size);
// memset(fft_fallingL, 1.f, max_fft_cache_size * sizeof(float));
// memset(fft_fallingR, 1.f, max_fft_cache_size * sizeof(float));
- memset(spline_buffer, 0, 200 * sizeof(int));
+ dsp::zero(spline_buffer, 200);
____analyzer_phase_was_drawn_here = 0;
}
}
@@@ -1046,8 -1062,8 +1062,8 @@@ bool analyzer_audio_module::get_graph(i
// null the overall buffer to feed the fft with if someone requested so
// in the last cycle
// afterwards quit this call
- memset(fft_inL, 1e-20, max_fft_cache_size * sizeof(float));
- memset(fft_inR, 1e-20, max_fft_cache_size * sizeof(float));
+ dsp::zero(fft_inL, max_fft_cache_size);
+ dsp::zero(fft_inR, max_fft_cache_size);
____analyzer_sanitize = 0;
return false;
}
@@@ -1168,28 -1184,15 +1184,28 @@@
a3 * cos((6.f * M_PI * i) / points - 1);
break;
case 6:
+ // Sine
+ _f = sin((M_PI * i) / (points - 1));
+ break;
+ case 7:
+ // Lanczos
+ _f = sinc((2.f * i) / (points - 1) - 1);
+ break;
+ case 8:
+ // GauÃ
+ _a = 2.718281828459045;
+ _f = pow(_a, -0.5f * pow((i - (points - 1) / 2) / (0.4 * (points - 1) / 2.f), 2));
+ break;
+ case 9:
// Bartlett
_f = (2.f / (points - 1)) * (((points - 1) / 2.f) - \
fabs(i - ((points - 1) / 2.f)));
break;
- case 7:
+ case 10:
// Triangular
_f = (2.f / points) * ((2.f / points) - fabs(i - ((points - 1) / 2.f)));
break;
- case 8:
+ case 11:
// Bartlett-Hann
a0 = 0.62;
a1 = 0.48;
@@@ -1197,6 -1200,19 +1213,6 @@@
_f = a0 - a1 * fabs((i / (points - 1)) - 0.5) - \
a2 * cos((2 * M_PI * i) / (points - 1));
break;
- case 9:
- // Sine
- _f = sin((M_PI * i) / (points - 1));
- break;
- case 10:
- // Lanczos
- _f = sinc((2.f * i) / (points - 1) - 1);
- break;
- case 11:
- // GauÃ
- _a = 2.718281828459045;
- _f = pow(_a, -0.5f * pow((i - (points - 1) / 2) / (0.4 * (points - 1) / 2.f), 2));
- break;
}
L *= _f;
if(_param_mode > _m)
@@@ -1772,3 -1788,4 +1788,4 @@@ bool analyzer_audio_module::get_clear_a
}
return false;
}
+
--
calf audio plugins packaging
More information about the pkg-multimedia-commits
mailing list