all of the changes

This commit is contained in:
2026-10-23 18:29:51 +02:00
parent 4c435fdd76
commit 5607dcf2b5
73 changed files with 4365 additions and 2059 deletions

View File

@@ -1,12 +1,14 @@
#pragma once
#include "FluidSim/AudioProcessing.hpp"
#include "FluidSim/OutdoorExhaustReverb.hpp"
#include <array>
#include <atomic>
#include <cstddef>
#include <vector>
namespace fluidsim::port {
enum class OutdoorScene { Dry, Field, Wall, Woodland };
enum class OutdoorScene { Dry, Field, Wall, Woodland, Tunnel };
const char *scene_name(OutdoorScene scene);
struct OutdoorAudioConfig {
@@ -28,9 +30,11 @@ struct OutdoorAudioConfig {
class OutdoorAudio {
public:
explicit OutdoorAudio(int sample_rate = 44100, OutdoorAudioConfig config = {});
// Acoustic source inputs are ambient-density times mouth volume flow, kg/s.
// Fluid transport still uses actual donor-density mass flux independently.
AudioFrame process(float intake_mass_flow, float exhaust_mass_flow, float second_exhaust_mass_flow = 0);
void set_scene(OutdoorScene scene) { scene_ = scene; }
OutdoorScene scene() const { return scene_; }
void set_scene(OutdoorScene scene) { requested_scene_.store(scene, std::memory_order_relaxed); }
OutdoorScene scene() const { return requested_scene_.load(std::memory_order_relaxed); }
void set_monitor_filter(bool enabled) { monitor_filter_ = enabled; } // Set before playback/capture.
AudioFrame dry_frame() const { return last_dry_; }
AudioFrame unfiltered_frame() const { return last_raw_; }
@@ -44,7 +48,7 @@ private:
std::size_t delay_left{}, delay_right{};
float fraction_left{}, fraction_right{}, gain_left{}, gain_right{}, alpha{1};
float state_left{}, state_right{};
int group{}; // direct, ground, wall, trees
int group{}; // direct, ground, wall, trees, tunnel
};
struct Emitter {
std::vector<float> filtered, raw;
@@ -53,22 +57,17 @@ private:
float previous_flow{};
LowPass filter;
};
struct TailLine {
std::vector<float> buffer;
std::size_t position{};
float gain{}, state{};
};
int rate_{};
OutdoorAudioConfig config_;
OutdoorScene scene_{OutdoorScene::Wall};
std::atomic<OutdoorScene> requested_scene_{OutdoorScene::Wall};
OutdoorScene active_scene_{OutdoorScene::Wall};
bool monitor_filter_{true};
std::array<Emitter, 3> emitters_;
std::array<TailLine, 4> tail_;
std::array<float, 4> weights_{1, 0, 0, 0};
float scene_alpha_{}, tail_alpha_{}, tail_mix_{};
OutdoorExhaustReverb late_reverb_;
std::array<float, 5> weights_{1, 0, 0, 0, 0};
float scene_alpha_{}, tail_mix_{};
AudioFrame last_dry_{}, last_raw_{};
void configure_emitter(Emitter &emitter, Vec3 position);
AudioFrame render(Emitter &emitter, float flow, AudioFrame &dry, AudioFrame &raw);
AudioFrame diffuse(float input);
};
} // namespace fluidsim::port