Skip to content

Commit

Permalink
feat(examples): Add audio reactive wled example
Browse files Browse the repository at this point in the history
  • Loading branch information
fooker committed Oct 28, 2024
1 parent 26816ec commit 0126a0a
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 0 deletions.
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ noise = { workspace = true }

photonic-effects = { path = "effects" }
photonic-lua = { path = "lua" }
photonic-audio = { path = "audio" }
photonic-interface-restore = { path = "interface-restore" }
photonic-interface-cli = { path = "interface-cli" }
photonic-interface-mqtt = { path = "interface-mqtt" }
Expand Down
32 changes: 32 additions & 0 deletions examples/wled-sound-demo.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
use anyhow::Result;

use photonic::attr::{AsFixedAttr, FreeAttrDeclExt, Range};
use photonic::color::palette::Hsl;
use photonic::Scene;
use photonic_audio::attr::Power;
use photonic_effects::nodes::Raindrops;
use photonic_output_net::wled;
use photonic_output_terminal::Terminal;

#[tokio::main]
async fn main() -> Result<()> {
let mut scene = Scene::new();

let raindrops = scene.node("raindrops", Raindrops {
rate: Power::new().with_low_pass_filter(200.0).scale(0.3),
decay: (2.0, 3.0).fixed(),
color: Range(Hsl::new(245.31, 0.5, 0.5), Hsl::new(333.47, 0.7, 0.5)).fixed(),
})?;

let _output = Terminal::new(80).with_waterfall(false);

let output = wled::WledSender {
mode: Default::default(),
size: 50,
target: "192.168.0.29:21324".parse()?,
};

let scene = scene.run(raindrops, output).await?;

return scene.run(60).await;
}

0 comments on commit 0126a0a

Please sign in to comment.