mirror of
https://github.com/portapack-mayhem/mayhem-firmware.git
synced 2025-08-14 08:07:37 +00:00
C8 capture support (#1286)
* C8 conversion * C8 conversion * C8 support * C8 support * C8 support * C8 support * Don't auto-convert GPS C8 files * C8 support * C8 support * C8 support * Remove hang workaround (different PR) * Comment change * Clang * Clang * Clang * Merged change from PR #1287 * C8 support * C8 support * Improve bandwidth display * Merged minor optimization from PR 1289 * Merge change from PR 1289 * Use complex types for C8/C16 conversion * C8 support * C8 support * C8 support * C8 support * Roll back changes * Roll back C8 changes * C8 support * C8 support * C8 support * C8 support * C8 support * Don't transmit samples past EOF * Don't transmit samples past EOF * Clang * Clang attempt * Clang attempt * C8 support * Clang
This commit is contained in:
@@ -44,27 +44,27 @@ ReplayProcessor::ReplayProcessor() {
|
||||
void ReplayProcessor::execute(const buffer_c8_t& buffer) {
|
||||
/* 2.6MHz, 2048 samples */
|
||||
|
||||
if (!configured) return;
|
||||
if (!configured || !stream) return;
|
||||
|
||||
// File data is in C8 format, which is what we need
|
||||
// File samplerate is 2.6MHz, which is what we need
|
||||
// To fill up the 2048-sample C8 buffer @ 2 bytes per sample = 4096 bytes
|
||||
if (stream) {
|
||||
const size_t bytes_to_read = sizeof(*buffer.p) * 1 * (buffer.count);
|
||||
size_t bytes_read_this_iteration = stream->read(iq_buffer.p, bytes_to_read);
|
||||
bytes_read += bytes_read_this_iteration;
|
||||
const size_t bytes_to_read = sizeof(*buffer.p) * 1 * (buffer.count);
|
||||
size_t bytes_read_this_iteration = stream->read(iq_buffer.p, bytes_to_read);
|
||||
size_t samples_read_this_iteration = bytes_read_this_iteration / sizeof(*buffer.p);
|
||||
|
||||
// NB: Couldn't we have just read the data into buffer.p to start with, or some DMA/cache coherency concern?
|
||||
//
|
||||
// for (size_t i = 0; i < buffer.count; i++) {
|
||||
// auto re_out = iq_buffer.p[i].real();
|
||||
// auto im_out = iq_buffer.p[i].imag();
|
||||
// buffer.p[i] = {(int8_t)re_out, (int8_t)im_out};
|
||||
// }
|
||||
memcpy(buffer.p, iq_buffer.p, bytes_read_this_iteration); // memcpy should be more efficient than 1 byte at a time
|
||||
}
|
||||
bytes_read += bytes_read_this_iteration;
|
||||
|
||||
spectrum_samples += buffer.count;
|
||||
// NB: Couldn't we have just read the data into buffer.p to start with, or some DMA/cache coherency concern?
|
||||
//
|
||||
// for (size_t i = 0; i < buffer.count; i++) {
|
||||
// auto re_out = iq_buffer.p[i].real();
|
||||
// auto im_out = iq_buffer.p[i].imag();
|
||||
// buffer.p[i] = {(int8_t)re_out, (int8_t)im_out};
|
||||
// }
|
||||
memcpy(buffer.p, iq_buffer.p, bytes_read_this_iteration); // memcpy should be more efficient than 1 byte at a time
|
||||
|
||||
spectrum_samples += samples_read_this_iteration;
|
||||
if (spectrum_samples >= spectrum_interval_samples) {
|
||||
spectrum_samples -= spectrum_interval_samples;
|
||||
|
||||
|
@@ -43,7 +43,7 @@ ReplayProcessor::ReplayProcessor() {
|
||||
void ReplayProcessor::execute(const buffer_c8_t& buffer) {
|
||||
/* 4MHz, 2048 samples */
|
||||
|
||||
if (!configured) return;
|
||||
if (!configured || !stream) return;
|
||||
|
||||
// File data is in C16 format, we need C8
|
||||
// File samplerate is 500kHz, we're at 4MHz
|
||||
@@ -52,13 +52,14 @@ void ReplayProcessor::execute(const buffer_c8_t& buffer) {
|
||||
// 2048 samples * 2 bytes per sample = 4096 bytes
|
||||
// Since we're oversampling by 4M/500k = 8, we only need 2048/8 = 256 samples from the file and duplicate them 8 times each
|
||||
// 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
|
||||
bytes_read += stream->read(iq_buffer.p, bytes_to_read);
|
||||
}
|
||||
const size_t bytes_to_read = sizeof(*buffer.p) * 2 * (buffer.count / 8); // *2 (C16), /8 (oversampling) should be == 1024
|
||||
size_t bytes_read_this_iteration = stream->read(iq_buffer.p, bytes_to_read);
|
||||
size_t oversamples_this_iteration = bytes_read_this_iteration * 8 / (sizeof(*buffer.p) * 2);
|
||||
|
||||
bytes_read += bytes_read_this_iteration;
|
||||
|
||||
// Fill and "stretch"
|
||||
for (size_t i = 0; i < buffer.count; i++) {
|
||||
for (size_t i = 0; i < oversamples_this_iteration; i++) {
|
||||
if (i & 7) {
|
||||
buffer.p[i] = buffer.p[i - 1];
|
||||
} else {
|
||||
@@ -68,7 +69,7 @@ void ReplayProcessor::execute(const buffer_c8_t& buffer) {
|
||||
}
|
||||
}
|
||||
|
||||
spectrum_samples += buffer.count;
|
||||
spectrum_samples += oversamples_this_iteration;
|
||||
if (spectrum_samples >= spectrum_interval_samples) {
|
||||
spectrum_samples -= spectrum_interval_samples;
|
||||
channel_spectrum.feed(iq_buffer, channel_filter_low_f, channel_filter_high_f, channel_filter_transition);
|
||||
|
Reference in New Issue
Block a user