Commit 822c33c
committed
[llm] Beef up wav loader to read audio format 3 (float format)
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.1 parent efc2be7 commit 822c33c
2 files changed
+76
-5
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
51 | 51 | | |
52 | 52 | | |
53 | 53 | | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
54 | 61 | | |
55 | 62 | | |
56 | 63 | | |
| |||
91 | 98 | | |
92 | 99 | | |
93 | 100 | | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
94 | 136 | | |
95 | 137 | | |
96 | 138 | | |
| |||
153 | 195 | | |
154 | 196 | | |
155 | 197 | | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
168 | 168 | | |
169 | 169 | | |
170 | 170 | | |
| 171 | + | |
171 | 172 | | |
172 | 173 | | |
173 | 174 | | |
174 | 175 | | |
175 | 176 | | |
176 | 177 | | |
177 | | - | |
178 | | - | |
179 | 178 | | |
180 | | - | |
181 | | - | |
182 | | - | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
183 | 194 | | |
184 | 195 | | |
185 | 196 | | |
| |||
0 commit comments