-
-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathsound.h
31 lines (23 loc) · 740 Bytes
/
sound.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#ifndef SOUND_H
#define SOUND_H
#include <complex>
#include <vector>
#include <fftw3.h>
#include <sndfile.h>
using Complex = std::complex<double>;
class Sound {
public:
Sound(const std::string& filename);
sf_count_t computeDelayInFrames(const Sound& other) const;
double computeDelayInSeconds(const Sound& other) const;
private:
Complex* computeFFT(const sf_count_t fftSize) const;
static void applyFFT(Complex* in, Complex* out, const sf_count_t fftSize, bool inverse);
Complex* newBuffer(const sf_count_t fftSize) const;
sf_count_t argmax(const Complex* const buffer, const sf_count_t size) const;
int channels;
sf_count_t frames;
int sampleRate;
std::vector<double> samples;
};
#endif