2 // Copyright (C) 2011 Tim Blechmann
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.
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
23 #include "utilities/aligned_class.hpp"
24 #include "nova-simd/simd_horizontal_functions.hpp"
30 static const size_t size
= 512; // 700 ms at 128 samples 96kHz, 6.9 s at 512 samples 44.1kHz
33 index(size
- 1), buffer(size
, 0.f
)
45 void get(float & peak
, float & average
) const
47 const float average_factor
= 1.f
/size
;
50 horizontal_maxsum_vec_simd(peak
, sum
, &buffer
.front(), size
);
52 horizontal_maxsum_vec_simd(peak
, sum
, buffer
.data(), size
);
54 average
= sum
* average_factor
;
58 std::vector
<float, aligned_allocator
<float> > buffer
;
63 #endif /* AUDIO_BACKEND_CPU_TIME_INFO_HPP */