1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-06-19 17:40:15 +02:00
audacity/libraries/lib-math/SampleCount.cpp
Paul Licameli f52dfd3ac3 New library for math...
... note the swap of target_link_libraries lines in src/CMakeLists.txt,
needed to build at least on macOS, becuase FFT.h must be looked up first in
lib-math, not in lib-src/twolame

Also making a dependency cycle of SampleFormat and Dither!  But we will tolerate
that within one small library.
2021-07-22 16:54:00 -04:00

27 lines
694 B
C++

/**********************************************************************
Audacity: A Digital Audio Editor
@file SampleCount.cpp
Paul Licameli split from audacity/Types.h
**********************************************************************/
#include "SampleCount.h"
#include <algorithm>
#include <wx/debug.h>
size_t sampleCount::as_size_t() const {
wxASSERT(value >= 0);
wxASSERT(static_cast<std::make_unsigned<type>::type>(value) <= std::numeric_limits<size_t>::max());
return value;
}
size_t limitSampleBufferSize( size_t bufferSize, sampleCount limit )
{
return
std::min( sampleCount( bufferSize ), std::max( sampleCount(0), limit ) )
.as_size_t();
}