foobar2000 SDK  2015-08-03
Public Types | Public Member Functions | Static Public Member Functions | Data Fields
replaygain_info

#include <file_info.h>

Public Types

enum  { text_buffer_size = 16 }
 
enum  { peak_invalid = -1, gain_invalid = -1000 }
 
typedef char t_text_buffer[text_buffer_size]
 

Public Member Functions

bool format_album_gain (char p_buffer[text_buffer_size]) const
 
bool format_album_peak (char p_buffer[text_buffer_size]) const
 
bool format_track_gain (char p_buffer[text_buffer_size]) const
 
bool format_track_peak (char p_buffer[text_buffer_size]) const
 
t_size get_value_count ()
 
bool is_album_gain_present () const
 
bool is_album_peak_present () const
 
bool is_track_gain_present () const
 
bool is_track_peak_present () const
 
void remove_album_gain ()
 
void remove_album_peak ()
 
void remove_track_gain ()
 
void remove_track_peak ()
 
void reset ()
 
void set_album_gain_text (const char *p_text, t_size p_text_len=pfc_infinite)
 
void set_album_peak_text (const char *p_text, t_size p_text_len=pfc_infinite)
 
bool set_from_meta (const char *p_name, const char *p_value)
 
bool set_from_meta_ex (const char *p_name, t_size p_name_len, const char *p_value, t_size p_value_len)
 
void set_track_gain_text (const char *p_text, t_size p_text_len=pfc_infinite)
 
void set_track_peak_text (const char *p_text, t_size p_text_len=pfc_infinite)
 

Static Public Member Functions

static bool g_equal (const replaygain_info &item1, const replaygain_info &item2)
 
static bool g_format_gain (float p_value, char p_buffer[text_buffer_size])
 
static bool g_format_peak (float p_value, char p_buffer[text_buffer_size])
 
static bool g_is_meta_replaygain (const char *p_name, t_size p_name_len=pfc_infinite)
 
static replaygain_info g_merge (replaygain_info r1, replaygain_info r2)
 

Data Fields

float m_album_gain
 
float m_album_peak
 
float m_track_gain
 
float m_track_peak
 

Detailed Description

Structure containing ReplayGain scan results from some playable object, also providing various helper methods to manipulate those results.

Definition at line 2 of file file_info.h.

Member Typedef Documentation

typedef char replaygain_info::t_text_buffer[text_buffer_size]

Definition at line 8 of file file_info.h.

Member Enumeration Documentation

anonymous enum
Enumerator
text_buffer_size 

Definition at line 7 of file file_info.h.

anonymous enum
Enumerator
peak_invalid 
gain_invalid 

Definition at line 10 of file file_info.h.

Member Function Documentation

bool replaygain_info::format_album_gain ( char  p_buffer[text_buffer_size]) const
inline

Definition at line 15 of file file_info.h.

15 {return g_format_gain(m_album_gain,p_buffer);}
static bool g_format_gain(float p_value, char p_buffer[text_buffer_size])
float m_album_gain
Definition: file_info.h:4
bool replaygain_info::format_album_peak ( char  p_buffer[text_buffer_size]) const
inline

Definition at line 17 of file file_info.h.

17 {return g_format_peak(m_album_peak,p_buffer);}
static bool g_format_peak(float p_value, char p_buffer[text_buffer_size])
float m_album_peak
Definition: file_info.h:5
bool replaygain_info::format_track_gain ( char  p_buffer[text_buffer_size]) const
inline

Definition at line 16 of file file_info.h.

16 {return g_format_gain(m_track_gain,p_buffer);}
float m_track_gain
Definition: file_info.h:4
static bool g_format_gain(float p_value, char p_buffer[text_buffer_size])
bool replaygain_info::format_track_peak ( char  p_buffer[text_buffer_size]) const
inline

Definition at line 18 of file file_info.h.

18 {return g_format_peak(m_track_peak,p_buffer);}
static bool g_format_peak(float p_value, char p_buffer[text_buffer_size])
float m_track_peak
Definition: file_info.h:5
bool replaygain_info::g_equal ( const replaygain_info item1,
const replaygain_info item2 
)
static

Definition at line 355 of file file_info.cpp.

356 {
357  return item1.m_album_gain == item2.m_album_gain &&
358  item1.m_track_gain == item2.m_track_gain &&
359  item1.m_album_peak == item2.m_album_peak &&
360  item1.m_track_peak == item2.m_track_peak;
361 }
float m_track_gain
Definition: file_info.h:4
float m_album_peak
Definition: file_info.h:5
float m_album_gain
Definition: file_info.h:4
float m_track_peak
Definition: file_info.h:5
bool replaygain_info::g_format_gain ( float  p_value,
char  p_buffer[text_buffer_size] 
)
static

Definition at line 9 of file replaygain_info.cpp.

10 {
11  RG_FPU();
12  if (p_value == gain_invalid)
13  {
14  p_buffer[0] = 0;
15  return false;
16  }
17  else
18  {
19  pfc::float_to_string(p_buffer,text_buffer_size - 4,p_value,2,true);
20  strcat(p_buffer," dB");
21  return true;
22  }
23 }
void float_to_string(char *out, t_size out_max, double val, unsigned precision, bool b_sign)
bool replaygain_info::g_format_peak ( float  p_value,
char  p_buffer[text_buffer_size] 
)
static

Definition at line 25 of file replaygain_info.cpp.

26 {
27  RG_FPU();
28  if (p_value == peak_invalid)
29  {
30  p_buffer[0] = 0;
31  return false;
32  }
33  else
34  {
35  pfc::float_to_string(p_buffer,text_buffer_size,p_value,6,false);
36  return true;
37  }
38 }
void float_to_string(char *out, t_size out_max, double val, unsigned precision, bool b_sign)
bool replaygain_info::g_is_meta_replaygain ( const char *  p_name,
t_size  p_name_len = pfc_infinite 
)
static

Definition at line 50 of file replaygain_info.cpp.

51 {
52  return
53  stricmp_utf8_ex(p_name,p_name_len,meta_album_gain,~0) == 0 ||
54  stricmp_utf8_ex(p_name,p_name_len,meta_album_peak,~0) == 0 ||
55  stricmp_utf8_ex(p_name,p_name_len,meta_track_gain,~0) == 0 ||
56  stricmp_utf8_ex(p_name,p_name_len,meta_track_peak,~0) == 0;
57 }
int SHARED_EXPORT stricmp_utf8_ex(const char *p1, t_size len1, const char *p2, t_size len2)
static const char meta_track_gain[]
static const char meta_album_peak[]
static const char meta_track_peak[]
static const char meta_album_gain[]
replaygain_info replaygain_info::g_merge ( replaygain_info  r1,
replaygain_info  r2 
)
static

Definition at line 134 of file replaygain_info.cpp.

135 {
136  replaygain_info ret = r1;
137  if (!ret.is_album_gain_present()) ret.m_album_gain = r2.m_album_gain;
138  if (!ret.is_album_peak_present()) ret.m_album_peak = r2.m_album_peak;
139  if (!ret.is_track_gain_present()) ret.m_track_gain = r2.m_track_gain;
140  if (!ret.is_track_peak_present()) ret.m_track_peak = r2.m_track_peak;
141  return ret;
142 }
bool is_track_peak_present() const
Definition: file_info.h:32
float m_track_gain
Definition: file_info.h:4
float m_album_peak
Definition: file_info.h:5
Structure containing ReplayGain scan results from some playable object, also providing various helper...
Definition: file_info.h:2
bool is_album_peak_present() const
Definition: file_info.h:31
bool is_track_gain_present() const
Definition: file_info.h:30
float m_album_gain
Definition: file_info.h:4
bool is_album_gain_present() const
Definition: file_info.h:29
float m_track_peak
Definition: file_info.h:5
t_size replaygain_info::get_value_count ( )

Definition at line 88 of file replaygain_info.cpp.

89 {
90  t_size ret = 0;
91  if (is_album_gain_present()) ret++;
92  if (is_album_peak_present()) ret++;
93  if (is_track_gain_present()) ret++;
94  if (is_track_peak_present()) ret++;
95  return ret;
96 }
bool is_track_peak_present() const
Definition: file_info.h:32
size_t t_size
Definition: int_types.h:48
bool is_album_peak_present() const
Definition: file_info.h:31
bool is_track_gain_present() const
Definition: file_info.h:30
bool is_album_gain_present() const
Definition: file_info.h:29
bool replaygain_info::is_album_gain_present ( ) const
inline

Definition at line 29 of file file_info.h.

bool replaygain_info::is_album_peak_present ( ) const
inline

Definition at line 31 of file file_info.h.

bool replaygain_info::is_track_gain_present ( ) const
inline

Definition at line 30 of file file_info.h.

bool replaygain_info::is_track_peak_present ( ) const
inline

Definition at line 32 of file file_info.h.

void replaygain_info::remove_album_gain ( )
inline

Definition at line 34 of file file_info.h.

void replaygain_info::remove_album_peak ( )
inline

Definition at line 36 of file file_info.h.

void replaygain_info::remove_track_gain ( )
inline

Definition at line 35 of file file_info.h.

void replaygain_info::remove_track_peak ( )
inline

Definition at line 37 of file file_info.h.

void replaygain_info::reset ( )
void replaygain_info::set_album_gain_text ( const char *  p_text,
t_size  p_text_len = pfc_infinite 
)

Definition at line 98 of file replaygain_info.cpp.

99 {
100  RG_FPU();
101  if (p_text != 0 && p_text_len > 0 && *p_text != 0)
102  m_album_gain = (float)pfc::string_to_float(p_text,p_text_len);
103  else
105 }
void remove_album_gain()
Definition: file_info.h:34
double string_to_float(const char *src, t_size max)
float m_album_gain
Definition: file_info.h:4
void replaygain_info::set_album_peak_text ( const char *  p_text,
t_size  p_text_len = pfc_infinite 
)

Definition at line 116 of file replaygain_info.cpp.

117 {
118  RG_FPU();
119  if (p_text != 0 && p_text_len > 0 && *p_text != 0)
120  m_album_peak = (float)pfc::string_to_float(p_text,p_text_len);
121  else
123 }
void remove_album_peak()
Definition: file_info.h:36
double string_to_float(const char *src, t_size max)
float m_album_peak
Definition: file_info.h:5
bool replaygain_info::set_from_meta ( const char *  p_name,
const char *  p_value 
)
inline

Definition at line 27 of file file_info.h.

27 {return set_from_meta_ex(p_name,pfc_infinite,p_value,pfc_infinite);}
bool set_from_meta_ex(const char *p_name, t_size p_name_len, const char *p_value, t_size p_value_len)
bool replaygain_info::set_from_meta_ex ( const char *  p_name,
t_size  p_name_len,
const char *  p_value,
t_size  p_value_len 
)

Definition at line 59 of file replaygain_info.cpp.

60 {
61  RG_FPU();
62  if (stricmp_utf8_ex(p_name,p_name_len,meta_album_gain,~0) == 0)
63  {
64  m_album_gain = (float)pfc::string_to_float(p_value,p_value_len);
65  return true;
66  }
67  else if (stricmp_utf8_ex(p_name,p_name_len,meta_album_peak,~0) == 0)
68  {
69  m_album_peak = (float)pfc::string_to_float(p_value,p_value_len);
70  if (m_album_peak < 0) m_album_peak = 0;
71  return true;
72  }
73  else if (stricmp_utf8_ex(p_name,p_name_len,meta_track_gain,~0) == 0)
74  {
75  m_track_gain = (float)pfc::string_to_float(p_value,p_value_len);
76  return true;
77  }
78  else if (stricmp_utf8_ex(p_name,p_name_len,meta_track_peak,~0) == 0)
79  {
80  m_track_peak = (float)pfc::string_to_float(p_value,p_value_len);
81  if (m_track_peak < 0) m_track_peak = 0;
82  return true;
83  }
84  else return false;
85 }
int SHARED_EXPORT stricmp_utf8_ex(const char *p1, t_size len1, const char *p2, t_size len2)
float m_track_gain
Definition: file_info.h:4
double string_to_float(const char *src, t_size max)
float m_album_peak
Definition: file_info.h:5
static const char meta_track_gain[]
static const char meta_album_peak[]
float m_album_gain
Definition: file_info.h:4
static const char meta_track_peak[]
float m_track_peak
Definition: file_info.h:5
static const char meta_album_gain[]
void replaygain_info::set_track_gain_text ( const char *  p_text,
t_size  p_text_len = pfc_infinite 
)

Definition at line 107 of file replaygain_info.cpp.

108 {
109  RG_FPU();
110  if (p_text != 0 && p_text_len > 0 && *p_text != 0)
111  m_track_gain = (float)pfc::string_to_float(p_text,p_text_len);
112  else
114 }
float m_track_gain
Definition: file_info.h:4
double string_to_float(const char *src, t_size max)
void remove_track_gain()
Definition: file_info.h:35
void replaygain_info::set_track_peak_text ( const char *  p_text,
t_size  p_text_len = pfc_infinite 
)

Definition at line 125 of file replaygain_info.cpp.

126 {
127  RG_FPU();
128  if (p_text != 0 && p_text_len > 0 && *p_text != 0)
129  m_track_peak = (float)pfc::string_to_float(p_text,p_text_len);
130  else
132 }
double string_to_float(const char *src, t_size max)
void remove_track_peak()
Definition: file_info.h:37
float m_track_peak
Definition: file_info.h:5

Field Documentation

float replaygain_info::m_album_gain

Definition at line 4 of file file_info.h.

float replaygain_info::m_album_peak

Definition at line 5 of file file_info.h.

float replaygain_info::m_track_gain

Definition at line 4 of file file_info.h.

float replaygain_info::m_track_peak

Definition at line 5 of file file_info.h.


The documentation for this struct was generated from the following files: