kwave  18.07.70
Sample.h File Reference
#include <QtGlobal>
#include <limits>
#include <sys/types.h>
Include dependency graph for Sample.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define SAMPLE_INDEX_MAX   ( std::numeric_limits<sample_index_t>::max() )
 
#define SAMPLE_BITS   24
 
#define SAMPLE_STORAGE_BITS   (sizeof(sample_storage_t) * 8)
 
#define SAMPLE_MIN   (-(1 << (SAMPLE_BITS - 1)) + 1)
 
#define SAMPLE_MAX   (+(1 << (SAMPLE_BITS - 1)) - 1)
 

Typedefs

typedef quint64 sample_index_t
 
typedef qint32 sample_t
 
typedef qint32 sample_storage_t
 

Functions

static sample_t float2sample (const float f)
 
static float sample2float (const sample_t s)
 
static double sample2double (const sample_t s)
 
static sample_t double2sample (const double f)
 

Macro Definition Documentation

◆ SAMPLE_BITS

◆ SAMPLE_INDEX_MAX

◆ SAMPLE_MAX

◆ SAMPLE_MIN

◆ SAMPLE_STORAGE_BITS

#define SAMPLE_STORAGE_BITS   (sizeof(sample_storage_t) * 8)

number of bits used for storing samples in integer representation

Definition at line 46 of file Sample.h.

Referenced by Kwave::AudiofileDecoder::decode(), Kwave::WavDecoder::decode(), Kwave::WavEncoder::encode(), Kwave::AudiofileDecoder::open(), and Kwave::WavDecoder::open().

Typedef Documentation

◆ sample_index_t

typedef quint64 sample_index_t

use an unsigned integer for sample offset/count calculations

Definition at line 28 of file Sample.h.

◆ sample_storage_t

typedef qint32 sample_storage_t

native data type used for storing a sample_t

Definition at line 40 of file Sample.h.

◆ sample_t

typedef qint32 sample_t

Currently a "sample" is defined as a 32 bit integer with 24 significant bits

Definition at line 37 of file Sample.h.

Function Documentation

◆ double2sample()

static sample_t double2sample ( const double  f)
inlinestatic

Simple conversion from double to sample_t

Definition at line 81 of file Sample.h.

References SAMPLE_BITS.

Referenced by Kwave::OpusDecoder::decode(), decodeFrame(), Kwave::Osc::goOn(), Kwave::CurveStreamAdapter::goOn(), Kwave::NoiseGenerator::input(), Kwave::Normalizer::input(), Kwave::LowPassFilter::input(), Kwave::NotchFilter::input(), Kwave::BandPass::input(), and Kwave::DebugPlugin::run().

81  {
82  return static_cast<sample_t>(
83  f * static_cast<double>(1 << (SAMPLE_BITS - 1)));
84 }
#define SAMPLE_BITS
Definition: Sample.h:43
qint32 sample_t
Definition: Sample.h:37
Here is the caller graph for this function:

◆ float2sample()

static sample_t float2sample ( const float  f)
inlinestatic

Simple conversion from float to sample_t

Definition at line 57 of file Sample.h.

References SAMPLE_BITS.

Referenced by Kwave::RateConverter::input(), Kwave::PitchShiftFilter::input(), Kwave::Mul::multiply(), and Kwave::DebugPlugin::run().

57  {
58  return static_cast<sample_t>(
59  f * static_cast<float>(1 << (SAMPLE_BITS - 1)));
60 }
#define SAMPLE_BITS
Definition: Sample.h:43
qint32 sample_t
Definition: Sample.h:37
Here is the caller graph for this function:

◆ sample2double()

static double sample2double ( const sample_t  s)
inlinestatic

Simple conversion from sample_t to double

Definition at line 73 of file Sample.h.

References SAMPLE_BITS.

Referenced by Kwave::NormalizePlugin::getMaxPowerOfTrack(), Kwave::NoiseGenerator::input(), Kwave::Normalizer::input(), Kwave::LowPassFilter::input(), Kwave::NotchFilter::input(), Kwave::BandPass::input(), Kwave::SonagramPlugin::makeAllValid(), and Kwave::NoiseDialog::updateDisplay().

73  {
74  return static_cast<double>(
75  static_cast<double>(s) / static_cast<double>(1 << (SAMPLE_BITS - 1)));
76 }
#define SAMPLE_BITS
Definition: Sample.h:43
Here is the caller graph for this function:

◆ sample2float()

static float sample2float ( const sample_t  s)
inlinestatic

Simple conversion from sample_t to float

Definition at line 65 of file Sample.h.

References SAMPLE_BITS.

Referenced by Kwave::RecordPlugin::checkTrigger(), Kwave::VorbisEncoder::encode(), Kwave::OpusEncoder::fillInBuffer(), Kwave::RateConverter::input(), Kwave::PitchShiftFilter::input(), Kwave::Mul::multiply(), and Kwave::LevelMeter::updateTrack().

65  {
66  return static_cast<float>(
67  static_cast<float>(s) / static_cast<float>(1 << (SAMPLE_BITS - 1)));
68 }
#define SAMPLE_BITS
Definition: Sample.h:43
Here is the caller graph for this function: