Audacity  2.2.2
Classes | Macros | Typedefs | Enumerations | Functions
SampleFormat.h File Reference
#include "Audacity.h"
#include "MemoryX.h"
#include <wx/defs.h>
#include "audacity/Types.h"

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

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

Macro Definition Documentation

#define SAMPLE_SIZE_DISK (   SampleFormat)
Value:
(((SampleFormat) == int24Sample) ? \
size_t{ 3 } : SAMPLE_SIZE(SampleFormat) )

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

Definition at line 43 of file SampleFormat.h.

Referenced by AudacityProject::GetEstimatedRecordingMinsLeftOnDisk(), and SimpleBlockFile::GetSpaceUsage().

Typedef Documentation

using Doubles = ArrayOf<double>

Definition at line 155 of file SampleFormat.h.

using FloatBuffers = ArraysOf<float>

Definition at line 154 of file SampleFormat.h.

using Floats = ArrayOf<float>

Definition at line 153 of file SampleFormat.h.

Enumeration Type Documentation

enum fillFormat
Enumerator
fillZero 
fillTwo 

Definition at line 37 of file SampleFormat.h.

37  {
38  fillZero = 0,
39  fillTwo = 2
40 }fillFormat;
fillFormat
Definition: SampleFormat.h:37

Function Documentation

void ClearSamples ( samplePtr  buffer,
sampleFormat  format,
size_t  start,
size_t  len 
)
void CopySamples ( samplePtr  src,
sampleFormat  srcFormat,
samplePtr  dst,
sampleFormat  dstFormat,
unsigned int  len,
bool  highQuality = true,
unsigned int  srcStride = 1,
unsigned int  dstStride = 1 
)

Definition at line 104 of file SampleFormat.cpp.

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

Referenced by Sequence::Append(), WaveClip::Append(), audacityAudioCallback(), ODPCMAliasBlockFile::CalcSummary(), ODDecodeBlockFile::CalcSummary(), BlockFile::CalcSummary(), BlockFile::CommonReadData(), ComputeLegacySummaryInfo(), Sequence::ConvertToSampleFormat(), DoSoftwarePlaythrough(), RingBuffer::Get(), NyquistEffect::GetCallback(), WaveClip::GetWaveDisplay(), Mixer::Process(), RingBuffer::Put(), BlockFile::Read256(), BlockFile::Read64K(), SimpleBlockFile::ReadData(), and Sequence::SetSamples().

110 {
112  highQuality ? gHighQualityDither : gLowQualityDither,
113  src, srcFormat, dst, dstFormat, len, srcStride, dstStride);
114 }
void Apply(DitherType ditherType, const samplePtr source, sampleFormat sourceFormat, samplePtr dest, sampleFormat destFormat, unsigned int len, unsigned int sourceStride=1, unsigned int destStride=1)
Definition: Dither.cpp:236
static Dither::DitherType gLowQualityDither
static Dither gDitherAlgorithm
static Dither::DitherType gHighQualityDither
void CopySamplesNoDither ( samplePtr  src,
sampleFormat  srcFormat,
samplePtr  dst,
sampleFormat  dstFormat,
unsigned int  len,
unsigned int  srcStride = 1,
unsigned int  dstStride = 1 
)

Definition at line 116 of file SampleFormat.cpp.

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

121 {
123  Dither::none,
124  src, srcFormat, dst, dstFormat, len, srcStride, dstStride);
125 }
void Apply(DitherType ditherType, const samplePtr source, sampleFormat sourceFormat, samplePtr dest, sampleFormat destFormat, unsigned int len, unsigned int sourceStride=1, unsigned int destStride=1)
Definition: Dither.cpp:236
static Dither gDitherAlgorithm
const wxChar* GetSampleFormatStr ( sampleFormat  format)

Definition at line 62 of file SampleFormat.cpp.

References _().

Referenced by Sequence::Paste(), and TrackInfo::Status2DrawFunction().

63 {
64  switch(format) {
65  case int16Sample:
66  /* i18n-hint: Audio data bit depth (precision): 16-bit integers */
67  return _("16-bit PCM");
68  case int24Sample:
69  /* i18n-hint: Audio data bit depth (precision): 24-bit integers */
70  return _("24-bit PCM");
71  case floatSample:
72  /* i18n-hint: Audio data bit depth (precision): 32-bit floating point */
73  return _("32-bit float");
74  }
75  return wxT("Unknown format"); // compiler food
76 }
int format
Definition: ExportPCM.cpp:56
_("Move Track &Down")+wxT("\t")+(GetActiveProject() -> GetCommandManager() ->GetKeyFromName(wxT("TrackMoveDown"))), OnMoveTrack) POPUP_MENU_ITEM(OnMoveTopID, _("Move Track to &Top")+wxT("\t")+(GetActiveProject() ->GetCommandManager() ->GetKeyFromName(wxT("TrackMoveTop"))), OnMoveTrack) POPUP_MENU_ITEM(OnMoveBottomID, _("Move Track to &Bottom")+wxT("\t")+(GetActiveProject() ->GetCommandManager() ->GetKeyFromName(wxT("TrackMoveBottom"))), OnMoveTrack) void TrackMenuTable::OnSetName(wxCommandEvent &)
void InitDitherers ( )

Definition at line 52 of file SampleFormat.cpp.

References gHighQualityDither, gLowQualityDither, gPrefs, Dither::none, and Dither::shaped.

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

53 {
54  // Read dither preferences
56  gPrefs->Read(wxT("/Quality/DitherAlgorithm"), (long)Dither::none);
57 
59  gPrefs->Read(wxT("/Quality/HQDitherAlgorithm"), (long)Dither::shaped);
60 }
DitherType
These ditherers are currently available:
Definition: Dither.h:23
wxFileConfig * gPrefs
Definition: Prefs.cpp:72
static Dither::DitherType gLowQualityDither
static Dither::DitherType gHighQualityDither
void ReverseSamples ( samplePtr  buffer,
sampleFormat  format,
int  start,
int  len 
)

Definition at line 86 of file SampleFormat.cpp.

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

88 {
89  auto size = SAMPLE_SIZE(format);
90  samplePtr first = dst + start * size;
91  samplePtr last = dst + (start + len - 1) * size;
92  enum : size_t { fixedSize = SAMPLE_SIZE(floatSample) };
93  wxASSERT(size <= fixedSize);
94  char temp[fixedSize];
95  while (first < last) {
96  memcpy(temp, first, size);
97  memcpy(first, last, size);
98  memcpy(last, temp, size);
99  first += size;
100  last -= size;
101  }
102 }
int format
Definition: ExportPCM.cpp:56