Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,10 @@ set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake")
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED OFF)
set(CMAKE_CXX_EXTENSIONS OFF)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++ -std=c++20")

if (CMAKE_SYSTEM_NAME STREQUAL "Darwin")
# Use libc++ on macOS, system default on Linux
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++")
include_directories(SYSTEM /usr/local/include)
elseif (CMAKE_SYSTEM_NAME STREQUAL "Linux")
link_libraries(stdc++fs)
Expand Down
13 changes: 7 additions & 6 deletions dsp/wav.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
// Created by Steven Atkinson on 12/31/22.
//

#include <cstdint>
#include <cstring> // strncmp
#include <cmath> // pow
#include <fstream>
Expand Down Expand Up @@ -43,9 +44,9 @@ struct WaveFileData
short bitsPerSample;
struct Extensible
{
uint16_t validBitsPerSample;
uint16_t channelMask;
uint32_t subFormat; // PCM, IEEE
std::uint16_t validBitsPerSample;
std::uint16_t channelMask;
std::uint32_t subFormat; // PCM, IEEE
} extensible;
} fmtChunk;

Expand Down Expand Up @@ -210,13 +211,13 @@ dsp::wav::LoadReturnCode ReadFmtChunk(std::ifstream& wavFile, WaveFileData& wfd,
unsigned short cbSize = ReadUnsignedShort(wavFile);
// Do we need to assert or modify the data loading below if this doesn't match bitsPerSample?
wfd.fmtChunk.extensible.validBitsPerSample = ReadUnsignedShort(wavFile);
auto read_u32 = [&]() -> uint32_t {
uint8_t b[4];
auto read_u32 = [&]() -> std::uint32_t {
std::uint8_t b[4];
wavFile.read((char*)b, 4);
return b[0] | (b[1] << 8) | (b[2] << 16) | (b[3] << 24);
};
wfd.fmtChunk.extensible.channelMask = read_u32();
uint8_t guid[16];
std::uint8_t guid[16];
wavFile.read((char*)guid, 16);
wfd.fmtChunk.extensible.subFormat = guid[1] << 8 | guid[0];
bytesRead += cbSize + 2; // Don't forget the 2 for the cbSize itself!
Expand Down