1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
//! Real-time audio frequency visualization via libcava.
//!
//! # Overview
//!
//! Captures system audio and produces frequency bar data for visual representations.
//! The service wraps libcava's FFI interface and exposes configuration and output
//! through reactive [`Property`] fields.
//!
//! # Reactive Properties
//!
//! All [`CavaService`] fields are [`Property<T>`] types:
//!
//! - **Snapshot**: Call `.get()` for the current value
//! - **Stream**: Call `.watch()` for a `Stream<Item = T>` that yields on changes
//!
//! ```rust,no_run
//! use wayle_cava::CavaService;
//! use futures::StreamExt;
//!
//! # async fn example() -> Result<(), wayle_cava::Error> {
//! let cava = CavaService::new().await?;
//!
//! // Snapshot: get current bar values
//! let bars = cava.values.get();
//! println!("Bar count: {}, first value: {:.2}", bars.len(), bars[0]);
//!
//! // Stream: react to visualization updates
//! let mut stream = cava.values.watch();
//! while let Some(values) = stream.next().await {
//! // values updates at configured framerate (default 60fps)
//! draw_visualization(&values);
//! }
//! # Ok(())
//! # }
//! # fn draw_visualization(_: &[f64]) {}
//! ```
//!
//! # Configuration
//!
//! Use the builder for initial configuration:
//!
//! ```rust,no_run
//! # async fn example() -> Result<(), wayle_cava::Error> {
//! use wayle_cava::{CavaService, InputMethod};
//!
//! let cava = CavaService::builder()
//! .bars(32)
//! .framerate(30)
//! .input(InputMethod::PipeWire)
//! .stereo(true)
//! .build()
//! .await?;
//! # Ok(())
//! # }
//! ```
//!
//! Runtime changes trigger automatic service restarts:
//!
//! ```rust,no_run
//! # async fn example() -> Result<(), wayle_cava::Error> {
//! # let cava = wayle_cava::CavaService::new().await?;
//! cava.set_bars(64).await?; // Restarts with new bar count
//! cava.set_noise_reduction(0.5).await?; // Restarts with new filter
//! # Ok(())
//! # }
//! ```
//!
//! # Service Fields
//!
//! | Field | Type | Description |
//! |-------|------|-------------|
//! | [`values`] | `Vec<f64>` | Bar amplitudes (0.0-1.0, can overshoot) |
//! | [`bars`] | `usize` | Number of frequency bars (1-256) |
//! | [`framerate`] | `u32` | Update rate in fps |
//! | [`input`] | `InputMethod` | Audio capture backend |
//! | [`source`] | `String` | Audio source ("auto" for auto-detect) |
//! | [`autosens`] | `bool` | Auto-adjust sensitivity |
//! | [`stereo`] | `bool` | Split bars between L/R channels |
//! | [`noise_reduction`] | `f64` | Smoothing filter (0.0-1.0) |
//! | [`monstercat`] | `f64` | Monstercat smoothing (0.0 = off) |
//! | [`waves`] | `u32` | Wave smoothing (0 = off) |
//! | [`low_cutoff`] | `u32` | Low frequency filter (Hz) |
//! | [`high_cutoff`] | `u32` | High frequency filter (Hz) |
//! | [`samplerate`] | `u32` | Audio sample rate (Hz) |
//!
//! [`values`]: CavaService::values
//! [`bars`]: CavaService::bars
//! [`framerate`]: CavaService::framerate
//! [`input`]: CavaService::input
//! [`source`]: CavaService::source
//! [`autosens`]: CavaService::autosens
//! [`stereo`]: CavaService::stereo
//! [`noise_reduction`]: CavaService::noise_reduction
//! [`monstercat`]: CavaService::monstercat
//! [`waves`]: CavaService::waves
//! [`low_cutoff`]: CavaService::low_cutoff
//! [`high_cutoff`]: CavaService::high_cutoff
//! [`samplerate`]: CavaService::samplerate
//! [`Property`]: wayle_core::Property
//! [`Property<T>`]: wayle_core::Property
//!
//! # Building
//!
//! Two options:
//!
//! **Vendored (recommended):**
//!
//! ```toml
//! [dependencies]
//! wayle-cava = { version = "...", features = ["vendored"] }
//! ```
//!
//! Compiles a pinned, tested version of libcava from source. Requires fftw3 and
//! libpipewire-0.3 development headers. PulseAudio support included if libpulse
//! is available.
//!
//! **System library:**
//!
//! ```toml
//! [dependencies]
//! wayle-cava = "..."
//! ```
//!
//! Links against system libcava. Arch Linux users can install from AUR:
//!
//! ```sh
//! yay -S libcava
//! ```
//!
//! Other distributions may need to build libcava from the
//! [LukashonakV/cava](https://github.com/LukashonakV/cava) fork, which provides
//! the shared library interface this crate requires.
/// Public types for configuring CAVA visualization.
pub use CavaServiceBuilder;
pub use ;
pub use CavaService;
pub use ;
;