audio_chunk Class Reference

Interface to container of a chunk of audio data. See audio_chunk_impl for an implementation. More...

#include <audio_chunk.h>

Inheritance diagram for audio_chunk:

audio_chunk_impl_t< t_alloc > audio_chunk_temp_impl

List of all members.

Public Types

enum  { sample_rate_min = 1000, sample_rate_max = 1000000 }
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_back_left | channel_back_right | channel_front_center | channel_lfe, defined_channel_count = 18
}
 Channel map flag declarations. Note that order of interleaved channel data in the stream is same as order of these flags. More...
enum  { FLAG_LITTLE_ENDIAN = 1, FLAG_BIG_ENDIAN = 2, FLAG_SIGNED = 4, FLAG_UNSIGNED = 8 }

Public Member Functions

virtual audio_sampleget_data ()=0
virtual const audio_sampleget_data () const =0
virtual t_size get_data_size () const =0
 Retrieves size of allocated buffer space, in audio_samples.
virtual void set_data_size (t_size p_new_size)=0
 Resizes audio data buffer to specified size. Throws std::bad_alloc on failure.
virtual unsigned get_srate () const =0
 Retrieves sample rate of contained audio data.
virtual void set_srate (unsigned val)=0
 Sets sample rate of contained audio data.
virtual unsigned get_channels () const =0
 Retrieves channel count of contained audio data.
unsigned get_channel_count () const
 Helper - for consistency - same as get_channels().
virtual unsigned get_channel_config () const =0
 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.
virtual void set_channels (unsigned p_count, unsigned p_config)=0
 Sets channel count / channel map.
virtual t_size get_sample_count () const =0
virtual void set_sample_count (t_size val)=0
 Sets number of valid samples in the buffer. WARNING: sample count * channel count should never be above allocated buffer size.
unsigned get_sample_rate () const
 Helper, same as get_srate().
void set_sample_rate (unsigned val)
 Helper, same as set_srate().
void set_channels (unsigned val)
 Helper; sets channel count to specified value and uses default channel map for this channel count.
void grow_data_size (t_size p_requested)
 Helper; resizes audio data buffer when it's current size is smaller than requested.
double get_duration () const
 Retrieves duration of contained audio data, in seconds.
bool is_empty () const
 Returns whether the chunk is empty (contains no audio data).
bool is_valid () const
 Returns whether the chunk contents are valid (for bug check purposes).
t_size get_data_length () const
 Returns actual amount of audio data contained in the buffer (sample count * channel count). Must not be greater than data size (see get_data_size()).
void reset ()
 Resets all audio_chunk data.
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 rate / channel map.
void set_data (const audio_sample *src, t_size samples, unsigned nch, unsigned srate)
 Helper, sets chunk data to contents of specified buffer, with specified number of channels / sample rate, using default channel map for specified channel count.
void set_data_fixedpoint (const void *ptr, t_size bytes, unsigned srate, unsigned nch, unsigned bps, unsigned channel_config)
 Helper, sets chunk data to contents of specified buffer, using default win32/wav conventions for signed/unsigned switch.
void set_data_fixedpoint_unsigned (const void *ptr, t_size bytes, unsigned srate, unsigned nch, unsigned bps, unsigned channel_config)
void set_data_fixedpoint_signed (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_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_32 (const float *src, t_size samples, unsigned nch, unsigned srate)
void pad_with_silence_ex (t_size samples, unsigned hint_nch, unsigned hint_srate)
void pad_with_silence (t_size samples)
void insert_silence_fromstart (t_size samples)
t_size skip_first_samples (t_size samples)
audio_sample get_peak (audio_sample p_peak=0) const
 Helper, calculates peak value of data in the chunk. The optional parameter specifies initial peak value, to simplify calling code.
void scale (audio_sample p_value)
 Helper function; scales entire chunk content by specified value.
void copy (const audio_chunk &p_source)
 Helper; copies content of another audio chunk to this chunk.
const audio_chunkoperator= (const audio_chunk &p_source)

Static Public Member Functions

static bool g_is_valid_sample_rate (t_uint32 p_val)
static unsigned g_guess_channel_config (unsigned count)
 Helper function; guesses default channel map for specified channel count.
static unsigned g_extract_channel_flag (unsigned p_config, unsigned p_index)
 Extracts flag describing Nth channel from specified map. Usable to figure what specific channel in a stream means.
static unsigned g_count_channels (unsigned p_config)
 Counts channels specified by channel map.
static unsigned g_channel_index_from_flag (unsigned p_config, unsigned p_flag)
 Calculates index of a channel specified by p_flag in a stream where channel map is described by p_config.
static unsigned flags_autoendian ()

Protected Member Functions

 audio_chunk ()
 ~audio_chunk ()


Detailed Description

Interface to container of a chunk of audio data. See audio_chunk_impl for an implementation.

Member Enumeration Documentation

anonymous enum

Enumerator:
sample_rate_min 
sample_rate_max 

anonymous enum

Channel map flag declarations. Note that order of interleaved channel data in the stream is same as order of these flags.

Enumerator:
channel_front_left 
channel_front_right 
channel_front_center 
channel_lfe 
channel_back_left 
channel_back_right 
channel_front_center_left 
channel_front_center_right 
channel_back_center 
channel_side_left 
channel_side_right 
channel_top_center 
channel_top_front_left 
channel_top_front_center 
channel_top_front_right 
channel_top_back_left 
channel_top_back_center 
channel_top_back_right 
channel_config_mono 
channel_config_stereo 
channel_config_5point1 
defined_channel_count 

anonymous enum

Enumerator:
FLAG_LITTLE_ENDIAN 
FLAG_BIG_ENDIAN 
FLAG_SIGNED 
FLAG_UNSIGNED 


Constructor & Destructor Documentation

audio_chunk::audio_chunk (  )  [inline, protected]

audio_chunk::~audio_chunk (  )  [inline, protected]


Member Function Documentation

static bool audio_chunk::g_is_valid_sample_rate ( t_uint32  p_val  )  [inline, static]

static unsigned audio_chunk::g_guess_channel_config ( unsigned  count  )  [static]

Helper function; guesses default channel map for specified channel count.

static unsigned audio_chunk::g_extract_channel_flag ( unsigned  p_config,
unsigned  p_index 
) [static]

Extracts flag describing Nth channel from specified map. Usable to figure what specific channel in a stream means.

static unsigned audio_chunk::g_count_channels ( unsigned  p_config  )  [static]

Counts channels specified by channel map.

static unsigned audio_chunk::g_channel_index_from_flag ( unsigned  p_config,
unsigned  p_flag 
) [static]

Calculates index of a channel specified by p_flag in a stream where channel map is described by p_config.

virtual audio_sample* audio_chunk::get_data (  )  [pure virtual]

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.

Implemented in audio_chunk_impl_t< t_alloc >, and audio_chunk_temp_impl.

virtual const audio_sample* audio_chunk::get_data (  )  const [pure virtual]

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.

Implemented in audio_chunk_impl_t< t_alloc >, and audio_chunk_temp_impl.

virtual t_size audio_chunk::get_data_size (  )  const [pure virtual]

Retrieves size of allocated buffer space, in audio_samples.

Implemented in audio_chunk_impl_t< t_alloc >, and audio_chunk_temp_impl.

virtual void audio_chunk::set_data_size ( t_size  p_new_size  )  [pure virtual]

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

Implemented in audio_chunk_impl_t< t_alloc >, and audio_chunk_temp_impl.

virtual unsigned audio_chunk::get_srate (  )  const [pure virtual]

Retrieves sample rate of contained audio data.

Implemented in audio_chunk_impl_t< t_alloc >, and audio_chunk_temp_impl.

virtual void audio_chunk::set_srate ( unsigned  val  )  [pure virtual]

Sets sample rate of contained audio data.

Implemented in audio_chunk_impl_t< t_alloc >, and audio_chunk_temp_impl.

virtual unsigned audio_chunk::get_channels (  )  const [pure virtual]

Retrieves channel count of contained audio data.

Implemented in audio_chunk_impl_t< t_alloc >, and audio_chunk_temp_impl.

unsigned audio_chunk::get_channel_count (  )  const [inline]

Helper - for consistency - same as get_channels().

virtual unsigned audio_chunk::get_channel_config (  )  const [pure virtual]

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.

Implemented in audio_chunk_impl_t< t_alloc >, and audio_chunk_temp_impl.

virtual void audio_chunk::set_channels ( unsigned  p_count,
unsigned  p_config 
) [pure virtual]

Sets channel count / channel map.

Implemented in audio_chunk_impl_t< t_alloc >, and audio_chunk_temp_impl.

virtual t_size audio_chunk::get_sample_count (  )  const [pure virtual]

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.

Implemented in audio_chunk_impl_t< t_alloc >, and audio_chunk_temp_impl.

virtual void audio_chunk::set_sample_count ( t_size  val  )  [pure virtual]

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

Implemented in audio_chunk_impl_t< t_alloc >, and audio_chunk_temp_impl.

unsigned audio_chunk::get_sample_rate (  )  const [inline]

Helper, same as get_srate().

void audio_chunk::set_sample_rate ( unsigned  val  )  [inline]

Helper, same as set_srate().

void audio_chunk::set_channels ( unsigned  val  )  [inline]

Helper; sets channel count to specified value and uses default channel map for this channel count.

Reimplemented in audio_chunk_impl_t< t_alloc >.

void audio_chunk::grow_data_size ( t_size  p_requested  )  [inline]

Helper; resizes audio data buffer when it's current size is smaller than requested.

double audio_chunk::get_duration (  )  const [inline]

Retrieves duration of contained audio data, in seconds.

bool audio_chunk::is_empty (  )  const [inline]

Returns whether the chunk is empty (contains no audio data).

bool audio_chunk::is_valid (  )  const

Returns whether the chunk contents are valid (for bug check purposes).

t_size audio_chunk::get_data_length (  )  const [inline]

Returns actual amount of audio data contained in the buffer (sample count * channel count). Must not be greater than data size (see get_data_size()).

void audio_chunk::reset (  )  [inline]

Resets all audio_chunk data.

void audio_chunk::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 rate / channel map.

void audio_chunk::set_data ( const audio_sample src,
t_size  samples,
unsigned  nch,
unsigned  srate 
) [inline]

Helper, sets chunk data to contents of specified buffer, with specified number of channels / sample rate, using default channel map for specified channel count.

void audio_chunk::set_data_fixedpoint ( const void *  ptr,
t_size  bytes,
unsigned  srate,
unsigned  nch,
unsigned  bps,
unsigned  channel_config 
) [inline]

Helper, sets chunk data to contents of specified buffer, using default win32/wav conventions for signed/unsigned switch.

void audio_chunk::set_data_fixedpoint_unsigned ( const void *  ptr,
t_size  bytes,
unsigned  srate,
unsigned  nch,
unsigned  bps,
unsigned  channel_config 
) [inline]

void audio_chunk::set_data_fixedpoint_signed ( const void *  ptr,
t_size  bytes,
unsigned  srate,
unsigned  nch,
unsigned  bps,
unsigned  channel_config 
) [inline]

static unsigned audio_chunk::flags_autoendian (  )  [inline, static]

void audio_chunk::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 audio_chunk::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 audio_chunk::set_data_32 ( const float *  src,
t_size  samples,
unsigned  nch,
unsigned  srate 
) [inline]

void audio_chunk::pad_with_silence_ex ( t_size  samples,
unsigned  hint_nch,
unsigned  hint_srate 
)

void audio_chunk::pad_with_silence ( t_size  samples  ) 

void audio_chunk::insert_silence_fromstart ( t_size  samples  ) 

t_size audio_chunk::skip_first_samples ( t_size  samples  ) 

audio_sample audio_chunk::get_peak ( audio_sample  p_peak = 0  )  const

Helper, calculates peak value of data in the chunk. The optional parameter specifies initial peak value, to simplify calling code.

void audio_chunk::scale ( audio_sample  p_value  ) 

Helper function; scales entire chunk content by specified value.

void audio_chunk::copy ( const audio_chunk p_source  )  [inline]

Helper; copies content of another audio chunk to this chunk.

const audio_chunk& audio_chunk::operator= ( const audio_chunk p_source  )  [inline]

Reimplemented in audio_chunk_impl_t< t_alloc >.


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

Generated on Fri Apr 25 18:49:40 2008 for foobar2000 SDK by  doxygen 1.5.5