Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove the NOMINMAX definition #86

Closed
wants to merge 1 commit into from
Closed
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
20 changes: 7 additions & 13 deletions AudioFile.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,6 @@
#ifndef _AS_AudioFile_h
#define _AS_AudioFile_h

#if defined (_MSC_VER)
#undef max
#undef min
#define NOMINMAX
#endif

#include <iostream>
#include <vector>
#include <cassert>
Expand Down Expand Up @@ -1343,7 +1337,7 @@ typename std::make_unsigned<SignedType>::type convertSignedToUnsigned (SignedTyp
{
static_assert (std::is_signed<SignedType>::value, "The input value must be signed");

typename std::make_unsigned<SignedType>::type unsignedValue = static_cast<typename std::make_unsigned<SignedType>::type> (1) + std::numeric_limits<SignedType>::max();
typename std::make_unsigned<SignedType>::type unsignedValue = static_cast<typename std::make_unsigned<SignedType>::type> (1) + (std::numeric_limits<SignedType>::max)();

unsignedValue += signedValue;
return unsignedValue;
Expand All @@ -1368,7 +1362,7 @@ T AudioSampleConverter<T>::thirtyTwoBitIntToSample (int32_t sample)
{
if constexpr (std::is_floating_point<T>::value)
{
return static_cast<T> (sample) / static_cast<T> (std::numeric_limits<int32_t>::max());
return static_cast<T> (sample) / static_cast<T> ((std::numeric_limits<int32_t>::max)());
}
else if (std::numeric_limits<T>::is_integer)
{
Expand All @@ -1391,15 +1385,15 @@ int32_t AudioSampleConverter<T>::sampleToThirtyTwoBitInt (T sample)
if constexpr (std::is_same_v<T, float>)
{
if (sample >= 1.f)
return std::numeric_limits<int32_t>::max();
return (std::numeric_limits<int32_t>::max)();
else if (sample <= -1.f)
return std::numeric_limits<int32_t>::lowest() + 1; // starting at 1 preserves symmetry
else
return static_cast<int32_t> (sample * std::numeric_limits<int32_t>::max());
return static_cast<int32_t> (sample * (std::numeric_limits<int32_t>::max)());
}
else
{
return static_cast<int32_t> (clamp (sample, -1., 1.) * std::numeric_limits<int32_t>::max());
return static_cast<int32_t> (clamp (sample, -1., 1.) * (std::numeric_limits<int32_t>::max)());
}
}
else
Expand Down Expand Up @@ -1556,8 +1550,8 @@ T AudioSampleConverter<T>::signedByteToSample (int8_t sample)
template <class T>
T AudioSampleConverter<T>::clamp (T value, T minValue, T maxValue)
{
value = std::min (value, maxValue);
value = std::max (value, minValue);
value = (std::min) (value, maxValue);
value = (std::max) (value, minValue);
return value;
}

Expand Down
2 changes: 1 addition & 1 deletion tests/GeneralTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ TEST_SUITE ("General Tests")
CHECK (a.getNumSamplesPerChannel() == b.getNumSamplesPerChannel());
CHECK (a.getLengthInSeconds() == b.getLengthInSeconds());

size_t numSamplesToTest = std::min (static_cast<size_t> (20000), a.samples[0].size());
size_t numSamplesToTest = (std::min) (static_cast<size_t> (20000), a.samples[0].size());

for (size_t channel = 0; channel < a.samples.size(); channel++)
{
Expand Down
Loading
Loading