92 DuctNetwork(
double length,
double radius,
double sample_rate = 48000.0);
100 DuctNetwork(
double length,
const std::vector<double>& radii,
double sample_rate = 48000.0);
109 DuctNetwork(
double length, std::function<
double(
double)> radius,
double sample_rate = 48000.0);
130 void reset()
override;
133 [[nodiscard]] std::optional<double> get_node_output(
size_t index)
const override;
134 [[nodiscard]] std::optional<std::span<const double>> get_node_audio_buffer(
size_t index)
const override;
135 [[nodiscard]] std::unordered_map<std::string, std::string> get_metadata()
const override;
137 void map_parameter(
const std::string& param_name,
138 const std::shared_ptr<Node>& source,
141 void map_parameter(
const std::string& param_name,
142 const std::shared_ptr<NodeNetwork>& source)
override;
144 void unmap_parameter(
const std::string& param_name)
override;
151 [[nodiscard]]
bool set_length(
double length);
154 [[nodiscard]]
bool set_radius(
double radius);
157 [[nodiscard]]
bool set_profile(
const std::vector<double>& radii);
160 [[nodiscard]]
bool set_profile(std::function<
double(
double)> radius);
170 [[nodiscard]]
bool set_mouth_volume(
double volume);
185 [[nodiscard]]
bool set_wall_losses(
double friction,
double viscosity);
191 [[nodiscard]]
bool use_viscothermal_losses();
201 [[nodiscard]]
bool set_mouth(std::shared_ptr<TerminationOperator> termination);
204 [[nodiscard]]
bool set_bell(std::shared_ptr<TerminationOperator> termination);
206 [[nodiscard]] std::shared_ptr<TerminationOperator> get_mouth()
const;
207 [[nodiscard]] std::shared_ptr<TerminationOperator> get_bell()
const;
217 [[nodiscard]] std::vector<double> pressure_field()
const;
235 void setup(
double length, Profile profile,
double sample_rate);
237 [[nodiscard]] std::shared_ptr<Prepared> build(
239 const Profile& profile,
240 const Losses& losses,
242 const std::shared_ptr<TerminationOperator>& mouth,
243 const std::shared_ptr<TerminationOperator>& bell)
const;
245 void publish(std::shared_ptr<Prepared> next);
246 void install_pending();
247 void bind(Prepared& prepared,
bool keep);
248 void update_mapped_parameters();
249 void apply_controls();
250 void apply_pickup_position(
double position);
251 void publish_block(std::span<const double> block);
262 std::shared_ptr<TerminationOperator>
m_bell;
#define MF_DESCRIBE(...)
Requests a generated member description for a struct at namespace scope.
Interleaved grid of a one dimensional acoustic bore.
Wall losses of a duct as friction and viscosity on the volume velocity.
void observe(T actual) noexcept
Shows the value the owner really has, unless a source is feeding it.
One named control of a network or operator: empty, a value, or a mapped source.
std::atomic< Output > m_output
std::shared_ptr< TerminationOperator > m_mouth
size_t get_node_count() const override
Number of pressure points along the duct.
std::shared_ptr< Prepared > m_slot
DuctNetwork(double length, double radius, double sample_rate=48000.0)
A cylinder.
std::shared_ptr< Prepared > m_active
Output
What the network publishes.
@ PICKUP
Pressure inside the duct at the pickup position.
@ RADIATED
Pressure radiated at one metre, from the flow out of the bell.
std::atomic< double > m_pickup
void process_batch(unsigned int num_samples) override
Process the network for the given number of samples.
std::atomic< uint8_t > m_handoff
std::shared_ptr< TerminationOperator > m_bell
double m_applied_viscosity
void read_controls(DuctControls &controls) const
Fills the controls whose value the network holds outside the struct.
std::atomic< size_t > m_field_points
std::vector< double > m_field
std::vector< double > m_scratch
DuctControls & m_controls
DuctNetwork & operator=(const DuctNetwork &)=delete
DuctNetwork & operator=(DuctNetwork &&)=delete
DuctNetwork(DuctNetwork &&)=delete
double m_applied_friction
std::mutex m_producer_mutex
DuctNetwork(const DuctNetwork &)=delete
double m_previous_outflow
A one dimensional acoustic duct of any bore shape, solved by finite differences, with a termination a...
Abstract base class for structured collections of nodes with defined relationships.
MappingMode
How one source maps to a network's elements.
@ BROADCAST
One source value applies to every network element.
Control pickup
Pickup position, 0 to 1 along the duct.
Control noise_cutoff
Reed breath noise cutoff.
Control driving_pressure
Junction driving pressure.
Control output
Above one half the output is the pickup pressure, not the radiated one.
Control maximum_flow
Junction maximum flow.
Control reed_area
Reed area.
Control resonance
Reed resonance.
Control lip
Lip pressure on the reed.
Control scale
Output scale.
Control pressure
Reed blowing pressure.
Control closing_pressure
Reed closing pressure.
Control smoothing
Reed pressure smoothing.
Control reed_damping
Reed damping.
Control opening
Reed rest opening.
Control noise
Reed breath noise.
Controls of a DuctNetwork, each a number or a mapped node.
std::vector< double > radii
std::function< double(double)> function