mirror of
https://github.com/portapack-mayhem/mayhem-firmware.git
synced 2026-09-12 01:29:29 +00:00
Unistroke in dirty code
This commit is contained in:
@@ -96,8 +96,8 @@ void AudioOutput::fill_audio_buffer(const buffer_f32_t& audio, const bool send_t
|
||||
audio_buffer.p[i].left = audio_buffer.p[i].right = sample_saturated;
|
||||
audio_int[i] = sample_saturated;
|
||||
}
|
||||
if( send_to_fifo ) {
|
||||
stream.write(audio_int.data(), audio_buffer.count * sizeof(audio_int[0]));
|
||||
if( stream && send_to_fifo ) {
|
||||
stream->write(audio_int.data(), audio_buffer.count * sizeof(audio_int[0]));
|
||||
}
|
||||
|
||||
feed_audio_stats(audio);
|
||||
|
||||
@@ -32,6 +32,7 @@
|
||||
#include "audio_stats_collector.hpp"
|
||||
|
||||
#include <cstdint>
|
||||
#include <memory>
|
||||
|
||||
class AudioOutput {
|
||||
public:
|
||||
@@ -44,6 +45,10 @@ public:
|
||||
void write(const buffer_s16_t& audio);
|
||||
void write(const buffer_f32_t& audio);
|
||||
|
||||
void set_stream(std::unique_ptr<StreamInput> new_stream) {
|
||||
stream = std::move(new_stream);
|
||||
}
|
||||
|
||||
private:
|
||||
static constexpr float k = 32768.0f;
|
||||
static constexpr float ki = 1.0f / k;
|
||||
@@ -54,7 +59,7 @@ private:
|
||||
IIRBiquadFilter deemph;
|
||||
FMSquelch squelch;
|
||||
|
||||
StreamInput stream { 14 };
|
||||
std::unique_ptr<StreamInput> stream;
|
||||
|
||||
AudioStatsCollector audio_stats;
|
||||
|
||||
|
||||
@@ -28,14 +28,14 @@
|
||||
#include "baseband_sgpio.hpp"
|
||||
#include "baseband_dma.hpp"
|
||||
|
||||
#include "rssi.hpp"
|
||||
#include "i2s.hpp"
|
||||
|
||||
#include "proc_playaudio.hpp"
|
||||
#include "proc_audiotx.hpp"
|
||||
#include "proc_xylos.hpp"
|
||||
#include "proc_fsk_lcr.hpp"
|
||||
|
||||
#include "rssi.hpp"
|
||||
#include "i2s.hpp"
|
||||
|
||||
#include "portapack_shared_memory.hpp"
|
||||
|
||||
#include <array>
|
||||
@@ -98,7 +98,7 @@ void BasebandThread::run() {
|
||||
|
||||
while(true) {
|
||||
// TODO: Place correct sampling rate into buffer returned here:
|
||||
const auto buffer_tmp = baseband::dma::wait_for_tx_buffer();
|
||||
const auto buffer_tmp = baseband::dma::wait_for_rx_buffer();
|
||||
if( buffer_tmp ) {
|
||||
buffer_c8_t buffer {
|
||||
buffer_tmp.p, buffer_tmp.count, baseband_configuration.sampling_rate
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
/*
|
||||
* Copyright (C) 2014 Jared Boone, ShareBrained Technology, Inc.
|
||||
*
|
||||
* This file is part of PortaPack.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2, or (at your option)
|
||||
* any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; see the file COPYING. If not, write to
|
||||
* the Free Software Foundation, Inc., 51 Franklin Street,
|
||||
* Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#include "clock_recovery.hpp"
|
||||
@@ -22,22 +22,26 @@
|
||||
#ifndef __STREAM_INPUT_H__
|
||||
#define __STREAM_INPUT_H__
|
||||
|
||||
#include "portapack_shared_memory.hpp"
|
||||
|
||||
#include "message.hpp"
|
||||
#include "fifo.hpp"
|
||||
|
||||
#include "lpc43xx_cpp.hpp"
|
||||
using namespace lpc43xx;
|
||||
|
||||
#include <cstdint>
|
||||
#include <cstddef>
|
||||
#include <memory>
|
||||
|
||||
class StreamInput {
|
||||
public:
|
||||
StreamInput(const size_t K, CaptureConfig& config) :
|
||||
K { K },
|
||||
StreamInput(CaptureConfig* const config) :
|
||||
config { config },
|
||||
K { config->write_size_log2 + config->buffer_count_log2 },
|
||||
event_bytes_mask { (1UL << config->write_size_log2) - 1 },
|
||||
data { std::make_unique<uint8_t[]>(1UL << K) },
|
||||
fifo { data.get(), K }
|
||||
{
|
||||
config.fifo = &fifo;
|
||||
config->fifo = &fifo;
|
||||
}
|
||||
|
||||
size_t write(const void* const data, const size_t length) {
|
||||
@@ -48,17 +52,16 @@ public:
|
||||
if( (bytes_written & event_bytes_mask) < (last_bytes_written & event_bytes_mask) ) {
|
||||
creg::m4txevent::assert();
|
||||
}
|
||||
config->baseband_bytes_received += length;
|
||||
config->baseband_bytes_dropped = config->baseband_bytes_received - bytes_written;
|
||||
|
||||
return written;
|
||||
}
|
||||
|
||||
uint64_t written() const {
|
||||
return bytes_written;
|
||||
}
|
||||
|
||||
private:
|
||||
CaptureConfig* const config;
|
||||
const size_t K;
|
||||
const uint64_t event_bytes_mask = (1ULL << (K - 2)) - 1;
|
||||
const uint64_t event_bytes_mask;
|
||||
uint64_t bytes_written = 0;
|
||||
std::unique_ptr<uint8_t[]> data;
|
||||
FIFO<uint8_t> fifo;
|
||||
|
||||
Reference in New Issue
Block a user