mirror of
https://github.com/eried/portapack-mayhem.git
synced 2025-06-24 14:50:43 -04:00
Replay buffer size and samplerate adjustment
This commit is contained in:
parent
33a2df9d2a
commit
46515ebb05
6 changed files with 36 additions and 26 deletions
|
@ -28,6 +28,9 @@
|
||||||
//TEST: Check AFSK transmit end, skips last bits ?
|
//TEST: Check AFSK transmit end, skips last bits ?
|
||||||
//TEST: Imperial in whipcalc
|
//TEST: Imperial in whipcalc
|
||||||
|
|
||||||
|
//BUG: CPLD-related rx ok, tx bad, see portapack.cpp lines 214+ to disable CPLD overlay
|
||||||
|
//BUG: REPLAY See what's wrong with quality (format, or need for interpolation filter ?)
|
||||||
|
//TODO: REPLAY Convert C16 to C8 on M0 core
|
||||||
//BUG: SCANNER Lock on frequency, if frequency jump, still locked on first one
|
//BUG: SCANNER Lock on frequency, if frequency jump, still locked on first one
|
||||||
//BUG: SCANNER Multiple slices
|
//BUG: SCANNER Multiple slices
|
||||||
//BUG: REPLAY freezes when SD card not present
|
//BUG: REPLAY freezes when SD card not present
|
||||||
|
|
|
@ -25,10 +25,6 @@
|
||||||
#include "baseband_api.hpp"
|
#include "baseband_api.hpp"
|
||||||
#include "buffer_exchange.hpp"
|
#include "buffer_exchange.hpp"
|
||||||
|
|
||||||
// DEBUG:
|
|
||||||
#include "hackrf_gpio.hpp"
|
|
||||||
using namespace hackrf::one;
|
|
||||||
|
|
||||||
struct BasebandReplay {
|
struct BasebandReplay {
|
||||||
BasebandReplay(ReplayConfig* const config) {
|
BasebandReplay(ReplayConfig* const config) {
|
||||||
baseband::replay_start(config);
|
baseband::replay_start(config);
|
||||||
|
@ -90,10 +86,7 @@ Optional<File::Error> ReplayThread::run() {
|
||||||
return read_result.error();
|
return read_result.error();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!buffers.put(buffer))
|
buffers.put(buffer);
|
||||||
for(;;){}; // DEBUG
|
|
||||||
|
|
||||||
led_tx.toggle(); // DEBUG
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return { };
|
return { };
|
||||||
|
|
|
@ -91,7 +91,7 @@ void ReplayView::set_file_list(const std::vector<std::filesystem::path>& file_li
|
||||||
|
|
||||||
for (const auto& file : file_list) {
|
for (const auto& file : file_list) {
|
||||||
bbd_file.open("/" + file.string());
|
bbd_file.open("/" + file.string());
|
||||||
duration = bbd_file.size() / (2 * 2 * (sampling_rate / 8));
|
duration = bbd_file.size() / (2 * 2 * sampling_rate / 4);
|
||||||
file_options.emplace_back(file.string().substr(0, 8), duration);
|
file_options.emplace_back(file.string().substr(0, 8), duration);
|
||||||
}
|
}
|
||||||
options_files.set_options(file_options);
|
options_files.set_options(file_options);
|
||||||
|
|
|
@ -59,7 +59,7 @@ private:
|
||||||
using option_t = std::pair<std::string, int32_t>;
|
using option_t = std::pair<std::string, int32_t>;
|
||||||
using options_t = std::vector<option_t>;
|
using options_t = std::vector<option_t>;
|
||||||
|
|
||||||
static constexpr uint32_t sampling_rate = 1000000;
|
static constexpr uint32_t sampling_rate = 4000000;
|
||||||
|
|
||||||
void toggle();
|
void toggle();
|
||||||
|
|
||||||
|
|
|
@ -27,26 +27,40 @@
|
||||||
#include "utility.hpp"
|
#include "utility.hpp"
|
||||||
|
|
||||||
ReplayProcessor::ReplayProcessor() {
|
ReplayProcessor::ReplayProcessor() {
|
||||||
|
// TODO: Interpolation filter needed !
|
||||||
|
|
||||||
|
/*spectrum_interval_samples = baseband_fs / spectrum_rate_hz;
|
||||||
|
spectrum_samples = 0;
|
||||||
|
|
||||||
|
channel_spectrum.set_decimation_factor(1);*/
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ReplayProcessor::execute(const buffer_c8_t& buffer) {
|
void ReplayProcessor::execute(const buffer_c8_t& buffer) {
|
||||||
/* 2.4576MHz, 2048 samples */
|
/* 4MHz, 2048 samples */
|
||||||
|
|
||||||
size_t pos = 0;
|
size_t pos = 0;
|
||||||
|
|
||||||
for (size_t c = 0; c < 4; c++) {
|
// File data is in C16 format, we need C8
|
||||||
|
// File samplerate is 500kHz, we're at 4MHz
|
||||||
|
// iq_buffer can only be 512 samples (RAM limitation)
|
||||||
|
// For a full 2048-sample C8 buffer, we need:
|
||||||
|
// 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
|
||||||
|
// So 256 * 4 bytes per sample (C16) = 1024 bytes from the file
|
||||||
if( stream ) {
|
if( stream ) {
|
||||||
const size_t bytes_to_read = sizeof(*buffer.p) * buffer.count / 4;
|
const size_t bytes_to_read = sizeof(*buffer.p) * 2 * (buffer.count / 8); // *2 (C16), /8 (oversampling)
|
||||||
const auto result = stream->read(iq_buffer.p, bytes_to_read);
|
const auto result = stream->read(iq_buffer.p, bytes_to_read);
|
||||||
}
|
}
|
||||||
|
|
||||||
//feed_channel_stats(channel);
|
//feed_channel_stats(channel);
|
||||||
|
|
||||||
for (size_t i = 0; i < (buffer.count / 4); i++) {
|
// Zero-stuff
|
||||||
buffer.p[pos] = { iq_buffer.p[i].real() >> 8, iq_buffer.p[i].imag() >> 8 };
|
for (size_t i = 0; i < buffer.count; i++) {
|
||||||
pos++;
|
if (i & 3)
|
||||||
}
|
buffer.p[i] = { 0, 0 };
|
||||||
|
else
|
||||||
|
buffer.p[i] = { iq_buffer.p[i >> 3].real() >> 8, iq_buffer.p[i >> 3].imag() >> 8 };
|
||||||
}
|
}
|
||||||
|
|
||||||
/*spectrum_samples += channel.count;
|
/*spectrum_samples += channel.count;
|
||||||
|
|
|
@ -26,6 +26,8 @@
|
||||||
#include "baseband_processor.hpp"
|
#include "baseband_processor.hpp"
|
||||||
#include "baseband_thread.hpp"
|
#include "baseband_thread.hpp"
|
||||||
|
|
||||||
|
#include "spectrum_collector.hpp"
|
||||||
|
|
||||||
#include "stream_output.hpp"
|
#include "stream_output.hpp"
|
||||||
|
|
||||||
#include <array>
|
#include <array>
|
||||||
|
@ -40,14 +42,12 @@ public:
|
||||||
void on_message(const Message* const message) override;
|
void on_message(const Message* const message) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// TODO: Repeated value needs to be transmitted from application side.
|
static constexpr size_t baseband_fs = 4000000;
|
||||||
static constexpr size_t baseband_fs = 1000000;
|
|
||||||
//static constexpr auto spectrum_rate_hz = 50.0f;
|
//static constexpr auto spectrum_rate_hz = 50.0f;
|
||||||
|
|
||||||
BasebandThread baseband_thread { baseband_fs, this, NORMALPRIO + 20, baseband::Direction::Transmit };
|
BasebandThread baseband_thread { baseband_fs, this, NORMALPRIO + 20, baseband::Direction::Transmit };
|
||||||
//RSSIThread rssi_thread { NORMALPRIO + 10 };
|
|
||||||
|
|
||||||
std::array<complex16_t, 512> iq { }; // 2048 doesn't fit in allocated RAM
|
std::array<complex16_t, 256> iq { }; // This fits in just right in allocated RAM
|
||||||
const buffer_c16_t iq_buffer {
|
const buffer_c16_t iq_buffer {
|
||||||
iq.data(),
|
iq.data(),
|
||||||
iq.size()
|
iq.size()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue