mirror of
https://github.com/eried/portapack-mayhem.git
synced 2025-07-31 18:49:15 -04: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:
parent
3221992ad1
commit
b38adf3769
23 changed files with 403 additions and 445 deletions
|
@ -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();
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue