Skip to content

Commit

Permalink
Further de-uint'ing of the audio devices
Browse files Browse the repository at this point in the history
  • Loading branch information
johnnovak committed Jun 19, 2024
1 parent 2993213 commit fc2f7b3
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 14 deletions.
5 changes: 3 additions & 2 deletions src/hardware/covox.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,9 @@ void Covox::ConfigureFilters(const FilterState state)
{
assert(channel);
if (state == FilterState::On) {
constexpr uint8_t lp_order = 2;
const uint16_t lp_cutoff_freq_hz = 9000;
constexpr auto lp_order = 2;
constexpr auto lp_cutoff_freq_hz = 9000;

channel->ConfigureLowPassFilter(lp_order, lp_cutoff_freq_hz);
}
channel->SetLowPassFilter(state);
Expand Down
4 changes: 2 additions & 2 deletions src/hardware/disney.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ void Disney::ConfigureFilters(const FilterState state)
channel->SetResampleMethod(ResampleMethod::ZeroOrderHoldAndResample);

// Pull audio frames from the Disney DAC at 7 kHz
channel->SetSampleRate(dss_7khz_rate_hz);
ms_per_frame = MillisInSecond / dss_7khz_rate_hz;
channel->SetSampleRate(SampleRateHz);
ms_per_frame = MillisInSecond / SampleRateHz;

if (state == FilterState::On) {
// The filters are meant to emulate the Disney's bandwidth
Expand Down
4 changes: 2 additions & 2 deletions src/hardware/disney.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ class Disney final : public LptDac {
void WriteControl(const io_port_t, const io_val_t value, const io_width_t);

// The DSS is an LPT DAC with a 16-level FIFO running at 7kHz
static constexpr auto dss_7khz_rate_hz = 7000;
static constexpr uint8_t max_fifo_size = 16;
static constexpr auto SampleRateHz = 7000;
static constexpr auto max_fifo_size = 16;

// Managed objects
std::queue<uint8_t> fifo = {};
Expand Down
4 changes: 2 additions & 2 deletions src/hardware/lpt_dac.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
#include "disney.h"
#include "ston1_dac.h"

LptDac::LptDac(const std::string_view name, const uint16_t channel_rate_hz,
LptDac::LptDac(const std::string_view name, const int channel_rate_hz,
std::set<ChannelFeature> extra_features)
: dac_name(name)
{
Expand Down Expand Up @@ -97,7 +97,7 @@ void LptDac::RenderUpToNow()
}
}

void LptDac::AudioCallback(const uint16_t requested_frames)
void LptDac::AudioCallback(const int requested_frames)
{
assert(channel);

Expand Down
4 changes: 2 additions & 2 deletions src/hardware/lpt_dac.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
// Provides mandatory scafolding for derived LPT DAC devices
class LptDac {
public:
LptDac(const std::string_view name, const uint16_t channel_rate_hz,
LptDac(const std::string_view name, const int channel_rate_hz,
std::set<ChannelFeature> extra_features = {});

virtual ~LptDac();
Expand All @@ -57,7 +57,7 @@ class LptDac {
// Base LPT DAC functionality
virtual AudioFrame Render() = 0;
void RenderUpToNow();
void AudioCallback(const uint16_t requested_frames);
void AudioCallback(const int requested_frames);
std::queue<AudioFrame> render_queue = {};

MixerChannelPtr channel = {};
Expand Down
4 changes: 2 additions & 2 deletions src/hardware/ston1_dac.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ void StereoOn1::ConfigureFilters(const FilterState state)
{
assert(channel);
if (state == FilterState::On) {
constexpr uint8_t lp_order = 2;
const uint16_t lp_cutoff_freq_hz = 9000;
constexpr auto lp_order = 2;
const auto lp_cutoff_freq_hz = 9000;
channel->ConfigureLowPassFilter(lp_order, lp_cutoff_freq_hz);
}
channel->SetLowPassFilter(state);
Expand Down
4 changes: 2 additions & 2 deletions src/hardware/ston1_dac.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
class StereoOn1 final : public LptDac {
public:
StereoOn1()
: LptDac(ChannelName::StereoOn1Dac, ston1_max_30_khz,
: LptDac(ChannelName::StereoOn1Dac, SampleRateHz,
{ChannelFeature::Stereo})
{}

Expand All @@ -45,7 +45,7 @@ class StereoOn1 final : public LptDac {
void WriteControl(const io_port_t, const io_val_t value, const io_width_t);

private:
static constexpr uint16_t ston1_max_30_khz = 30000u;
static constexpr auto SampleRateHz = 30000;

uint8_t stereo_data[2] = {data_reg, data_reg};
};
Expand Down

0 comments on commit fc2f7b3

Please sign in to comment.