Switch Controller
Loading...
Searching...
No Matches
SoundEvent.h
Go to the documentation of this file.
1#pragma once
2
3#include "pch.h"
4
6
7#include <fftw3.h>
8
9class SoundEvent {
10private:
11 std::vector<float> matchAudio;
12
13 AudioFrameSink *audioFrameSink;
14 mutable std::vector<uint8_t> audioData;
15
16 // fftw
17 mutable std::vector<float> fftwIn;
18 mutable std::vector<std::complex<float>> fftwOut;
19 struct fftwf_deleter {
20 void operator()(fftwf_plan *f) const noexcept {
21 fftwf_destroy_plan(*f);
22 delete f;
23 };
24 };
25 std::unique_ptr<fftwf_plan, fftwf_deleter> fftwPlan;
26 std::size_t fftwSize;
27
28 std::vector<float> matchFrequencies;
29 double matchThreshold;
30 std::atomic<double> matchValue;
31
32 std::vector<float> findFrequencies(const std::vector<float> &samples) const;
33
34public:
35 SoundEvent(const std::string &filename, double matchThreshold,
36 AudioFrameSink *audioFrameSink);
37
38 uint8_t value() const;
39};
Definition: AudioFrameSink.h:14
Definition: SoundEvent.h:9
uint8_t value() const
Definition: SoundEvent.cpp:59