Skip to main content

Simple Python wrapper for the SteelSeries Sonar API

Project description

publish Downloads

SteelSeries Sonar Python API

Overview

This Python package provides a convenient interface for interacting with the SteelSeries Sonar application API. The Sonar application allows users to control and display volumes for various audio channels.

Installation

To use this package, follow these steps:

  1. Install the package using pip:

    pip install steelseries-sonar-py
    
  2. Import the Sonar class in your Python script or application:

    from steelseries_sonar_py import Sonar
    

Usage

Initializing the Sonar Object

The Sonar class accepts two optional parameters during initialization: streamer_mode: Set to True to use streamer mode (default is False). app_data_path: Specify a custom path for the SteelSeries Engine 3 coreProps.json file (default is the default installation path: C:\\ProgramData\\SteelSeries\\SteelSeries Engine 3\\coreProps.json).

sonar = Sonar(streamer_mode=True, app_data_path="C:\\path\\to\\coreProps.json")

Retrieving Volume Information

Retrieve information about the current volume settings for all channels:

volume_data = sonar.get_volume_data()
print(volume_data)

Setting Volume for a Channel

Set the volume for a specific channel. The channel parameter should be one of the following: "master", "game", "chatRender", "media", "aux", "chatCapture". The volume parameter should be a float between 0 and 1:

channel = "master"
volume = 0.75

result = sonar.set_volume(channel, volume)
print(result)

Muting/Unmuting a Channel

Toggle mute status for a specific channel. The channel parameter should be one of the following: master, game, chatRender, media, aux, chatCapture. The muted parameter should be a boolean indicating whether to mute (True) or unmute (False) the channel:

channel = "game"
muted = True

result = sonar.mute_channel(channel, muted)
print(result)

Chatmix

Chatmix value between -1 and 1 to focus sound from the game or chatRender channel:

result = sonar.chat_mix(0.5)
print(result)

Exceptions

The package introduces a set of exceptions that might be raised during usage. It is advisable to handle these exceptions accordingly in your code. You can import them from steelseries_sonar_py.exceptions. Here is the list of potential exceptions:

  • EnginePathNotFoundError: Raised when SteelSeries Engine 3 is not installed or not in the default location.
  • ServerNotAccessibleError: Raised when the SteelSeries server is not accessible. Provides the HTTP status code.
  • SonarNotEnabledError: Raised when SteelSeries Sonar is not enabled.
  • ServerNotReadyError: Raised when SteelSeries Sonar is not ready.
  • ServerNotRunningError: Raised when SteelSeries Sonar is not running.
  • WebServerAddressNotFoundError: Raised when the web server address is not found.
  • ChannelNotFoundError: Raised when the specified channel is not found.
  • InvalidVolumeError: Raised when an invalid volume value is provided.

Example

Here is a complete example demonstrating the usage of the SteelSeries Sonar Python API:

from steelseries_sonar_py import Sonar
from steelseries_sonar_py.exceptions import EnginePathNotFoundError

# Initialize Sonar object
try:
    sonar = Sonar(streamer_mode=False, app_data_path="C:\\path\\to\\coreProps.json")
except EnginePathNotFoundError:
    print("Engine not found!")
    quit()

# Retrieve volume data
volume_data = sonar.get_volume_data()
print("Volume Data:", volume_data)

# Set volume for the 'master' channel
channel = "master"
volume = 0.8
result = sonar.set_volume(channel, volume)
print(f"Set volume for {channel}:", result)

# Mute the 'game' channel
channel = "game"
muted = True
result = sonar.mute_channel(channel, muted)
print(f"Mute {channel}:", result)

Special Thanks

Thanks to two contributors who made this package possible - wex for figuring out the API and TotalPanther317 for understanding streamer mode. Grateful for their efforts!

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

steelseries_sonar_py-1.1.1.tar.gz (8.2 kB view details)

Uploaded Source

Built Distribution

steelseries_sonar_py-1.1.1-py3-none-any.whl (5.9 kB view details)

Uploaded Python 3

File details

Details for the file steelseries_sonar_py-1.1.1.tar.gz.

File metadata

  • Download URL: steelseries_sonar_py-1.1.1.tar.gz
  • Upload date:
  • Size: 8.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.0.0 CPython/3.12.3

File hashes

Hashes for steelseries_sonar_py-1.1.1.tar.gz
Algorithm Hash digest
SHA256 e33245a95006f6a7bb142a66dd11fae6488a3cfd223628ec2161361f092c8c29
MD5 d42af57f96a2f0f1e2bfaa9946d749da
BLAKE2b-256 87668aecc10800cec54fb52ba0d4d01059928070d830d049abba82cac9338864

See more details on using hashes here.

File details

Details for the file steelseries_sonar_py-1.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for steelseries_sonar_py-1.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 207ebbbc6aeec58222c72a6a55df9483119ade9738075c86337fd35652eac4ee
MD5 b887e2ac1ffc955a0fade59e4fe1f72d
BLAKE2b-256 c0f27a4d4b8aa0a83a320d3ef6bff5737804c74861cb55af8fd83e50eae7544b

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page