tone-generator/tone.cpp

15 lines
254 B
C++
Raw Permalink Normal View History

#include <math.h>
#include "tone.hpp"
static int8_t abs(int8_t v) {
return v >= 0 ? v : -v;
}
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);
}
}