38#include <wx/textfile.h>
49 kind = (*f)[f->GetCurrentLine()];
51 if (kind ==
wxT(
"WaveTrack")) {
55 wxString channel = f->GetNextLine();
56 if (channel ==
wxT(
"left")) {
58 line = f->GetNextLine();
60 else if (channel ==
wxT(
"right")) {
62 line = f->GetNextLine();
64 else if (channel ==
wxT(
"mono")) {
66 line = f->GetNextLine();
73 if (line ==
wxT(
"linked")) {
75 line = f->GetNextLine();
78 if (line !=
wxT(
"offset"))
84 if (f->GetNextLine() !=
wxT(
"EnvNumPoints"))
86 line = f->GetNextLine();
88 if (envLen < 0 || envLen > 10000)
91 size_t envStart = f->GetCurrentLine();
92 if (f->GetLineCount() < envStart+(2*envLen)+1)
95 f->GoToLine(envStart+(2*envLen));
96 if (f->GetNextLine() !=
wxT(
"EnvEnd"))
98 if (f->GetNextLine() !=
wxT(
"numSamples"))
101 wxString numSamples = f->GetNextLine();
103 if (f->GetNextLine() !=
wxT(
"rate"))
113 for(i=0; i<envLen; i++) {
115 xmlFile.
WriteAttr(
wxT(
"t"), f->GetLine(envStart + 2*i + 1));
116 xmlFile.
WriteAttr(
wxT(
"val"), f->GetLine(envStart + 2*i + 2));
123 if (f->GetNextLine() !=
wxT(
"numBlocks"))
126 line = f->GetNextLine();
127 line.ToLong(&numBlocks);
129 if (numBlocks < 0 || numBlocks > 131072)
138 for(b=0; b<numBlocks; b++) {
143 if (f->GetNextLine() !=
wxT(
"Block start"))
145 start = f->GetNextLine();
146 if (f->GetNextLine() !=
wxT(
"Block len"))
148 len = f->GetNextLine();
149 if (f->GetNextLine() !=
wxT(
"Block info"))
151 name = f->GetNextLine();
158 wxString aliasPath = f->GetNextLine();
159 wxString localLen = f->GetNextLine();
160 wxString aliasStart = f->GetNextLine();
161 wxString aliasLen = f->GetNextLine();
162 wxString aliasChannel = f->GetNextLine();
163 wxString localName = f->GetNextLine();
193 else if (kind ==
wxT(
"LabelTrack")) {
194 line = f->GetNextLine();
195 if (line !=
wxT(
"NumMLabels"))
200 line = f->GetNextLine();
201 line.ToLong(&numLabels);
202 if (numLabels < 0 || numLabels > 1000000)
209 for(l=0; l<numLabels; l++) {
212 t = f->GetNextLine();
213 title = f->GetNextLine();
223 line = f->GetNextLine();
224 if (line !=
wxT(
"MLabelsEnd"))
229 else if (kind ==
wxT(
"NoteTrack")) {
233 line = f->GetNextLine();
234 if (line ==
wxT(
"WaveTrack") ||
235 line ==
wxT(
"NoteTrack") ||
236 line ==
wxT(
"LabelTrack") ||
237 line ==
wxT(
"EndTracks")) {
238 f->GoToLine(f->GetCurrentLine()-1);
241 }
while (f->GetCurrentLine() < f->GetLineCount());
253 const wxString
name = filename.GetFullPath();
258 return GuardedCall< bool >( [&] {
261 xmlFile.Write(
wxT(
"<?xml version=\"1.0\"?>\n"));
266 if (f.GetFirstLine() !=
wxT(
"AudacityProject"))
268 if (f.GetNextLine() !=
wxT(
"Version"))
270 if (f.GetNextLine() !=
wxT(
"0.95"))
272 if (f.GetNextLine() !=
wxT(
"projName"))
275 xmlFile.StartTag(
wxT(
"audacityproject"));
276 xmlFile.WriteAttr(
wxT(
"projname"), f.GetNextLine());
277 xmlFile.WriteAttr(
wxT(
"version"),
wxT(
"1.1.0"));
278 xmlFile.WriteAttr(
wxT(
"audacityversion"),AUDACITY_VERSION_STRING);
280 label = f.GetNextLine();
281 while (
label !=
wxT(
"BeginTracks")) {
282 xmlFile.WriteAttr(
label, f.GetNextLine());
283 label = f.GetNextLine();
286 label = f.GetNextLine();
291 label = f.GetNextLine();
297 xmlFile.EndTag(
wxT(
"audacityproject"));
302"Converted a 1.0 project file to the new format.\nThe old file has been saved as '%s'")
303 .
Format( xmlFile.GetBackupName() ),
304 XO(
"Opening Audacity Project"));
int AudacityMessageBox(const TranslatableString &message, const TranslatableString &caption, long style, wxWindow *parent, int x, int y)
static bool ConvertLegacyTrack(wxTextFile *f, XMLFileWriter &xmlFile)
bool ConvertLegacyProjectFile(const wxFileName &filename)
Update Audacity 1.0 file in-place to XML format.
Wrapper to output XML data to files.
virtual void StartTag(const wxString &name)
void WriteAttr(const wxString &name, const Identifier &value)
virtual void EndTag(const wxString &name)