Metadata-Version: 2.4
Name: audio_validation
Version: 0.1.2
Summary: Tools for validating audio data, including feature extraction and visualization.
Maintainer-email: Hubert Stepniewski <hubert.stepniewski@int2code.com>, Marcin Tomiczek <marcin.tomiczek@int2code.com>, Piotr Sznapka <piotr.sznapka@int2code.com>
License: MIT License
        
        Copyright (c) 2026 int2code
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
        SOFTWARE.
        
Requires-Python: >=3.11
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: numpy
Requires-Dist: scipy
Requires-Dist: matplotlib
Requires-Dist: pandas
Requires-Dist: pytest
Provides-Extra: test
Requires-Dist: coverage; extra == "test"
Requires-Dist: pytest; extra == "test"
Requires-Dist: pytest-cov; extra == "test"
Requires-Dist: pytest-html; extra == "test"
Provides-Extra: dev
Requires-Dist: coverage; extra == "dev"
Requires-Dist: pytest; extra == "dev"
Requires-Dist: pytest-cov; extra == "dev"
Requires-Dist: pytest-html; extra == "dev"
Requires-Dist: black; extra == "dev"
Requires-Dist: pylint; extra == "dev"
Requires-Dist: tox; extra == "dev"
Provides-Extra: docs
Requires-Dist: coverage; extra == "docs"
Requires-Dist: pytest; extra == "docs"
Requires-Dist: pytest-cov; extra == "docs"
Requires-Dist: pytest-html; extra == "docs"
Requires-Dist: sphinx; extra == "docs"
Requires-Dist: sphinx-rtd-theme; extra == "docs"
Requires-Dist: sphinxcontrib-programoutput; extra == "docs"
Requires-Dist: myst-parser; extra == "docs"
Dynamic: license-file

# audio_validation

A Python library for validating and analysing audio data, including feature extraction, bit-exact verification against a reference, and waveform generation utilities.

## Features

- **Feature extraction** — compute RMS, peak/min/max, mean, FFT-based frequency detection, and per-channel audio onset offset for multi-channel captures.
- **Audio verification** — validate a captured audio stream against a reference WAV file with drift-tolerant re-synchronisation, detailed mismatch reporting, and automatic artefact generation (PNG plots and WAV snippets).
- **Waveform generation** — generate multi-channel WAV files with configurable waveforms: sine, square, sawtooth, white noise, and pink noise; supports 16-, 24-, and 32-bit PCM output.

## Requirements

- Python ≥ 3.11
- See [requirements.txt](requirements.txt) for runtime dependencies (`numpy`, `scipy`, `sounddevice`, `pymodbus`, …).

## Installation

```bash
pip install audio_validation
```

Or, for development:

```bash
pip install -e ".[dev]"
```

## Usage

### Feature extraction

```python
from audio_validation.audio_features import AudioFeatures

features = AudioFeatures.compute(
    samples=raw_samples,           # numpy array, shape (n_samples, n_channels)
    sample_rate=48000,
    expected_frequencies=[400, 800],
    tolerance=50,
)

for ch_idx, ch in enumerate(features.channels):
    print(f"Ch {ch_idx}: detected={ch.detected}, rms={ch.rms:.4f}, peaks={ch.peak_frequencies}")
```

### Audio verification

```python
from audio_validation.audio_verification import verify_audio

results = verify_audio(
    reference_path="reference.wav",
    detected_samples=captured_array,
    sample_rate=48000,
    artifacts_dir="test_artifacts/",
)
```

### Waveform generation

```python
from audio_validation.utils.audio_generation import generate_wave_file

generate_wave_file(
    shape="sine",
    freq_list=[1000.0],
    sample_rate=48000,
    duration=5.0,
    num_channels=2,
    active_channels=[0, 1],
    amplitude=0.05,
    resolution_bits=16,
    output_dir="output.wav",
)
```

## Maintainers

- Hubert Stepniewski — hubert.stepniewski@int2code.com
- Marcin Tomiczek — marcin.tomiczek@int2code.com
- Piotr Sznapka — piotr.sznapka@int2code.com

## License

See [LICENSE](LICENSE).
