mirror of
https://github.com/eried/portapack-mayhem.git
synced 2025-07-31 18:49:15 -04:00
Improved tone generator for proper frequency control. Also
features a square wave mode. Added proportional beep duration based on the RSSI as well. Now reading the current radiosonde frequency from the battery backed RAM instead starting with the same frequency all the time.
This commit is contained in:
parent
a80d91fb1e
commit
8aff0bb4d8
5 changed files with 25 additions and 22 deletions
|
@ -24,8 +24,8 @@
|
|||
#include "sine_table_int8.hpp"
|
||||
|
||||
|
||||
int32_t ToneGen::tone_from_sine_table() {
|
||||
int32_t tone_sample = sine_table_i8[(tone_phase_ & 0xFF000000U) >> 24] << 24;
|
||||
int32_t ToneGen::tone_sine() {
|
||||
int32_t tone_sample = sine_table_i8[tone_phase_] * 0x1000000;
|
||||
tone_phase_ += delta_;
|
||||
|
||||
return tone_sample;
|
||||
|
@ -47,14 +47,15 @@ int32_t ToneGen::tone_square() {
|
|||
}
|
||||
|
||||
void ToneGen::configure(const uint32_t delta, const float tone_mix_weight) {
|
||||
delta_ = delta;
|
||||
delta_ = (uint8_t) ((delta & 0xFF000000U) >> 24);
|
||||
tone_mix_weight_ = tone_mix_weight;
|
||||
input_mix_weight_ = 1.0 - tone_mix_weight;
|
||||
|
||||
current_tone_type_ = sine;
|
||||
}
|
||||
|
||||
void ToneGen::configure(const uint32_t delta, const float tone_mix_weight, const tone_type tone_type) {
|
||||
delta_ = delta;
|
||||
void ToneGen::configure(const uint32_t freq, const float tone_mix_weight, const tone_type tone_type, const uint32_t sample_rate) {
|
||||
delta_ = (uint8_t) ((freq * sizeof(sine_table_i8)) / sample_rate);
|
||||
tone_mix_weight_ = tone_mix_weight;
|
||||
input_mix_weight_ = 1.0 - tone_mix_weight;
|
||||
current_tone_type_ = tone_type;
|
||||
|
@ -67,7 +68,7 @@ int32_t ToneGen::process(const int32_t sample_in) {
|
|||
int32_t tone_sample = 0;
|
||||
|
||||
if(current_tone_type_ == sine) {
|
||||
tone_sample = tone_from_sine_table();
|
||||
tone_sample = tone_sine();
|
||||
}
|
||||
else if(current_tone_type_ == square) {
|
||||
tone_sample = tone_square();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue