foobar2000 SDK  2015-01-14
Public Member Functions | Private Types | Private Attributes
audio_chunk_impl_t< container_t >

#include <audio_chunk.h>

+ Inheritance diagram for audio_chunk_impl_t< container_t >:

Public Member Functions

 audio_chunk_impl_t ()
 
 audio_chunk_impl_t (const audio_sample *src, unsigned samples, unsigned nch, unsigned srate)
 
 audio_chunk_impl_t (const audio_chunk &p_source)
 
 audio_chunk_impl_t (const t_self &p_source)
 
virtual unsigned get_channel_config () const
 
virtual unsigned get_channels () const
 
virtual audio_sampleget_data ()
 
virtual const audio_sampleget_data () const
 
virtual t_size get_data_size () const
 
virtual t_size get_sample_count () const
 
virtual unsigned get_srate () const
 
const t_selfoperator= (const audio_chunk &p_source)
 
const t_selfoperator= (const t_self &p_source)
 
virtual void set_channels (unsigned val, unsigned setup)
 
void set_channels (unsigned val)
 
virtual void set_data_size (t_size new_size)
 
virtual void set_sample_count (t_size val)
 
virtual void set_srate (unsigned val)
 
- Public Member Functions inherited from audio_chunk
void allocate (size_t size)
 
void copy (const audio_chunk &p_source)
 
unsigned get_channel_count () const
 
size_t get_data_length () const
 
double get_duration () const
 
audio_sample get_peak (audio_sample p_peak) const
 
audio_sample get_peak () const
 
unsigned get_sample_rate () const
 
spec_t get_spec () const
 
size_t get_used_size () const
 
void grow_data_size (t_size p_requested)
 
void insert_silence_fromstart (t_size samples)
 
bool is_empty () const
 
bool is_spec_valid () const
 
bool is_valid () const
 
const audio_chunkoperator= (const audio_chunk &p_source)
 
void pad_with_silence (t_size samples)
 
void pad_with_silence_ex (t_size samples, unsigned hint_nch, unsigned hint_srate)
 
bool process_skip (double &skipDuration)
 
void reset ()
 
void scale (audio_sample p_value)
 
void set_channels (unsigned val)
 
void set_data (const audio_sample *src, t_size samples, unsigned nch, unsigned srate, unsigned channel_config)
 
void set_data (const audio_sample *src, t_size samples, unsigned nch, unsigned srate)
 
void set_data_32 (const float *src, t_size samples, unsigned nch, unsigned srate)
 
void set_data_fixedpoint (const void *ptr, t_size bytes, unsigned srate, unsigned nch, unsigned bps, unsigned channel_config)
 
void set_data_fixedpoint_ex (const void *ptr, t_size bytes, unsigned p_sample_rate, unsigned p_channels, unsigned p_bits_per_sample, unsigned p_flags, unsigned p_channel_config)
 
void set_data_fixedpoint_ms (const void *ptr, size_t bytes, unsigned sampleRate, unsigned channels, unsigned bps, unsigned channelConfig)
 
void set_data_fixedpoint_signed (const void *ptr, t_size bytes, unsigned srate, unsigned nch, unsigned bps, unsigned channel_config)
 
void set_data_floatingpoint_ex (const void *ptr, t_size bytes, unsigned p_sample_rate, unsigned p_channels, unsigned p_bits_per_sample, unsigned p_flags, unsigned p_channel_config)
 
void set_data_int16 (const int16_t *src, t_size samples, unsigned nch, unsigned srate, unsigned channel_config)
 
void set_sample_rate (unsigned val)
 
void set_silence (t_size samples)
 
void set_silence_seconds (double seconds)
 
void set_spec (const spec_t &)
 
t_size skip_first_samples (t_size samples)
 
bool to_raw_data (class mem_block_container &out, t_uint32 bps, bool useUpperBits=true, float scale=1.0) const
 
bool toFixedPoint (class mem_block_container &out, uint32_t bps, uint32_t bpsValid, bool useUpperBits=true, float scale=1.0) const
 

Private Types

typedef audio_chunk_impl_t< container_t > t_self
 

Private Attributes

container_t m_data
 
unsigned m_nch
 
t_size m_samples
 
unsigned m_setup
 
unsigned m_srate
 

Additional Inherited Members

- Public Types inherited from audio_chunk
enum  { sample_rate_min = 1000, sample_rate_max = 2822400 }
 
enum  {
  channel_front_left = 1<<0, channel_front_right = 1<<1, channel_front_center = 1<<2, channel_lfe = 1<<3,
  channel_back_left = 1<<4, channel_back_right = 1<<5, channel_front_center_left = 1<<6, channel_front_center_right = 1<<7,
  channel_back_center = 1<<8, channel_side_left = 1<<9, channel_side_right = 1<<10, channel_top_center = 1<<11,
  channel_top_front_left = 1<<12, channel_top_front_center = 1<<13, channel_top_front_right = 1<<14, channel_top_back_left = 1<<15,
  channel_top_back_center = 1<<16, channel_top_back_right = 1<<17, channel_config_mono = channel_front_center, channel_config_stereo = channel_front_left | channel_front_right,
  channel_config_5point1 = channel_front_left | channel_front_right | channel_front_center | channel_lfe | channel_back_left | channel_back_right, channel_config_5point1_side = channel_front_left | channel_front_right | channel_front_center | channel_lfe | channel_side_left | channel_side_right, channel_config_7point1 = channel_config_5point1 | channel_side_left | channel_side_right, defined_channel_count = 18
}
 
enum  { FLAG_LITTLE_ENDIAN = 1, FLAG_BIG_ENDIAN = 2, FLAG_SIGNED = 4, FLAG_UNSIGNED = 8 }
 
- Static Public Member Functions inherited from audio_chunk
static unsigned flags_autoendian ()
 
static unsigned g_channel_config_from_wfx (uint32_t p_wfx)
 
static uint32_t g_channel_config_to_wfx (unsigned p_config)
 
static unsigned g_channel_index_from_flag (unsigned p_config, unsigned p_flag)
 
static const char * g_channel_name (unsigned p_flag)
 
static const char * g_channel_name_byidx (unsigned p_index)
 
static unsigned g_count_channels (unsigned p_config)
 
static unsigned g_extract_channel_flag (unsigned p_config, unsigned p_index)
 
static unsigned g_find_channel_idx (unsigned p_flag)
 
static void g_formatChannelMaskDesc (unsigned flags, pfc::string_base &out)
 
static unsigned g_guess_channel_config (unsigned count)
 
static unsigned g_guess_channel_config_xiph (unsigned count)
 
static bool g_is_valid_sample_rate (t_uint32 p_val)
 
static bool g_toFixedPoint (const audio_sample *in, void *out, size_t count, uint32_t bps, uint32_t bpsValid, bool useUpperBits=true, float scale=1.0)
 
static spec_t makeSpec (uint32_t rate, uint32_t channels)
 
static spec_t makeSpec (uint32_t rate, uint32_t channels, uint32_t chanMask)
 
- Protected Member Functions inherited from audio_chunk
 audio_chunk ()
 
 ~audio_chunk ()
 

Detailed Description

template<typename container_t = pfc::mem_block_aligned_t<audio_sample, 16>>
class audio_chunk_impl_t< container_t >

Implementation of audio_chunk. Takes pfc allocator template as template parameter.

Definition at line 242 of file audio_chunk.h.

Member Typedef Documentation

template<typename container_t = pfc::mem_block_aligned_t<audio_sample, 16>>
typedef audio_chunk_impl_t<container_t> audio_chunk_impl_t< container_t >::t_self
private

Definition at line 243 of file audio_chunk.h.

Constructor & Destructor Documentation

template<typename container_t = pfc::mem_block_aligned_t<audio_sample, 16>>
audio_chunk_impl_t< container_t >::audio_chunk_impl_t ( )
inline

Definition at line 248 of file audio_chunk.h.

248 : m_srate(0), m_nch(0), m_samples(0), m_setup(0) {}
template<typename container_t = pfc::mem_block_aligned_t<audio_sample, 16>>
audio_chunk_impl_t< container_t >::audio_chunk_impl_t ( const audio_sample src,
unsigned  samples,
unsigned  nch,
unsigned  srate 
)
inline

Definition at line 249 of file audio_chunk.h.

249  : m_srate(0), m_nch(0), m_samples(0)
250  {set_data(src,samples,nch,srate);}
void set_data(const audio_sample *src, t_size samples, unsigned nch, unsigned srate, unsigned channel_config)
Helper, sets chunk data to contents of specified buffer, with specified number of channels / sample r...
Definition: audio_chunk.cpp:3
template<typename container_t = pfc::mem_block_aligned_t<audio_sample, 16>>
audio_chunk_impl_t< container_t >::audio_chunk_impl_t ( const audio_chunk p_source)
inline

Definition at line 251 of file audio_chunk.h.

251 : m_srate(0), m_nch(0), m_samples(0), m_setup(0) {copy(p_source);}
void copy(const audio_chunk &p_source)
Helper; copies content of another audio chunk to this chunk.
Definition: audio_chunk.h:212
template<typename container_t = pfc::mem_block_aligned_t<audio_sample, 16>>
audio_chunk_impl_t< container_t >::audio_chunk_impl_t ( const t_self p_source)
inline

Definition at line 252 of file audio_chunk.h.

252 : m_srate(0), m_nch(0), m_samples(0), m_setup(0) {copy(p_source);}
void copy(const audio_chunk &p_source)
Helper; copies content of another audio chunk to this chunk.
Definition: audio_chunk.h:212

Member Function Documentation

template<typename container_t = pfc::mem_block_aligned_t<audio_sample, 16>>
virtual unsigned audio_chunk_impl_t< container_t >::get_channel_config ( ) const
inlinevirtual

Retrieves channel map of contained audio data. Conditions where number of channels specified by channel map don't match get_channels() return value should not be possible.

Implements audio_chunk.

Definition at line 262 of file audio_chunk.h.

262 {return m_setup;}
template<typename container_t = pfc::mem_block_aligned_t<audio_sample, 16>>
virtual unsigned audio_chunk_impl_t< container_t >::get_channels ( ) const
inlinevirtual

Retrieves channel count of contained audio data.

Implements audio_chunk.

Definition at line 261 of file audio_chunk.h.

261 {return m_nch;}
template<typename container_t = pfc::mem_block_aligned_t<audio_sample, 16>>
virtual audio_sample* audio_chunk_impl_t< container_t >::get_data ( )
inlinevirtual

Retrieves audio data buffer pointer (non-const version). Returned pointer is for temporary use only; it is valid until next set_data_size call, or until the object is destroyed.
Size of returned buffer is equal to get_data_size() return value (in audio_samples). Amount of actual data may be smaller, depending on sample count and channel count. Conditions where sample count * channel count are greater than data size should not be possible.

Implements audio_chunk.

Definition at line 254 of file audio_chunk.h.

254 {return m_data.get_ptr();}
container_t m_data
Definition: audio_chunk.h:244
template<typename container_t = pfc::mem_block_aligned_t<audio_sample, 16>>
virtual const audio_sample* audio_chunk_impl_t< container_t >::get_data ( ) const
inlinevirtual

Retrieves audio data buffer pointer (const version). Returned pointer is for temporary use only; it is valid until next set_data_size call, or until the object is destroyed.
Size of returned buffer is equal to get_data_size() return value (in audio_samples). Amount of actual data may be smaller, depending on sample count and channel count. Conditions where sample count * channel count are greater than data size should not be possible.

Implements audio_chunk.

Definition at line 255 of file audio_chunk.h.

255 {return m_data.get_ptr();}
container_t m_data
Definition: audio_chunk.h:244
template<typename container_t = pfc::mem_block_aligned_t<audio_sample, 16>>
virtual t_size audio_chunk_impl_t< container_t >::get_data_size ( ) const
inlinevirtual

Retrieves size of allocated buffer space, in audio_samples.

Implements audio_chunk.

Definition at line 256 of file audio_chunk.h.

256 {return m_data.get_size();}
container_t m_data
Definition: audio_chunk.h:244
template<typename container_t = pfc::mem_block_aligned_t<audio_sample, 16>>
virtual t_size audio_chunk_impl_t< container_t >::get_sample_count ( ) const
inlinevirtual

Retrieves number of valid samples in the buffer.
Note that a "sample" means a unit of interleaved PCM data representing states of each channel at given point of time, not a single PCM value.
For an example, duration of contained audio data is equal to sample count / sample rate, while actual size of contained data is equal to sample count * channel count.

Implements audio_chunk.

Definition at line 266 of file audio_chunk.h.

266 {return m_samples;}
template<typename container_t = pfc::mem_block_aligned_t<audio_sample, 16>>
virtual unsigned audio_chunk_impl_t< container_t >::get_srate ( ) const
inlinevirtual

Retrieves sample rate of contained audio data.

Implements audio_chunk.

Definition at line 259 of file audio_chunk.h.

259 {return m_srate;}
template<typename container_t = pfc::mem_block_aligned_t<audio_sample, 16>>
const t_self& audio_chunk_impl_t< container_t >::operator= ( const audio_chunk p_source)
inline

Definition at line 269 of file audio_chunk.h.

269 {copy(p_source);return *this;}
void copy(const audio_chunk &p_source)
Helper; copies content of another audio chunk to this chunk.
Definition: audio_chunk.h:212
template<typename container_t = pfc::mem_block_aligned_t<audio_sample, 16>>
const t_self& audio_chunk_impl_t< container_t >::operator= ( const t_self p_source)
inline

Definition at line 270 of file audio_chunk.h.

270 {copy(p_source);return *this;}
void copy(const audio_chunk &p_source)
Helper; copies content of another audio chunk to this chunk.
Definition: audio_chunk.h:212
template<typename container_t = pfc::mem_block_aligned_t<audio_sample, 16>>
virtual void audio_chunk_impl_t< container_t >::set_channels ( unsigned  p_count,
unsigned  p_config 
)
inlinevirtual

Sets channel count / channel map.

Implements audio_chunk.

Definition at line 263 of file audio_chunk.h.

263 {m_nch = val;m_setup = setup;}
template<typename container_t = pfc::mem_block_aligned_t<audio_sample, 16>>
void audio_chunk_impl_t< container_t >::set_channels ( unsigned  val)
inline

Definition at line 264 of file audio_chunk.h.

virtual void set_channels(unsigned val, unsigned setup)
Sets channel count / channel map.
Definition: audio_chunk.h:263
static unsigned g_guess_channel_config(unsigned count)
Helper function; guesses default channel map for the specified channel count. Returns 0 on failure...
template<typename container_t = pfc::mem_block_aligned_t<audio_sample, 16>>
virtual void audio_chunk_impl_t< container_t >::set_data_size ( t_size  p_new_size)
inlinevirtual

Resizes audio data buffer to specified size. Throws std::bad_alloc on failure.

Implements audio_chunk.

Definition at line 257 of file audio_chunk.h.

257 {m_data.set_size(new_size);}
container_t m_data
Definition: audio_chunk.h:244
template<typename container_t = pfc::mem_block_aligned_t<audio_sample, 16>>
virtual void audio_chunk_impl_t< container_t >::set_sample_count ( t_size  val)
inlinevirtual

Sets number of valid samples in the buffer. WARNING: sample count * channel count should never be above allocated buffer size.

Implements audio_chunk.

Definition at line 267 of file audio_chunk.h.

267 {m_samples = val;}
template<typename container_t = pfc::mem_block_aligned_t<audio_sample, 16>>
virtual void audio_chunk_impl_t< container_t >::set_srate ( unsigned  val)
inlinevirtual

Sets sample rate of contained audio data.

Implements audio_chunk.

Definition at line 260 of file audio_chunk.h.

260 {m_srate=val;}

Field Documentation

template<typename container_t = pfc::mem_block_aligned_t<audio_sample, 16>>
container_t audio_chunk_impl_t< container_t >::m_data
private

Definition at line 244 of file audio_chunk.h.

template<typename container_t = pfc::mem_block_aligned_t<audio_sample, 16>>
unsigned audio_chunk_impl_t< container_t >::m_nch
private

Definition at line 245 of file audio_chunk.h.

template<typename container_t = pfc::mem_block_aligned_t<audio_sample, 16>>
t_size audio_chunk_impl_t< container_t >::m_samples
private

Definition at line 246 of file audio_chunk.h.

template<typename container_t = pfc::mem_block_aligned_t<audio_sample, 16>>
unsigned audio_chunk_impl_t< container_t >::m_setup
private

Definition at line 245 of file audio_chunk.h.

template<typename container_t = pfc::mem_block_aligned_t<audio_sample, 16>>
unsigned audio_chunk_impl_t< container_t >::m_srate
private

Definition at line 245 of file audio_chunk.h.


The documentation for this class was generated from the following file: