WE Core
Loading...
Searching...
No Matches
TestUtils.h
Go to the documentation of this file.
1/*
2 * File: TestUtils.h
3 *
4 * Created: 05/12/2020
5 *
6 * This file is part of WECore.
7 *
8 * WECore is free software: you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation, either version 3 of the License, or
11 * (at your option) any later version.
12 *
13 * WECore is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with WECore. If not, see <http://www.gnu.org/licenses/>.
20 */
21
22#include <vector>
23
24#include "General/CoreMath.h"
25
27 static void generateSine(std::vector<double>& buffer, double sampleRate, double frequency) {
28
29 const double samplesPerCycle {sampleRate / frequency};
30
31 std::generate(buffer.begin(),
32 buffer.end(),
33 [index = 0, samplesPerCycle]() mutable {return std::sin(CoreMath::LONG_TAU * (index++ / samplesPerCycle));} );
34 }
35}
static void generateSine(std::vector< double > &buffer, double sampleRate, double frequency)
Definition TestUtils.h:27