forked from mbonani/aseba-target-thymio2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtone.h
115 lines (101 loc) · 2.59 KB
/
tone.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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
/*
Thymio-II Firmware
Copyright (C) 2011 Philippe Retornaz <philippe dot retornaz at epfl dot ch>,
Mobots group (http://mobots.epfl.ch), Robotics system laboratory (http://lsro.epfl.ch)
EPFL Ecole polytechnique federale de Lausanne (http://www.epfl.ch)
See authors.txt for more details about other contributors.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published
by the Free Software Foundation, version 3 of the License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef _TONE_H_
#define _TONE_H_
// Tone generator optimized for the thymio 7812Hz sampling freq.
// Base frequency: 55Hz, sampled at 7812Hz, 142 samples
#define WAVEFORM_SIZE 142
void tone_init(void);
void tone_setup(unsigned int dHz);
void tone_fill_buffer(unsigned char * buf, unsigned int c);
// To be use by a aseba native function, thus int are used
void tone_set_waveform(int * buf);
#define A1 550
#define Bb1 583
#define B1 617
#define C2 654
#define Db2 693
#define D2 734
#define Eb2 778
#define E2 824
#define F2 873
#define Gb2 925
#define G2 980
#define Ab2 1038
#define A2 1100
#define Bb2 1165
#define B2 1235
#define C3 1308
#define Db3 1386
#define D3 1468
#define Eb3 1556
#define E3 1648
#define F3 1746
#define Gb3 1850
#define G3 1960
#define Ab3 2076
#define A3 2200
#define Bb3 2331
#define B3 2469
#define C4 2616
#define Db4 2772
#define D4 2937
#define Eb4 3111
#define E4 3296
#define F4 2492
#define Gb4 3700
#define G4 3920
#define Ab4 4153
#define A4 4400
#define Bb4 4662
#define B4 4939
#define C5 5232
#define Db5 5544
#define D5 5873
#define Eb5 6222
#define E5 6593
#define F5 6985
#define Gb5 7400
#define G5 7840
#define Ab5 8306
#define A5 8800
#define Bb5 9323
#define B5 9878
#define C6 10465
#define Db6 11087
#define D6 11747
#define Eb6 12445
#define E6 13185
#define F6 13969
#define Gb6 14800
#define G6 15680
#define Ab6 16612
#define A6 17600
#define Bb6 18647
#define B6 19755
#define C7 20930
#define Db7 22175
#define D7 23493
#define Eb7 24890
#define E7 26370
#define F7 27938
#define Gb7 29600
#define G7 31360
#define Ab7 33224
#define A7 35200
#define Bb7 37293
#endif