diff --git a/.clang-format b/.clang-format new file mode 100644 index 0000000..38ad09f --- /dev/null +++ b/.clang-format @@ -0,0 +1,31 @@ +--- + +BasedOnStyle: LLVM + +ColumnLimit: 120 # Arbitrary, feel free to adjust locally. 0 to ignore. +PenaltyExcessCharacter: 1 # Softest limit on line length. +ReflowComments: false # Best we don't do this without a consistent length limit. + +AlwaysBreakTemplateDeclarations: true + +AllowShortFunctionsOnASingleLine: Empty + +SpaceAfterTemplateKeyword: false + +ConstructorInitializerIndentWidth: 2 +ContinuationIndentWidth: 2 +IndentWidth: 2 + +AllowShortCaseLabelsOnASingleLine: true + +DerivePointerAlignment: true + +IndentCaseLabels: true + +BinPackArguments: false +BinPackParameters: false + +--- +Language: Cpp + +... diff --git a/.gitignore b/.gitignore index 7c9deb6..596d073 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ .idea cmake-build* .DS_Store +/win_build diff --git a/CMakeLists.txt b/CMakeLists.txt index fb95b6a..05f8911 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -7,12 +7,21 @@ cmake_minimum_required(VERSION 3.12) project(libstdaudio) set(CMAKE_CXX_STANDARD 17) -set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror") + +if (MSVC) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /W4 /WX") +else () + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror") +endif () if (APPLE) set(CMAKE_EXE_LINKER_FLAGS "-framework CoreAudio") endif () +if (MSVC) + set(CMAKE_EXE_LINKER_FLAGS "winmm.lib") +endif () + include_directories(include) add_executable(white_noise examples/white_noise.cpp) @@ -24,4 +33,10 @@ add_executable(level_meter examples/level_meter.cpp) add_executable(test test/test_main.cpp test/audio_buffer_test.cpp - test/audio_device_test.cpp) \ No newline at end of file + test/audio_device_test.cpp) + +if (MSVC) +add_executable(test_asio + test/test_main.cpp + test/asio_test.cpp) +endif () \ No newline at end of file diff --git a/examples/level_meter.cpp b/examples/level_meter.cpp index 1fc0cae..07c2409 100644 --- a/examples/level_meter.cpp +++ b/examples/level_meter.cpp @@ -30,9 +30,9 @@ int main() { auto& in = *io.input_buffer; - for (int frame = 0; frame < in.size_frames(); ++frame) { - for (int channel = 0; channel < in.size_channels(); ++channel) { - float abs_value = std::abs(in(frame, channel)); + for (size_t frame = 0; frame < in.size_frames(); ++frame) { + for (size_t channel = 0; channel < in.size_channels(); ++channel) { + const float abs_value = std::abs(in(frame, channel)); if (abs_value > max_abs_value) max_abs_value.store(abs_value); @@ -45,4 +45,4 @@ int main() { std::this_thread::sleep_for(std::chrono::milliseconds(250)); std::cout << gain_to_db(max_abs_value.exchange(0)) << " dB\n"; } -} \ No newline at end of file +} diff --git a/examples/melody.cpp b/examples/melody.cpp index 440260c..70cf61a 100644 --- a/examples/melody.cpp +++ b/examples/melody.cpp @@ -3,9 +3,14 @@ // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) +#ifdef WIN32 +#define _USE_MATH_DEFINES +#endif + #include #include #include +#include #include