foobar2000 SDK  2015-08-03
Public Member Functions | Private Attributes
audio_chunk_memref_impl

#include <audio_chunk.h>

+ Inheritance diagram for audio_chunk_memref_impl:

Public Member Functions

 audio_chunk_memref_impl (const audio_sample *p_data, t_size p_samples, t_uint32 p_sample_rate, t_uint32 p_channels, t_uint32 p_channel_config)
 
unsigned get_channel_config () const
 
unsigned get_channels () const
 
audio_sampleget_data ()
 
const audio_sampleget_data () const
 
t_size get_data_size () const
 
t_size get_sample_count () const
 
unsigned get_srate () const
 
void set_channels (unsigned p_count, unsigned p_config)
 
void set_data_size (t_size p_new_size)
 
void set_sample_count (t_size val)
 
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 Attributes

t_uint32 m_channel_config
 
t_uint32 m_channels
 
const audio_samplem_data
 
t_uint32 m_sample_rate
 
t_size m_samples
 

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

Implements const methods of audio_chunk only, referring to an external buffer. For temporary use only (does not maintain own storage), e.g.: somefunc( audio_chunk_temp_impl(mybuffer,....) );.

Definition at line 277 of file audio_chunk.h.

Constructor & Destructor Documentation

audio_chunk_memref_impl::audio_chunk_memref_impl ( const audio_sample p_data,
t_size  p_samples,
t_uint32  p_sample_rate,
t_uint32  p_channels,
t_uint32  p_channel_config 
)
inline

Definition at line 279 of file audio_chunk.h.

279  :
280  m_data(p_data), m_samples(p_samples), m_sample_rate(p_sample_rate), m_channels(p_channels), m_channel_config(p_channel_config)
281  {
282  PFC_ASSERT(is_valid());
283  }
const audio_sample * m_data
Definition: audio_chunk.h:303
bool is_valid() const
Returns whether the chunk contents are valid (for bug check purposes).

Member Function Documentation

unsigned audio_chunk_memref_impl::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 293 of file audio_chunk.h.

293 {return m_channel_config;}
unsigned audio_chunk_memref_impl::get_channels ( ) const
inlinevirtual

Retrieves channel count of contained audio data.

Implements audio_chunk.

Definition at line 292 of file audio_chunk.h.

292 {return m_channels;}
audio_sample* audio_chunk_memref_impl::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 285 of file audio_chunk.h.

285 {throw pfc::exception_not_implemented();}
const audio_sample* audio_chunk_memref_impl::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 286 of file audio_chunk.h.

286 {return m_data;}
const audio_sample * m_data
Definition: audio_chunk.h:303
t_size audio_chunk_memref_impl::get_data_size ( ) const
inlinevirtual

Retrieves size of allocated buffer space, in audio_samples.

Implements audio_chunk.

Definition at line 287 of file audio_chunk.h.

t_size audio_chunk_memref_impl::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 296 of file audio_chunk.h.

296 {return m_samples;}
unsigned audio_chunk_memref_impl::get_srate ( ) const
inlinevirtual

Retrieves sample rate of contained audio data.

Implements audio_chunk.

Definition at line 290 of file audio_chunk.h.

290 {return m_sample_rate;}
void audio_chunk_memref_impl::set_channels ( unsigned  p_count,
unsigned  p_config 
)
inlinevirtual

Sets channel count / channel map.

Implements audio_chunk.

Definition at line 294 of file audio_chunk.h.

294 {throw pfc::exception_not_implemented();}
void audio_chunk_memref_impl::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 288 of file audio_chunk.h.

288 {throw pfc::exception_not_implemented();}
void audio_chunk_memref_impl::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 298 of file audio_chunk.h.

298 {throw pfc::exception_not_implemented();}
void audio_chunk_memref_impl::set_srate ( unsigned  val)
inlinevirtual

Sets sample rate of contained audio data.

Implements audio_chunk.

Definition at line 291 of file audio_chunk.h.

291 {throw pfc::exception_not_implemented();}

Field Documentation

t_uint32 audio_chunk_memref_impl::m_channel_config
private

Definition at line 302 of file audio_chunk.h.

t_uint32 audio_chunk_memref_impl::m_channels
private

Definition at line 302 of file audio_chunk.h.

const audio_sample* audio_chunk_memref_impl::m_data
private

Definition at line 303 of file audio_chunk.h.

t_uint32 audio_chunk_memref_impl::m_sample_rate
private

Definition at line 302 of file audio_chunk.h.

t_size audio_chunk_memref_impl::m_samples
private

Definition at line 301 of file audio_chunk.h.


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