Audacity 3.2.0
SampleCount.cpp
Go to the documentation of this file.
1/**********************************************************************
2
3 Audacity: A Digital Audio Editor
4
5 @file SampleCount.cpp
6
7 Paul Licameli split from audacity/Types.h
8
9**********************************************************************/
10#include "SampleCount.h"
11
12#include <algorithm>
13#include <limits>
14
15#include <wx/debug.h>
16
17size_t sampleCount::as_size_t() const {
18 wxASSERT(value >= 0);
19 wxASSERT(static_cast<std::make_unsigned_t<type>>(value) <= std::numeric_limits<size_t>::max());
20 return value;
21}
22
23size_t limitSampleBufferSize( size_t bufferSize, sampleCount limit )
24{
25 return
26 std::min( sampleCount( bufferSize ), std::max( sampleCount(0), limit ) )
27 .as_size_t();
28}
int min(int a, int b)
size_t limitSampleBufferSize(size_t bufferSize, sampleCount limit)
Definition: SampleCount.cpp:23
Positions or offsets within audio files need a wide type.
Definition: SampleCount.h:18
size_t as_size_t() const
Definition: SampleCount.cpp:17