|
arduino-audio-tools
|
Utility for reading and rewriting WAV file metadata in place. More...
#include <WAVFileInfo.h>
Public Member Functions | |
| WAVFileInfo ()=default | |
| bool | getInfo (FileT file, WAVAudioInfo &info) |
| Reads and parses the WAV header from a file. | |
| bool | updateSize (FileT file) |
| Reads the current WAV header and rewrites it with the actual file size. | |
| bool | updateSize (FileT file, WAVAudioInfo &info) |
| Rewrites the WAV header with the current file size information. | |
Utility for reading and rewriting WAV file metadata in place.
The class parses the existing WAV header, extracts the current audio information, and can rewrite the header with an updated file size so the RIFF and data chunk lengths stay consistent.
|
default |
|
inline |
Reads and parses the WAV header from a file.
The method reads up to MAX_WAV_HEADER_LEN bytes from the beginning of the provided file, parses the WAV header, and copies the extracted audio metadata into info.
| file | File-like object that provides read(). |
| info | Target structure that receives the parsed WAV metadata. |
true if a complete and valid WAV header was parsed successfully; otherwise false. Reads the current WAV header and rewrites it with the actual file size.
This overload parses the existing header metadata from the file, seeks back to the beginning of the stream, and then updates the header fields using the current file size.
| file | File-like object that provides read(), seek(), size(), and write(). The file must be open in a mode that allows both reading and writing. |
true if the header was read, the file was repositioned, and the updated header was written successfully; otherwise false.
|
inline |
Rewrites the WAV header with the current file size information.
This updates info.file_size from the actual file size and recalculates the payload size before writing a refreshed WAV header back to the file.
| file | File-like object that provides size() and write(). |
| info | WAV metadata to update and write back into the file header. |
true if the header was written successfully; otherwise false.