[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Traverso-commit] traverso/src core/Export.cpp core/Export.h core...
From: |
Nicola Doebelin |
Subject: |
[Traverso-commit] traverso/src core/Export.cpp core/Export.h core... |
Date: |
Wed, 09 May 2007 20:11:47 +0000 |
CVSROOT: /sources/traverso
Module name: traverso
Changes by: Nicola Doebelin <n_doebelin> 07/05/09 20:11:47
Modified files:
src/core : Export.cpp Export.h Marker.cpp Marker.h
Project.cpp Project.h Song.cpp Song.h
TimeLine.cpp TimeLine.h
src/traverso/songcanvas: TimeLineView.cpp
Log message:
Improved cdrdao-export. When exporting "All Songs", a correct TOC file
is written
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/traverso/src/core/Export.cpp?cvsroot=traverso&r1=1.5&r2=1.6
http://cvs.savannah.gnu.org/viewcvs/traverso/src/core/Export.h?cvsroot=traverso&r1=1.6&r2=1.7
http://cvs.savannah.gnu.org/viewcvs/traverso/src/core/Marker.cpp?cvsroot=traverso&r1=1.9&r2=1.10
http://cvs.savannah.gnu.org/viewcvs/traverso/src/core/Marker.h?cvsroot=traverso&r1=1.9&r2=1.10
http://cvs.savannah.gnu.org/viewcvs/traverso/src/core/Project.cpp?cvsroot=traverso&r1=1.38&r2=1.39
http://cvs.savannah.gnu.org/viewcvs/traverso/src/core/Project.h?cvsroot=traverso&r1=1.18&r2=1.19
http://cvs.savannah.gnu.org/viewcvs/traverso/src/core/Song.cpp?cvsroot=traverso&r1=1.89&r2=1.90
http://cvs.savannah.gnu.org/viewcvs/traverso/src/core/Song.h?cvsroot=traverso&r1=1.49&r2=1.50
http://cvs.savannah.gnu.org/viewcvs/traverso/src/core/TimeLine.cpp?cvsroot=traverso&r1=1.5&r2=1.6
http://cvs.savannah.gnu.org/viewcvs/traverso/src/core/TimeLine.h?cvsroot=traverso&r1=1.5&r2=1.6
http://cvs.savannah.gnu.org/viewcvs/traverso/src/traverso/songcanvas/TimeLineView.cpp?cvsroot=traverso&r1=1.31&r2=1.32
Patches:
Index: core/Export.cpp
===================================================================
RCS file: /sources/traverso/traverso/src/core/Export.cpp,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -b -r1.5 -r1.6
--- core/Export.cpp 8 May 2007 01:15:59 -0000 1.5
+++ core/Export.cpp 9 May 2007 20:11:47 -0000 1.6
@@ -17,7 +17,7 @@
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- $Id: Export.cpp,v 1.5 2007/05/08 01:15:59 r_sijrier Exp $
+ $Id: Export.cpp,v 1.6 2007/05/09 20:11:47 n_doebelin Exp $
*/
#include "Export.h"
@@ -62,6 +62,7 @@
breakout = false;
isRecording = -1;
exportdir = "";
+ basename = "";
name = "";
writeToc = false;
normalize = false;
Index: core/Export.h
===================================================================
RCS file: /sources/traverso/traverso/src/core/Export.h,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -b -r1.6 -r1.7
--- core/Export.h 8 May 2007 01:15:59 -0000 1.6
+++ core/Export.h 9 May 2007 20:11:47 -0000 1.7
@@ -17,7 +17,7 @@
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
-$Id: Export.h,v 1.6 2007/05/08 01:15:59 r_sijrier Exp $
+$Id: Export.h,v 1.7 2007/05/09 20:11:47 n_doebelin Exp $
*/
#ifndef EXPORT_H
@@ -74,6 +74,7 @@
bool allSongs;
int isRecording;
QString exportdir;
+ QString basename;
QString name;
bool writeToc;
bool normalize;
Index: core/Marker.cpp
===================================================================
RCS file: /sources/traverso/traverso/src/core/Marker.cpp,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -b -r1.9 -r1.10
--- core/Marker.cpp 10 Apr 2007 19:37:57 -0000 1.9
+++ core/Marker.cpp 9 May 2007 20:11:47 -0000 1.10
@@ -25,7 +25,7 @@
#include "TimeLine.h"
#include "Utils.h"
-Marker::Marker(TimeLine* tl, nframes_t when, uint type)
+Marker::Marker(TimeLine* tl, nframes_t when, Type type)
: ContextItem()
, Snappable()
, m_timeline(tl)
@@ -63,7 +63,6 @@
domNode.setAttribute("position", m_when);
domNode.setAttribute("description", m_description);
- domNode.setAttribute("type", m_type);
domNode.setAttribute("id", m_id);
domNode.setAttribute("performer", m_performer);
domNode.setAttribute("composer", m_composer);
@@ -74,6 +73,18 @@
domNode.setAttribute("preemphasis", m_preemph);
domNode.setAttribute("copyprotection", m_copyprotect);
+ switch (m_type) {
+ case CDTRACK:
+ domNode.setAttribute("type", "CDTRACK");
+ break;
+ case TEMPORARY:
+ domNode.setAttribute("type", "TEMPORARY");
+ break;
+ case ENDMARKER:
+ domNode.setAttribute("type", "ENDMARKER");
+ break;
+ }
+
return domNode;
}
@@ -82,7 +93,7 @@
QDomElement e = node.toElement();
m_description = e.attribute("description", "");
- m_type = e.attribute("type", "0").toUInt();
+ QString tp = e.attribute("type", "CDTRACK");
m_when = e.attribute("position", "0").toUInt();
m_id = e.attribute("id", "0").toLongLong();
m_performer = e.attribute("performer", "");
@@ -94,6 +105,10 @@
m_preemph = e.attribute("preemphasis", "0").toInt();
m_copyprotect = e.attribute("copyprotection", "0").toInt();
+ if (tp == "CDTRACK") m_type = CDTRACK;
+ if (tp == "TEMPORARY") m_type = TEMPORARY;
+ if (tp == "ENDMARKER") m_type = ENDMARKER;
+
return 1;
}
Index: core/Marker.h
===================================================================
RCS file: /sources/traverso/traverso/src/core/Marker.h,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -b -r1.9 -r1.10
--- core/Marker.h 22 Apr 2007 20:05:38 -0000 1.9
+++ core/Marker.h 9 May 2007 20:11:47 -0000 1.10
@@ -35,7 +35,13 @@
Q_OBJECT
public:
- Marker(TimeLine* tl, nframes_t when, uint type = 0);
+ enum Type {
+ CDTRACK,
+ TEMPORARY,
+ ENDMARKER
+ };
+
+ Marker(TimeLine* tl, nframes_t when, Type type = CDTRACK);
Marker(TimeLine* tl, const QDomNode node);
~Marker() {};
@@ -64,7 +70,7 @@
QString get_isrc() const {return m_isrc;}
bool get_preemphasis();
bool get_copyprotect();
- uint get_type() {return m_type;};
+ Type get_type() {return m_type;};
private:
TimeLine* m_timeline;
@@ -78,7 +84,7 @@
m_isrc;
bool m_preemph,
m_copyprotect;
- uint m_type;
+ Type m_type;
signals:
void positionChanged(Snappable*);
Index: core/Project.cpp
===================================================================
RCS file: /sources/traverso/traverso/src/core/Project.cpp,v
retrieving revision 1.38
retrieving revision 1.39
diff -u -b -r1.38 -r1.39
--- core/Project.cpp 8 May 2007 01:15:59 -0000 1.38
+++ core/Project.cpp 9 May 2007 20:11:47 -0000 1.39
@@ -23,6 +23,7 @@
#include <QDir>
#include <QTextStream>
#include <QMessageBox>
+#include <QString>
#include <sys/stat.h>
#include <sys/types.h>
@@ -461,6 +462,7 @@
songsToRender.append(song);
}
+ QString cdrdaoImg = get_cdrdao_header(spec);
foreach(Song* song, songsToRender) {
PMESG("Starting export for song %lld", song->get_id());
@@ -496,6 +498,8 @@
continue;
}
+ cdrdaoImg += song->get_cdrdao_tracklist(spec);
+
while(song->render(spec) > 0) {}
song->set_transport_pos(spec->resumeTransportFrame);
@@ -511,6 +515,27 @@
renderedSongs++;
}
+ if (spec->writeToc) {
+ PMESG("Writing cdrdao toc-file");
+
+ QString name = spec->exportdir + "/";
+
+ if (spec->allSongs) {
+ // filename of the toc file is "project-name.toc"
+ name += get_title() + ".toc";
+ } else {
+ // filename of the toc file is "song-name.toc"
+ name += spec->basename + ".toc";
+ }
+
+ QFile file(name);
+
+ if (file.open(QFile::WriteOnly)) {
+ QTextStream out(&file);
+ out << cdrdaoImg;
+ }
+ }
+
PMESG("Export Finished");
spec->running = false;
@@ -522,6 +547,29 @@
return 1;
}
+QString Project::get_cdrdao_header(ExportSpecification* spec)
+{
+ QString output;
+
+ output += "CD_DA\n\n";
+ output += "CD_TEXT {\n";
+
+ output += " LANGUAGE_MAP {\n 0 : EN\n }\n\n";
+
+ output += " LANGUAGE 0 {\n";
+ output += " TITLE \"" + get_title() + "\"\n";
+ output += " PERFORMER \"\"\n";
+ output += " DISC_ID \"\"\n";
+ output += " UPC_EAN \"\"\n\n";
+
+ output += " ARRANGER \"\"\n";
+ output += " SONGWRITER \"\"\n";
+ output += " MESSAGE \"\"\n";
+ output += " GENRE \"\"\n }\n}\n\n";
+
+ return output;
+}
+
Command* Project::select()
{
int index = ie().collected_number();
Index: core/Project.h
===================================================================
RCS file: /sources/traverso/traverso/src/core/Project.h,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -b -r1.18 -r1.19
--- core/Project.h 3 May 2007 14:04:59 -0000 1.18
+++ core/Project.h 9 May 2007 20:11:47 -0000 1.19
@@ -108,6 +108,7 @@
qint64 m_currentSongId;
int create(int songcount, int numtracks);
+ QString get_cdrdao_header(ExportSpecification* spec);
friend class ProjectManager;
Index: core/Song.cpp
===================================================================
RCS file: /sources/traverso/traverso/src/core/Song.cpp,v
retrieving revision 1.89
retrieving revision 1.90
diff -u -b -r1.89 -r1.90
--- core/Song.cpp 9 May 2007 01:58:25 -0000 1.89
+++ core/Song.cpp 9 May 2007 20:11:47 -0000 1.90
@@ -365,7 +365,8 @@
if (m_id < 10) {
idString.prepend("0");
}
- spec->name = "Song" + QString::number(m_project->get_song_index(m_id))
+"-" + title + spec->extension;
+ spec->basename = "Song" +
QString::number(m_project->get_song_index(m_id)) +"-" + title;
+ spec->name = spec->basename + spec->extension;
if (spec->start_frame >= spec->end_frame) {
PWARN("illegal frame range in export specification");
@@ -377,10 +378,6 @@
return -1;
}
- if (spec->writeToc) {
- write_cdrdao_toc(spec);
- }
-
if (spec->renderpass == ExportSpecification::WRITE_TO_HARDDISK) {
m_exportSource = new WriteSource(spec);
}
@@ -865,44 +862,46 @@
return 1;
}
-void Song::write_cdrdao_toc(ExportSpecification* spec)
+QString Song::get_cdrdao_tracklist(ExportSpecification* spec)
{
- QString idString = QString::number(m_id);
- if (m_id < 10) {
- idString.prepend("0");
- }
- QString name = spec->exportdir + "/";
- QFileInfo fi(spec->name);
- QString basename = fi.completeBaseName() + ".toc";
- name += basename;
-
- QFile file(name);
-
- // check if the selected file can be opened for writing
- if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) {
- printf("Could not open file for writing.");
- return;
- }
-
- QTextStream out(&file);
- out << "CD_DA\n\n";
- out << "CD_TEXT {\n";
-
- out << " LANGUAGE_MAP {\n 0 : EN\n }\n\n";
-
- out << " LANGUAGE 0 {\n";
- out << " TITLE \"" << m_project->get_title() << "\"\n";
- out << " PERFORMER \"\"\n";
- out << " DISC_ID \"\"\n";
- out << " UPC_EAN \"\"\n\n";
-
- out << " ARRANGER \"\"\n";
- out << " SONGWRITER \"\"\n";
- out << " MESSAGE \"\"\n";
- out << " GENRE \"\"\n }\n}\n\n";
+ QString output;
QList<Marker*> mlist = m_timeline->get_markers();
+ //Â Here we make the marker-stuff idiot-proof ;-). Traverso doesn't
insist on having any
+ //Â marker at all, so we need to handle cases like:
+ // - no markers at all
+ // - one marker (doesn't make sense)
+ // - enough markers, but no end marker
+
+ if (mlist.size() < 2) {
+ switch (mlist.size()) {
+ case 0:
+ // no markers present. We add one at the
beginning and one at the
+ // end of the render area.
+ mlist.append(new Marker(m_timeline,
spec->start_frame, Marker::TEMPORARY));
+ mlist.append(new Marker(m_timeline,
spec->end_frame, Marker::TEMPORARY));
+ break;
+ case 1:
+ // one marker is present. We add two more at
the beginning
+ // and at the end of the render area. But we
must check if
+ // the present marker happens to be at one of
these positions.
+ if (mlist.at(0)->get_when() !=
spec->start_frame) {
+ mlist.append(new Marker(m_timeline,
spec->start_frame, Marker::TEMPORARY));
+ }
+ if (mlist.at(0)->get_when() != spec->end_frame)
{
+ mlist.append(new Marker(m_timeline,
spec->end_frame, Marker::TEMPORARY));
+ }
+ break;
+ }
+ } else {
+ //Â would be ok, but let's check if there is an end marker
present. If not,
+ //Â add one to spec->end_frame
+ if (!m_timeline->has_end_marker()) {
+ mlist.append(new Marker(m_timeline, spec->end_frame,
Marker::TEMPORARY));
+ }
+ }
+
// Sort the list according to Marker::get_when() values. This
// is the correct way to do it according to the Qt docu.
QMap<nframes_t, Marker*> mmap;
@@ -911,36 +910,36 @@
}
mlist = mmap.values();
- nframes_t start;
+ nframes_t start = 0;
for(int i = 0; i < mlist.size()-1; ++i) {
Marker *m_start = mlist.at(i);
Marker *m_end = mlist.at(i+1);
- out << "TRACK AUDIO\n";
+ output += "TRACK AUDIO\n";
if (m_start->get_copyprotect()) {
- out << " NO COPY\n";
+ output += " NO COPY\n";
} else {
- out << " COPY\n";
+ output += " COPY\n";
}
if (m_start->get_preemphasis()) {
- out << " PRE_EMPHASIS\n";
+ output += " PRE_EMPHASIS\n";
}
- out << " CD_TEXT {\n LANGUAGE 0 {\n";
- out << " TITLE \"" << m_start->get_description() << "\"\n";
- out << " PERFORMER \"" << m_start->get_performer() <<
"\"\n";
- out << " ISRC \"" << m_start->get_isrc() << "\"\n";
- out << " ARRANGER \"" << m_start->get_arranger() << "\"\n";
- out << " SONGWRITER \"" << m_start->get_songwriter() <<
"\"\n";
- out << " MESSAGE \"" << m_start->get_message() << "\"\n
}\n }\n";
+ output += " CD_TEXT {\n LANGUAGE 0 {\n";
+ output += " TITLE \"" + m_start->get_description() +
"\"\n";
+ output += " PERFORMER \"" + m_start->get_performer() +
"\"\n";
+ output += " ISRC \"" + m_start->get_isrc() + "\"\n";
+ output += " ARRANGER \"" + m_start->get_arranger() +
"\"\n";
+ output += " SONGWRITER \"" + m_start->get_songwriter() +
"\"\n";
+ output += " MESSAGE \"" + m_start->get_message() + "\"\n
}\n }\n";
if (i == 0) {
start = cd_to_frame(frame_to_cd(m_start->get_when(),
m_project->get_rate()), m_project->get_rate());
// I thought some cd players required a 2-second PREGAP
on the first track?
// FIXME: Uncomment, remove, or make configurable in
the Export dialog.
- // out << " PREGAP 0:02:00\n";
+ // output += " PREGAP 0:02:00\n";
}
nframes_t end = cd_to_frame(frame_to_cd(m_end->get_when(),
m_project->get_rate()), m_project->get_rate());
@@ -949,9 +948,25 @@
QString s_start = frame_to_cd(start, m_project->get_rate());
QString s_length = frame_to_cd(length, m_project->get_rate());
- out << " FILE \"" << spec->name << "\" " << s_start << " " <<
s_length << "\n\n";
+ output += " FILE \"" + spec->name + "\" " + s_start + " " +
s_length + "\n\n";
start += length;
+
+ // check if the second marker is of type "Endmarker"
+ if (m_end->get_type() == 10) {
+ break;
+ }
}
+
+ //Â delete all temporary markers
+ for(int i = mlist.size() - 1; i >= 0; --i) {
+ Marker *marker = mlist.at(i);
+ if (marker->get_type() == Marker::TEMPORARY) {
+ mlist.removeAt(i);
+ delete marker;
+ }
+ }
+
+ return output;
}
void Song::resize_buffer(bool updateArmStatus, nframes_t size)
Index: core/Song.h
===================================================================
RCS file: /sources/traverso/traverso/src/core/Song.h,v
retrieving revision 1.49
retrieving revision 1.50
diff -u -b -r1.49 -r1.50
--- core/Song.h 8 May 2007 01:15:59 -0000 1.49
+++ core/Song.h 9 May 2007 20:11:47 -0000 1.50
@@ -132,7 +132,7 @@
void disconnect_from_audiodevice();
void connect_to_audiodevice();
void schedule_for_deletion();
- void write_cdrdao_toc(ExportSpecification* spec);
+ QString get_cdrdao_tracklist(ExportSpecification* spec);
audio_sample_t* mixdown;
audio_sample_t* gainbuffer;
Index: core/TimeLine.cpp
===================================================================
RCS file: /sources/traverso/traverso/src/core/TimeLine.cpp,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -b -r1.5 -r1.6
--- core/TimeLine.cpp 22 Apr 2007 20:05:38 -0000 1.5
+++ core/TimeLine.cpp 9 May 2007 20:11:47 -0000 1.6
@@ -127,7 +127,7 @@
bool TimeLine::get_end_position(nframes_t & pos)
{
foreach(Marker* marker, m_markers) {
- if (marker->get_type() == 10) {
+ if (marker->get_type() == Marker::ENDMARKER) {
pos = marker->get_when();
return true;
}
@@ -136,6 +136,17 @@
return false;
}
+bool TimeLine::has_end_marker()
+{
+ foreach(Marker* marker, m_markers) {
+ if (marker->get_type() == Marker::ENDMARKER) {
+ return true;
+ }
+ }
+
+ return false;
+}
+
//eof
Index: core/TimeLine.h
===================================================================
RCS file: /sources/traverso/traverso/src/core/TimeLine.h,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -b -r1.5 -r1.6
--- core/TimeLine.h 22 Apr 2007 20:05:38 -0000 1.5
+++ core/TimeLine.h 9 May 2007 20:11:47 -0000 1.6
@@ -45,6 +45,7 @@
Marker* get_marker(qint64 id);
bool get_end_position(nframes_t &pos);
+ bool has_end_marker();
Command* add_marker(Marker* marker, bool historable=true);
Command* remove_marker(Marker* marker, bool historable=true);
Index: traverso/songcanvas/TimeLineView.cpp
===================================================================
RCS file: /sources/traverso/traverso/src/traverso/songcanvas/TimeLineView.cpp,v
retrieving revision 1.31
retrieving revision 1.32
diff -u -b -r1.31 -r1.32
--- traverso/songcanvas/TimeLineView.cpp 9 May 2007 13:48:04 -0000
1.31
+++ traverso/songcanvas/TimeLineView.cpp 9 May 2007 20:11:47 -0000
1.32
@@ -341,19 +341,19 @@
// check if it is the first marker added to the timeline
if (!m_timeline->get_markers().size()) {
if (when > 0) { // add one at the beginning of the song
- Marker* m = new Marker(m_timeline, 0);
+ Marker* m = new Marker(m_timeline, Marker::CDTRACK);
m->set_description("");
group->add_command(m_timeline->add_marker(m));
}
if (when < m_sv->get_song()->get_last_frame()) { // add one at
the end of the song
- Marker* me = new Marker(m_timeline,
m_sv->get_song()->get_last_frame(), 10);
+ Marker* me = new Marker(m_timeline,
m_sv->get_song()->get_last_frame(), Marker::ENDMARKER);
me->set_description(tr("End"));
group->add_command(m_timeline->add_marker(me));
}
}
- Marker* marker = new Marker(m_timeline, when);
+ Marker* marker = new Marker(m_timeline, when, Marker::CDTRACK);
marker->set_description("");
group->setText(tr("Add Marker"));