Skip to main content

SLM Open API Package

Python helpers for streaming measurements and audio from an HBK sound level meter (SLM) through WebXi.

This PyPI package is made for the Open Interface for Sound Level Meter repository. Refer to that repository for more detailed usage information and additional examples.

Install

pip install slm_open_api_package

Or add it to an uv project:

uv add slm_open_api_package

The package requires Python 3.12 or newer and a network connection to a compatible SLM.

Connect To A Device

Give every stream one host, either an IP address or host name:

host = "192.168.1.183"

The bundled examples use set_host() to read a host from a local slm_ip file. If the file is missing, it prompts once and creates it:

from slm_api.helpers import webxi_helper_functions as webxi_helper

host = webxi_helper.set_host(__file__)

Basic Leq Stream

WebXiStreamHandler is the main API. mode="leq" is the default and streams one sequence selected by sequenceID.

from slm_api.enums.sequence_id_enum import SequenceIdEnums
from slm_api.helpers.stream_handlers import WebXiStreamHandler

streamer = WebXiStreamHandler(
	host="192.168.1.183",
	sequenceID=SequenceIdEnums.LAeq.value,
	mode="leq",
	saving="csv",
	saving_path="saved_data/laeq",
)

try:
	streamer.startStream()
except KeyboardInterrupt:
	streamer.stopStream()

stopStream() stops the measurement, removes the device stream, and writes buffered saved data. Supported saving formats are "csv", "json", and "pickle"; their extensions are added automatically.

Multiple Sequences

Based on example_multi.py, use mode="multi" for several enabled broadband sequences in a single stream:

from slm_api.helpers.data_handler import DataHandler
from slm_api.helpers.stream_handlers import WebXiStreamHandler


class PrintHandler(DataHandler):
	def handle(self, *, host, name, value, **data):
		print(f"{host} {name}: {value}")


streamer = WebXiStreamHandler(
	host="192.168.1.183",
	sequenceNames=["LAeq", "LCeq", "LAF"],
	mode="multi",
	saving="json",
	saving_path="saved_data/broadband",
)
streamer.setDataHandler(PrintHandler())

try:
	streamer.startStream()
except KeyboardInterrupt:
	streamer.stopStream()

Enable the requested sequences and frequency weightings on the SLM before starting the stream. Each DataHandler.handle() call receives the source host, name, and value. The saving= handler continues saving when a custom handler is attached.

Fast Logging

Based on fast_log_example.py, use mode="fast_logging" for fast broadband samples:

from slm_api.enums.fast_log_intervals_enum import FastLogInterval
from slm_api.enums.sequence_id_enum import SequenceIdEnums
from slm_api.helpers.stream_handlers import WebXiStreamHandler

streamer = WebXiStreamHandler(
	host="192.168.1.183",
	sequenceID=SequenceIdEnums.FastLAF.value,
	mode="fast_logging",
	fast_logging_interval=FastLogInterval.interval_1000ms.value,
	saving="csv",
	saving_path="saved_data/fast_laf",
)

try:
	streamer.startStream()
except KeyboardInterrupt:
	streamer.stopStream()

Audio

Use the MP3 or FLAC examples for decoded audio samples:

from slm_api.enums.sequence_id_enum import SequenceIdEnums
from slm_api.helpers.stream_handlers import WebXiStreamHandler

streamer = WebXiStreamHandler(
	host="192.168.1.183",
	sequenceID=SequenceIdEnums.MP3Signal.value,
	mode="mp3",
)

The matching flac form uses SequenceIdEnums.FLACSignal.value and mode="flac". Audio setup is enabled by the handler. The SLM can take a few seconds to initialize audio recording when its quality setting changes.

Synchronized Multi-Device Stream

Based on multi_device_flac.py, pass multi_device=True and start/stop the group through the synchronized helpers:

from slm_api.enums.sequence_id_enum import SequenceIdEnums
from slm_api.helpers.stream_handlers import WebXiStreamHandler, start_all_synced, stop_all

hosts = ["192.168.1.183", "192.168.1.216"]
streams = [
	WebXiStreamHandler(
		host=host,
		sequenceID=SequenceIdEnums.MP3Signal.value,
		mode="mp3",
		streamName=f"Audio_{host}",
		multi_device=True,
		saving="csv",
		saving_path=f"saved_data/{host}",
	)
	for host in hosts
]

start_all_synced(streams)

try:
    while True:
        time.sleep(1)
except KeyboardInterrupt:
    stop_all(streams)

stop_all() synchronizes the device measurement stops, flushes saving handlers, and removes each device stream.

Modes

Mode Use
"leq" One broadband sequence; this is the default.
"multi" Several named broadband sequences.
"cpb" Constant-percentage-band data.
"fast_logging" Fast broadband samples.
"flac" / "mp3" Decoded audio samples.
"screen_record" Latest SLM screen image in streamer.image_bytes.

Legacy flags such as mp3=True remain supported, but mode= is preferred. Only select one mode per stream.


## Troubleshooting

- **No values arrive:** Confirm the requested sequences are enabled on the SLM.
- **Audio returns no samples after first enable:** Allow the SLM a few seconds to initialize audio recording before retrying.
- **Saved file is missing:** Call `stopStream()` or `stop_all()`; buffered files are written during shutdown.

Metadata

Release files for slm_open_api_package 0.2.10

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for slm_open_api_package 0.2.10
File Size Uploaded
slm_open_api_package-0.2.10.tar.gz 35.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for slm_open_api_package 0.2.10
File Interpreter ABI Platform
slm_open_api_package-0.2.10-py3-none-any.whl Python 3 none any Details

Total release size: 82.3 kB

Release files / slm_open_api_package-0.2.10.tar.gz

Download URL slm_open_api_package-0.2.10.tar.gz
Size 35.7 kB
Tags Source
SHA-256 checksum
How to use checksums
5ad674fcd3a52de0a44e13d47e6067b068f42ef8af91da9eb4b35d526b855afd
BLAKE2b-256 checksum
How to use checksums
ffeb90374f5d06ce6fa7dc62e90e6f443caf3fd5a9c9424b4674bdb7864331f2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.1 {"installer":{"name":"uv","version":"0.13.1","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / slm_open_api_package-0.2.10-py3-none-any.whl

Download URL slm_open_api_package-0.2.10-py3-none-any.whl
Size 46.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
9500da43a679d2246e90cc6c3435d16d97d5ecbbe515d4fada6715338cb6d2f3
BLAKE2b-256 checksum
How to use checksums
57341665732cf65e3ae616a7fa0ce6086e77c8ef1e914e441f40844a01c54e24
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.1 {"installer":{"name":"uv","version":"0.13.1","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release history Release notifications | RSS feed

This release

0.2.10 This release

2 release files

0.2.9

2 release files

0.2.8

2 release files

0.2.7

2 release files

0.2.6

2 release files

0.2.5

2 release files

0.2.4

2 release files

0.2.3

2 release files

0.2.2

2 release files

0.2.1

2 release files

0.2.0

2 release files

0.1.9

2 release files

0.1.8

2 release files

0.1.7

2 release files

0.1.6

2 release files

0.1.5

2 release files

0.1.4

2 release files

0.1.3

2 release files

0.1.2

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page