mirror of
https://github.com/eried/portapack-mayhem.git
synced 2025-08-02 19:46:45 -04:00
Tone generator class
This commit is contained in:
parent
32ae059c44
commit
1b93dd53e8
16 changed files with 143 additions and 78 deletions
|
@ -153,13 +153,13 @@ void kill_afsk() {
|
|||
}
|
||||
|
||||
void set_audiotx_data(const uint32_t divider, const uint32_t bw, const uint32_t gain_x10,
|
||||
const bool ctcss_enabled, const uint32_t ctcss_phase_inc) {
|
||||
const uint32_t tone_key_delta, const float tone_key_mix_weight) {
|
||||
const AudioTXConfigMessage message {
|
||||
divider,
|
||||
bw,
|
||||
gain_x10,
|
||||
ctcss_phase_inc,
|
||||
ctcss_enabled
|
||||
tone_key_delta,
|
||||
tone_key_mix_weight
|
||||
};
|
||||
send_message(&message);
|
||||
}
|
||||
|
|
|
@ -61,7 +61,7 @@ void set_tones_config(const uint32_t bw, const uint32_t pre_silence, const uint1
|
|||
void kill_tone();
|
||||
void set_sstv_data(const uint8_t vis_code, const uint32_t pixel_duration);
|
||||
void set_audiotx_data(const uint32_t divider, const uint32_t bw, const uint32_t gain_x10,
|
||||
const bool ctcss_enabled, const uint32_t ctcss_phase_inc);
|
||||
const uint32_t tone_key_delta, const float tone_key_mix_weight);
|
||||
void set_fifo_data(const int8_t * data);
|
||||
void set_pwmrssi(int32_t avg, bool enabled);
|
||||
void set_afsk_data(const uint32_t afsk_samples_per_bit, const uint32_t afsk_phase_inc_mark, const uint32_t afsk_phase_inc_space,
|
||||
|
|
|
@ -217,7 +217,7 @@ std::string filesystem_error::what() const {
|
|||
case FR_OK: return "ok";
|
||||
case FR_DISK_ERR: return "disk error";
|
||||
case FR_INT_ERR: return "insanity detected";
|
||||
case FR_NOT_READY: return "not ready";
|
||||
case FR_NOT_READY: return "SD card not ready";
|
||||
case FR_NO_FILE: return "no file";
|
||||
case FR_NO_PATH: return "no path";
|
||||
case FR_INVALID_NAME: return "invalid name";
|
||||
|
|
|
@ -33,7 +33,6 @@
|
|||
//BUG: SCANNER Lock on frequency, if frequency jump, still locked on first one
|
||||
//BUG: SCANNER Multiple slices
|
||||
|
||||
//TODO: Make tone generator class for baseband (with freq, samplerate and mixing ratio parameters)
|
||||
//TODO: Cap Wav viewer position
|
||||
//TODO: Adapt wav viewer position step
|
||||
//TODO: Use unit_auto_scale
|
||||
|
|
|
@ -26,6 +26,7 @@
|
|||
namespace tonekey {
|
||||
|
||||
const tone_key_t tone_keys[] = {
|
||||
{ "None", 0.0 },
|
||||
{ "0 XZ", 67.000 },
|
||||
{ "1 WZ", 69.400 },
|
||||
{ "2 XA", 71.900 },
|
||||
|
@ -88,9 +89,8 @@ void tone_keys_populate(OptionsField& field) {
|
|||
options_t tone_key_options;
|
||||
std::string tone_name;
|
||||
|
||||
tone_key_options.emplace_back(std::make_pair("None", 0));
|
||||
for (size_t c = 0; c < KEY_TONES_NB; c++) {
|
||||
if (c < 50)
|
||||
if (c && (c < 51))
|
||||
tone_name = "CTCSS " + tone_keys[c].first;
|
||||
else
|
||||
tone_name = tone_keys[c].first;
|
||||
|
|
|
@ -59,8 +59,8 @@ void MicTXView::configure_baseband() {
|
|||
sampling_rate / 20, // Update vu-meter at 20Hz
|
||||
transmitting ? transmitter_model.channel_bandwidth() : 0,
|
||||
mic_gain_x10,
|
||||
transmitting ? tone_key_enabled : false,
|
||||
TONES_F2D(tone_keys[tone_key_index].second)
|
||||
TONES_F2D(tone_keys[tone_key_index].second),
|
||||
0.2 // 20% mix
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -150,12 +150,6 @@ MicTXView::MicTXView(
|
|||
tone_keys_populate(options_tone_key);
|
||||
options_tone_key.on_change = [this](size_t i, int32_t) {
|
||||
tone_key_index = i;
|
||||
|
||||
if (tone_key_index) {
|
||||
tone_key_enabled = true;
|
||||
tone_key_index--;
|
||||
} else
|
||||
tone_key_enabled = false;
|
||||
};
|
||||
options_tone_key.set_selected_index(0);
|
||||
|
||||
|
|
|
@ -73,7 +73,6 @@ private:
|
|||
bool va_enabled { };
|
||||
bool rogerbeep_enabled { };
|
||||
uint32_t tone_key_index { };
|
||||
bool tone_key_enabled { };
|
||||
uint32_t mic_gain_x10 { 10 };
|
||||
uint32_t audio_level { 0 };
|
||||
uint32_t va_level { };
|
||||
|
|
|
@ -26,6 +26,7 @@
|
|||
|
||||
#include "lfsr_random.hpp"
|
||||
#include "string_format.hpp"
|
||||
#include "tonesets.hpp"
|
||||
|
||||
using namespace tonekey;
|
||||
using namespace portapack;
|
||||
|
@ -96,7 +97,6 @@ void SoundBoardView::on_tuning_frequency_changed(rf::Frequency f) {
|
|||
|
||||
void SoundBoardView::play_sound(uint16_t id) {
|
||||
uint32_t tone_key_index;
|
||||
bool tone_key_enabled;
|
||||
uint32_t divider;
|
||||
|
||||
if (sounds[id].size == 0) return;
|
||||
|
@ -121,20 +121,14 @@ void SoundBoardView::play_sound(uint16_t id) {
|
|||
|
||||
tone_key_index = options_tone_key.selected_index();
|
||||
|
||||
if (tone_key_index) {
|
||||
tone_key_enabled = true;
|
||||
tone_key_index--;
|
||||
} else
|
||||
tone_key_enabled = false;
|
||||
|
||||
divider = (1536000 / sounds[id].sample_rate) - 1;
|
||||
|
||||
baseband::set_audiotx_data(
|
||||
divider,
|
||||
number_bw.value() * 1000,
|
||||
1,
|
||||
tone_key_enabled,
|
||||
(uint32_t)((tone_keys[tone_key_index].second / 1536000.0) * 0xFFFFFFFFULL)
|
||||
10,
|
||||
TONES_F2D(tone_keys[tone_key_index].second),
|
||||
0.2 // 20% mix
|
||||
);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue