bbx_net/lib.rs
1//! # BBX Net
2//!
3//! Network audio control for art installations and live performance: OSC and WebSocket protocols.
4//!
5//! This crate provides lock-free, realtime-safe network message passing for
6//! distributed audio systems. It supports:
7//!
8//! - **OSC (UDP)**: For TouchOSC, Max/MSP, and other creative tools
9//! - **WebSocket**: For phone PWA interfaces
10//!
11//! ## Features
12//!
13//! - `osc` - Enable OSC protocol support (requires `rosc` crate)
14//! - `websocket` - Enable WebSocket support (requires tokio runtime)
15//! - `full` - Enable all protocols
16//!
17//! ## Example
18//!
19//! ```rust,ignore
20//! use bbx_net::{net_buffer, NetMessage, NodeId};
21//! use bbx_core::random::XorShiftRng;
22//!
23//! // Create a buffer for network -> audio thread communication
24//! let (mut producer, mut consumer) = net_buffer(256);
25//!
26//! // Generate a node ID
27//! let mut rng = XorShiftRng::new(12345);
28//! let node_id = NodeId::generate(&mut rng);
29//!
30//! // In network thread: send parameter changes
31//! let msg = NetMessage::param_change("gain", 0.5, node_id);
32//! producer.try_send(msg);
33//!
34//! // In audio thread: receive messages (realtime-safe)
35//! let events = consumer.drain_into_stack();
36//! for event in events {
37//! // Apply parameter change to DSP graph
38//! }
39//! ```
40
41pub mod address;
42pub mod buffer;
43pub mod clock;
44pub mod error;
45pub mod message;
46
47#[cfg(feature = "osc")]
48pub mod osc;
49
50#[cfg(feature = "websocket")]
51pub mod websocket;
52
53pub use address::{AddressPath, NodeId};
54pub use buffer::{MAX_NET_EVENTS_PER_BUFFER, NetBufferConsumer, NetBufferProducer, net_buffer};
55pub use clock::{ClockSync, SyncedTimestamp};
56pub use error::{NetError, Result};
57pub use message::{NetEvent, NetMessage, NetMessageType, NetPayload, hash_param_name};