From 247750abcbf6760bbc52aa5d64fc375d6fbee8a3 Mon Sep 17 00:00:00 2001 From: Michele Calgaro Date: Sun, 6 Dec 2020 19:28:06 +0900 Subject: Renaming of files in preparation for code style tools. Signed-off-by: Michele Calgaro (cherry picked from commit 00d4f92b717fbcbed6f9eee361975d6ee5380d59) --- flow/stereofftscope_impl.cpp | 131 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 131 insertions(+) create mode 100644 flow/stereofftscope_impl.cpp (limited to 'flow/stereofftscope_impl.cpp') diff --git a/flow/stereofftscope_impl.cpp b/flow/stereofftscope_impl.cpp new file mode 100644 index 0000000..1b280a5 --- /dev/null +++ b/flow/stereofftscope_impl.cpp @@ -0,0 +1,131 @@ + /* + + Copyright (C) 2000 Stefan Westerfeld + stefan@space.twc.de + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to + the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. + + */ + +#include "artsflow.h" +#include "fft.h" +#include "stdsynthmodule.h" +#include +#include + +using namespace std; +using namespace Arts; + +namespace Arts { + +class StereoFFTScope_impl : public StereoFFTScope_skel, public StdSynthModule { +protected: + static const unsigned long SAMPLES = 4096; + vector _scope; + /* + * some gcc versions expose ugly behaviour with virtual inheritance: + * putting window[4096] & inbuffer[4096] here bloats the vtable then, + * and tells you to recompile with -fhuge-objects ... so allocate them + * dynamically + */ + float *window; + float *inbuffer; + unsigned long inbufferpos; +public: + void do_fft() + { + float out_real[SAMPLES],out_img[SAMPLES]; + arts_fft_float(SAMPLES,0,inbuffer,0,out_real,out_img); + + _scope.clear(); + unsigned int i = 3; + unsigned int j = 0; + for(;;) { + float xrange = 0.0; + while(j != i) + { + xrange += (fabs(out_img[j]) + fabs(out_real[j]))/(float)SAMPLES; + j++; + } + _scope.push_back(xrange); + + if(i == SAMPLES/2) return; + + i += i/2; + if(i > SAMPLES/2) i = SAMPLES/2; + } + } + void streamInit() + { + unsigned long i; + for(i=0;i *scope() + { + return new vector(_scope); + } + /* + in audio stream inleft, inright; + out audio stream outleft, outright; + */ + void calculateBlock(unsigned long samples) + { + unsigned long i; + for(i=0;i