Skip to main content

An async python package for interfacing with Cambridge Audio / Stream Magic compatible streamers.

Project description

aiostreammagic

An async python package for interfacing with Cambridge Audio / Stream Magic compatible streamers

📖 Read the docs »

GitHub Release Python Versions License

About

This module implements a Python client for the Stream Magic API used to control Cambridge Audio streamers. The API connects over websockets and supports several streamers, receivers, and pre-amps.

Supported Devices

  • Cambridge Audio Evo One
  • Cambridge Audio Evo 75
  • Cambridge Audio Evo 150
  • Cambridge Audio CXN
  • Cambridge Audio CXN V2
  • Cambridge Audio CXN100
  • Cambridge Audio CXR120
  • Cambridge Audio CXR200
  • Cambridge Audio 851N
  • Cambridge Audio Edge NQ
  • Cambridge Audio AXN10

If your model is not on the list of supported devices, and everything works correctly then add it to the list by opening a pull request.

Installation

pip install aiostreammagic

Usage

Basic Example

import asyncio

from aiostreammagic import StreamMagicClient

HOST = "192.168.20.218"


async def main():
    """Basic demo entrypoint."""
    async with StreamMagicClient(HOST) as client:

        print(f"Model: {client.info.model}")

        for source in client.sources:
            print(f"Name: {source.id} ({source.id})")

if __name__ == '__main__':
    asyncio.run(main())

Subscription Example

The Cambridge Audio StreamMagic API can automatically notify the client of changes instead of the need for polling. Register a callback to be called whenver new information is available.

import asyncio

from aiostreammagic import StreamMagicClient

HOST = "192.168.20.218"


async def on_state_change(client: StreamMagicClient):
    """Called when new information is received."""
    print(f"System info: {client.info}")
    print(f"Sources: {client.sources}")
    print(f"State: {client.state}")
    print(f"Play State: {client.play_state}")
    print(f"Now Playing: {client.now_playing}")

async def main():
    """Subscribe demo entrypoint."""
    client = StreamMagicClient(HOST)
    await client.register_state_update_callbacks(on_state_change)
    await client.connect()

    # Play media using the unit's front controls or StreamMagic app
    await asyncio.sleep(60)

    await client.disconnect()


if __name__ == '__main__':
    asyncio.run(main())

Advanced Audio Settings

Balance

Adjust left/right speaker balance (requires pre-amp mode):

async with StreamMagicClient(HOST) as client:
    await client.set_pre_amp_mode(True)
    await client.set_balance(-5)  # Range: -15 (left) to 15 (right)

Room Correction

Enable and adjust tilt EQ for room acoustics (negative values add warmth for bright/hard-surfaced rooms, positive values add brightness for soft/damped rooms):

async with StreamMagicClient(HOST) as client:
    await client.set_room_correction_mode(True)
    await client.set_room_correction_intensity(8)  # Range: -15 to 15

Equalizer

Configure the 7-band parametric equalizer (bands 0-6 at 80, 120, 315, 800, 2000, 5000, 8000 Hz):

from aiostreammagic import EQBand, EQ_PRESETS

async with StreamMagicClient(HOST) as client:
    # Enable equalizer
    await client.set_equalizer_mode(True)

    # Apply a preset ('flat', 'bass_boost', 'bass_reduction',
    # 'voice_clarity', 'treble_boost', 'treble_reduction', 'tv',
    # 'movie', 'gaming')
    await client.set_equalizer_preset("bass_boost")

    # Adjust individual bands (0-6)
    await client.set_equalizer_band_gain(3, 2.5)  # Band 3, +2.5 dB, Range: -6 to +3

    # Set custom gains for all bands
    gains = [1.0, 0.5, 0.0, 0.0, 0.0, 0.5, 1.0]
    bands = [EQBand(index=i, gain=gains[i]) for i in range(7)]
    await client.set_equalizer_params(bands)

    # Reset to defaults
    await client.set_equalizer_defaults()

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

aiostreammagic-2.13.1.tar.gz (13.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

aiostreammagic-2.13.1-py3-none-any.whl (14.6 kB view details)

Uploaded Python 3

File details

Details for the file aiostreammagic-2.13.1.tar.gz.

File metadata

  • Download URL: aiostreammagic-2.13.1.tar.gz
  • Upload date:
  • Size: 13.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for aiostreammagic-2.13.1.tar.gz
Algorithm Hash digest
SHA256 c700b2b90e1c49819c3e82bd92be027d0a042a78fff840fbfa859afd515a1944
MD5 0b5321bcc5aefbdff484fc218f89f471
BLAKE2b-256 b91709b92feadd8c1b05a5867126337a2b1484e215083862f49e00af85012f2b

See more details on using hashes here.

Provenance

The following attestation bundles were made for aiostreammagic-2.13.1.tar.gz:

Publisher: release.yml on noahhusby/aiostreammagic

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file aiostreammagic-2.13.1-py3-none-any.whl.

File metadata

File hashes

Hashes for aiostreammagic-2.13.1-py3-none-any.whl
Algorithm Hash digest
SHA256 47dddd2f150df27adb6bd2e4b819479e6f5aedcbf0064c3768d954904a495c5e
MD5 3cd4253b0b4c99569e3af91f1a61d134
BLAKE2b-256 db50f1099efdf881f94742dec232316067d45ee739f50ce5f723c34c49c1a5d8

See more details on using hashes here.

Provenance

The following attestation bundles were made for aiostreammagic-2.13.1-py3-none-any.whl:

Publisher: release.yml on noahhusby/aiostreammagic

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

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