[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: |
Sun, 03 May 2009 21:47:34 +0000 |
CVSROOT: /sources/traverso
Module name: traverso
Changes by: Nicola Doebelin <n_doebelin> 09/05/03 21:47:33
Modified files:
src/core : Export.cpp Export.h Project.cpp Project.h
Sheet.cpp Sheet.h TimeLine.cpp TimeLine.h
src/traverso/dialogs: ExportDialog.cpp ExportDialog.h
Log message:
* export and CD-burning writes each CD-track into a separate file.
Seems to work but needs some serious testing.
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/traverso/src/core/Export.cpp?cvsroot=traverso&r1=1.16&r2=1.17
http://cvs.savannah.gnu.org/viewcvs/traverso/src/core/Export.h?cvsroot=traverso&r1=1.18&r2=1.19
http://cvs.savannah.gnu.org/viewcvs/traverso/src/core/Project.cpp?cvsroot=traverso&r1=1.69&r2=1.70
http://cvs.savannah.gnu.org/viewcvs/traverso/src/core/Project.h?cvsroot=traverso&r1=1.31&r2=1.32
http://cvs.savannah.gnu.org/viewcvs/traverso/src/core/Sheet.cpp?cvsroot=traverso&r1=1.25&r2=1.26
http://cvs.savannah.gnu.org/viewcvs/traverso/src/core/Sheet.h?cvsroot=traverso&r1=1.9&r2=1.10
http://cvs.savannah.gnu.org/viewcvs/traverso/src/core/TimeLine.cpp?cvsroot=traverso&r1=1.20&r2=1.21
http://cvs.savannah.gnu.org/viewcvs/traverso/src/core/TimeLine.h?cvsroot=traverso&r1=1.15&r2=1.16
http://cvs.savannah.gnu.org/viewcvs/traverso/src/traverso/dialogs/ExportDialog.cpp?cvsroot=traverso&r1=1.14&r2=1.15
http://cvs.savannah.gnu.org/viewcvs/traverso/src/traverso/dialogs/ExportDialog.h?cvsroot=traverso&r1=1.4&r2=1.5
Patches:
Index: core/Export.cpp
===================================================================
RCS file: /sources/traverso/traverso/src/core/Export.cpp,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -b -r1.16 -r1.17
--- core/Export.cpp 21 Jan 2008 16:22:13 -0000 1.16
+++ core/Export.cpp 3 May 2009 21:47:32 -0000 1.17
@@ -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.16 2008/01/21 16:22:13 r_sijrier Exp $
+ $Id: Export.cpp,v 1.17 2009/05/03 21:47:32 n_doebelin Exp $
*/
#include "Export.h"
@@ -53,6 +53,8 @@
channels = -1;
startLocation = qint64(-1);
endLocation = qint64(-1);
+ trackStart = qint64(-1);
+ trackEnd = qint64(-1);
dither_type = GDitherTri;
dataF = 0;
Index: core/Export.h
===================================================================
RCS file: /sources/traverso/traverso/src/core/Export.h,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -b -r1.18 -r1.19
--- core/Export.h 21 Jan 2008 16:22:13 -0000 1.18
+++ core/Export.h 3 May 2009 21:47:32 -0000 1.19
@@ -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.18 2008/01/21 16:22:13 r_sijrier Exp $
+$Id: Export.h,v 1.19 2009/05/03 21:47:32 n_doebelin Exp $
*/
#ifndef EXPORT_H
@@ -34,6 +34,7 @@
class Project;
class ExportThread;
+class Marker;
struct ExportSpecification
{
@@ -52,6 +53,8 @@
int channels;
TimeRef startLocation;
TimeRef endLocation;
+ TimeRef trackStart;
+ TimeRef trackEnd;
GDitherType dither_type;
/* used exclusively during export */
@@ -89,6 +92,7 @@
TimeRef resumeTransportLocation;
bool renderfinished;
bool isCdExport;
+ QList<Marker*> markers;
ExportThread* thread;
};
Index: core/Project.cpp
===================================================================
RCS file: /sources/traverso/traverso/src/core/Project.cpp,v
retrieving revision 1.69
retrieving revision 1.70
diff -u -b -r1.69 -r1.70
--- core/Project.cpp 26 Apr 2009 19:22:29 -0000 1.69
+++ core/Project.cpp 3 May 2009 21:47:32 -0000 1.70
@@ -605,7 +605,7 @@
continue;
}
- while(sheet->render(spec) > 0) {}
+ sheet->start_export(spec);
spec->normvalue = (1.0 - FLT_EPSILON) / spec->peakvalue;
@@ -629,7 +629,7 @@
}
// ... then start the render process and wait until it's
finished
- while(sheet->render(spec) > 0) {}
+ sheet->start_export(spec);
if (!QMetaObject::invokeMethod(sheet, "set_transport_pos",
Qt::QueuedConnection, Q_ARG(TimeRef, spec->resumeTransportLocation))) {
printf("Invoking Sheet::set_transport_pos() failed\n");
@@ -659,6 +659,7 @@
return 1;
}
+// this method is called by the CDWritingDialog
int Project::create_cdrdao_toc(ExportSpecification* spec)
{
QList<Sheet* > sheets;
@@ -765,6 +766,12 @@
emit overallExportProgressChanged(overallExportProgress);
}
+void Project::set_export_message(QString message)
+{
+ emit exportMessage(message);
+}
+
+
QList<Sheet* > Project::get_sheets( ) const
{
return m_sheets;
Index: core/Project.h
===================================================================
RCS file: /sources/traverso/traverso/src/core/Project.h,v
retrieving revision 1.31
retrieving revision 1.32
diff -u -b -r1.31 -r1.32
--- core/Project.h 1 Jan 2009 11:30:09 -0000 1.31
+++ core/Project.h 3 May 2009 21:47:32 -0000 1.32
@@ -81,6 +81,7 @@
void set_upc_ean(const QString& pUPC);
void set_genre(int pGenre);
void set_sheet_export_progress(int pogress);
+ void set_export_message(QString message);
void set_current_sheet(qint64 id);
void set_import_dir(const QString& dir);
@@ -159,6 +160,7 @@
void exportFinished();
void exportStartedForSheet(Sheet* );
void projectLoadFinished();
+ void exportMessage(QString);
};
#endif
Index: core/Sheet.cpp
===================================================================
RCS file: /sources/traverso/traverso/src/core/Sheet.cpp,v
retrieving revision 1.25
retrieving revision 1.26
diff -u -b -r1.25 -r1.26
--- core/Sheet.cpp 26 Apr 2009 19:22:29 -0000 1.25
+++ core/Sheet.cpp 3 May 2009 21:47:33 -0000 1.26
@@ -424,8 +424,6 @@
}
if (spec->isCdExport) {
- QList<Marker*> markers = m_timeline->get_markers();
-
if (m_timeline->get_start_location(startlocation)) {
PMESG2(" Start marker found at %s",
QS_C(timeref_to_ms(startlocation)));
// round down to the start of the CD frame (75th of a
sec)
@@ -443,6 +441,7 @@
}
}
+ // compute some default values
spec->totalTime = spec->endLocation - spec->startLocation;
// PWARN("Render length is:
%s",timeref_to_ms_3(spec->totalTime).toAscii().data() );
@@ -471,14 +470,6 @@
return 1;
}
- if (spec->renderpass == ExportSpecification::WRITE_TO_HARDDISK) {
- m_exportSource = new WriteSource(spec);
- if (m_exportSource->prepare_export() == -1) {
- delete m_exportSource;
- return -1;
- }
- }
-
m_transportLocation = spec->startLocation;
resize_buffer(false, spec->blocksize);
@@ -490,24 +481,67 @@
int Sheet::finish_audio_export()
{
- m_exportSource->finish_export();
- delete m_exportSource;
+ qDebug("export: done, tidying up and exiting");
delete renderDecodeBuffer;
resize_buffer(false, audiodevice().get_buffer_size());
+ m_rendering = false;
return 0;
}
-// this function is called from the parent project. It sends the audio data
-// to Sheet::export_process(), which does the acutal processing, but
normalisation
-// and writing to disk is done here.
+// this function is called from the parent project. if several cd-tracks
should be exported
+// to separate files, we will call the render() process for each file.
+int Sheet::start_export(ExportSpecification* spec)
+{
+ QString message;
+ spec->markers = get_cdtrack_list(spec);
+
+ for (int i = 0; i < spec->markers.size()-1; ++i) {
+ spec->trackStart = spec->markers.at(i)->get_when();
+ spec->trackEnd = spec->markers.at(i+1)->get_when();
+ spec->name =
format_track_name(spec->markers.at(i)->get_description(), i+1);
+ spec->totalTime = spec->trackEnd - spec->trackStart;
+ spec->pos = spec->trackStart;
+ m_transportLocation = spec->trackStart;
+
+ if (spec->renderpass ==
ExportSpecification::WRITE_TO_HARDDISK) {
+ m_exportSource = new WriteSource(spec);
+
+ if (m_exportSource->prepare_export() == -1) {
+ delete m_exportSource;
+ return -1;
+ }
+
+ message = QString(tr("Rendering Sheet %1 - Track %2 of
%3")).arg(title).arg(i+1).arg(spec->markers.size()-1);
+
+ } else if (spec->renderpass ==
ExportSpecification::CALC_NORM_FACTOR) {
+ message = QString(tr("Normalising Sheet %1 - Track %2
of %3")).arg(title).arg(i+1).arg(spec->markers.size()-1);
+ }
+
+ m_project->set_export_message(message);
+
+ qDebug("export: starting render process");
+ while(render(spec) > 0) {}
+
+ if (spec->renderpass ==
ExportSpecification::WRITE_TO_HARDDISK) {
+ qDebug("export: deleting writesource");
+ m_exportSource->finish_export();
+ delete m_exportSource;
+ }
+ qDebug("restarting loop");
+ }
+
+ finish_audio_export();
+ return 1;
+}
+
int Sheet::render(ExportSpecification* spec)
{
int chn;
uint32_t x;
int ret = -1;
- int progress;
+ int progress = 0;
- nframes_t diff = (spec->endLocation -
spec->pos).to_frame(audiodevice().get_sample_rate());
+ nframes_t diff = (spec->trackEnd -
spec->pos).to_frame(audiodevice().get_sample_rate());
nframes_t nframes = spec->blocksize;
nframes_t this_nframes = std::min(diff, nframes);
@@ -517,12 +551,8 @@
PWARN("running is %d", spec->running);
PWARN("stop is %d", spec->stop);
PWARN("this_nframes is %d", this_nframes);*/
- if (spec->renderpass == ExportSpecification::WRITE_TO_HARDDISK)
{
- return finish_audio_export();
- } else {
return 0;
}
- }
/* do the usual stuff */
@@ -572,19 +602,9 @@
spec->pos.add_frames(nframes, audiodevice().get_sample_rate());
- if (! spec->normalize ) {
- progress = int((double((spec->pos -
spec->startLocation).universal_frame()) / spec->totalTime.universal_frame()) *
100);
- } else {
- progress = (int) (double( 100 * (spec->pos -
spec->startLocation).universal_frame()) / (spec->totalTime.universal_frame() *
2));
- if (spec->renderpass == ExportSpecification::WRITE_TO_HARDDISK)
{
- progress += 50;
- }
- }
-
- if (progress > spec->progress) {
+ progress = (int) (double( 100 * (spec->pos -
spec->trackStart).universal_frame()) / (spec->totalTime.universal_frame()));
spec->progress = progress;
m_project->set_sheet_export_progress(progress);
- }
/* and we're good to go */
@@ -593,14 +613,47 @@
out:
if (!ret) {
- spec->running = false;
spec->status = ret;
- m_rendering = false;
}
return ret;
}
+// formatting the track names in a separate function to guarantee that
+// the file names of exported tracks and the entry in the TOC file always
+// match
+QString Sheet::format_track_name(QString n, int i)
+{
+ QString name;
+ if (n.isEmpty()) {
+ name = QString("%1").arg(i, 2, 10, QChar('0'));
+ } else {
+ name = QString("%1-%2").arg(i, 2, 10, QChar('0')).arg(n);
+ }
+
+ name.replace(QRegExp("\\s"), "_");
+ return name;
+}
+
+// creates a valid list of markers for CD export. Takes care of special cases
+// such as if no markers are present, or if an end marker is missing.
+QList<Marker*> Sheet::get_cdtrack_list(ExportSpecification *spec)
+{
+ bool endmarker;
+ QList<Marker*> lst = m_timeline->get_cd_layout(endmarker);
+
+ // make sure there are at least a start- and end-marker in the list
+ if (lst.size() == 0) {
+ lst.push_back(new Marker(m_timeline, spec->startLocation,
Marker::CDTRACK));
+ }
+
+ if (!endmarker) {
+ lst.push_back(new Marker(m_timeline, spec->endLocation,
Marker::ENDMARKER));
+ }
+
+ return lst;
+}
+
SnapList* Sheet::get_snap_list() const
{
@@ -879,61 +932,9 @@
{
QString output;
- QList<Marker*> mlist = m_timeline->get_markers();
- QList<Marker*> tempmarkers;
+ QList<Marker*> mlist = get_cdtrack_list(spec);
- // 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
-
- Marker* temp;
-
- 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.
- temp = new Marker(m_timeline,
spec->startLocation, Marker::CDTRACK);
- tempmarkers.append(temp);
- mlist.prepend(temp);
- temp = new Marker(m_timeline,
spec->endLocation, Marker::ENDMARKER);
- tempmarkers.append(temp);
- mlist.append(temp);
- break;
- case 1:
- // one marker is present. We add two more, one
at the beginning
- // and one at the end of the render area. If
the present marker
- // happened to be at either the start or the
end position,
- // it will now be overwritten, so we will never
end up with
- // two markers at the same position.
-
- // deactivate the next if-condition (only the
first one) if you want the
- // stuff before the first marker to go into the
pre-gap
- if (mlist.at(0)->get_when() !=
(spec->startLocation)) {
- temp = new Marker(m_timeline,
spec->startLocation, Marker::CDTRACK);
- tempmarkers.append(temp);
- mlist.prepend(temp);
- }
- if (mlist.at(0)->get_when() !=
(spec->startLocation)) {
- temp = new Marker(m_timeline,
spec->endLocation, Marker::ENDMARKER);
- tempmarkers.append(temp);
- mlist.append(temp);
- }
- 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()) {
- temp = new Marker(m_timeline, spec->endLocation,
Marker::ENDMARKER);
- tempmarkers.append(temp);
- mlist.append(temp);
- }
- }
-
- TimeRef start;
+// TimeRef start;
for(int i = 0; i < mlist.size()-1; ++i) {
@@ -973,13 +974,14 @@
//}
}
- TimeRef length =
cd_to_timeref(timeref_to_cd(endmarker->get_when())) -
cd_to_timeref(timeref_to_cd(startmarker->get_when()));
+// TimeRef length =
cd_to_timeref(timeref_to_cd(endmarker->get_when())) -
cd_to_timeref(timeref_to_cd(startmarker->get_when()));
- QString s_start = timeref_to_cd(start);
- QString s_length = timeref_to_cd(length);
+// QString s_start = timeref_to_cd(start);
+// QString s_length = timeref_to_cd(length);
- output += " FILE \"" + spec->name + "." +
spec->extraFormat["filetype"] + "\" " + s_start + " " + s_length + "\n\n";
- start += length;
+// output += " FILE \"" + spec->name + "." +
spec->extraFormat["filetype"] + "\" " + s_start + " " + s_length + "\n\n";
+ output += " FILE \"" +
format_track_name(startmarker->get_description(), i+1) + "." +
spec->extraFormat["filetype"] + "\"\n\n";
+// start += length;
// check if the second marker is of type "Endmarker"
if (endmarker->get_type() == Marker::ENDMARKER) {
@@ -987,11 +989,6 @@
}
}
- // delete all temporary markers
- foreach(Marker* marker, tempmarkers) {
- delete marker;
- }
-
return output;
}
Index: core/Sheet.h
===================================================================
RCS file: /sources/traverso/traverso/src/core/Sheet.h,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -b -r1.9 -r1.10
--- core/Sheet.h 7 Feb 2009 17:41:25 -0000 1.9
+++ core/Sheet.h 3 May 2009 21:47:33 -0000 1.10
@@ -46,6 +46,7 @@
class TimeLine;
class Snappable;
class DecodeBuffer;
+class Marker;
struct ExportSpecification;
@@ -134,6 +135,7 @@
int process_export(nframes_t nframes);
int prepare_export(ExportSpecification* spec);
int render(ExportSpecification* spec);
+ int start_export(ExportSpecification* spec);
void solo_track(Track* track);
void create(int tracksToCreate);
@@ -222,6 +224,8 @@
void start_transport_rolling(bool realtime);
void stop_transport_rolling();
void update_skip_positions();
+ QString format_track_name(QString, int);
+ QList<Marker *> get_cdtrack_list(ExportSpecification*);
void resize_buffer(bool updateArmStatus, nframes_t size);
Index: core/TimeLine.cpp
===================================================================
RCS file: /sources/traverso/traverso/src/core/TimeLine.cpp,v
retrieving revision 1.20
retrieving revision 1.21
diff -u -b -r1.20 -r1.21
--- core/TimeLine.cpp 7 Nov 2008 10:43:08 -0000 1.20
+++ core/TimeLine.cpp 3 May 2009 21:47:33 -0000 1.21
@@ -196,3 +196,23 @@
}
}
+// returns all markers of type CDTRACK
+// sets 'endmarker' to true if an endmarker is present, else to false.
+QList<Marker*> TimeLine::get_cd_layout(bool & endmarker)
+{
+ QList<Marker*> list;
+ endmarker = false;
+
+ foreach(Marker* marker, m_markers) {
+ if (marker->get_type() == Marker::CDTRACK) {
+ list.push_back(marker);
+ }
+
+ if (marker->get_type() == Marker::ENDMARKER) {
+ list.push_back(marker);
+ endmarker = true;
+ }
+ }
+
+ return list;
+}
Index: core/TimeLine.h
===================================================================
RCS file: /sources/traverso/traverso/src/core/TimeLine.h,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -b -r1.15 -r1.16
--- core/TimeLine.h 5 Nov 2008 00:42:22 -0000 1.15
+++ core/TimeLine.h 3 May 2009 21:47:33 -0000 1.16
@@ -43,6 +43,7 @@
int set_state(const QDomNode& node);
QList<Marker*> get_markers() const {return m_markers;}
+ QList<Marker*> get_cd_layout(bool & endmarker);
Sheet *get_sheet() const {return m_sheet;}
Marker* get_marker(qint64 id);
Index: traverso/dialogs/ExportDialog.cpp
===================================================================
RCS file: /sources/traverso/traverso/src/traverso/dialogs/ExportDialog.cpp,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -b -r1.14 -r1.15
--- traverso/dialogs/ExportDialog.cpp 26 Jan 2009 20:11:42 -0000 1.14
+++ traverso/dialogs/ExportDialog.cpp 3 May 2009 21:47:33 -0000 1.15
@@ -94,6 +94,7 @@
connect(m_project, SIGNAL(overallExportProgressChanged(int)), this,
SLOT(update_overall_progress(int)));
connect(m_project, SIGNAL(exportFinished()), this,
SLOT(render_finished()));
connect(m_project, SIGNAL(exportStartedForSheet(Sheet*)), this, SLOT
(set_exporting_sheet(Sheet*)));
+ connect(m_project, SIGNAL(exportMessage(QString)), this,
SLOT(set_export_message(QString)));
// clear extraformats, it might be different now from previous runs!
m_exportSpec->extraFormat.clear();
@@ -164,6 +165,11 @@
progressBar->setValue(progress);
}
+void ExportDialog::set_export_message(QString message)
+{
+ currentProcessingSheetName->setText(message);
+}
+
void ExportDialog::render_finished( )
{
disconnect(m_project, SIGNAL(sheetExportProgressChanged(int)), this,
SLOT(update_sheet_progress(int)));
Index: traverso/dialogs/ExportDialog.h
===================================================================
RCS file: /sources/traverso/traverso/src/traverso/dialogs/ExportDialog.h,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -b -r1.4 -r1.5
--- traverso/dialogs/ExportDialog.h 22 May 2008 14:54:23 -0000 1.4
+++ traverso/dialogs/ExportDialog.h 3 May 2009 21:47:33 -0000 1.5
@@ -61,6 +61,7 @@
void update_overall_progress(int progress);
void render_finished();
void set_exporting_sheet(Sheet* sheet);
+ void set_export_message(QString message);
void on_fileSelectButton_clicked();
void on_startButton_clicked();
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Traverso-commit] traverso/src core/Export.cpp core/Export.h core...,
Nicola Doebelin <=