Improved audio beep tone (#2014)

* Improved sine wave beep tone

* Prevent divide-by-zero
This commit is contained in:
Mark Thompson 2024-03-19 15:30:05 -05:00 committed by GitHub
parent 308573918c
commit 807c76346b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 26 additions and 2 deletions

View file

@ -27,6 +27,7 @@
// Functions for audio beep (used by Sonde RSSI)
void ToneGen::configure_beep(const uint32_t freq, const uint32_t sample_rate) {
f_delta_ = (float)(freq * sizeof(sine_table_i8)) / sample_rate;
f_tone_phase_ = 0.0;
}
int16_t ToneGen::process_beep() {
@ -44,6 +45,7 @@ int16_t ToneGen::process_beep() {
void ToneGen::configure(const uint32_t delta, const float tone_mix_weight) {
delta_ = delta;
tone_phase_ = 0;
tone_mix_weight_ = tone_mix_weight;
input_mix_weight_ = 1.0 - tone_mix_weight;
}