mirror of
https://github.com/portapack-mayhem/mayhem-firmware.git
synced 2026-09-12 09:39:30 +00:00
Remove sine table lookup from proc_ook (#3201)
This commit is contained in:
@@ -22,25 +22,19 @@
|
|||||||
|
|
||||||
#include "proc_ook.hpp"
|
#include "proc_ook.hpp"
|
||||||
#include "portapack_shared_memory.hpp"
|
#include "portapack_shared_memory.hpp"
|
||||||
#include "sine_table_int8.hpp"
|
|
||||||
#include "event_m4.hpp"
|
#include "event_m4.hpp"
|
||||||
|
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
|
|
||||||
inline void OOKProcessor::write_sample(const buffer_c8_t& buffer, uint8_t bit_value, size_t i) {
|
inline void OOKProcessor::write_sample(const buffer_c8_t& buffer, uint8_t bit_value, size_t i) {
|
||||||
int8_t re, im;
|
int8_t re, im;
|
||||||
|
|
||||||
if (bit_value) {
|
if (bit_value) {
|
||||||
phase = (phase + 200); // What ?
|
re = INT8_MAX;
|
||||||
sphase = phase + (64 << 18);
|
im = 0;
|
||||||
|
|
||||||
re = (sine_table_i8[(sphase & 0x03FC0000) >> 18]);
|
|
||||||
im = (sine_table_i8[(phase & 0x03FC0000) >> 18]);
|
|
||||||
} else {
|
} else {
|
||||||
re = 0;
|
re = 0;
|
||||||
im = 0;
|
im = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
buffer.p[i] = {re, im};
|
buffer.p[i] = {re, im};
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -125,11 +119,8 @@ inline size_t OOKProcessor::duval_algo_step() {
|
|||||||
void OOKProcessor::scan_process(const buffer_c8_t& buffer) {
|
void OOKProcessor::scan_process(const buffer_c8_t& buffer) {
|
||||||
size_t buf_ptr = 0;
|
size_t buf_ptr = 0;
|
||||||
|
|
||||||
// transmit any leftover bits from previous step
|
// Encode the sequence into required format. First call transmits any leftover bits from previous step
|
||||||
if (!scan_encode(buffer, buf_ptr))
|
while (scan_encode(buffer, buf_ptr)) {
|
||||||
return;
|
|
||||||
|
|
||||||
while (1) {
|
|
||||||
// calculate next chunk of deBruijn sequence
|
// calculate next chunk of deBruijn sequence
|
||||||
duval_length = duval_algo_step();
|
duval_length = duval_algo_step();
|
||||||
|
|
||||||
@@ -151,10 +142,6 @@ void OOKProcessor::scan_process(const buffer_c8_t& buffer) {
|
|||||||
duval_bit = 0;
|
duval_bit = 0;
|
||||||
duval_sample_bit = 0;
|
duval_sample_bit = 0;
|
||||||
duval_symbol = 0;
|
duval_symbol = 0;
|
||||||
|
|
||||||
// encode the sequence into required format
|
|
||||||
if (!scan_encode(buffer, buf_ptr))
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -46,8 +46,6 @@ class OOKProcessor : public BasebandProcessor {
|
|||||||
uint16_t bit_pos{0};
|
uint16_t bit_pos{0};
|
||||||
uint8_t cur_bit{0};
|
uint8_t cur_bit{0};
|
||||||
uint32_t sample_count{0};
|
uint32_t sample_count{0};
|
||||||
uint32_t tone_phase{0}, phase{0}, sphase{0};
|
|
||||||
int32_t tone_sample{0}, sig{0}, frq{0};
|
|
||||||
|
|
||||||
TXProgressMessage txprogress_message{};
|
TXProgressMessage txprogress_message{};
|
||||||
|
|
||||||
|
|||||||
@@ -23,9 +23,9 @@
|
|||||||
#ifndef __SINE_TABLE_I8_H__
|
#ifndef __SINE_TABLE_I8_H__
|
||||||
#define __SINE_TABLE_I8_H__
|
#define __SINE_TABLE_I8_H__
|
||||||
|
|
||||||
#include <cmath>
|
#include <cstdint>
|
||||||
|
|
||||||
static const int8_t sine_table_i8[256] = {
|
static constexpr int8_t sine_table_i8[256] = {
|
||||||
0, 2, 5, 8, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42, 45,
|
0, 2, 5, 8, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42, 45,
|
||||||
48, 51, 54, 57, 59, 62, 65, 67, 70, 73, 75, 78, 80, 83, 85, 87,
|
48, 51, 54, 57, 59, 62, 65, 67, 70, 73, 75, 78, 80, 83, 85, 87,
|
||||||
90, 92, 94, 96, 98, 100, 102, 104, 105, 107, 109, 110, 112, 113, 115, 116,
|
90, 92, 94, 96, 98, 100, 102, 104, 105, 107, 109, 110, 112, 113, 115, 116,
|
||||||
|
|||||||
Reference in New Issue
Block a user