Crates.io | steelseries-sonar |
lib.rs | steelseries-sonar |
version | 0.1.0 |
created_at | 2025-08-29 19:16:22.941017+00 |
updated_at | 2025-08-29 19:16:22.941017+00 |
description | A Rust library for interacting with the SteelSeries Sonar API |
homepage | |
repository | https://github.com/Mark7888/steelseries-sonar-rs |
max_upload_size | |
id | 1816404 |
size | 112,565 |
A Rust library for interacting with the SteelSeries Sonar application API. This crate provides a convenient interface for controlling audio volumes, muting channels, and managing chat mix settings programmatically.
Add this to your Cargo.toml
:
[dependencies]
steelseries-sonar = "0.1.0"
tokio = { version = "1.0", features = ["full"] }
use steelseries_sonar::{Sonar, SonarError};
#[tokio::main]
async fn main() -> Result<(), SonarError> {
// Create a new Sonar client
let sonar = Sonar::new().await?;
// Set master volume to 50%
sonar.set_volume("master", 0.5, None).await?;
// Mute the game channel
sonar.mute_channel("game", true, None).await?;
// Get current volume data
let volume_data = sonar.get_volume_data().await?;
println!("Current volume data: {}", volume_data);
Ok(())
}
use steelseries_sonar::Sonar;
let sonar = Sonar::new().await?;
use steelseries_sonar::Sonar;
use std::path::Path;
// With custom app data path and explicit streamer mode
let sonar = Sonar::with_config(
Some(Path::new("C:\\Custom\\Path\\coreProps.json")),
Some(true), // Enable streamer mode
).await?;
// Set master volume to 75%
sonar.set_volume("master", 0.75, None).await?;
// In streamer mode, specify the slider
sonar.set_volume("game", 0.8, Some("streaming")).await?;
let volume_data = sonar.get_volume_data().await?;
println!("Volume data: {:#}", volume_data);
// Mute the media channel
sonar.mute_channel("media", true, None).await?;
// Unmute the media channel
sonar.mute_channel("media", false, None).await?;
// In streamer mode
sonar.mute_channel("chatRender", true, Some("monitoring")).await?;
// Set chat mix (range: -1.0 to 1.0)
sonar.set_chat_mix(0.3).await?;
// Get current chat mix data
let chat_mix_data = sonar.get_chat_mix_data().await?;
// Check if streamer mode is enabled
let is_streamer_mode = sonar.is_streamer_mode().await?;
println!("Streamer mode: {}", is_streamer_mode);
// Toggle streamer mode
let mut sonar = Sonar::new().await?;
sonar.set_streamer_mode(true).await?;
The following audio channels are supported:
"master"
- Master volume"game"
- Game audio"chatRender"
- Chat playback"media"
- Media/music"aux"
- Auxiliary audio"chatCapture"
- Microphone/chat captureSteelSeries Sonar supports streamer mode, which provides two separate slider controls:
"streaming"
- Audio levels for the stream output"monitoring"
- Audio levels for personal monitoringWhen streamer mode is enabled, you can specify which slider to control:
// Control the streaming slider
sonar.set_volume("game", 0.8, Some("streaming")).await?;
// Control the monitoring slider
sonar.set_volume("game", 0.6, Some("monitoring")).await?;
The library provides comprehensive error handling through the SonarError
enum:
use steelseries_sonar::{Sonar, SonarError};
match sonar.set_volume("invalid_channel", 0.5, None).await {
Ok(_) => println!("Volume set successfully"),
Err(SonarError::ChannelNotFound(channel)) => {
eprintln!("Invalid channel: {}", channel);
}
Err(SonarError::InvalidVolume(volume)) => {
eprintln!("Invalid volume: {}", volume);
}
Err(err) => eprintln!("Other error: {}", err),
}
Check out the examples/
directory for more comprehensive usage examples:
basic_usage.rs
- Basic volume and mute controlsstreamer_mode.rs
- Working with streamer modechat_mix.rs
- Chat mix managementContributions are welcome! Please feel free to submit a Pull Request. For major changes, please open an issue first to discuss what you would like to change.
# Clone the repository
git clone https://github.com/Mark7888/steelseries-sonar-rs.git
cd steelseries-sonar-rs
# Run tests
cargo test
# Build documentation
cargo doc --open
# Run examples
cargo run --example basic_usage
This project is licensed under the MIT License - see the LICENSE file for details.
See CHANGELOG.md for a list of changes and version history.