Audacity  3.0.3
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 
17 size_t sampleCount::as_size_t() const {
18  wxASSERT(value >= 0);
19  wxASSERT(static_cast<std::make_unsigned<type>::type>(value) <= std::numeric_limits<size_t>::max());
20  return value;
21 }
22 
23 size_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 }
SampleCount.h
sampleCount::as_size_t
size_t as_size_t() const
Definition: SampleCount.cpp:17
min
int min(int a, int b)
Definition: CompareAudioCommand.cpp:106
sampleCount
Positions or offsets within audio files need a wide type.
Definition: SampleCount.h:18
sampleCount::value
type value
Definition: SampleCount.h:68
limitSampleBufferSize
size_t limitSampleBufferSize(size_t bufferSize, sampleCount limit)
Definition: SampleCount.cpp:23