foobar2000 SDK  2015-01-14
Data Structures | Typedefs | Functions
cue_creator Namespace Reference

Data Structures

struct  t_entry
 

Typedefs

typedef pfc::chain_list_v2_t< t_entryt_entry_list
 

Functions

void create (pfc::string_formatter &p_out, const t_entry_list &p_data)
 

Typedef Documentation

Definition at line 15 of file cue_creator.h.

Function Documentation

void cue_creator::create ( pfc::string_formatter p_out,
const t_entry_list p_data 
)

Definition at line 44 of file cue_creator.cpp.

45  {
46  if (p_data.get_count() == 0) return;
47  bool album_artist_global = is_meta_same_everywhere(p_data,"album artist"),
48  artist_global = is_meta_same_everywhere(p_data,"artist"),
49  album_global = is_meta_same_everywhere(p_data,"album"),
50  genre_global = is_meta_same_everywhere(p_data,"genre"),
51  date_global = is_meta_same_everywhere(p_data,"date"),
52  discid_global = is_meta_same_everywhere(p_data,"discid"),
53  comment_global = is_meta_same_everywhere(p_data,"comment"),
54  catalog_global = is_meta_same_everywhere(p_data,"catalog"),
55  songwriter_global = is_meta_same_everywhere(p_data,"songwriter");
56 
57  if (genre_global) {
58  p_out << "REM GENRE " << format_meta(p_data.first()->m_infos,"genre") << g_eol;
59  }
60  if (date_global) {
61  p_out << "REM DATE " << format_meta(p_data.first()->m_infos,"date") << g_eol;
62  }
63  if (discid_global) {
64  p_out << "REM DISCID " << format_meta(p_data.first()->m_infos,"discid") << g_eol;
65  }
66  if (comment_global) {
67  p_out << "REM COMMENT " << format_meta(p_data.first()->m_infos,"comment") << g_eol;
68  }
69  if (catalog_global) {
70  p_out << "CATALOG " << format_meta(p_data.first()->m_infos,"catalog") << g_eol;
71  }
72  if (songwriter_global) {
73  p_out << "SONGWRITER \"" << format_meta(p_data.first()->m_infos,"songwriter") << "\"" << g_eol;
74  }
75 
76  if (album_artist_global)
77  {
78  p_out << "PERFORMER \"" << format_meta(p_data.first()->m_infos,"album artist") << "\"" << g_eol;
79  artist_global = false;
80  }
81  else if (artist_global)
82  {
83  p_out << "PERFORMER \"" << format_meta(p_data.first()->m_infos,"artist") << "\"" << g_eol;
84  }
85  if (album_global)
86  {
87  p_out << "TITLE \"" << format_meta(p_data.first()->m_infos,"album") << "\"" << g_eol;
88  }
89 
90  {
92  replaygain_info rg = p_data.first()->m_infos.get_replaygain();
93  if (rg.format_album_gain(rgbuffer))
94  p_out << "REM REPLAYGAIN_ALBUM_GAIN " << rgbuffer << g_eol;
95  if (rg.format_album_peak(rgbuffer))
96  p_out << "REM REPLAYGAIN_ALBUM_PEAK " << rgbuffer << g_eol;
97  }
98 
99  pfc::string8 last_file;
100 
101  for(t_entry_list::const_iterator iter = p_data.first();iter.is_valid();++iter)
102  {
103  if (strcmp(last_file,iter->m_file) != 0)
104  {
105  p_out << "FILE \"" << iter->m_file << "\" WAVE" << g_eol;
106  last_file = iter->m_file;
107  }
108 
109  p_out << " TRACK " << pfc::format_int(iter->m_track_number,2) << " AUDIO" << g_eol;
110 
111  if (iter->m_infos.meta_find("title") != pfc_infinite)
112  p_out << " TITLE \"" << format_meta(iter->m_infos,"title") << "\"" << g_eol;
113 
114  if (!artist_global && iter->m_infos.meta_find("artist") != pfc_infinite)
115  p_out << " PERFORMER \"" << format_meta(iter->m_infos,"artist") << "\"" << g_eol;
116 
117  if (!songwriter_global && iter->m_infos.meta_find("songwriter") != pfc_infinite) {
118  p_out << " SONGWRITER \"" << format_meta(iter->m_infos,"songwriter") << "\"" << g_eol;
119  }
120 
121  if (iter->m_infos.meta_find("isrc") != pfc_infinite) {
122  p_out << " ISRC " << format_meta(iter->m_infos,"isrc") << g_eol;
123  }
124 
125  if (!date_global && iter->m_infos.meta_find("date") != pfc_infinite) {
126  p_out << " REM DATE " << format_meta(iter->m_infos,"date") << g_eol;
127  }
128 
129 
130 
131  {
133  replaygain_info rg = iter->m_infos.get_replaygain();
134  if (rg.format_track_gain(rgbuffer))
135  p_out << " REM REPLAYGAIN_TRACK_GAIN " << rgbuffer << g_eol;
136  if (rg.format_track_peak(rgbuffer))
137  p_out << " REM REPLAYGAIN_TRACK_PEAK " << rgbuffer << g_eol;
138  }
139 
140  if (!iter->m_flags.is_empty()) {
141  p_out << " FLAGS " << iter->m_flags << g_eol;
142  }
143 
144  if (iter->m_index_list.m_positions[0] < iter->m_index_list.m_positions[1])
145  {
146  if (iter->m_index_list.m_positions[0] < 0)
147  p_out << " PREGAP " << cuesheet_format_index_time(iter->m_index_list.m_positions[1] - iter->m_index_list.m_positions[0]) << g_eol;
148  else
149  p_out << " INDEX 00 " << cuesheet_format_index_time(iter->m_index_list.m_positions[0]) << g_eol;
150  }
151 
152  p_out << " INDEX 01 " << cuesheet_format_index_time(iter->m_index_list.m_positions[1]) << g_eol;
153 
154  for(unsigned n=2;n<t_cuesheet_index_list::count && iter->m_index_list.m_positions[n] > 0;n++)
155  {
156  p_out << " INDEX " << pfc::format_uint(n,2) << " " << cuesheet_format_index_time(iter->m_index_list.m_positions[n]) << g_eol;
157  }
158 
159  // p_out << " INDEX 01 " << cuesheet_format_index_time(iter->m_offset) << g_eol;
160  }
161  }
static const char g_eol[]
Definition: cue_creator.cpp:39
bool format_track_gain(char p_buffer[text_buffer_size]) const
Definition: file_info.h:16
bool format_album_peak(char p_buffer[text_buffer_size]) const
Definition: file_info.h:17
Structure containing ReplayGain scan results from some playable object, also providing various helper...
Definition: file_info.h:2
bool format_track_peak(char p_buffer[text_buffer_size]) const
Definition: file_info.h:18
bool format_album_gain(char p_buffer[text_buffer_size]) const
Definition: file_info.h:15
static bool is_meta_same_everywhere(const cue_creator::t_entry_list &p_list, const char *p_meta)
Definition: cue_creator.cpp:23
char t_text_buffer[text_buffer_size]
Definition: file_info.h:8