Fix scvim regsitry file for updated filename (thanks Carlo Capocasa)
[supercollider.git] / server / supernova / audio_backend / cpu_time_info.hpp
blobf8bb941989f9159e25a1a748cb90047a6663be43
1 // cpu time info
2 // Copyright (C) 2011 Tim Blechmann
3 //
4 // This program is free software; you can redistribute it and/or modify
5 // it under the terms of the GNU General Public License as published by
6 // the Free Software Foundation; either version 2 of the License, or
7 // (at your option) any later version.
8 //
9 // This program is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU General Public License for more details.
14 // You should have received a copy of the GNU General Public License
15 // along with this program; see the file COPYING. If not, write to
16 // the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17 // Boston, MA 02111-1307, USA.
19 #ifndef AUDIO_BACKEND_CPU_TIME_INFO_HPP
20 #define AUDIO_BACKEND_CPU_TIME_INFO_HPP
22 #include <boost/array.hpp>
23 #include "utilities/aligned_class.hpp"
24 #include "nova-simd/simd_horizontal_functions.hpp"
26 namespace nova {
28 struct cpu_time_info
30 static const size_t size = 512; // 700 ms at 128 samples 96kHz, 6.9 s at 512 samples 44.1kHz
32 cpu_time_info(void):
33 index(size - 1), buffer(size, 0.f)
36 void update(float f)
38 ++index;
39 if (index == size)
40 index = 0;
42 buffer[index] = f;
45 void get(float & peak, float & average) const
47 const float average_factor = 1.f/size;
48 float sum;
49 #ifdef __PATHCC__
50 horizontal_maxsum_vec_simd(peak, sum, &buffer.front(), size);
51 #else
52 horizontal_maxsum_vec_simd(peak, sum, buffer.data(), size);
53 #endif
54 average = sum * average_factor;
57 std::size_t index;
58 std::vector<float, aligned_allocator<float> > buffer;
63 #endif /* AUDIO_BACKEND_CPU_TIME_INFO_HPP */