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:
26
libraries/lib-math/SampleCount.cpp
Normal file
26
libraries/lib-math/SampleCount.cpp
Normal 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();
|
||||
}
|
||||
Reference in New Issue
Block a user