Skip to content

Conversation

@larryliu0820
Copy link
Contributor

@larryliu0820 larryliu0820 commented Oct 29, 2025

This PR enables audio format 3 (IEEE float format) on wav_loader.h, which allows direct reading of float values without normalization. Also adds a unit test.

This PR adds test coverage for WAV files using audio format 3 (IEEE float format), which allows direct reading of float values without normalization. The existing `**wav_loader.h**` implementation already supports this format (lines 179-185), but there was no test coverage for this code path.

**Test additions in `**test_wav_loader.cpp**`:**

1.  Added `append_float()` helper function to serialize float values into byte arrays
2.  Added `make_float_wav_bytes()` helper function to generate WAV files with audio format 3 (IEEE float)
3.  Added `LoadAudioDataFloatFormatReadsDirectly` test case that verifies:
    *   WAV header correctly identifies audio format as 3
    *   Float samples are read directly without normalization
    *   Output float values match the input exactly

The new test case `LoadAudioDataFloatFormatReadsDirectly` validates that:

*   A WAV file with audio format 3 (IEEE float, 32-bit) is correctly parsed
*   The audio format is detected as 3 in the header
*   Float values [0.0f, 0.5f, -0.5f, 1.0f, -1.0f] are read directly without normalization
*   All float values match exactly using `EXPECT_FLOAT_EQ`

Run the test with:

`buck2 test //extension/llm/runner/test:test_wav_loader`

The WAV loader already has logic to handle IEEE float format (audio format 3) differently from PCM integer formats, but this code path was not covered by tests. This test ensures the float format path works correctly and prevents regressions.
@pytorch-bot
Copy link

pytorch-bot bot commented Oct 29, 2025

🔗 Helpful Links

🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/executorch/15452

Note: Links to docs will display an error until the docs builds have been completed.

❗ 1 Active SEVs

There are 1 currently active SEVs. If your PR is affected, please view them below:

✅ No Failures

As of commit d177c64 with merge base efc2be7 (image):
💚 Looks good so far! There are no failures yet. 💚

This comment was automatically generated by Dr. CI and updates every 15 minutes.

@meta-cla meta-cla bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Oct 29, 2025
@larryliu0820 larryliu0820 added the release notes: llm Changes to llm utilities label Oct 29, 2025
@larryliu0820 larryliu0820 merged commit 5761866 into main Oct 30, 2025
151 checks passed
@larryliu0820 larryliu0820 deleted the wav_float branch October 30, 2025 01:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. release notes: llm Changes to llm utilities

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants