foobar2000 SDK  2015-08-03
Namespaces | Functions
audio_math.cpp File Reference

Go to the source code of this file.

Namespaces

 pfc
 

Functions

static audio_sample noopt_calculate_peak (const audio_sample *p_src, t_size p_num)
 
static void noopt_convert_from_int16 (const t_int16 *p_source, t_size p_count, audio_sample *p_output, float p_scale)
 
static void noopt_convert_from_int32 (const t_int32 *p_source, t_size p_count, audio_sample *p_output, float p_scale)
 
static void noopt_convert_to_16bit (const audio_sample *p_source, t_size p_count, t_int16 *p_output, float p_scale)
 
static void noopt_convert_to_32bit (const audio_sample *p_source, t_size p_count, t_int32 *p_output, float p_scale)
 
static void noopt_scale (const audio_sample *p_source, t_size p_count, audio_sample *p_output, audio_sample p_scale)
 

Function Documentation

static audio_sample noopt_calculate_peak ( const audio_sample p_src,
t_size  p_num 
)
static

Definition at line 3 of file audio_math.cpp.

4 {
5  audio_sample peak = 0;
6  t_size num = p_num;
7  for(;num;num--)
8  {
9  audio_sample temp = (audio_sample)fabs(*(p_src++));
10  if (temp>peak) peak = temp;
11  }
12  return peak;
13 }
size_t t_size
Definition: int_types.h:48
float audio_sample
Definition: audio_sample.h:6
static void noopt_convert_from_int16 ( const t_int16 p_source,
t_size  p_count,
audio_sample p_output,
float  p_scale 
)
inlinestatic

Definition at line 36 of file audio_math.cpp.

37 {
38  t_size num = p_count;
39  for(;num;num--)
40  *(p_output++) = (audio_sample)*(p_source++) * p_scale;
41 }
size_t t_size
Definition: int_types.h:48
float audio_sample
Definition: audio_sample.h:6
static void noopt_convert_from_int32 ( const t_int32 p_source,
t_size  p_count,
audio_sample p_output,
float  p_scale 
)
inlinestatic

Definition at line 45 of file audio_math.cpp.

46 {
47  t_size num = p_count;
48  for(;num;num--)
49  *(p_output++) = (audio_sample)*(p_source++) * p_scale;
50 }
size_t t_size
Definition: int_types.h:48
float audio_sample
Definition: audio_sample.h:6
static void noopt_convert_to_16bit ( const audio_sample p_source,
t_size  p_count,
t_int16 p_output,
float  p_scale 
)
inlinestatic

Definition at line 30 of file audio_math.cpp.

30  {
31  for(t_size n=0;n<p_count;n++) {
32  *(p_output++) = (t_int16) pfc::clip_t(pfc::audio_math::rint32(*(p_source++)*p_scale),-0x8000,0x7FFF);
33  }
34 }
static t_int32 rint32(audio_sample val)
Definition: audio_sample.h:54
int16_t t_int16
Definition: int_types.h:6
size_t t_size
Definition: int_types.h:48
T clip_t(const T &p_item, const T &p_min, const T &p_max)
Definition: primitives.h:565
static void noopt_convert_to_32bit ( const audio_sample p_source,
t_size  p_count,
t_int32 p_output,
float  p_scale 
)
static

Definition at line 18 of file audio_math.cpp.

19 {
20  t_size num = p_count;
21  for(;num;--num)
22  {
23  t_int64 val = pfc::audio_math::rint64( *(p_source++) * p_scale );
24  if (val < -(t_int64)0x80000000) val = -(t_int64)0x80000000;
25  else if (val > 0x7FFFFFFF) val = 0x7FFFFFFF;
26  *(p_output++) = (t_int32) val;
27  }
28 }
int32_t t_int32
Definition: int_types.h:4
size_t t_size
Definition: int_types.h:48
static t_int64 rint64(audio_sample val)
Definition: audio_sample.h:46
int64_t t_int64
Definition: int_types.h:2
static void noopt_scale ( const audio_sample p_source,
t_size  p_count,
audio_sample p_output,
audio_sample  p_scale 
)
inlinestatic

Definition at line 52 of file audio_math.cpp.

53 {
54  for(t_size n=0;n<p_count;n++)
55  p_output[n] = p_source[n] * p_scale;
56 }
size_t t_size
Definition: int_types.h:48