| 193 | } |
| 194 | |
| 195 | bool AudioDecoderWav::open(std::string_view fullPath) |
| 196 | { |
| 197 | if (wav_open(fullPath, &_wavf)) |
| 198 | { |
| 199 | auto& fmtInfo = _wavf.FileHeader.Fmt; |
| 200 | _sampleRate = fmtInfo.SampleRate; |
| 201 | _channelCount = fmtInfo.NumChannels; |
| 202 | _bytesPerBlock = fmtInfo.BlockAlign; // == fmtInfo.BitsPerSample * _channelCount / 8; |
| 203 | _sourceFormat = _wavf.SourceFormat; |
| 204 | |
| 205 | // See: https://github.com/openalext/openalext/wiki/AL_SOFT_block_alignment |
| 206 | switch (_sourceFormat) |
| 207 | { |
| 208 | case AUDIO_SOURCE_FORMAT::ADPCM: |
| 209 | _samplesPerBlock = (_bytesPerBlock / _channelCount - 7) * 2 + 2; |
| 210 | break; |
| 211 | case AUDIO_SOURCE_FORMAT::IMA_ADPCM: |
| 212 | _samplesPerBlock = (_bytesPerBlock / _channelCount - 4) / 4 * 8 + 1; |
| 213 | break; |
| 214 | default:; |
| 215 | } |
| 216 | |
| 217 | _totalFrames = bytesToFrames(_wavf.FileHeader.PcmData.ChunkSize); |
| 218 | |
| 219 | _isOpened = true; |
| 220 | return true; |
| 221 | } |
| 222 | return false; |
| 223 | } |
| 224 | |
| 225 | uint32_t AudioDecoderWav::framesToBytes(uint32_t frames) const |
| 226 | { |
nothing calls this directly
no test coverage detected