Skip to content

feat(sv56): variable bit-width support (8-32 bit) for speech voltmeter#181

Open
jr2804 wants to merge 10 commits into
openitu:devfrom
jr2804:feature/p56-bitdepth-extension
Open

feat(sv56): variable bit-width support (8-32 bit) for speech voltmeter#181
jr2804 wants to merge 10 commits into
openitu:devfrom
jr2804:feature/p56-bitdepth-extension

Conversation

@jr2804
Copy link
Copy Markdown

@jr2804 jr2804 commented May 28, 2026

Summary

Extends the P.56 speech voltmeter (sv56) module to support variable bit-width input files from 8 to 32 bits per sample, up from the previous 16-bit limitation.

Changes

Core algorithm (sv-p56.c, sv-p56.h)

  • Added int bitno parameter to init_speech_voltmeter() controlling threshold count and peak detectors
  • New constants: SVP56_MAX_NO_BITS (32) and SVP56_MAX_THRESHOLDS (31) for array sizing
  • State struct gains thres_no and bitno fields; arrays expanded accordingly

Variable-width I/O (sv56-util.h — new)

  • sv56_bytes_per_sample(bitno) — returns 1/2/3/4 bytes based on bit depth
  • sv56_raw2fl() — converts raw bytes to normalized float (-1..+1) in native byte order
  • sv56_fl2raw() — converts normalized float back to raw bytes with truncation and clipping
  • Supports 8-bit (1 B), 16-bit (2 B), 24-bit (3 B), 32-bit (4 B) storage; legacy 12-15 bit masking preserved

CLI tools (sv56demo.c, actlevel.c)

  • Replaced short buffer[] with unsigned char raw_buf[] for variable-width I/O
  • Replaced sh2fl()/fl2sh() with sv56_raw2fl()/sv56_fl2raw()
  • Fixed out-of-bounds mask[] array access for bitno > 16
  • bitno parameter now controls both P.56 algorithm AND file format

New utilities

  • sv56test.c — minimal non-interactive test program for automated verification
  • sv56-convert.c — utility to convert between bit-width formats (used for test data generation)

Tests

  • 6 new CTest cases: run + verify for 16-bit, 24-bit, and 32-bit inputs
  • All 11 sv56 tests pass (5 original + 6 new)
  • Full test suite: 1173/1182 pass (9 pre-existing failures in unrelated modules)

Documentation (doc/manual/sv56.tex)

  • Updated init_speech_voltmeter signature and parameter docs
  • Documented new constants, struct fields, and variable-width I/O
  • Updated example code

Build system

  • CMake minimum version updated to 3.10
  • Added sv56test and sv56-convert build targets

Backward compatibility

  • bitno=16: Identical behavior to previous version (2 bytes/sample, divide by 32768, native byte order)
  • bitno=12-15: Same 2-byte file format, correct normalization and LSB masking
  • bitno=8, 24, 32: New functionality
  • All existing test reference files produce identical results

Jan.Reimes and others added 8 commits April 28, 2026 16:34
Add bitno parameter to init_speech_voltmeter() to allow the P.56
Method B speech voltmeter to operate correctly with 24-bit and 32-bit
A/D converters instead of being limited to 16-bit (approx. 90 dB
dynamic range).

Changes:
- sv-p56.h: SVP56_state now stores bitno and thres_no (bitno-1);
  arrays expanded to 31 elements to support 32-bit; init_speech_voltmeter
  prototype updated to accept bitno parameter
- sv-p56.c: init_speech_voltmeter() derives threshold count from bitno
  (N-1); maxP/maxN are now computed as ±2^(bitno-1) instead of
  hard-coded ±32768; speech_voltmeter() uses state->thres_no instead
  of THRES_NO macro
- actlevel.c: passes bitno to init_speech_voltmeter()
- sv56demo.c: passes bitno to init_speech_voltmeter()

Backward compatible: 16-bit input produces identical results to the
original implementation (THRES_NO=15, maxP=-32768, maxN=32767).

Note: No C compiler available in this environment to verify compilation.
Build should be verified with 'cmake --build build && ctest' before merging.
* Set minimum CMake version to 3.1...3.25 in CMakeLists.txt
* Remove unnecessary entries from .gitignore
* Add .vscode/ to .gitignore for IDE configuration
* Update LongTermLevel and Delta array size to support SVP56_MAX_THRESHOLDS.
* Modify threshold-related structures to accommodate dynamic bit depth.
* Add new entries to .gitignore for build artifacts and output files.
* Update sv56.tex to include new parameters for bit depth.
* Modify CMakeLists.txt to add new executables for testing.
* Enhance actlevel.c to support variable bit-width input files.
* Introduce sv56-convert.c for converting PCM files with different bit depths.
* Create sv56-util.h for utility functions related to bit-width handling.
* Add sv56test.c for testing the speech voltmeter with variable bit widths.
Comment thread .gitignore
Comment thread CMakeLists.txt
@ludomal
Copy link
Copy Markdown
Member

ludomal commented May 29, 2026

@jr2804 - Thanks for the great contribution. Would you mind committing the test reference files?

Jan.Reimes added 2 commits May 29, 2026 17:59
* Add voice_16bit.ref with audio level data
* Add voice_24bit.ref with audio level data
* Add voice_32bit.ref with audio level data
* Add voice_24.src and voice_32.src as binary files
@jr2804
Copy link
Copy Markdown
Author

jr2804 commented May 29, 2026

Thanks for the review! All feedback addressed in the latest two commits:

  • .gitignore: Removed the blanket src/**/test_data/ rule. Added a local src/sv56/.gitignore instead to scope ignore rules to the sv56 module only.
  • Test reference files: Committed in 353558a — includes voice_24.src, voice_32.src, and .ref files for 16/24/32-bit verification.
  • CMakeLists.txt: Noted — happy to align with whatever cmake version normalization you settle on for the new release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants