297 #if defined(_MSC_VER) && _MSC_VER < 1600
320 #define DRWAV_FALSE 0
327 #define DRWAV_SUCCESS 0
328 #define DRWAV_ERROR -1
329 #define DRWAV_INVALID_ARGS -2
330 #define DRWAV_INVALID_OPERATION -3
331 #define DRWAV_INVALID_FILE -100
332 #define DRWAV_EOF -101
335 #define DR_WAVE_FORMAT_PCM 0x1
336 #define DR_WAVE_FORMAT_ADPCM 0x2
337 #define DR_WAVE_FORMAT_IEEE_FLOAT 0x3
338 #define DR_WAVE_FORMAT_ALAW 0x6
339 #define DR_WAVE_FORMAT_MULAW 0x7
340 #define DR_WAVE_FORMAT_DVI_ADPCM 0x11
341 #define DR_WAVE_FORMAT_EXTENSIBLE 0xFFFE
344 #ifndef DRWAV_MAX_SMPL_LOOPS
345 #define DRWAV_MAX_SMPL_LOOPS 1
349 #define DRWAV_SEQUENTIAL 0x00000001
378 unsigned int paddingSize;
393 typedef size_t (*
drwav_read_proc)(
void* pUserData,
void* pBufferOut,
size_t bytesToRead);
406 typedef size_t (*
drwav_write_proc)(
void* pUserData,
const void* pData,
size_t bytesToWrite);
443 void* (* onMalloc)(
size_t sz,
void* pUserData);
444 void* (* onRealloc)(
void* p,
size_t sz,
void* pUserData);
445 void (* onFree)(
void* p,
void* pUserData);
453 size_t currentReadPos;
463 size_t currentWritePos;
771 #ifndef DR_WAV_NO_CONVERSION_API
876 #ifndef DR_WAV_NO_STDIO
928 #ifndef DR_WAV_NO_CONVERSION_API
937 #ifndef DR_WAV_NO_STDIO
976 #ifdef DR_WAV_IMPLEMENTATION
981 #ifndef DR_WAV_NO_STDIO
989 #define DRWAV_ASSERT(expression) assert(expression)
992 #define DRWAV_MALLOC(sz) malloc((sz))
994 #ifndef DRWAV_REALLOC
995 #define DRWAV_REALLOC(p, sz) realloc((p), (sz))
998 #define DRWAV_FREE(p) free((p))
1000 #ifndef DRWAV_COPY_MEMORY
1001 #define DRWAV_COPY_MEMORY(dst, src, sz) memcpy((dst), (src), (sz))
1003 #ifndef DRWAV_ZERO_MEMORY
1004 #define DRWAV_ZERO_MEMORY(p, sz) memset((p), 0, (sz))
1007 #define drwav_countof(x) (sizeof(x) / sizeof(x[0]))
1008 #define drwav_align(x, a) ((((x) + (a) - 1) / (a)) * (a))
1009 #define drwav_min(a, b) (((a) < (b)) ? (a) : (b))
1010 #define drwav_max(a, b) (((a) > (b)) ? (a) : (b))
1011 #define drwav_clamp(x, lo, hi) (drwav_max((lo), drwav_min((hi), (x))))
1013 #define DRWAV_MAX_SIMD_VECTOR_SIZE 64
1016 #if defined(__x86_64__) || defined(_M_X64)
1018 #elif defined(__i386) || defined(_M_IX86)
1020 #elif defined(__arm__) || defined(_M_ARM)
1025 #define DRWAV_INLINE __forceinline
1026 #elif defined(__GNUC__)
1034 #if defined(__STRICT_ANSI__)
1035 #define DRWAV_INLINE __inline__ __attribute__((always_inline))
1037 #define DRWAV_INLINE inline __attribute__((always_inline))
1040 #define DRWAV_INLINE
1043 #if defined(SIZE_MAX)
1044 #define DRWAV_SIZE_MAX SIZE_MAX
1046 #if defined(_WIN64) || defined(_LP64) || defined(__LP64__)
1047 #define DRWAV_SIZE_MAX ((drwav_uint64)0xFFFFFFFFFFFFFFFF)
1049 #define DRWAV_SIZE_MAX 0xFFFFFFFF
1053 #if defined(_MSC_VER) && _MSC_VER >= 1400
1054 #define DRWAV_HAS_BYTESWAP16_INTRINSIC
1055 #define DRWAV_HAS_BYTESWAP32_INTRINSIC
1056 #define DRWAV_HAS_BYTESWAP64_INTRINSIC
1057 #elif defined(__clang__)
1058 #if defined(__has_builtin)
1059 #if __has_builtin(__builtin_bswap16)
1060 #define DRWAV_HAS_BYTESWAP16_INTRINSIC
1062 #if __has_builtin(__builtin_bswap32)
1063 #define DRWAV_HAS_BYTESWAP32_INTRINSIC
1065 #if __has_builtin(__builtin_bswap64)
1066 #define DRWAV_HAS_BYTESWAP64_INTRINSIC
1069 #elif defined(__GNUC__)
1070 #if ((__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3))
1071 #define DRWAV_HAS_BYTESWAP32_INTRINSIC
1072 #define DRWAV_HAS_BYTESWAP64_INTRINSIC
1074 #if ((__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 8))
1075 #define DRWAV_HAS_BYTESWAP16_INTRINSIC
1083 #ifndef DRWAV_MAX_SAMPLE_RATE
1084 #define DRWAV_MAX_SAMPLE_RATE 384000
1086 #ifndef DRWAV_MAX_CHANNELS
1087 #define DRWAV_MAX_CHANNELS 256
1089 #ifndef DRWAV_MAX_BITS_PER_SAMPLE
1090 #define DRWAV_MAX_BITS_PER_SAMPLE 64
1093 static const drwav_uint8 drwavGUID_W64_RIFF[16] = {0x72,0x69,0x66,0x66, 0x2E,0x91, 0xCF,0x11, 0xA5,0xD6, 0x28,0xDB,0x04,0xC1,0x00,0x00};
1094 static const drwav_uint8 drwavGUID_W64_WAVE[16] = {0x77,0x61,0x76,0x65, 0xF3,0xAC, 0xD3,0x11, 0x8C,0xD1, 0x00,0xC0,0x4F,0x8E,0xDB,0x8A};
1095 static const drwav_uint8 drwavGUID_W64_JUNK[16] = {0x6A,0x75,0x6E,0x6B, 0xF3,0xAC, 0xD3,0x11, 0x8C,0xD1, 0x00,0xC0,0x4F,0x8E,0xDB,0x8A};
1096 static const drwav_uint8 drwavGUID_W64_FMT [16] = {0x66,0x6D,0x74,0x20, 0xF3,0xAC, 0xD3,0x11, 0x8C,0xD1, 0x00,0xC0,0x4F,0x8E,0xDB,0x8A};
1097 static const drwav_uint8 drwavGUID_W64_FACT[16] = {0x66,0x61,0x63,0x74, 0xF3,0xAC, 0xD3,0x11, 0x8C,0xD1, 0x00,0xC0,0x4F,0x8E,0xDB,0x8A};
1098 static const drwav_uint8 drwavGUID_W64_DATA[16] = {0x64,0x61,0x74,0x61, 0xF3,0xAC, 0xD3,0x11, 0x8C,0xD1, 0x00,0xC0,0x4F,0x8E,0xDB,0x8A};
1099 static const drwav_uint8 drwavGUID_W64_SMPL[16] = {0x73,0x6D,0x70,0x6C, 0xF3,0xAC, 0xD3,0x11, 0x8C,0xD1, 0x00,0xC0,0x4F,0x8E,0xDB,0x8A};
1104 for (i = 0; i < 16; i += 1) {
1126 #if defined(DRWAV_X86) || defined(DRWAV_X64)
1128 #elif defined(__BYTE_ORDER) && defined(__LITTLE_ENDIAN) && __BYTE_ORDER == __LITTLE_ENDIAN
1132 return (*(
char*)&n) == 1;
1136 static DRWAV_INLINE unsigned short drwav__bytes_to_u16(
const unsigned char* data)
1138 return (data[0] << 0) | (data[1] << 8);
1141 static DRWAV_INLINE short drwav__bytes_to_s16(
const unsigned char* data)
1143 return (
short)drwav__bytes_to_u16(data);
1146 static DRWAV_INLINE unsigned int drwav__bytes_to_u32(
const unsigned char* data)
1148 return (data[0] << 0) | (data[1] << 8) | (data[2] << 16) | (data[3] << 24);
1161 for (i = 0; i < 16; ++i) {
1169 #ifdef DRWAV_HAS_BYTESWAP16_INTRINSIC
1170 #if defined(_MSC_VER)
1171 return _byteswap_ushort(n);
1172 #elif defined(__GNUC__) || defined(__clang__)
1173 return __builtin_bswap16(n);
1175 #error "This compiler does not support the byte swap intrinsic."
1178 return ((n & 0xFF00) >> 8) |
1179 ((n & 0x00FF) << 8);
1185 #ifdef DRWAV_HAS_BYTESWAP32_INTRINSIC
1186 #if defined(_MSC_VER)
1187 return _byteswap_ulong(n);
1188 #elif defined(__GNUC__) || defined(__clang__)
1189 #if defined(DRWAV_ARM) && (defined(__ARM_ARCH) && __ARM_ARCH >= 6) && !defined(DRWAV_64BIT)
1192 __asm__ __volatile__ (
1193 #
if defined(DRWAV_64BIT)
1194 "rev %w[out], %w[in]" : [out]
"=r"(r) : [in]
"r"(n)
1196 "rev %[out], %[in]" : [out]
"=r"(r) : [in]
"r"(n)
1201 return __builtin_bswap32(n);
1204 #error "This compiler does not support the byte swap intrinsic."
1207 return ((n & 0xFF000000) >> 24) |
1208 ((n & 0x00FF0000) >> 8) |
1209 ((n & 0x0000FF00) << 8) |
1210 ((n & 0x000000FF) << 24);
1216 #ifdef DRWAV_HAS_BYTESWAP64_INTRINSIC
1217 #if defined(_MSC_VER)
1218 return _byteswap_uint64(n);
1219 #elif defined(__GNUC__) || defined(__clang__)
1220 return __builtin_bswap64(n);
1222 #error "This compiler does not support the byte swap intrinsic."
1225 return ((n & (
drwav_uint64)0xFF00000000000000) >> 56) |
1245 for (iSample = 0; iSample < sampleCount; iSample += 1) {
1262 for (iSample = 0; iSample < sampleCount; iSample += 1) {
1277 for (iSample = 0; iSample < sampleCount; iSample += 1) {
1298 for (iSample = 0; iSample < sampleCount; iSample += 1) {
1319 for (iSample = 0; iSample < sampleCount; iSample += 1) {
1328 switch (bytesPerSample)
1352 switch (bytesPerSample)
1357 drwav__bswap_samples_f16((drwav_float16*)pSamples, sampleCount);
1428 if (pAllocationCallbacks ==
NULL) {
1446 if (pAllocationCallbacks ==
NULL) {
1476 if (p ==
NULL || pAllocationCallbacks ==
NULL) {
1488 if (pAllocationCallbacks !=
NULL) {
1490 return *pAllocationCallbacks;
1498 return allocationCallbacks;
1512 return (
unsigned int)(chunkSize % 2);
1517 return (
unsigned int)(chunkSize % 8);
1527 unsigned char sizeInBytes[4];
1529 if (onRead(pUserData, pHeaderOut->
id.
fourcc, 4) != 4) {
1533 if (onRead(pUserData, sizeInBytes, 4) != 4) {
1537 pHeaderOut->
sizeInBytes = drwav__bytes_to_u32(sizeInBytes);
1539 *pRunningBytesReadOut += 8;
1541 unsigned char sizeInBytes[8];
1543 if (onRead(pUserData, pHeaderOut->
id.
guid, 16) != 16) {
1547 if (onRead(pUserData, sizeInBytes, 8) != 8) {
1551 pHeaderOut->
sizeInBytes = drwav__bytes_to_u64(sizeInBytes) - 24;
1553 *pRunningBytesReadOut += 24;
1562 while (bytesRemainingToSeek > 0) {
1563 if (bytesRemainingToSeek > 0x7FFFFFFF) {
1567 bytesRemainingToSeek -= 0x7FFFFFFF;
1572 bytesRemainingToSeek = 0;
1581 if (offset <= 0x7FFFFFFF) {
1589 offset -= 0x7FFFFFFF;
1592 if (offset <= 0x7FFFFFFF) {
1599 offset -= 0x7FFFFFFF;
1610 unsigned char fmt[16];
1622 *pRunningBytesReadOut +=
header.sizeInBytes +
header.paddingSize;
1633 if (!drwav__fourcc_equal(
header.id.fourcc,
"fmt ")) {
1643 if (onRead(pUserData, fmt,
sizeof(fmt)) !=
sizeof(fmt)) {
1646 *pRunningBytesReadOut +=
sizeof(fmt);
1648 fmtOut->
formatTag = drwav__bytes_to_u16(fmt + 0);
1649 fmtOut->
channels = drwav__bytes_to_u16(fmt + 2);
1650 fmtOut->
sampleRate = drwav__bytes_to_u32(fmt + 4);
1652 fmtOut->
blockAlign = drwav__bytes_to_u16(fmt + 12);
1660 if (
header.sizeInBytes > 16) {
1661 unsigned char fmt_cbSize[2];
1662 int bytesReadSoFar = 0;
1664 if (onRead(pUserData, fmt_cbSize,
sizeof(fmt_cbSize)) !=
sizeof(fmt_cbSize)) {
1667 *pRunningBytesReadOut +=
sizeof(fmt_cbSize);
1669 bytesReadSoFar = 18;
1671 fmtOut->
extendedSize = drwav__bytes_to_u16(fmt_cbSize);
1681 unsigned char fmtext[22];
1687 fmtOut->
channelMask = drwav__bytes_to_u32(fmtext + 2);
1688 drwav__bytes_to_guid(fmtext + 6, fmtOut->
subFormat);
1703 *pRunningBytesReadOut += (
header.sizeInBytes - bytesReadSoFar);
1706 if (
header.paddingSize > 0) {
1710 *pRunningBytesReadOut +=
header.paddingSize;
1724 bytesRead = onRead(pUserData, pBufferOut, bytesToRead);
1725 *pCursor += bytesRead;
1734 if (!onSeek(pUserData, offset, origin)) {
1766 if (pWav ==
NULL || onRead ==
NULL || onSeek ==
NULL) {
1789 unsigned char riff[4];
1791 unsigned short translatedFormatTag;
1809 if (drwav__fourcc_equal(riff,
"RIFF")) {
1811 }
else if (drwav__fourcc_equal(riff,
"riff")) {
1822 for (i = 0; i < 12; ++i) {
1833 unsigned char chunkSizeBytes[4];
1834 unsigned char wave[4];
1841 if (drwav__bytes_to_u32(chunkSizeBytes) < 36) {
1849 if (!drwav__fourcc_equal(wave,
"WAVE")) {
1853 unsigned char chunkSizeBytes[8];
1861 if (drwav__bytes_to_u64(chunkSizeBytes) < 80) {
1892 translatedFormatTag = drwav__bytes_to_u16(fmt.
subFormat + 0);
1897 sampleCountFromFactChunk = 0;
1915 if (!foundDataChunk) {
1923 if (!sequential && onChunk !=
NULL) {
1930 if (callbackBytesRead > 0) {
1938 if (!foundDataChunk) {
1942 chunkSize =
header.sizeInBytes;
1944 if (drwav__fourcc_equal(
header.id.fourcc,
"data")) {
1946 dataChunkSize = chunkSize;
1951 dataChunkSize = chunkSize;
1959 if (foundDataChunk && sequential) {
1965 if (drwav__fourcc_equal(
header.id.fourcc,
"fact")) {
1972 if (!foundDataChunk) {
1981 sampleCountFromFactChunk = sampleCount;
1983 sampleCountFromFactChunk = 0;
1993 if (!foundDataChunk) {
2001 if (drwav__fourcc_equal(
header.id.fourcc,
"smpl")) {
2002 unsigned char smplHeaderData[36];
2003 if (chunkSize >=
sizeof(smplHeaderData)) {
2005 chunkSize -= bytesJustRead;
2007 if (bytesJustRead ==
sizeof(smplHeaderData)) {
2011 pWav->
smpl.
product = drwav__bytes_to_u32(smplHeaderData+4);
2021 unsigned char smplLoopData[24];
2023 chunkSize -= bytesJustRead;
2025 if (bytesJustRead ==
sizeof(smplLoopData)) {
2027 pWav->
smpl.
loops[iLoop].
type = drwav__bytes_to_u32(smplLoopData+4);
2028 pWav->
smpl.
loops[iLoop].
start = drwav__bytes_to_u32(smplLoopData+8);
2029 pWav->
smpl.
loops[iLoop].
end = drwav__bytes_to_u32(smplLoopData+12);
2042 if (drwav__guid_equal(
header.id.guid, drwavGUID_W64_SMPL)) {
2051 chunkSize +=
header.paddingSize;
2055 cursor += chunkSize;
2057 if (!foundDataChunk) {
2063 if (!foundDataChunk) {
2086 if (sampleCountFromFactChunk != 0) {
2096 if ((blockCount * fmt.
blockAlign) < dataChunkSize) {
2101 totalBlockHeaderSizeInBytes = blockCount * (6*fmt.
channels);
2109 if ((blockCount * fmt.
blockAlign) < dataChunkSize) {
2114 totalBlockHeaderSizeInBytes = blockCount * (4*fmt.
channels);
2129 #ifdef DR_WAV_LIBSNDFILE_COMPAT
2158 if (!
drwav_preinit(pWav, onRead, onSeek, pReadSeekUserData, pAllocationCallbacks)) {
2170 if (dataChunkSize <= (0xFFFFFFFFUL - 36 - dataSubchunkPaddingSize)) {
2171 return 36 + (
drwav_uint32)(dataChunkSize + dataSubchunkPaddingSize);
2179 if (dataChunkSize <= 0xFFFFFFFFUL) {
2182 return 0xFFFFFFFFUL;
2190 return 80 + 24 + dataChunkSize + dataSubchunkPaddingSize;
2195 return 24 + dataChunkSize;
2201 if (pWav ==
NULL || onWrite ==
NULL) {
2205 if (!isSequential && onSeek ==
NULL) {
2243 size_t runningPos = 0;
2260 if (initialDataChunkSize > (0xFFFFFFFFUL - 36)) {
2276 drwav_uint64 chunkSizeRIFF = 80 + 24 + initialDataChunkSize;
2308 drwav_uint64 chunkSizeDATA = 24 + initialDataChunkSize;
2316 if (runningPos != 20 + chunkSizeFMT + 8) {
2320 if (runningPos != 40 + chunkSizeFMT + 24) {
2357 if (pFormat ==
NULL) {
2372 fileSizeBytes = (8 + riffChunkSizeBytes);
2375 fileSizeBytes = riffChunkSizeBytes;
2378 return fileSizeBytes;
2382 #ifndef DR_WAV_NO_STDIO
2383 FILE*
drwav_fopen(
const char* filePath,
const char* openMode)
2386 #if defined(_MSC_VER) && _MSC_VER >= 1400
2387 if (fopen_s(&pFile, filePath, openMode) != 0) {
2391 pFile = fopen(filePath, openMode);
2392 if (pFile ==
NULL) {
2405 (void)pAllocationCallbacks;
2406 #if defined(_MSC_VER) && _MSC_VER >= 1400
2407 if (_wfopen_s(&pFile, pFilePath, pOpenMode) != 0) {
2411 pFile = _wfopen(pFilePath, pOpenMode);
2412 if (pFile ==
NULL) {
2425 const wchar_t* pFilePathTemp = pFilePath;
2426 char* pFilePathMB =
NULL;
2427 const wchar_t* pOpenModeMBTemp = pOpenMode;
2428 char pOpenModeMB[16];
2435 lenMB = wcsrtombs(
NULL, &pFilePathTemp, 0, &mbs);
2436 if (lenMB == (
size_t)-1) {
2441 if (pFilePathMB ==
NULL) {
2445 pFilePathTemp = pFilePath;
2447 wcsrtombs(pFilePathMB, &pFilePathTemp, lenMB + 1, &mbs);
2450 wcsrtombs(pOpenModeMB, &pOpenModeMBTemp,
sizeof(pOpenModeMB), &mbs);
2452 pFile = fopen(pFilePathMB, pOpenModeMB);
2464 return fread(pBufferOut, 1, bytesToRead, (FILE*)pUserData);
2469 return fwrite(pData, 1, bytesToWrite, (FILE*)pUserData);
2496 if (pFile ==
NULL) {
2511 FILE* pFile =
drwav_wfopen(filename,
L"rb", pAllocationCallbacks);
2512 if (pFile ==
NULL) {
2534 if (pFile ==
NULL) {
2544 FILE* pFile =
drwav_wfopen(filename,
L"wb", pAllocationCallbacks);
2545 if (pFile ==
NULL) {
2565 if (pFormat ==
NULL) {
2584 if (pFormat ==
NULL) {
2596 size_t bytesRemaining;
2602 if (bytesToRead > bytesRemaining) {
2603 bytesToRead = bytesRemaining;
2606 if (bytesToRead > 0) {
2633 if ((
drwav_uint32)offset <= pWav->memoryStream.dataSize) {
2646 size_t bytesRemaining;
2652 if (bytesRemaining < bytesToWrite) {
2663 if (pNewData ==
NULL) {
2680 return bytesToWrite;
2719 if (data ==
NULL || dataSize == 0) {
2737 if (ppData ==
NULL || pDataSize ==
NULL) {
2769 if (pFormat ==
NULL) {
2801 if (paddingSize > 0) {
2846 #ifndef DR_WAV_NO_STDIO
2865 if (pWav ==
NULL || bytesToRead == 0 || pBufferOut ==
NULL) {
2885 if (pWav ==
NULL || framesToRead == 0 || pBufferOut ==
NULL) {
2895 if (bytesPerFrame == 0) {
2904 return drwav_read_raw(pWav, (
size_t)(framesToRead * bytesPerFrame), pBufferOut) / bytesPerFrame;
2978 if (targetFrameIndex < pWav->compressed.iCurrentPCMFrame) {
2988 while (offsetInFrames > 0) {
3003 if (framesRead != framesToRead) {
3007 offsetInFrames -= framesRead;
3022 if (currentBytePos < targetBytePos) {
3024 offset = (targetBytePos - currentBytePos);
3030 offset = targetBytePos;
3033 while (offset > 0) {
3034 int offset32 = ((offset > INT_MAX) ? INT_MAX : (
int)offset);
3050 size_t bytesWritten;
3052 if (pWav ==
NULL || bytesToWrite == 0 || pData ==
NULL) {
3059 return bytesWritten;
3069 if (pWav ==
NULL || framesToWrite == 0 || pData ==
NULL) {
3081 while (bytesToWrite > 0) {
3082 size_t bytesJustWritten;
3085 bytesToWriteThisIteration = bytesToWrite;
3088 bytesJustWritten =
drwav_write_raw(pWav, (
size_t)bytesToWriteThisIteration, pRunningData);
3089 if (bytesJustWritten == 0) {
3093 bytesToWrite -= bytesJustWritten;
3094 bytesWritten += bytesJustWritten;
3095 pRunningData += bytesJustWritten;
3108 if (pWav ==
NULL || framesToWrite == 0 || pData ==
NULL) {
3122 while (bytesToWrite > 0) {
3125 size_t bytesJustWritten;
3128 bytesToWriteThisIteration = bytesToWrite;
3135 sampleCount =
sizeof(temp)/bytesPerSample;
3137 if (bytesToWriteThisIteration > ((
drwav_uint64)sampleCount)*bytesPerSample) {
3138 bytesToWriteThisIteration = ((
drwav_uint64)sampleCount)*bytesPerSample;
3144 bytesJustWritten =
drwav_write_raw(pWav, (
size_t)bytesToWriteThisIteration, temp);
3145 if (bytesJustWritten == 0) {
3149 bytesToWrite -= bytesJustWritten;
3150 bytesWritten += bytesJustWritten;
3151 pRunningData += bytesJustWritten;
3183 if (pWav->
onRead(pWav->
pUserData, header,
sizeof(header)) !=
sizeof(header)) {
3184 return totalFramesRead;
3189 pWav->
msadpcm.
delta[0] = drwav__bytes_to_s16(header + 1);
3198 if (pWav->
onRead(pWav->
pUserData, header,
sizeof(header)) !=
sizeof(header)) {
3199 return totalFramesRead;
3205 pWav->
msadpcm.
delta[0] = drwav__bytes_to_s16(header + 2);
3206 pWav->
msadpcm.
delta[1] = drwav__bytes_to_s16(header + 4);
3223 for (iSample = 0; iSample < pWav->
channels; iSample += 1) {
3229 totalFramesRead += 1;
3234 if (framesToRead == 0) {
3235 return totalFramesRead;
3248 230, 230, 230, 230, 307, 409, 512, 614,
3249 768, 614, 512, 409, 307, 230, 230, 230
3251 static drwav_int32 coeff1Table[] = { 256, 512, 0, 192, 240, 460, 392 };
3252 static drwav_int32 coeff2Table[] = { 0, -256, 0, 64, 0, -208, -232 };
3259 return totalFramesRead;
3264 nibble0 = ((nibbles & 0xF0) >> 4);
if ((nibbles & 0x80)) { nibble0 |= 0xFFFFFFF0UL; }
3265 nibble1 = ((nibbles & 0x0F) >> 0);
if ((nibbles & 0x08)) { nibble1 |= 0xFFFFFFF0UL; }
3274 newSample0 =
drwav_clamp(newSample0, -32768, 32767);
3287 newSample1 =
drwav_clamp(newSample1, -32768, 32767);
3309 newSample0 =
drwav_clamp(newSample0, -32768, 32767);
3323 newSample1 =
drwav_clamp(newSample1, -32768, 32767);
3341 return totalFramesRead;
3361 if (pWav->
onRead(pWav->
pUserData, header,
sizeof(header)) !=
sizeof(header)) {
3362 return totalFramesRead;
3366 pWav->
ima.
predictor[0] = drwav__bytes_to_s16(header + 0);
3373 if (pWav->
onRead(pWav->
pUserData, header,
sizeof(header)) !=
sizeof(header)) {
3374 return totalFramesRead;
3378 pWav->
ima.
predictor[0] = drwav__bytes_to_s16(header + 0);
3380 pWav->
ima.
predictor[1] = drwav__bytes_to_s16(header + 4);
3392 for (iSample = 0; iSample < pWav->
channels; iSample += 1) {
3398 totalFramesRead += 1;
3403 if (framesToRead == 0) {
3404 return totalFramesRead;
3416 -1, -1, -1, -1, 2, 4, 6, 8,
3417 -1, -1, -1, -1, 2, 4, 6, 8
3421 7, 8, 9, 10, 11, 12, 13, 14, 16, 17,
3422 19, 21, 23, 25, 28, 31, 34, 37, 41, 45,
3423 50, 55, 60, 66, 73, 80, 88, 97, 107, 118,
3424 130, 143, 157, 173, 190, 209, 230, 253, 279, 307,
3425 337, 371, 408, 449, 494, 544, 598, 658, 724, 796,
3426 876, 963, 1060, 1166, 1282, 1411, 1552, 1707, 1878, 2066,
3427 2272, 2499, 2749, 3024, 3327, 3660, 4026, 4428, 4871, 5358,
3428 5894, 6484, 7132, 7845, 8630, 9493, 10442, 11487, 12635, 13899,
3429 15289, 16818, 18500, 20350, 22385, 24623, 27086, 29794, 32767
3439 for (iChannel = 0; iChannel < pWav->
channels; ++iChannel) {
3444 return totalFramesRead;
3448 for (iByte = 0; iByte < 4; ++iByte) {
3449 drwav_uint8 nibble0 = ((nibbles[iByte] & 0x0F) >> 0);
3450 drwav_uint8 nibble1 = ((nibbles[iByte] & 0xF0) >> 4);
3456 if (nibble0 & 1) diff += step >> 2;
3457 if (nibble0 & 2) diff += step >> 1;
3458 if (nibble0 & 4) diff += step;
3459 if (nibble0 & 8) diff = -diff;
3461 predictor =
drwav_clamp(predictor + diff, -32768, 32767);
3471 if (nibble1 & 1) diff += step >> 2;
3472 if (nibble1 & 2) diff += step >> 1;
3473 if (nibble1 & 4) diff += step;
3474 if (nibble1 & 8) diff = -diff;
3476 predictor =
drwav_clamp(predictor + diff, -32768, 32767);
3486 return totalFramesRead;
3490 #ifndef DR_WAV_NO_CONVERSION_API
3492 0xEA80, 0xEB80, 0xE880, 0xE980, 0xEE80, 0xEF80, 0xEC80, 0xED80, 0xE280, 0xE380, 0xE080, 0xE180, 0xE680, 0xE780, 0xE480, 0xE580,
3493 0xF540, 0xF5C0, 0xF440, 0xF4C0, 0xF740, 0xF7C0, 0xF640, 0xF6C0, 0xF140, 0xF1C0, 0xF040, 0xF0C0, 0xF340, 0xF3C0, 0xF240, 0xF2C0,
3494 0xAA00, 0xAE00, 0xA200, 0xA600, 0xBA00, 0xBE00, 0xB200, 0xB600, 0x8A00, 0x8E00, 0x8200, 0x8600, 0x9A00, 0x9E00, 0x9200, 0x9600,
3495 0xD500, 0xD700, 0xD100, 0xD300, 0xDD00, 0xDF00, 0xD900, 0xDB00, 0xC500, 0xC700, 0xC100, 0xC300, 0xCD00, 0xCF00, 0xC900, 0xCB00,
3496 0xFEA8, 0xFEB8, 0xFE88, 0xFE98, 0xFEE8, 0xFEF8, 0xFEC8, 0xFED8, 0xFE28, 0xFE38, 0xFE08, 0xFE18, 0xFE68, 0xFE78, 0xFE48, 0xFE58,
3497 0xFFA8, 0xFFB8, 0xFF88, 0xFF98, 0xFFE8, 0xFFF8, 0xFFC8, 0xFFD8, 0xFF28, 0xFF38, 0xFF08, 0xFF18, 0xFF68, 0xFF78, 0xFF48, 0xFF58,
3498 0xFAA0, 0xFAE0, 0xFA20, 0xFA60, 0xFBA0, 0xFBE0, 0xFB20, 0xFB60, 0xF8A0, 0xF8E0, 0xF820, 0xF860, 0xF9A0, 0xF9E0, 0xF920, 0xF960,
3499 0xFD50, 0xFD70, 0xFD10, 0xFD30, 0xFDD0, 0xFDF0, 0xFD90, 0xFDB0, 0xFC50, 0xFC70, 0xFC10, 0xFC30, 0xFCD0, 0xFCF0, 0xFC90, 0xFCB0,
3500 0x1580, 0x1480, 0x1780, 0x1680, 0x1180, 0x1080, 0x1380, 0x1280, 0x1D80, 0x1C80, 0x1F80, 0x1E80, 0x1980, 0x1880, 0x1B80, 0x1A80,
3501 0x0AC0, 0x0A40, 0x0BC0, 0x0B40, 0x08C0, 0x0840, 0x09C0, 0x0940, 0x0EC0, 0x0E40, 0x0FC0, 0x0F40, 0x0CC0, 0x0C40, 0x0DC0, 0x0D40,
3502 0x5600, 0x5200, 0x5E00, 0x5A00, 0x4600, 0x4200, 0x4E00, 0x4A00, 0x7600, 0x7200, 0x7E00, 0x7A00, 0x6600, 0x6200, 0x6E00, 0x6A00,
3503 0x2B00, 0x2900, 0x2F00, 0x2D00, 0x2300, 0x2100, 0x2700, 0x2500, 0x3B00, 0x3900, 0x3F00, 0x3D00, 0x3300, 0x3100, 0x3700, 0x3500,
3504 0x0158, 0x0148, 0x0178, 0x0168, 0x0118, 0x0108, 0x0138, 0x0128, 0x01D8, 0x01C8, 0x01F8, 0x01E8, 0x0198, 0x0188, 0x01B8, 0x01A8,
3505 0x0058, 0x0048, 0x0078, 0x0068, 0x0018, 0x0008, 0x0038, 0x0028, 0x00D8, 0x00C8, 0x00F8, 0x00E8, 0x0098, 0x0088, 0x00B8, 0x00A8,
3506 0x0560, 0x0520, 0x05E0, 0x05A0, 0x0460, 0x0420, 0x04E0, 0x04A0, 0x0760, 0x0720, 0x07E0, 0x07A0, 0x0660, 0x0620, 0x06E0, 0x06A0,
3507 0x02B0, 0x0290, 0x02F0, 0x02D0, 0x0230, 0x0210, 0x0270, 0x0250, 0x03B0, 0x0390, 0x03F0, 0x03D0, 0x0330, 0x0310, 0x0370, 0x0350
3511 0x8284, 0x8684, 0x8A84, 0x8E84, 0x9284, 0x9684, 0x9A84, 0x9E84, 0xA284, 0xA684, 0xAA84, 0xAE84, 0xB284, 0xB684, 0xBA84, 0xBE84,
3512 0xC184, 0xC384, 0xC584, 0xC784, 0xC984, 0xCB84, 0xCD84, 0xCF84, 0xD184, 0xD384, 0xD584, 0xD784, 0xD984, 0xDB84, 0xDD84, 0xDF84,
3513 0xE104, 0xE204, 0xE304, 0xE404, 0xE504, 0xE604, 0xE704, 0xE804, 0xE904, 0xEA04, 0xEB04, 0xEC04, 0xED04, 0xEE04, 0xEF04, 0xF004,
3514 0xF0C4, 0xF144, 0xF1C4, 0xF244, 0xF2C4, 0xF344, 0xF3C4, 0xF444, 0xF4C4, 0xF544, 0xF5C4, 0xF644, 0xF6C4, 0xF744, 0xF7C4, 0xF844,
3515 0xF8A4, 0xF8E4, 0xF924, 0xF964, 0xF9A4, 0xF9E4, 0xFA24, 0xFA64, 0xFAA4, 0xFAE4, 0xFB24, 0xFB64, 0xFBA4, 0xFBE4, 0xFC24, 0xFC64,
3516 0xFC94, 0xFCB4, 0xFCD4, 0xFCF4, 0xFD14, 0xFD34, 0xFD54, 0xFD74, 0xFD94, 0xFDB4, 0xFDD4, 0xFDF4, 0xFE14, 0xFE34, 0xFE54, 0xFE74,
3517 0xFE8C, 0xFE9C, 0xFEAC, 0xFEBC, 0xFECC, 0xFEDC, 0xFEEC, 0xFEFC, 0xFF0C, 0xFF1C, 0xFF2C, 0xFF3C, 0xFF4C, 0xFF5C, 0xFF6C, 0xFF7C,
3518 0xFF88, 0xFF90, 0xFF98, 0xFFA0, 0xFFA8, 0xFFB0, 0xFFB8, 0xFFC0, 0xFFC8, 0xFFD0, 0xFFD8, 0xFFE0, 0xFFE8, 0xFFF0, 0xFFF8, 0x0000,
3519 0x7D7C, 0x797C, 0x757C, 0x717C, 0x6D7C, 0x697C, 0x657C, 0x617C, 0x5D7C, 0x597C, 0x557C, 0x517C, 0x4D7C, 0x497C, 0x457C, 0x417C,
3520 0x3E7C, 0x3C7C, 0x3A7C, 0x387C, 0x367C, 0x347C, 0x327C, 0x307C, 0x2E7C, 0x2C7C, 0x2A7C, 0x287C, 0x267C, 0x247C, 0x227C, 0x207C,
3521 0x1EFC, 0x1DFC, 0x1CFC, 0x1BFC, 0x1AFC, 0x19FC, 0x18FC, 0x17FC, 0x16FC, 0x15FC, 0x14FC, 0x13FC, 0x12FC, 0x11FC, 0x10FC, 0x0FFC,
3522 0x0F3C, 0x0EBC, 0x0E3C, 0x0DBC, 0x0D3C, 0x0CBC, 0x0C3C, 0x0BBC, 0x0B3C, 0x0ABC, 0x0A3C, 0x09BC, 0x093C, 0x08BC, 0x083C, 0x07BC,
3523 0x075C, 0x071C, 0x06DC, 0x069C, 0x065C, 0x061C, 0x05DC, 0x059C, 0x055C, 0x051C, 0x04DC, 0x049C, 0x045C, 0x041C, 0x03DC, 0x039C,
3524 0x036C, 0x034C, 0x032C, 0x030C, 0x02EC, 0x02CC, 0x02AC, 0x028C, 0x026C, 0x024C, 0x022C, 0x020C, 0x01EC, 0x01CC, 0x01AC, 0x018C,
3525 0x0174, 0x0164, 0x0154, 0x0144, 0x0134, 0x0124, 0x0114, 0x0104, 0x00F4, 0x00E4, 0x00D4, 0x00C4, 0x00B4, 0x00A4, 0x0094, 0x0084,
3526 0x0078, 0x0070, 0x0068, 0x0060, 0x0058, 0x0050, 0x0048, 0x0040, 0x0038, 0x0030, 0x0028, 0x0020, 0x0018, 0x0010, 0x0008, 0x0000
3546 if (bytesPerSample == 1) {
3553 if (bytesPerSample == 2) {
3554 for (i = 0; i < totalSampleCount; ++i) {
3559 if (bytesPerSample == 3) {
3563 if (bytesPerSample == 4) {
3570 if (bytesPerSample > 8) {
3577 for (i = 0; i < totalSampleCount; ++i) {
3579 unsigned int shift = (8 - bytesPerSample) * 8;
3582 for (j = 0; j < bytesPerSample; j += 1) {
3595 if (bytesPerSample == 4) {
3598 }
else if (bytesPerSample == 8) {
3612 unsigned char sampleData[4096];
3620 if (bytesPerFrame == 0) {
3624 totalFramesRead = 0;
3626 while (framesToRead > 0) {
3628 if (framesRead == 0) {
3634 pBufferOut += framesRead*pWav->
channels;
3635 framesToRead -= framesRead;
3636 totalFramesRead += framesRead;
3639 return totalFramesRead;
3645 unsigned char sampleData[4096];
3648 if (bytesPerFrame == 0) {
3652 totalFramesRead = 0;
3654 while (framesToRead > 0) {
3656 if (framesRead == 0) {
3662 pBufferOut += framesRead*pWav->
channels;
3663 framesToRead -= framesRead;
3664 totalFramesRead += framesRead;
3667 return totalFramesRead;
3673 unsigned char sampleData[4096];
3676 if (bytesPerFrame == 0) {
3680 totalFramesRead = 0;
3682 while (framesToRead > 0) {
3684 if (framesRead == 0) {
3690 pBufferOut += framesRead*pWav->
channels;
3691 framesToRead -= framesRead;
3692 totalFramesRead += framesRead;
3695 return totalFramesRead;
3701 unsigned char sampleData[4096];
3704 if (bytesPerFrame == 0) {
3708 totalFramesRead = 0;
3710 while (framesToRead > 0) {
3712 if (framesRead == 0) {
3718 pBufferOut += framesRead*pWav->
channels;
3719 framesToRead -= framesRead;
3720 totalFramesRead += framesRead;
3723 return totalFramesRead;
3728 if (pWav ==
NULL || framesToRead == 0 || pBufferOut ==
NULL) {
3789 for (i = 0; i < sampleCount; ++i) {
3801 for (i = 0; i < sampleCount; ++i) {
3802 int x = ((int)(((
unsigned int)(((
const unsigned char*)pIn)[i*3+0]) << 8) | ((
unsigned int)(((
const unsigned char*)pIn)[i*3+1]) << 16) | ((
unsigned int)(((
const unsigned char*)pIn)[i*3+2])) << 24)) >> 8;
3812 for (i = 0; i < sampleCount; ++i) {
3823 for (i = 0; i < sampleCount; ++i) {
3826 c = ((x < -1) ? -1 : ((x > 1) ? 1 : x));
3828 r = (int)(c * 32767.5f);
3838 for (i = 0; i < sampleCount; ++i) {
3841 c = ((x < -1) ? -1 : ((x > 1) ? 1 : x));
3843 r = (int)(c * 32767.5);
3852 for (i = 0; i < sampleCount; ++i) {
3860 for (i = 0; i < sampleCount; ++i) {
3867 static void drwav__pcm_to_f32(
float* pOut,
const unsigned char* pIn,
size_t sampleCount,
unsigned int bytesPerSample)
3872 if (bytesPerSample == 1) {
3878 if (bytesPerSample == 2) {
3882 if (bytesPerSample == 3) {
3886 if (bytesPerSample == 4) {
3893 if (bytesPerSample > 8) {
3900 for (i = 0; i < sampleCount; ++i) {
3902 unsigned int shift = (8 - bytesPerSample) * 8;
3905 for (j = 0; j < bytesPerSample; j += 1) {
3912 *pOut++ = (float)((
drwav_int64)sample / 9223372036854775807.0);
3916 static void drwav__ieee_to_f32(
float* pOut,
const unsigned char* pIn,
size_t sampleCount,
unsigned int bytesPerSample)
3918 if (bytesPerSample == 4) {
3920 for (i = 0; i < sampleCount; ++i) {
3921 *pOut++ = ((
const float*)pIn)[i];
3924 }
else if (bytesPerSample == 8) {
3938 unsigned char sampleData[4096];
3941 if (bytesPerFrame == 0) {
3945 totalFramesRead = 0;
3947 while (framesToRead > 0) {
3949 if (framesRead == 0) {
3955 pBufferOut += framesRead*pWav->
channels;
3956 framesToRead -= framesRead;
3957 totalFramesRead += framesRead;
3960 return totalFramesRead;
3971 while (framesToRead > 0) {
3973 if (framesRead == 0) {
3979 pBufferOut += framesRead*pWav->
channels;
3980 framesToRead -= framesRead;
3981 totalFramesRead += framesRead;
3984 return totalFramesRead;
3995 while (framesToRead > 0) {
3997 if (framesRead == 0) {
4003 pBufferOut += framesRead*pWav->
channels;
4004 framesToRead -= framesRead;
4005 totalFramesRead += framesRead;
4008 return totalFramesRead;
4014 unsigned char sampleData[4096];
4023 if (bytesPerFrame == 0) {
4027 totalFramesRead = 0;
4029 while (framesToRead > 0) {
4031 if (framesRead == 0) {
4037 pBufferOut += framesRead*pWav->
channels;
4038 framesToRead -= framesRead;
4039 totalFramesRead += framesRead;
4042 return totalFramesRead;
4048 unsigned char sampleData[4096];
4050 if (bytesPerFrame == 0) {
4054 totalFramesRead = 0;
4056 while (framesToRead > 0) {
4058 if (framesRead == 0) {
4064 pBufferOut += framesRead*pWav->
channels;
4065 framesToRead -= framesRead;
4066 totalFramesRead += framesRead;
4069 return totalFramesRead;
4075 unsigned char sampleData[4096];
4078 if (bytesPerFrame == 0) {
4082 totalFramesRead = 0;
4084 while (framesToRead > 0) {
4086 if (framesRead == 0) {
4092 pBufferOut += framesRead*pWav->
channels;
4093 framesToRead -= framesRead;
4094 totalFramesRead += framesRead;
4097 return totalFramesRead;
4102 if (pWav ==
NULL || framesToRead == 0 || pBufferOut ==
NULL) {
4167 #ifdef DR_WAV_LIBSNDFILE_COMPAT
4174 for (i = 0; i < sampleCount; ++i) {
4175 *pOut++ = (pIn[i] / 256.0f) * 2 - 1;
4178 for (i = 0; i < sampleCount; ++i) {
4180 x = x * 0.00784313725490196078f;
4196 for (i = 0; i < sampleCount; ++i) {
4197 *pOut++ = pIn[i] * 0.000030517578125f;
4209 for (i = 0; i < sampleCount; ++i) {
4211 *pOut++ = (float)(x * 0.00000011920928955078125);
4222 for (i = 0; i < sampleCount; ++i) {
4223 *pOut++ = (float)(pIn[i] / 2147483648.0);
4235 for (i = 0; i < sampleCount; ++i) {
4236 *pOut++ = (float)pIn[i];
4248 for (i = 0; i < sampleCount; ++i) {
4261 for (i = 0; i < sampleCount; ++i) {
4273 if (bytesPerSample == 1) {
4279 if (bytesPerSample == 2) {
4283 if (bytesPerSample == 3) {
4287 if (bytesPerSample == 4) {
4288 for (i = 0; i < totalSampleCount; ++i) {
4296 if (bytesPerSample > 8) {
4303 for (i = 0; i < totalSampleCount; ++i) {
4305 unsigned int shift = (8 - bytesPerSample) * 8;
4308 for (j = 0; j < bytesPerSample; j += 1) {
4321 if (bytesPerSample == 4) {
4324 }
else if (bytesPerSample == 8) {
4338 unsigned char sampleData[4096];
4347 if (bytesPerFrame == 0) {
4351 totalFramesRead = 0;
4353 while (framesToRead > 0) {
4355 if (framesRead == 0) {
4361 pBufferOut += framesRead*pWav->
channels;
4362 framesToRead -= framesRead;
4363 totalFramesRead += framesRead;
4366 return totalFramesRead;
4377 while (framesToRead > 0) {
4379 if (framesRead == 0) {
4385 pBufferOut += framesRead*pWav->
channels;
4386 framesToRead -= framesRead;
4387 totalFramesRead += framesRead;
4390 return totalFramesRead;
4401 while (framesToRead > 0) {
4403 if (framesRead == 0) {
4409 pBufferOut += framesRead*pWav->
channels;
4410 framesToRead -= framesRead;
4411 totalFramesRead += framesRead;
4414 return totalFramesRead;
4420 unsigned char sampleData[4096];
4423 if (bytesPerFrame == 0) {
4427 totalFramesRead = 0;
4429 while (framesToRead > 0) {
4431 if (framesRead == 0) {
4437 pBufferOut += framesRead*pWav->
channels;
4438 framesToRead -= framesRead;
4439 totalFramesRead += framesRead;
4442 return totalFramesRead;
4448 unsigned char sampleData[4096];
4451 if (bytesPerFrame == 0) {
4455 totalFramesRead = 0;
4457 while (framesToRead > 0) {
4459 if (framesRead == 0) {
4465 pBufferOut += framesRead*pWav->
channels;
4466 framesToRead -= framesRead;
4467 totalFramesRead += framesRead;
4470 return totalFramesRead;
4476 unsigned char sampleData[4096];
4479 if (bytesPerFrame == 0) {
4483 totalFramesRead = 0;
4485 while (framesToRead > 0) {
4487 if (framesRead == 0) {
4493 pBufferOut += framesRead*pWav->
channels;
4494 framesToRead -= framesRead;
4495 totalFramesRead += framesRead;
4498 return totalFramesRead;
4503 if (pWav ==
NULL || framesToRead == 0 || pBufferOut ==
NULL) {
4569 for (i = 0; i < sampleCount; ++i) {
4570 *pOut++ = ((int)pIn[i] - 128) << 24;
4582 for (i = 0; i < sampleCount; ++i) {
4583 *pOut++ = pIn[i] << 16;
4595 for (i = 0; i < sampleCount; ++i) {
4596 unsigned int s0 = pIn[i*3 + 0];
4597 unsigned int s1 = pIn[i*3 + 1];
4598 unsigned int s2 = pIn[i*3 + 2];
4613 for (i = 0; i < sampleCount; ++i) {
4626 for (i = 0; i < sampleCount; ++i) {
4639 for (i = 0; i < sampleCount; ++i) {
4652 for (i= 0; i < sampleCount; ++i) {
4674 if (pSampleData ==
NULL) {
4694 if (totalFrameCount) {
4716 if (pSampleData ==
NULL) {
4736 if (totalFrameCount) {
4758 if (pSampleData ==
NULL) {
4778 if (totalFrameCount) {
4794 if (sampleRateOut) {
4797 if (totalFrameCountOut) {
4798 *totalFrameCountOut = 0;
4801 if (!
drwav_init(&wav, onRead, onSeek, pUserData, pAllocationCallbacks)) {
4815 if (sampleRateOut) {
4818 if (totalFrameCountOut) {
4819 *totalFrameCountOut = 0;
4822 if (!
drwav_init(&wav, onRead, onSeek, pUserData, pAllocationCallbacks)) {
4836 if (sampleRateOut) {
4839 if (totalFrameCountOut) {
4840 *totalFrameCountOut = 0;
4843 if (!
drwav_init(&wav, onRead, onSeek, pUserData, pAllocationCallbacks)) {
4850 #ifndef DR_WAV_NO_STDIO
4858 if (sampleRateOut) {
4861 if (totalFrameCountOut) {
4862 *totalFrameCountOut = 0;
4879 if (sampleRateOut) {
4882 if (totalFrameCountOut) {
4883 *totalFrameCountOut = 0;
4900 if (sampleRateOut) {
4903 if (totalFrameCountOut) {
4904 *totalFrameCountOut = 0;
4919 if (sampleRateOut) {
4925 if (totalFrameCountOut) {
4926 *totalFrameCountOut = 0;
4940 if (sampleRateOut) {
4946 if (totalFrameCountOut) {
4947 *totalFrameCountOut = 0;
4961 if (sampleRateOut) {
4967 if (totalFrameCountOut) {
4968 *totalFrameCountOut = 0;
4986 if (sampleRateOut) {
4989 if (totalFrameCountOut) {
4990 *totalFrameCountOut = 0;
5007 if (sampleRateOut) {
5010 if (totalFrameCountOut) {
5011 *totalFrameCountOut = 0;
5028 if (sampleRateOut) {
5031 if (totalFrameCountOut) {
5032 *totalFrameCountOut = 0;
5046 if (pAllocationCallbacks !=
NULL) {