Audacity  2.2.0
SampleFormat.cpp File Reference

Functions that work with Dither and initialise it. More...

#include <wx/intl.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "SampleFormat.h"
#include "Prefs.h"
#include "Dither.h"

Functions

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

Variables

static Dither::DitherType gLowQualityDither = Dither::none
 
static Dither::DitherType gHighQualityDither = Dither::none
 
static Dither gDitherAlgorithm
 

Detailed Description

Functions that work with Dither and initialise it.

This file handles converting between all of the different sample formats that Audacity supports, such as 16-bit, 24-bit (packed into a 32-bit int), and 32-bit float.

Floating-point samples use the range -1.0...1.0, inclusive. Integer formats use the full signed range of their data type, for example 16-bit samples use the range -32768...32767. This means that reading in a wav file and writing it out again ('round tripping'), via floats, is lossless; -32768 equates to -1.0f and 32767 equates to +1.0f - (a little bit). It also means (unfortunatly) that writing out +1.0f leads to clipping by 1 LSB. This creates some distortion, but I (MJS) have not been able to measure it, it's so small. Zero is preserved.

http://limpet.net/audacity/bugzilla/show_bug.cgi?id=200 leads to some of the discussions that were held about this.

Note: These things are now handled by the Dither class, which also replaces the CopySamples() method (msmeyer)

Function Documentation

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

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

const wxChar* GetSampleFormatStr ( sampleFormat  format)

References _().

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

void ReverseSamples ( samplePtr  src,
sampleFormat  format,
int  start,
int  len 
)

Variable Documentation

Dither gDitherAlgorithm
static
Dither::DitherType gHighQualityDither = Dither::none
static

Referenced by CopySamples(), and InitDitherers().

Dither::DitherType gLowQualityDither = Dither::none
static

Referenced by CopySamples(), and InitDitherers().