mirror of
https://github.com/portapack-mayhem/mayhem-firmware.git
synced 2025-08-14 09:57:50 +00:00
Replay of IQ files ! :D
Added icons and colors for commonly used files in Fileman Fileman can filter by file extension Bugfix: Fileman doesn't crash anymore on renaming long file names Updated binary
This commit is contained in:
@@ -22,6 +22,7 @@
|
||||
|
||||
#include "proc_replay.hpp"
|
||||
#include "sine_table_int8.hpp"
|
||||
#include "portapack_shared_memory.hpp"
|
||||
|
||||
#include "event_m4.hpp"
|
||||
|
||||
@@ -31,16 +32,18 @@ ReplayProcessor::ReplayProcessor() {
|
||||
channel_filter_pass_f = taps_200k_decim_1.pass_frequency_normalized * 1000000; // 162760.416666667
|
||||
channel_filter_stop_f = taps_200k_decim_1.stop_frequency_normalized * 1000000; // 337239.583333333
|
||||
|
||||
spectrum_interval_samples = (baseband_fs / 8) / spectrum_rate_hz;
|
||||
spectrum_interval_samples = baseband_fs / spectrum_rate_hz;
|
||||
spectrum_samples = 0;
|
||||
|
||||
channel_spectrum.set_decimation_factor(1);
|
||||
|
||||
configured = false;
|
||||
}
|
||||
|
||||
void ReplayProcessor::execute(const buffer_c8_t& buffer) {
|
||||
/* 4MHz, 2048 samples */
|
||||
|
||||
size_t pos = 0;
|
||||
|
||||
if (!configured) return;
|
||||
|
||||
// File data is in C16 format, we need C8
|
||||
// File samplerate is 500kHz, we're at 4MHz
|
||||
@@ -51,37 +54,28 @@ void ReplayProcessor::execute(const buffer_c8_t& buffer) {
|
||||
// So 256 * 4 bytes per sample (C16) = 1024 bytes from the file
|
||||
if( stream ) {
|
||||
const size_t bytes_to_read = sizeof(*buffer.p) * 2 * (buffer.count / 8); // *2 (C16), /8 (oversampling) should be == 1024
|
||||
const auto result = stream->read(iq_buffer.p, bytes_to_read);
|
||||
bytes_read += stream->read(iq_buffer.p, bytes_to_read);
|
||||
}
|
||||
|
||||
//feed_channel_stats(channel);
|
||||
|
||||
// Zero-stuff
|
||||
// Fill and "stretch"
|
||||
for (size_t i = 0; i < buffer.count; i++) {
|
||||
|
||||
// DEBUG: This works. Transmits a 1kHz tone
|
||||
/*sample = (sine_table_i8[(tone_phase & 0xFF000000) >> 24]);
|
||||
tone_phase += (1000 * ((1ULL << 32) / baseband_fs));
|
||||
// Do FM
|
||||
delta = sample * 30000 * (0xFFFFFFULL / baseband_fs);
|
||||
phase += delta;
|
||||
sphase = phase + (64 << 24);
|
||||
iq_buffer.p[i >> 3] = { (int16_t)(sine_table_i8[(sphase & 0xFF000000) >> 24]) << 8, (int16_t)(sine_table_i8[(phase & 0xFF000000) >> 24]) << 8 };
|
||||
*/
|
||||
|
||||
/*if (i & 3)
|
||||
if (i & 3) {
|
||||
buffer.p[i] = buffer.p[i - 1];
|
||||
else {*/
|
||||
} else {
|
||||
auto re_out = iq_buffer.p[i >> 3].real() >> 8;
|
||||
auto im_out = iq_buffer.p[i >> 3].imag() >> 8;
|
||||
buffer.p[i] = { re_out, im_out };
|
||||
//}
|
||||
buffer.p[i] = { (int8_t)re_out, (int8_t)im_out };
|
||||
}
|
||||
}
|
||||
|
||||
spectrum_samples += buffer.count;
|
||||
if( spectrum_samples >= spectrum_interval_samples ) {
|
||||
spectrum_samples -= spectrum_interval_samples;
|
||||
channel_spectrum.feed(iq_buffer, channel_filter_pass_f, channel_filter_stop_f);
|
||||
|
||||
txprogress_message.progress = bytes_read; // Inform UI about progress
|
||||
txprogress_message.done = false;
|
||||
shared_memory.application_queue.push(txprogress_message);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -93,8 +87,15 @@ void ReplayProcessor::on_message(const Message* const message) {
|
||||
break;
|
||||
|
||||
case Message::ID::ReplayConfig:
|
||||
configured = false;
|
||||
bytes_read = 0;
|
||||
replay_config(*reinterpret_cast<const ReplayConfigMessage*>(message));
|
||||
break;
|
||||
|
||||
// App has prefilled the buffers, we're ready to go now
|
||||
case Message::ID::FIFOData:
|
||||
configured = true;
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
@@ -104,6 +105,9 @@ void ReplayProcessor::on_message(const Message* const message) {
|
||||
void ReplayProcessor::replay_config(const ReplayConfigMessage& message) {
|
||||
if( message.config ) {
|
||||
stream = std::make_unique<StreamOutput>(message.config);
|
||||
|
||||
// Tell application that the buffers and FIFO pointers are ready, prefill
|
||||
shared_memory.application_queue.push(sig_message);
|
||||
} else {
|
||||
stream.reset();
|
||||
}
|
||||
|
@@ -47,26 +47,29 @@ private:
|
||||
|
||||
BasebandThread baseband_thread { baseband_fs, this, NORMALPRIO + 20, baseband::Direction::Transmit };
|
||||
|
||||
std::array<complex16_t, 256> iq { }; // This fits in just right in allocated RAM - Too big ?
|
||||
std::array<complex16_t, 256> iq { };
|
||||
const buffer_c16_t iq_buffer {
|
||||
iq.data(),
|
||||
iq.size()
|
||||
iq.size(),
|
||||
baseband_fs / 8
|
||||
};
|
||||
|
||||
uint32_t channel_filter_pass_f = 0;
|
||||
uint32_t channel_filter_stop_f = 0;
|
||||
|
||||
// DEBUG
|
||||
//uint32_t tone_phase { 0 }, phase { 0 }, delta { 0 }, sphase { 0 };
|
||||
//int8_t sample { 0 };
|
||||
|
||||
std::unique_ptr<StreamOutput> stream { };
|
||||
|
||||
SpectrumCollector channel_spectrum { };
|
||||
size_t spectrum_interval_samples = 0;
|
||||
size_t spectrum_samples = 0;
|
||||
|
||||
bool configured { false };
|
||||
uint32_t bytes_read { 0 };
|
||||
|
||||
void replay_config(const ReplayConfigMessage& message);
|
||||
|
||||
TXProgressMessage txprogress_message { };
|
||||
RequestSignalMessage sig_message { RequestSignalMessage::Signal::FillRequest };
|
||||
};
|
||||
|
||||
#endif/*__PROC_REPLAY_HPP__*/
|
||||
|
@@ -51,8 +51,6 @@ size_t StreamOutput::read(void* const data, const size_t length) {
|
||||
// We need a full buffer...
|
||||
if( !fifo_buffers_full.out(active_buffer) ) {
|
||||
// ...but none are available. Hole in transmission (inform app and stop ?)
|
||||
//active_buffer = nullptr;
|
||||
//creg::m4txevent::assert();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user