Skip to main content

a_law_lib is a Python library designed to perform A-law companding, quantization, and WAV audio processing. It provides core functions for compressing and reconstructing signals, useful in digital audio signal processing and educational simulations.

It mainly comes with four functions: a_law_encode(), a_law_decode(), quantize(), and process_wave_file().

a_law_encode(signal, A=87.6):

Perform A-law companding on the input signal.

Parameters:

  • signal (numpy.ndarray): Input signal to be encoded.
  • A (float, optional): Companding parameter (default is 87.6).

Returns:

  • numpy.ndarray: A-law encoded signal.

a_law_decode(companded_signal, A=87.6):

Decode an A-law companded signal.

Parameters:

  • companded_signal (numpy.ndarray): Encoded signal.
  • A (float, optional): Companding parameter (same as used in encoding).

Returns:

  • numpy.ndarray: Decoded signal approximating the original input.

quantize(signal, num_levels):

Apply uniform quantization to the input signal.

Parameters:

  • signal (numpy.ndarray): Input signal to be quantized.
  • num_levels (int): Number of quantization levels.

Returns:

  • numpy.ndarray: Quantized signal.

process_wave_file(file_path, output_path, A=87.6, num_levels=16):

Read a WAV file, apply A-law encoding, quantization, decoding, and save the output.

Parameters:

  • file_path (str): Path to the input WAV file.
  • output_path (str): Destination path for the processed WAV file.
  • A (float, optional): Companding parameter (default is 87.6).
  • num_levels (int, optional): Number of quantization levels (default is 16).

Returns:

  • None. Writes processed audio to the specified output path.

Features:

  • A-law companding and reconstruction.
  • Uniform quantization.
  • Works with mono and stereo WAV files.
  • Handles both integer and floating-point audio data.

Sample usage:

import a_law_lib as al
import numpy as np

signal = np.linspace(-1.0, 1.0, 100)
encoded = al.a_law_encode(signal)
decoded = al.a_law_decode(encoded)
quantized = al.quantize(decoded, num_levels=16)
al.process_wave_file("input.wav", "output.wav", A=87.6, num_levels=16)

Metadata

Release files for a-law-lib 0.2.0

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

Source distribution (sdist)

Source distribution for a-law-lib 0.2.0
File Size Uploaded Provenance Actions
a_law_lib-0.2.0.tar.gz 3.1 kB Without provenance Details for a_law_lib-0.2.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for a-law-lib 0.2.0
File Interpreter ABI Platform Actions
a_law_lib-0.2.0-py3-none-any.whl Python 3 none any Details for a_law_lib-0.2.0-py3-none-any.whl

Total release size: 6.5 kB

Release files / a_law_lib-0.2.0.tar.gz

Download URL a_law_lib-0.2.0.tar.gz
Size 3.1 kB
Tags Source
SHA-256 checksum
How to use checksums
badb21678c0f2d3a4f18ab32d1fd5dc9bbe82b3f26e820f10dbdf3ef229cf0a4
BLAKE2b-256 checksum
How to use checksums
6d7ff1fc81560c0b4f59ed47d091c5c36ce13fa6e09cb211100d569f92f8e308
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.1

Release files / a_law_lib-0.2.0-py3-none-any.whl

Download URL a_law_lib-0.2.0-py3-none-any.whl
Size 3.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
a88e6631c5c23e216adc12c6920b3c0ba2149f76b93e82d443b134de164f9eb6
BLAKE2b-256 checksum
How to use checksums
74fbb2d7d9b4eab76a68b8a1c6d1c0074ba398df888b5fbcf501a441a9c139b0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.1

Security for a-law-lib 0.2.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.2.0 This release

2 release files No provenance

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