MayaFlux 1.0.0
Digital-First Multimedia Processing Framework
Loading...
Searching...
No Matches

◆ process_batch()

void MayaFlux::Nodes::Network::DuctNetwork::process_batch ( unsigned int num_samples)
overridevirtual

Process the network for the given number of samples.

Parameters
num_samplesNumber of samples/frames to process

Subclasses implement their specific processing logic:

  1. Update internal state (physics, relationships, etc.)
  2. Process individual nodes
  3. Apply inter-node interactions
  4. Aggregate outputs if needed

Called by NodeGraphManager during token processing.

Implements MayaFlux::Nodes::Network::NodeNetwork.

Definition at line 385 of file DuctNetwork.cpp.

386{
389
390 if (!is_enabled() || !m_active || num_samples == 0) {
391 m_scratch.assign(num_samples, 0.0);
393 return;
394 }
395
399
400 Prepared& state = *m_active;
401 state.mouth->process(static_cast<float>(num_samples));
402 state.bell->process(static_cast<float>(num_samples));
403
404 const Output output = m_output.load(std::memory_order_relaxed);
405 const double pickup = m_pickup.load(std::memory_order_relaxed);
406 const Acoustics::DuctGrid& grid = state.grid;
407
408 m_scratch.assign(num_samples, 0.0);
409 for (unsigned int i = 0; i < num_samples; ++i) {
410 Acoustics::advance_velocity(state.velocity, state.pressure, grid.velocity_gain);
411 state.loss.apply(state.velocity);
412
413 const auto [mouth_pressure, mouth_inflow] = state.mouth->couple(state.pressure.front(), state.velocity.front());
414 Acoustics::advance_pressure(state.pressure, state.velocity, grid.pressure_gain);
415 state.pressure.front() = mouth_pressure;
416
417 const auto [bell_pressure, bell_inflow] = state.bell->couple(state.pressure.back(), -state.velocity.back());
418 state.pressure.back() = bell_pressure;
419
420 const double outflow = -bell_inflow;
421 m_scratch[i] = output == Output::RADIATED
422 ? Acoustics::radiated_pressure(outflow, m_previous_outflow, grid.time_step, state.spec.air_density)
423 : Acoustics::sample_pressure(state.pressure, pickup);
424 m_previous_outflow = outflow;
425 }
426
428}
std::shared_ptr< Prepared > m_active
Output
What the network publishes.
@ RADIATED
Pressure radiated at one metre, from the flow out of the bell.
void publish_block(std::span< const double > block)
bool is_enabled() const
Check if network is enabled.
void refresh_controls()
Read node sources and apply the shared scale.
void ensure_initialized()
Ensure initialize() is called exactly once.
double sample_pressure(std::span< const double > pressure, double position) noexcept
Pressure at a position along the bore, linearly interpolated.

References apply_controls(), MayaFlux::Nodes::Network::DuctNetwork::Prepared::bell, MayaFlux::Nodes::Network::NodeNetwork::ensure_initialized(), MayaFlux::Nodes::Network::DuctNetwork::Prepared::grid, install_pending(), MayaFlux::Nodes::Network::NodeNetwork::is_enabled(), MayaFlux::Nodes::Network::DuctNetwork::Prepared::loss, m_active, m_output, m_pickup, m_previous_outflow, m_scratch, MayaFlux::Nodes::Network::DuctNetwork::Prepared::mouth, MayaFlux::Nodes::Network::DuctNetwork::Prepared::pressure, publish_block(), RADIATED, MayaFlux::Nodes::Network::NodeNetwork::refresh_controls(), MayaFlux::Nodes::Network::DuctNetwork::Prepared::spec, update_mapped_parameters(), and MayaFlux::Nodes::Network::DuctNetwork::Prepared::velocity.

Referenced by operator=().

Here is the call graph for this function:
Here is the caller graph for this function: