Audacity 3.2.0
MirUtils.h
Go to the documentation of this file.
1/* SPDX-License-Identifier: GPL-2.0-or-later */
2/*!********************************************************************
3
4 Audacity: A Digital Audio Editor
5
6 MirUtils.h
7
8 Matthieu Hodgkinson
9
10**********************************************************************/
11#pragma once
12
13#include <algorithm>
14#include <vector>
15
16namespace MIR
17{
22std::vector<int> GetPossibleBarDivisors(int lower, int upper);
23
24std::vector<int> GetPeakIndices(const std::vector<float>& x);
25
26std::vector<float> GetNormalizedHann(int size);
27
28constexpr auto IsPowOfTwo(int x)
29{
30 return x > 0 && (x & (x - 1)) == 0;
31}
32
33//*******************************
34// TESTS
35//*******************************
36
37static_assert(!IsPowOfTwo(-2));
38static_assert(!IsPowOfTwo(-1));
39static_assert(!IsPowOfTwo(0));
40static_assert(IsPowOfTwo(1));
41static_assert(IsPowOfTwo(2));
42static_assert(!IsPowOfTwo(3));
43static_assert(IsPowOfTwo(4));
44} // namespace MIR
std::vector< int > GetPossibleBarDivisors(int lower, int upper)
Function to generate numbers whose prime factorization contains only twos or threes.
Definition: MirUtils.cpp:54
std::vector< float > GetNormalizedHann(int size)
Definition: MirUtils.cpp:80
std::vector< int > GetPeakIndices(const std::vector< float > &x)
Definition: MirUtils.cpp:67
constexpr auto IsPowOfTwo(int x)
Definition: MirUtils.h:28