-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathguitar_tuner.h
97 lines (70 loc) · 1.84 KB
/
guitar_tuner.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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
/*
* File: guitar_tuner.h
* Author: menezes
*
* Created on October 23, 2017, 3:38 PM
*/
#ifndef GUITAR_TUNER_H
#define GUITAR_TUNER_H
#include <stdint.h>
#include <math.h>
#include "dsp.h"
#include "mcc_generated_files/pin_manager.h"
#define NUM_SAMP 512
#define NUM_ZEROS 512
#define NUM_NOTES 36
#define LOG2_NUM_SAMP 10
#define SAMPLING_RATE 4000
enum sampleStatus{NO, YES};
enum tuningDistance{BELOW, ABOVE};
enum tuningInterval{A, B, C, D};
typedef struct note_features
{
uint8_t note_index;
uint8_t tuning;
uint8_t tuning_interval;
}noteFeatures;
/**
@Summary
Updates 16-bit timer value
@Description
This routine uses the Grandke interpolation frequency algorithm to compute
the approximate true peak frequency of a spectrum
@Param
peakFreqBin - The bin of greatest frequency of spectrum
spectrumAbsVector - The vector with the frequency spectrum magnitude
trueValueFreq - The variable address to store the approximate true peak frequency
@Returns
None
@Example
*/
void GrandkeFreqInterpolation (uint16_t peakFreqBin, fractional* spectrumAbsVector, float *trueValueFreq);
/**
@Summary
Updates 16-bit timer value
@Description
This routine fill a vector with a specified value
@Param
vectorSize - Size of vector
vector2Fill - The vector to fill
trueValueFreq - Data to be assigned
@Returns
None
@Example
*/
void FillVector(uint16_t vectorSize, fractional *vector2Fill, fractional data);
/**
@Summary
Updates 16-bit timer value
@Description
This routine detect what note was played and how is its frequency
regarding the correct tuning
@Param
freq_value - Frequency from FFT
note - Struct with note features
@Returns
None
@Example
*/
void NoteDetect(float freq_value, noteFeatures *note);
#endif /* GUITAR_TUNER_H */