41#include <wx/textfile.h>
52 kind = (*f)[f->GetCurrentLine()];
54 if (kind == wxT(
"WaveTrack")) {
56 xmlFile.
WriteAttr(wxT(
"name"), f->GetNextLine());
58 wxString channel = f->GetNextLine();
59 if (channel == wxT(
"left")) {
61 line = f->GetNextLine();
63 else if (channel == wxT(
"right")) {
65 line = f->GetNextLine();
67 else if (channel == wxT(
"mono")) {
69 line = f->GetNextLine();
76 if (line == wxT(
"linked")) {
78 line = f->GetNextLine();
81 if (line != wxT(
"offset"))
83 xmlFile.
WriteAttr(wxT(
"offset"), f->GetNextLine());
87 if (f->GetNextLine() != wxT(
"EnvNumPoints"))
89 line = f->GetNextLine();
91 if (envLen < 0 || envLen > 10000)
94 size_t envStart = f->GetCurrentLine();
95 if (f->GetLineCount() < envStart+(2*envLen)+1)
98 f->GoToLine(envStart+(2*envLen));
99 if (f->GetNextLine() != wxT(
"EnvEnd"))
101 if (f->GetNextLine() != wxT(
"numSamples"))
104 wxString numSamples = f->GetNextLine();
106 if (f->GetNextLine() != wxT(
"rate"))
109 xmlFile.
WriteAttr(wxT(
"rate"), f->GetNextLine());
113 xmlFile.
WriteAttr(wxT(
"numpoints"), envLen);
116 for(i=0; i<envLen; i++) {
117 xmlFile.
StartTag(wxT(
"controlpoint"));
118 xmlFile.
WriteAttr(wxT(
"t"), f->GetLine(envStart + 2*i + 1));
119 xmlFile.
WriteAttr(wxT(
"val"), f->GetLine(envStart + 2*i + 2));
120 xmlFile.
EndTag(wxT(
"controlpoint"));
123 xmlFile.
EndTag(wxT(
"envelope"));
126 if (f->GetNextLine() != wxT(
"numBlocks"))
129 line = f->GetNextLine();
130 line.ToLong(&numBlocks);
132 if (numBlocks < 0 || numBlocks > 131072)
136 xmlFile.
WriteAttr(wxT(
"maxsamples"), 524288);
137 xmlFile.
WriteAttr(wxT(
"sampleformat"), 131073);
138 xmlFile.
WriteAttr(wxT(
"numsamples"), numSamples);
141 for(b=0; b<numBlocks; b++) {
146 if (f->GetNextLine() != wxT(
"Block start"))
148 start = f->GetNextLine();
149 if (f->GetNextLine() != wxT(
"Block len"))
151 len = f->GetNextLine();
152 if (f->GetNextLine() != wxT(
"Block info"))
154 name = f->GetNextLine();
159 xmlFile.
StartTag(wxT(
"legacyblockfile"));
160 if (
name == wxT(
"Alias")) {
161 wxString aliasPath = f->GetNextLine();
162 wxString localLen = f->GetNextLine();
163 wxString aliasStart = f->GetNextLine();
164 wxString aliasLen = f->GetNextLine();
165 wxString aliasChannel = f->GetNextLine();
166 wxString localName = f->GetNextLine();
168 xmlFile.
WriteAttr(wxT(
"name"), localName);
170 xmlFile.
WriteAttr(wxT(
"aliaspath"), aliasPath);
173 xmlFile.
WriteAttr(wxT(
"aliasstart"), aliasStart);
175 xmlFile.
WriteAttr(wxT(
"aliaslen"), aliasLen);
176 xmlFile.
WriteAttr(wxT(
"aliaschannel"), aliasChannel);
177 xmlFile.
WriteAttr(wxT(
"summarylen"), localLen);
183 xmlFile.
WriteAttr(wxT(
"summarylen"), 8244);
186 xmlFile.
EndTag(wxT(
"legacyblockfile"));
188 xmlFile.
EndTag(wxT(
"waveblock"));
191 xmlFile.
EndTag(wxT(
"sequence"));
192 xmlFile.
EndTag(wxT(
"wavetrack"));
196 else if (kind == wxT(
"LabelTrack")) {
197 line = f->GetNextLine();
198 if (line != wxT(
"NumMLabels"))
203 line = f->GetNextLine();
204 line.ToLong(&numLabels);
205 if (numLabels < 0 || numLabels > 1000000)
208 xmlFile.
StartTag(wxT(
"labeltrack"));
209 xmlFile.
WriteAttr(wxT(
"name"), wxT(
"Labels"));
210 xmlFile.
WriteAttr(wxT(
"numlabels"), numLabels);
212 for(l=0; l<numLabels; l++) {
215 t = f->GetNextLine();
216 title = f->GetNextLine();
221 xmlFile.
EndTag(wxT(
"label"));
224 xmlFile.
EndTag(wxT(
"labeltrack"));
226 line = f->GetNextLine();
227 if (line != wxT(
"MLabelsEnd"))
232 else if (kind == wxT(
"NoteTrack")) {
236 line = f->GetNextLine();
237 if (line == wxT(
"WaveTrack") ||
238 line == wxT(
"NoteTrack") ||
239 line == wxT(
"LabelTrack") ||
240 line == wxT(
"EndTracks")) {
241 f->GoToLine(f->GetCurrentLine()-1);
244 }
while (f->GetCurrentLine() < f->GetLineCount());
256 const wxString
name = filename.GetFullPath();
261 return GuardedCall< bool >( [&] {
264 xmlFile.Write(wxT(
"<?xml version=\"1.0\"?>\n"));
269 if (f.GetFirstLine() != wxT(
"AudacityProject"))
271 if (f.GetNextLine() != wxT(
"Version"))
273 if (f.GetNextLine() != wxT(
"0.95"))
275 if (f.GetNextLine() != wxT(
"projName"))
278 xmlFile.StartTag(wxT(
"audacityproject"));
279 xmlFile.WriteAttr(wxT(
"projname"), f.GetNextLine());
280 xmlFile.WriteAttr(wxT(
"version"), wxT(
"1.1.0"));
281 xmlFile.WriteAttr(wxT(
"audacityversion"),AUDACITY_VERSION_STRING);
283 label = f.GetNextLine();
284 while (
label != wxT(
"BeginTracks")) {
285 xmlFile.WriteAttr(
label, f.GetNextLine());
286 label = f.GetNextLine();
289 label = f.GetNextLine();
290 while (
label != wxT(
"EndTracks")) {
294 label = f.GetNextLine();
300 xmlFile.EndTag(wxT(
"audacityproject"));
305"Converted a 1.0 project file to the new format.\nThe old file has been saved as '%s'")
306 .
Format( xmlFile.GetBackupName() ),
307 XO(
"Opening Audacity Project"));
int AudacityMessageBox(const TranslatableString &message, const TranslatableString &caption, long style, wxWindow *parent, int x, int y)
const TranslatableString name
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)