Skip to main content

Python bindings for blip25-mbe — P25 MBE/IMBE/AMBE+2 vocoder family

Project description

blip25-mbe (Python)

Python bindings for blip25-mbe, a research-grade Rust implementation of the MBE / IMBE / AMBE+2 vocoder family for P25 Phase 1 and Phase 2 pipelines.

Patents. AMBE+2 is covered by US 8,359,197 until 2028-05-20. See PATENT_NOTICE.md.

Install

pip install blip25-mbe

Wheels are published for Linux (manylinux 2_28), macOS (x86_64 + arm64), and Windows for Python 3.9+.

Quick start

import numpy as np
import blip25_mbe

# One-shot frame round-trip
vc = blip25_mbe.Vocoder(blip25_mbe.Rate.IMBE_7200X4400)
pcm_in = np.zeros(vc.frame_samples, dtype=np.int16)   # 160 samples = 20 ms
bits = vc.encode_pcm(pcm_in)                          # 18-byte FEC frame
pcm_out = vc.decode_bits(bits)                        # back to np.int16

# Streaming over arbitrary-sized chunks
enc = blip25_mbe.LiveEncoder(blip25_mbe.Rate.AMBEPLUS2_3600X2450)
for chunk in pcm_chunks:                              # any size, any rate
    for frame in enc.push(chunk):
        socket.send(frame)                            # 9 bytes each

# Wire-format bridge (Phase 1 IMBE ⇄ Phase 2 AMBE+2)
tc = blip25_mbe.Transcoder(
    blip25_mbe.Rate.IMBE_7200X4400,
    blip25_mbe.Rate.AMBEPLUS2_3600X2450,
)
out_bits = tc.transcode(in_bits)

encode_pcm accepts any np.int16 array; decode_bits returns a fresh np.int16 array. Length must match vc.frame_samples / vc.fec_frame_bytes.

Rates

Python Codec Wire size Bitrate
Rate.IMBE_7200X4400 IMBE 18 bytes 7 200 bps
Rate.IMBE_4400X4400 IMBE no-FEC 11 bytes 4 400 bps
Rate.AMBEPLUS2_3600X2450 AMBE+2 9 bytes 3 600 bps
Rate.AMBEPLUS2_2450X2450 AMBE+2 no-FEC 7 bytes 2 450 bps

AMBEPLUS2_2450X2450 byte order. The 7-byte no-FEC frame packs the 49 info bits in DVSI r34 column-interleave order (byte-exact with DVSI's chip rate-index 34 no-FEC stream), not naive MSB-first sequential. Consumers expecting natural / "AMBE_d" order (mbelib, IDAS/NXDN over-the-air) must de-interleave first.

Encoder tuning (blip25-mbe 0.2.0)

Vocoder exposes the upstream encode-quality and denoiser levers. The AMBE+2 production encode-quality stack (octave-escape pitch guard, parabolic sub-sample pitch, M(ξ) voicing relaxation) is on by default for AMBE+2 rates; full-rate IMBE stays bit-for-bit spec-faithful. The denoiser front-ends are opt-in (default off).

vc = blip25_mbe.Vocoder(blip25_mbe.Rate.AMBEPLUS2_3600X2450)

# Encode-quality stack (per-lever opt-out)
vc.pitch_decide_escape          # -> True   (set_pitch_decide_escape)
vc.pitch_subsample              # -> True   (set_pitch_subsample)
vc.vuv_mxi_grade                # -> True   (set_vuv_mxi_grade)
vc.pitch_refine                 # -> False  §0.4 refine bypassed by the stack
vc.set_vuv_pitch_coef(0.0)      # write-only loudness/shape levers
vc.set_level_scale(True)

# Pre-analysis denoiser front-ends (opt-in 'exceed' levers for noisy audio)
vc.set_denoise(True)                              # log-MMSE STFT denoiser
vc.set_denoise_kind(blip25_mbe.DenoiseKind.WIENER)  # or LOG_MMSE / SPEC_SUB
vc.set_hum_notch(True)                            # 60/120 Hz (US) mains notch
vc.set_hum_notch_mains(50.0)                      # 50/100 Hz (EU)

Note. As of 0.2.0, input-side spectral_subtraction defaults off (was on in 0.1.x); enable it with set_spectral_subtraction(True). The post-decode EnhancementMode.CLASSICAL chain remains on by default.

DVSI soft-decision packets

blip25_mbe.dvsi_soft_decision provides the 4-bit soft-decision (LLR) packet format for soft-FEC interchange with DVSI AMBE-2000/2020/3000 hardware: pack_channel_bits / unpack_packet, the raw USB-3000 nibble stream (pack_nibble_stream / unpack_nibble_stream), SdPacketHeader, and the verified P25 rate-control vectors.

import numpy as np
from blip25_mbe import dvsi_soft_decision as dsd

llrs = np.array(channel_soft_bits, dtype=np.int8)   # one i8 LLR per bit
header = dsd.SdPacketHeader()       # rate_info words are chip-/rate-specific
packet = dsd.pack_channel_bits(llrs, header)        # uint16[60]
wire = dsd.packet_to_bytes(packet)                  # 120 big-endian bytes

DVSI_P25_FULLRATE_FEC / DVSI_P25_FULLRATE_NOFEC are the 6-word chip -r rate-control vectors — a different framing from the packet's 5-word rate_info field; don't cross-assign them.

Half-rate channel frame (rate33)

blip25_mbe.rate33 exposes the half-rate (DVSI rate-33) AMBE+2 channel frame layer that sits below the PCM↔wire façade — the four info vectors û₀..û₃, the FEC code vectors c₀..c₃, and the deprioritized b̂₀..b̂₈ voice-parameter fields. Use it to pull parameter fields out of captured frames or to drive the FEC core directly (the reuse point for other half-rate AMBE+2 protocols: DMR, NXDN, P25 Phase 2).

The one-call field extractors cover all three on-wire forms:

from blip25_mbe import rate33

b = rate33.fields_from_fec(frame9)       # 9-byte FEC (Rate.AMBEPLUS2_3600X2450)
b = rate33.fields_from_no_fec(frame7)    # 7-byte DVSI r34 no-FEC (AMBEPLUS2_2450X2450)
b = rate33.fields_from_natural(frame7)   # 7-byte natural / AMBE_d (mbelib, IDAS/NXDN OTA)
# each returns the 9 deprioritized fields b̂₀..b̂₈ (widths AMBE_PARAM_WIDTHS)

Lower-level primitives are also exposed: unpack_no_fec / pack_no_fec and natural_to_info / info_to_natural (the two 7-byte byte orders), deinterleave / interleave and decode_frame / encode_frame (Annex-S + Golay/PN FEC core, with a soft-decision decode_frame_soft), prioritize / deprioritize, and unpack_dibits / pack_dibits. decode_frame returns a Rate33Frame with .info, .errors, and .error_total().

r34 vs natural order. The 7-byte no-FEC frame has two incompatible layouts. Rate.AMBEPLUS2_2450X2450 and *_no_fec use the DVSI r34 column interleave; mbelib and IDAS/NXDN over-the-air use natural / AMBE_d sequential order. Pick the matching fields_from_* / *_to_info function — they are not interchangeable.

Building from source

pip install maturin
maturin develop --release       # editable install into current venv
pytest                          # smoke tests

Sibling packages

blip25-mbe is the vocoder wrapper. Future blip25 components (decoder / SDR layer) will ship as separate PyPI packages with their own blip25_* import names — they don't share a namespace with this one.

License

MIT — see LICENSE.

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

blip25_mbe-0.2.2.tar.gz (26.1 kB view details)

Uploaded Source

Built Distributions

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

blip25_mbe-0.2.2-cp39-abi3-win_amd64.whl (688.7 kB view details)

Uploaded CPython 3.9+Windows x86-64

blip25_mbe-0.2.2-cp39-abi3-manylinux_2_28_x86_64.whl (841.0 kB view details)

Uploaded CPython 3.9+manylinux: glibc 2.28+ x86-64

blip25_mbe-0.2.2-cp39-abi3-manylinux_2_28_aarch64.whl (693.7 kB view details)

Uploaded CPython 3.9+manylinux: glibc 2.28+ ARM64

blip25_mbe-0.2.2-cp39-abi3-macosx_11_0_arm64.whl (641.4 kB view details)

Uploaded CPython 3.9+macOS 11.0+ ARM64

blip25_mbe-0.2.2-cp39-abi3-macosx_10_12_x86_64.whl (752.7 kB view details)

Uploaded CPython 3.9+macOS 10.12+ x86-64

File details

Details for the file blip25_mbe-0.2.2.tar.gz.

File metadata

  • Download URL: blip25_mbe-0.2.2.tar.gz
  • Upload date:
  • Size: 26.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for blip25_mbe-0.2.2.tar.gz
Algorithm Hash digest
SHA256 a6f2245a12602fc370adb34ba09eca0636180a5de0314ce613316d7f4fbe8659
MD5 f5bae3ccd2ba1b5042eb7dc957332053
BLAKE2b-256 e99be8bcaf950649dd7f1dff1d029cb15878cbb3d95a3f23e9c172a3f26fd252

See more details on using hashes here.

Provenance

The following attestation bundles were made for blip25_mbe-0.2.2.tar.gz:

Publisher: wheels.yml on OpenBLIP25/blip25-mbe-py

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

File details

Details for the file blip25_mbe-0.2.2-cp39-abi3-win_amd64.whl.

File metadata

  • Download URL: blip25_mbe-0.2.2-cp39-abi3-win_amd64.whl
  • Upload date:
  • Size: 688.7 kB
  • Tags: CPython 3.9+, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for blip25_mbe-0.2.2-cp39-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 23c96e6445d216a8bad492be8f75540b48790c81bade5e5f709bfa80a8839b7d
MD5 8e10b715ee71baf340a5abe69bf49f25
BLAKE2b-256 a6f0fb9c5809c12f9222fa9a57228612c38882b1a9fd1c8563671989058ca9b8

See more details on using hashes here.

Provenance

The following attestation bundles were made for blip25_mbe-0.2.2-cp39-abi3-win_amd64.whl:

Publisher: wheels.yml on OpenBLIP25/blip25-mbe-py

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

File details

Details for the file blip25_mbe-0.2.2-cp39-abi3-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for blip25_mbe-0.2.2-cp39-abi3-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 9e8f2cea09bca58367aa87b3b5f09288562b4b2dc4fc4a2691f007eb9e04b84d
MD5 54e48927e453f1392435d88808edc67c
BLAKE2b-256 51e6042bed56193c24b2c9e571f86b1d215e9dc4b89b7d99a5c92d73c6cc1f87

See more details on using hashes here.

Provenance

The following attestation bundles were made for blip25_mbe-0.2.2-cp39-abi3-manylinux_2_28_x86_64.whl:

Publisher: wheels.yml on OpenBLIP25/blip25-mbe-py

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

File details

Details for the file blip25_mbe-0.2.2-cp39-abi3-manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for blip25_mbe-0.2.2-cp39-abi3-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 6cf351b3bf3544eb4f35a8dc47326d9216c2d595d75a8fe9b8918c0dfc1a7d4f
MD5 102d9f2c977d2e05f6f2041d41db4c7b
BLAKE2b-256 eb274bf50701eeeaaca02b4113f577cc34933056d790b1798839f576d9881196

See more details on using hashes here.

Provenance

The following attestation bundles were made for blip25_mbe-0.2.2-cp39-abi3-manylinux_2_28_aarch64.whl:

Publisher: wheels.yml on OpenBLIP25/blip25-mbe-py

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

File details

Details for the file blip25_mbe-0.2.2-cp39-abi3-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for blip25_mbe-0.2.2-cp39-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 30b65c46dd33d10dbe745926d8525a3b1d644a688ba656d8dd482d8e4ba0e611
MD5 7ac053fe068b33e7a5a1f67310fd64fc
BLAKE2b-256 3e0debc0e43cd3103aa3e35d7cfa25954aa282ff96c767e7ad563e3a4b0a2f89

See more details on using hashes here.

Provenance

The following attestation bundles were made for blip25_mbe-0.2.2-cp39-abi3-macosx_11_0_arm64.whl:

Publisher: wheels.yml on OpenBLIP25/blip25-mbe-py

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

File details

Details for the file blip25_mbe-0.2.2-cp39-abi3-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for blip25_mbe-0.2.2-cp39-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 76f8dcda4d518d664cb2e67b5ad73d1798651fe87d5fa4fc963f9874b8a63489
MD5 17a9147ce2e9b1cbcfbff6cfb35dbd81
BLAKE2b-256 f334b9bf59407db06b5b1ecd95ca92c03a2afcb832c0e8d43d9c8e2283faa950

See more details on using hashes here.

Provenance

The following attestation bundles were made for blip25_mbe-0.2.2-cp39-abi3-macosx_10_12_x86_64.whl:

Publisher: wheels.yml on OpenBLIP25/blip25-mbe-py

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