-
Notifications
You must be signed in to change notification settings - Fork 0
/
dft.h
56 lines (42 loc) · 1.04 KB
/
dft.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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <stdbool.h>
#include <string.h>
#include <math.h>
#ifndef DFT_H
#define DFT_H
#define NULL_WAVE ((struct Wave){NULL , 0})
typedef unsigned int uint;
#define PI 3.14159
#define TAU (PI * 2)
#define KHZ 1000
#define MHZ (KHZ * 1000)
#define GHZ (MHZ * 1000)
#define MS (1.f / 1000)
#define US (MS / 1000)
struct Wave
{
double* data;
uint samplesPerSecond;
float duration;//In seconds
};
struct FreqData
{
uint freq;
float phase;
float ampitude;
};
struct DFT_data
{
uint minFreq;
uint maxFreq;
struct FreqData* data;
uint increment;
};
struct FreqData MultiplyByFreq(struct Wave wave, uint freq);
struct Wave SinWaveByFreq(uint freq, uint samplesPerSecond, float duration, float phase);
struct Wave CosWaveByFreq(uint freq, uint samplesPerSecond, float duration, float phase);
void PrintFreqData(struct FreqData freqData);
struct DFT_data DiscreteFourierTranform(struct Wave wave, uint minFreq, uint maxFreq, int increment, bool logProgress);
#endif