-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFrequencyTable.pde
More file actions
29 lines (28 loc) · 918 Bytes
/
FrequencyTable.pde
File metadata and controls
29 lines (28 loc) · 918 Bytes
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
/**
* Class that calculates the used frequencys.
* @author Finn Bayer 24-11-2017
**/
public class FrequencyTable {
private float[] frequencys = new float[64];
/**
* Initialize the Frequencys based on the calculation of the piano key frequencys.
* Because the programm only uses a maximum of 64 different frequencys, a start and and end tone was set (key 13: A 55 Hz and key 76: c'''' 2093Hz)
**/
public void initFrequencys() {
int startNo = 13;
int endNo = 76;
int counter = 0;
for (int i = startNo; i<=endNo; i++) {
this.frequencys[counter] = (float)Math.pow(2, ((float)i-49)/12)*440;
counter++;
}
}
/**
* Returns the frequency at the location i.
* @param i The location in the array of frequencys
* @return float The frequency at the location i
**/
public float getFrequency(int i) {
return this.frequencys[i];
}
}