Audacity  3.0.3
Classes | Macros | Typedefs | Enumerations | Functions
SampleFormat.h File Reference
#include "MemoryX.h"
#include <wx/defs.h>
#include "audacity/Types.h"
Include dependency graph for SampleFormat.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  SampleBuffer
 
class  GrowableSampleBuffer
 

Macros

#define SAMPLE_SIZE_DISK(SampleFormat)
 Return the size on disk of one uncompressed sample (bytes) More...
 

Typedefs

using Floats = ArrayOf< float >
 
using FloatBuffers = ArraysOf< float >
 
using Doubles = ArrayOf< double >
 

Enumerations

enum  fillFormat { fillZero = 0, fillTwo = 2 }
 

Functions

AUDACITY_DLL_API TranslatableString GetSampleFormatStr (sampleFormat format)
 
AUDACITY_DLL_API void CopySamples (constSamplePtr src, sampleFormat srcFormat, samplePtr dst, sampleFormat dstFormat, unsigned int len, bool highQuality=true, unsigned int srcStride=1, unsigned int dstStride=1)
 
AUDACITY_DLL_API void CopySamplesNoDither (samplePtr src, sampleFormat srcFormat, samplePtr dst, sampleFormat dstFormat, unsigned int len, unsigned int srcStride=1, unsigned int dstStride=1)
 
AUDACITY_DLL_API void ClearSamples (samplePtr buffer, sampleFormat format, size_t start, size_t len)
 
AUDACITY_DLL_API void ReverseSamples (samplePtr buffer, sampleFormat format, int start, int len)
 
AUDACITY_DLL_API void InitDitherers ()
 

Macro Definition Documentation

◆ SAMPLE_SIZE_DISK

#define SAMPLE_SIZE_DISK (   SampleFormat)
Value:
size_t{ 3 } : SAMPLE_SIZE(SampleFormat) )

Return the size on disk of one uncompressed sample (bytes)

Definition at line 44 of file SampleFormat.h.

Typedef Documentation

◆ Doubles

using Doubles = ArrayOf<double>

Definition at line 161 of file SampleFormat.h.

◆ FloatBuffers

using FloatBuffers = ArraysOf<float>

Definition at line 160 of file SampleFormat.h.

◆ Floats

using Floats = ArrayOf<float>

Definition at line 159 of file SampleFormat.h.

Enumeration Type Documentation

◆ fillFormat

enum fillFormat
Enumerator
fillZero 
fillTwo 

Definition at line 38 of file SampleFormat.h.

38  {
39  fillZero = 0,
40  fillTwo = 2
41 }fillFormat;

Function Documentation

◆ ClearSamples()

AUDACITY_DLL_API void ClearSamples ( samplePtr  buffer,
sampleFormat  format,
size_t  start,
size_t  len 
)

Definition at line 77 of file SampleFormat.cpp.

79 {
80  auto size = SAMPLE_SIZE(format);
81  memset(dst + start*size, 0, len*size);
82 }

References format, and SAMPLE_SIZE.

Referenced by RingBuffer::Clear(), AudioIO::FillBuffers(), Sequence::Get(), WaveTrack::Get(), SampleBlock::GetSamples(), RingBuffer::Put(), ODDecodeBlockFile::Read256(), ODPCMAliasBlockFile::Read256(), ODDecodeBlockFile::Read64K(), ODPCMAliasBlockFile::Read64K(), ODDecodeBlockFile::ReadData(), SilentBlockFile::ReadData(), and Sequence::SetSamples().

Here is the caller graph for this function:

◆ CopySamples()

AUDACITY_DLL_API void CopySamples ( constSamplePtr  src,
sampleFormat  srcFormat,
samplePtr  dst,
sampleFormat  dstFormat,
unsigned int  len,
bool  highQuality = true,
unsigned int  srcStride = 1,
unsigned int  dstStride = 1 
)

Definition at line 102 of file SampleFormat.cpp.

108 {
110  highQuality ? gHighQualityDither : gLowQualityDither,
111  src, srcFormat, dst, dstFormat, len, srcStride, dstStride);
112 }

References Dither::Apply(), gDitherAlgorithm, gHighQualityDither, and gLowQualityDither.

Referenced by AUPImportFileHandle::AddSamples(), WaveClip::Append(), AudioIoCallback::AudioCallback(), ODDecodeBlockFile::CalcSummary(), ODPCMAliasBlockFile::CalcSummary(), SqliteSampleBlock::CalcSummary(), ComputeLegacySummaryInfo(), Sequence::ConvertToSampleFormat(), Sequence::DoAppend(), DoSoftwarePlaythrough(), ExportPCM::Export(), RingBuffer::Get(), SqliteSampleBlock::GetBlob(), NyquistEffect::GetCallback(), WaveClip::GetWaveDisplay(), Mixer::Process(), RingBuffer::Put(), and Sequence::SetSamples().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ CopySamplesNoDither()

AUDACITY_DLL_API void CopySamplesNoDither ( samplePtr  src,
sampleFormat  srcFormat,
samplePtr  dst,
sampleFormat  dstFormat,
unsigned int  len,
unsigned int  srcStride = 1,
unsigned int  dstStride = 1 
)

Definition at line 114 of file SampleFormat.cpp.

119 {
122  src, srcFormat, dst, dstFormat, len, srcStride, dstStride);
123 }

References Dither::Apply(), gDitherAlgorithm, and none.

Referenced by ExportPCM::Export().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetSampleFormatStr()

AUDACITY_DLL_API TranslatableString GetSampleFormatStr ( sampleFormat  format)

Definition at line 60 of file SampleFormat.cpp.

61 {
62  switch(format) {
63  case int16Sample:
64  /* i18n-hint: Audio data bit depth (precision): 16-bit integers */
65  return XO("16-bit PCM");
66  case int24Sample:
67  /* i18n-hint: Audio data bit depth (precision): 24-bit integers */
68  return XO("24-bit PCM");
69  case floatSample:
70  /* i18n-hint: Audio data bit depth (precision): 32-bit floating point */
71  return XO("32-bit float");
72  }
73  return XO("Unknown format"); // compiler food
74 }

References floatSample, format, int16Sample, int24Sample, and XO.

Referenced by FormatMenuTable::OnFormatChange(), Sequence::Paste(), and anonymous_namespace{WaveTrackControls.cpp}::Status2DrawFunction().

Here is the caller graph for this function:

◆ InitDitherers()

AUDACITY_DLL_API void InitDitherers ( )

Definition at line 53 of file SampleFormat.cpp.

54 {
55  // Read dither preferences
58 }

References Dither::BestDitherChoice(), Dither::FastDitherChoice(), gHighQualityDither, and gLowQualityDither.

Referenced by QualityPrefs::Commit(), and AudacityApp::InitPart2().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ReverseSamples()

AUDACITY_DLL_API void ReverseSamples ( samplePtr  buffer,
sampleFormat  format,
int  start,
int  len 
)

Definition at line 84 of file SampleFormat.cpp.

86 {
87  auto size = SAMPLE_SIZE(format);
88  samplePtr first = dst + start * size;
89  samplePtr last = dst + (start + len - 1) * size;
90  enum : size_t { fixedSize = SAMPLE_SIZE(floatSample) };
91  wxASSERT(static_cast<size_t>(size) <= fixedSize);
92  char temp[fixedSize];
93  while (first < last) {
94  memcpy(temp, first, size);
95  memcpy(first, last, size);
96  memcpy(last, temp, size);
97  first += size;
98  last -= size;
99  }
100 }

References floatSample, format, and SAMPLE_SIZE.

Referenced by Mixer::MixSameRate(), and Mixer::MixVariableRates().

Here is the caller graph for this function:
Dither::BestDitherChoice
static DitherType BestDitherChoice()
Definition: Dither.cpp:438
SampleFormat
#define SampleFormat
Definition: Benchmark.cpp:53
int24Sample
@ int24Sample
Definition: Types.h:721
fillFormat
fillFormat
Definition: SampleFormat.h:38
fillTwo
@ fillTwo
Definition: SampleFormat.h:40
Dither::Apply
void Apply(DitherType ditherType, constSamplePtr source, sampleFormat sourceFormat, samplePtr dest, sampleFormat destFormat, unsigned int len, unsigned int sourceStride=1, unsigned int destStride=1)
Definition: Dither.cpp:239
XO
#define XO(s)
Definition: Internat.h:32
floatSample
@ floatSample
Definition: Types.h:722
fillZero
@ fillZero
Definition: SampleFormat.h:39
samplePtr
char * samplePtr
Definition: Types.h:737
none
@ none
Definition: Dither.h:20
format
int format
Definition: ExportPCM.cpp:54
gDitherAlgorithm
static Dither gDitherAlgorithm
Definition: SampleFormat.cpp:51
Dither::FastDitherChoice
static DitherType FastDitherChoice()
Definition: Dither.cpp:433
int16Sample
@ int16Sample
Definition: Types.h:720
gLowQualityDither
static DitherType gLowQualityDither
Definition: SampleFormat.cpp:49
gHighQualityDither
static DitherType gHighQualityDither
Definition: SampleFormat.cpp:50
SAMPLE_SIZE
#define SAMPLE_SIZE(SampleFormat)
Definition: Types.h:732