2024-08-26 13:02:17 +10:00
|
|
|
|
|
|
|
#include <math.h>
|
|
|
|
#include "tone.hpp"
|
|
|
|
|
2024-10-03 02:27:58 +10:00
|
|
|
static int8_t abs(int8_t v) {
|
|
|
|
return v >= 0 ? v : -v;
|
|
|
|
}
|
|
|
|
|
2024-08-26 13:02:17 +10:00
|
|
|
void Tone::init() {
|
|
|
|
for(unsigned i = 0; i < sizeof(sin_lookup); i++) {
|
|
|
|
sin_lookup[i] = round(sin((float)i / sizeof(sin_lookup) * M_PI * 2) * 127);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|