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
14#include <wx/debug.h>
15
16size_t sampleCount::as_size_t() const {
17 assert(value >= 0);
18 assert(static_cast<std::make_unsigned_t<type>>(value) <= std::numeric_limits<size_t>::max());
19 return value;
20}
21
22size_t limitSampleBufferSize( size_t bufferSize, sampleCount limit )
23{
24 return
25 std::min( sampleCount( bufferSize ), std::max( sampleCount(0), limit ) )
26 .as_size_t();
27}
int min(int a, int b)
size_t limitSampleBufferSize(size_t bufferSize, sampleCount limit)
Definition: SampleCount.cpp:22
Positions or offsets within audio files need a wide type.
Definition: SampleCount.h:19
size_t as_size_t() const
Definition: SampleCount.cpp:16