mirror of
https://github.com/portapack-mayhem/mayhem-firmware.git
synced 2025-08-23 06:07:55 +00:00
Microphone tx is mostly working, Voice activation, PTT, CTCSS...
Transmit bandwidth bugfix TX LED is now only lit when using rf amp VU-meter widget Added gain parameter for baseband audio TX
This commit is contained in:
@@ -32,28 +32,9 @@
|
||||
#include <cstddef>
|
||||
#include <array>
|
||||
|
||||
void AudioInput::configure(
|
||||
const iir_biquad_config_t& hpf_config,
|
||||
const float squelch_threshold
|
||||
) {
|
||||
//hpf.configure(hpf_config);
|
||||
//squelch.set_threshold(squelch_threshold);
|
||||
}
|
||||
|
||||
void AudioInput::read_audio_buffer(buffer_s16_t& audio) {
|
||||
//std::array<int16_t, 32> audio_int;
|
||||
|
||||
auto audio_buffer = audio::dma::rx_empty_buffer();
|
||||
|
||||
for(size_t i=0; i<audio_buffer.count; i++) {
|
||||
//const int32_t sample_int = audio.p[i] * k;
|
||||
//const int32_t sample_saturated = __SSAT(sample_int, 16);
|
||||
for (size_t i=0; i<audio_buffer.count; i++)
|
||||
audio.p[i] = audio_buffer.p[i].left;
|
||||
//audio_int[i] = sample_saturated;
|
||||
}
|
||||
/*if( stream && send_to_fifo ) {
|
||||
stream->write(audio_int.data(), audio_buffer.count * sizeof(audio_int[0]));
|
||||
}*/
|
||||
|
||||
//feed_audio_stats(audio);
|
||||
}
|
||||
|
@@ -35,27 +35,13 @@
|
||||
|
||||
class AudioInput {
|
||||
public:
|
||||
void configure(
|
||||
const iir_biquad_config_t& hpf_config,
|
||||
const float squelch_threshold = 0.0f
|
||||
);
|
||||
|
||||
void read_audio_buffer(buffer_s16_t& audio);
|
||||
|
||||
/*void set_stream(std::unique_ptr<StreamInput> new_stream) {
|
||||
stream = std::move(new_stream);
|
||||
}*/
|
||||
|
||||
private:
|
||||
static constexpr float k = 32768.0f;
|
||||
/*static constexpr float k = 32768.0f;
|
||||
static constexpr float ki = 1.0f / k;
|
||||
|
||||
IIRBiquadFilter hpf { };
|
||||
//FMSquelch squelch { };
|
||||
|
||||
//std::unique_ptr<StreamInput> stream { };
|
||||
|
||||
//AudioStatsCollector audio_stats { };
|
||||
IIRBiquadFilter hpf { };*/
|
||||
};
|
||||
|
||||
#endif/*__AUDIO_INPUT_H__*/
|
||||
|
@@ -37,13 +37,14 @@ void MicTXProcessor::execute(const buffer_c8_t& buffer){
|
||||
|
||||
for (size_t i = 0; i<buffer.count; i++) {
|
||||
|
||||
sample = audio_buffer.p[i >> 6] >> 8;
|
||||
sample = audio_buffer.p[i >> 6] >> 8; // 1536000 / 64 = 24000
|
||||
sample = (sample * (int32_t)gain_x10) / 10;
|
||||
|
||||
power += (sample < 0) ? -sample : sample;
|
||||
power += (sample < 0) ? -sample : sample; // Power mean for UI vu-meter
|
||||
|
||||
if (!as) {
|
||||
as = divider;
|
||||
level_message.value = power / (divider / 4);
|
||||
level_message.value = power / (divider / 4); // Why ?
|
||||
shared_memory.application_queue.push(level_message);
|
||||
power = 0;
|
||||
} else {
|
||||
@@ -59,13 +60,18 @@ void MicTXProcessor::execute(const buffer_c8_t& buffer){
|
||||
}
|
||||
|
||||
// FM
|
||||
delta = sample_mixed * fm_delta;
|
||||
|
||||
phase += delta;
|
||||
sphase = phase + (64 << 24);
|
||||
if (fm_delta) {
|
||||
delta = sample_mixed * fm_delta;
|
||||
|
||||
phase += delta;
|
||||
sphase = phase + (64 << 24);
|
||||
|
||||
re = (sine_table_i8[(sphase & 0xFF000000U) >> 24]);
|
||||
im = (sine_table_i8[(phase & 0xFF000000U) >> 24]);
|
||||
re = (sine_table_i8[(sphase & 0xFF000000U) >> 24]);
|
||||
im = (sine_table_i8[(phase & 0xFF000000U) >> 24]);
|
||||
} else {
|
||||
re = 0;
|
||||
im = 0;
|
||||
}
|
||||
|
||||
buffer.p[i] = {re, im};
|
||||
}
|
||||
@@ -77,6 +83,7 @@ void MicTXProcessor::on_message(const Message* const msg) {
|
||||
switch(msg->id) {
|
||||
case Message::ID::AudioTXConfig:
|
||||
fm_delta = message.fm_delta * (0xFFFFFFULL / 1536000);
|
||||
gain_x10 = message.gain_x10;
|
||||
divider = message.divider;
|
||||
ctcss_enabled = message.ctcss_enabled;
|
||||
ctcss_phase_inc = message.ctcss_phase_inc;
|
||||
|
@@ -46,7 +46,7 @@ private:
|
||||
|
||||
AudioInput audio_input { };
|
||||
|
||||
uint32_t divider { };
|
||||
uint32_t divider { }, gain_x10 { };
|
||||
uint32_t as { 0 };
|
||||
uint32_t fm_delta { 0 };
|
||||
bool ctcss_enabled { false };
|
||||
|
Reference in New Issue
Block a user