1
0
mirror of https://github.com/cookiengineer/audacity synced 2026-03-07 23:15:36 +01:00

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.
This commit is contained in:
Paul Licameli
2021-07-03 14:54:29 -04:00
parent 749a0575b6
commit f52dfd3ac3
58 changed files with 131 additions and 133 deletions

View File

@@ -0,0 +1,26 @@
/**********************************************************************
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();
}