MCPcopy Create free account
hub / github.com/BillyDM/Firewheel / new

Method new

crates/firewheel-graph/src/context.rs:329–393  ·  view source on GitHub ↗

Create a new Firewheel context.

(config: FirewheelConfig)

Source from the content-addressed store, hash-verified

327 let initial_event_group_capacity = config.initial_event_group_capacity as usize;
328 let mut event_group_pool = Vec::with_capacity(16);
329 for _ in 0..3 {
330 event_group_pool.push(Vec::with_capacity(initial_event_group_capacity));
331 }
332
333 let graph = AudioGraph::new(&config);
334
335 let (shared_clock_input, shared_clock_output) =
336 triple_buffer::triple_buffer(&SharedClock::default());
337
338 let (logger, logger_rx) = firewheel_core::log::realtime_logger(config.logger_config);
339 let (profiler_tx, profiler_rx) = crate::processor::profiling::profiler_channel(
340 config.initial_node_capacity as usize,
341 #[cfg(feature = "node_profiling")]
342 graph.graph_out_node(),
343 );
344 let shared_flags = Arc::new(SharedFlags::default());
345
346 let store = ProcStore::with_capacity(config.proc_store_capacity);
347
348 Self {
349 graph,
350 to_processor_tx,
351 from_processor_rx,
352 processor_drop_flag: None,
353 profiler_rx,
354 logger_rx,
355 pending_processor_channel: Some(ProcessorChannel {
356 shared_flags: Arc::clone(&shared_flags),
357 from_context_rx,
358 to_context_tx,
359 logger,
360 store,
361 profiler_tx,
362 shared_clock_input,
363 }),
364 processor_drop_rx: None,
365 shared_clock_output: RefCell::new(shared_clock_output),
366 sample_rate: NonZeroU32::new(44100).unwrap(),
367 sample_rate_recip: 44100.0f64.recip(),
368 stream_info: None,
369 shared_flags,
370 #[cfg(feature = "musical_transport")]
371 transport_state: Box::new(TransportState::default()),
372 #[cfg(feature = "musical_transport")]
373 transport_state_alloc_reuse: None,
374 event_group_pool,
375 event_group: Vec::with_capacity(initial_event_group_capacity),
376 initial_event_group_capacity,
377 #[cfg(feature = "scheduled_events")]
378 queued_clear_scheduled_events: Vec::new(),
379 config,
380 }
381 }
382
383 /// Try to modify the graph. If the given closure returns an error (or
384 /// if a cycle is detected), then any changes made to the graph inside
385 /// the closure will be reverted.
386 ///

Callers

nothing calls this directly

Calls 4

realtime_loggerFunction · 0.85
profiler_channelFunction · 0.85
graph_out_nodeMethod · 0.80
pushMethod · 0.45

Tested by

no test coverage detected