WAV audio loader and writer. Choice of public domain or MIT-0. See license statements at the end of this file.
WAV audio loader and writer. Choice of public domain or MIT-0. See license statements at the end of this file.
dr_wav - v0.12.10 - 2020-08-24
dr_wav - v0.12.12 - 2020-09-28
David Reid - mackron@gmail.com
David Reid - mackron@gmail.com
...
@@ -18,7 +18,7 @@ Changes to Chunk Callback
...
@@ -18,7 +18,7 @@ Changes to Chunk Callback
dr_wav supports the ability to fire a callback when a chunk is encounted (except for WAVE and FMT chunks). The callback has been updated to include both the
dr_wav supports the ability to fire a callback when a chunk is encounted (except for WAVE and FMT chunks). The callback has been updated to include both the
container (RIFF or Wave64) and the FMT chunk which contains information about the format of the data in the wave file.
container (RIFF or Wave64) and the FMT chunk which contains information about the format of the data in the wave file.
Previously, there was no direct way to determine the container, and therefore no way discriminate against the different IDs in the chunk header (RIFF and
Previously, there was no direct way to determine the container, and therefore no way to discriminate against the different IDs in the chunk header (RIFF and
Wave64 containers encode chunk ID's differently). The `container` parameter can be used to know which ID to use.
Wave64 containers encode chunk ID's differently). The `container` parameter can be used to know which ID to use.
Sometimes it can be useful to know the data format at the time the chunk callback is fired. A pointer to a `drwav_fmt` object is now passed into the chunk
Sometimes it can be useful to know the data format at the time the chunk callback is fired. A pointer to a `drwav_fmt` object is now passed into the chunk
@@ -419,8 +420,8 @@ Returns the number of bytes read + seeked.
...
@@ -419,8 +420,8 @@ Returns the number of bytes read + seeked.
To read data from the chunk, call onRead(), passing in pReadSeekUserData as the first parameter. Do the same for seeking with onSeek(). The return value must
To read data from the chunk, call onRead(), passing in pReadSeekUserData as the first parameter. Do the same for seeking with onSeek(). The return value must
be the total number of bytes you have read _plus_ seeked.
be the total number of bytes you have read _plus_ seeked.
Use the `container` argument to discriminate the fields in `pChunkHeader->id`. If the container is `drwav_container_riff` you should use `id.fourcc`,
Use the `container` argument to discriminate the fields in `pChunkHeader->id`. If the container is `drwav_container_riff` or `drwav_container_rf64` you should
otherwise you should use `id.guid`.
use `id.fourcc`, otherwise you should use `id.guid`.
The `pFMT` parameter can be used to determine the data format of the wave file. Use `drwav_fmt_get_format()` to get the sample format, which will be one of the
The `pFMT` parameter can be used to determine the data format of the wave file. Use `drwav_fmt_get_format()` to get the sample format, which will be one of the
`DR_WAVE_FORMAT_*` identifiers.
`DR_WAVE_FORMAT_*` identifiers.
...
@@ -881,8 +882,8 @@ Helper for initializing a writer which outputs data to a memory buffer.
...
@@ -881,8 +882,8 @@ Helper for initializing a writer which outputs data to a memory buffer.
dr_wav will manage the memory allocations, however it is up to the caller to free the data with drwav_free().
dr_wav will manage the memory allocations, however it is up to the caller to free the data with drwav_free().
The buffer will remain allocated even after drwav_uninit() is called. Indeed, the buffer should not be
The buffer will remain allocated even after drwav_uninit() is called. The buffer should not be considered valid
considered valid until after drwav_uninit() has been called anyway.
drwav_uint64dataChunkSize=0;/* <-- Important! Don't explicitly set this to 0 anywhere else. Calculation of the size of the data chunk is performed in different paths depending on the container. */
drwav_uint64sampleCountFromFactChunk=0;/* Same as dataChunkSize - make sure this is the only place this is initialized to 0. */
if(pWav->container!=drwav_container_rf64){/* The data chunk size for RF64 will always be set to 0xFFFFFFFF here. It was set to it's true value earlier. */
runningPos+=drwav__write_u32ne_to_le(pWav,0xFFFFFFFF);/* Always set to 0xFFFFFFFF for RF64. The true size of the data chunk is specified in the ds64 chunk. */
}
}
/* Simple validation. */
if(pFormat->container==drwav_container_riff){
if(runningPos!=20+chunkSizeFMT+8){
returnDRWAV_FALSE;
}
}else{
if(runningPos!=40+chunkSizeFMT+24){
returnDRWAV_FALSE;
}
}
/* Set some properties for the client's convenience. */
/* Set some properties for the client's convenience. */