traverso-commit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Traverso-commit] traverso/src core/AudioFileCopyConvert.cpp core...


From: Remon Sijrier
Subject: [Traverso-commit] traverso/src core/AudioFileCopyConvert.cpp core...
Date: Thu, 22 May 2008 15:14:18 +0000

CVSROOT:        /sources/traverso
Module name:    traverso
Changes by:     Remon Sijrier <r_sijrier>       08/05/22 15:14:18

Modified files:
        src/core       : AudioFileCopyConvert.cpp AudioFileCopyConvert.h 
        src/traverso/dialogs/project: NewProjectDialog.cpp 
                                      NewProjectDialog.h 

Log message:
        * almost possible to set format options for copied files.. but where to 
put the format options widget ?

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/traverso/src/core/AudioFileCopyConvert.cpp?cvsroot=traverso&r1=1.2&r2=1.3
http://cvs.savannah.gnu.org/viewcvs/traverso/src/core/AudioFileCopyConvert.h?cvsroot=traverso&r1=1.1&r2=1.2
http://cvs.savannah.gnu.org/viewcvs/traverso/src/traverso/dialogs/project/NewProjectDialog.cpp?cvsroot=traverso&r1=1.10&r2=1.11
http://cvs.savannah.gnu.org/viewcvs/traverso/src/traverso/dialogs/project/NewProjectDialog.h?cvsroot=traverso&r1=1.5&r2=1.6

Patches:
Index: core/AudioFileCopyConvert.cpp
===================================================================
RCS file: /sources/traverso/traverso/src/core/AudioFileCopyConvert.cpp,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -b -r1.2 -r1.3
--- core/AudioFileCopyConvert.cpp       22 May 2008 12:55:54 -0000      1.2
+++ core/AudioFileCopyConvert.cpp       22 May 2008 15:14:17 -0000      1.3
@@ -50,7 +50,11 @@
  * @param outfilename 
  * @param tracknumber 
  */
-void AudioFileCopyConvert::enqueue_task(ReadSource * source, const QString& 
dir, const QString & outfilename, int tracknumber)
+void AudioFileCopyConvert::enqueue_task(ReadSource * source,
+       ExportSpecification* spec,
+       const QString& dir,
+       const QString& outfilename,
+       int tracknumber)
 {
        QFileInfo fi(outfilename);
 
@@ -60,6 +64,7 @@
        task.extension = fi.suffix();
        task.tracknumber = tracknumber;
        task.dir = dir;
+       task.spec = spec;
        
        m_mutex.lock();
        m_tasks.enqueue(task);
@@ -87,24 +92,23 @@
        uint buffersize = 16384;
        DecodeBuffer decodebuffer;
        
-       ExportSpecification* spec = new ExportSpecification();
-       spec->startLocation = TimeRef();
-       spec->endLocation = task.readsource->get_length();
-       spec->totalTime = spec->endLocation;
-       spec->pos = TimeRef();
-       spec->isRecording = false;
-       
-       spec->exportdir = task.dir;
-       spec->writerType = "sndfile";
-       spec->extraFormat["filetype"] = "wav";
-       spec->data_width = 1;   // 1 means float
-       spec->channels = task.readsource->get_channel_count();
-       spec->sample_rate = task.readsource->get_rate();
-       spec->blocksize = buffersize;
-       spec->name = task.outFileName;
-       spec->dataF = new audio_sample_t[buffersize * 2];
+       task.spec->startLocation = TimeRef();
+       task.spec->endLocation = task.readsource->get_length();
+       task.spec->totalTime = task.spec->endLocation;
+       task.spec->pos = TimeRef();
+       task.spec->isRecording = false;
+       
+       task.spec->exportdir = task.dir;
+       task.spec->writerType = "sndfile";
+       task.spec->extraFormat["filetype"] = "wav";
+       task.spec->data_width = 1;      // 1 means float
+       task.spec->channels = task.readsource->get_channel_count();
+       task.spec->sample_rate = task.readsource->get_rate();
+       task.spec->blocksize = buffersize;
+       task.spec->name = task.outFileName;
+       task.spec->dataF = new audio_sample_t[buffersize * 2];
        
-       WriteSource* writesource = new WriteSource(spec);
+       WriteSource* writesource = new WriteSource(task.spec);
        bool failedToPrepareWritesource = false;
        int oldprogress = 0;
 
@@ -123,39 +127,39 @@
                        goto out;
                }
                        
-               nframes_t diff = (spec->endLocation - 
spec->pos).to_frame(task.readsource->get_rate());
+               nframes_t diff = (task.spec->endLocation - 
task.spec->pos).to_frame(task.readsource->get_rate());
                nframes_t this_nframes = std::min(diff, buffersize);
                nframes_t nframes = this_nframes;
                
-               memset (spec->dataF, 0, sizeof (spec->dataF[0]) * nframes * 
spec->channels);
+               memset (task.spec->dataF, 0, sizeof (task.spec->dataF[0]) * 
nframes * task.spec->channels);
                
-               task.readsource->file_read(&decodebuffer, spec->pos, nframes);
+               task.readsource->file_read(&decodebuffer, task.spec->pos, 
nframes);
                        
                for (uint x = 0; x < nframes; ++x) {
-                       for (int y = 0; y < spec->channels; ++y) {
-                               spec->dataF[y + x*spec->channels] = 
decodebuffer.destination[y][x];
+                       for (int y = 0; y < task.spec->channels; ++y) {
+                               task.spec->dataF[y + x*task.spec->channels] = 
decodebuffer.destination[y][x];
                        }
                }
                
                // due the fact peak generating does _not_ happen in 
writesource->process
                // but in a function used by DiskIO, we have to hack the peak 
processing 
                // in here.
-               for (int y = 0; y < spec->channels; ++y) {
+               for (int y = 0; y < task.spec->channels; ++y) {
                        writesource->get_peak()->process(y, 
decodebuffer.destination[y], nframes);
                }
                
                // Process the data, and write to disk
                writesource->process(buffersize);
                
-               spec->pos.add_frames(nframes, task.readsource->get_rate());
+               task.spec->pos.add_frames(nframes, task.readsource->get_rate());
                
-               int currentprogress = int(double(spec->pos.universal_frame()) / 
double(spec->totalTime.universal_frame()) * 100);
+               int currentprogress = 
int(double(task.spec->pos.universal_frame()) / 
double(task.spec->totalTime.universal_frame()) * 100);
                if (currentprogress > oldprogress) {
                        oldprogress = currentprogress;
                        emit progress(currentprogress);
                }
                        
-       } while (spec->pos != spec->totalTime);
+       } while (task.spec->pos != task.spec->totalTime);
                
        
        out:
@@ -163,8 +167,8 @@
                writesource->finish_export();
        }
        delete writesource;
-       delete [] spec->dataF;
-       delete spec;
+       delete [] task.spec->dataF;
+       delete task.spec;
        resources_manager()->remove_source(task.readsource);
        
        //  The user asked to stop processing, exit the event loop

Index: core/AudioFileCopyConvert.h
===================================================================
RCS file: /sources/traverso/traverso/src/core/AudioFileCopyConvert.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -b -r1.1 -r1.2
--- core/AudioFileCopyConvert.h 22 May 2008 11:28:34 -0000      1.1
+++ core/AudioFileCopyConvert.h 22 May 2008 15:14:17 -0000      1.2
@@ -27,6 +27,7 @@
 #include <QMutex>
 
 class ReadSource;
+struct ExportSpecification;
 
 class AudioFileCopyConvert : public QThread
 {
@@ -37,7 +38,7 @@
                exec();
        }
        
-       void enqueue_task(ReadSource* source, const QString& dir, const 
QString& outfilename, int tracknumber);
+       void enqueue_task(ReadSource* source, ExportSpecification* spec, const 
QString& dir, const QString& outfilename, int tracknumber);
        void stop_merging();
 
                
@@ -51,6 +52,7 @@
                QString extension;
                int tracknumber;
                ReadSource* readsource;
+               ExportSpecification* spec;
        };
        
        QQueue<CopyTask> m_tasks;

Index: traverso/dialogs/project/NewProjectDialog.cpp
===================================================================
RCS file: 
/sources/traverso/traverso/src/traverso/dialogs/project/NewProjectDialog.cpp,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -b -r1.10 -r1.11
--- traverso/dialogs/project/NewProjectDialog.cpp       22 May 2008 12:55:55 
-0000      1.10
+++ traverso/dialogs/project/NewProjectDialog.cpp       22 May 2008 15:14:17 
-0000      1.11
@@ -39,6 +39,7 @@
 #include <QProgressDialog>
 
 #include <Config.h>
+#include "Export.h"
 #include "Information.h"
 #include "ProjectManager.h"
 #include "ResourcesManager.h"
@@ -51,6 +52,7 @@
 #include "AudioFileCopyConvert.h"
 #include "ReadSource.h"
 
+#include "widgets/ExportFormatOptionsWidget.h"
 
 // Always put me below _all_ includes, this is needed
 // in case we run with memory leak detection enabled!
@@ -69,6 +71,7 @@
 
        m_converter = new AudioFileCopyConvert();
        m_progressDialog = new QProgressDialog(this);
+       m_exportSpec = new ExportSpecification;
 
        connect(useTemplateCheckBox, SIGNAL(stateChanged (int)), this, 
SLOT(use_template_checkbox_state_changed(int)));
        connect(pushButtonAddFiles, SIGNAL(clicked()), this, SLOT(add_files()));
@@ -240,12 +243,14 @@
 
                // TODO: check for free disk space
                // TODO: progress dialog for copying files
-               // TODO: offer file format conversion while copying
+               
+               // TODO: offer file format conversion while copying: format 
options widget not there yet.
+//             m_formatOptionsWidget->get_format_options(m_exportSpec);
 
                ReadSource* readsource = 
resources_manager()->import_source(list.at(n).absolutePath() + "/", 
list.at(n).fileName());
 
                if (readsource) {
-                       m_converter->enqueue_task(readsource, destination, 
list.at(n).fileName(), n);
+                       m_converter->enqueue_task(readsource, m_exportSpec, 
destination, list.at(n).fileName(), n);
        
                        // copy was successful, thus update the file path
                        QTreeWidgetItem* item = 
treeWidgetFiles->topLevelItem(n);

Index: traverso/dialogs/project/NewProjectDialog.h
===================================================================
RCS file: 
/sources/traverso/traverso/src/traverso/dialogs/project/NewProjectDialog.h,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -b -r1.5 -r1.6
--- traverso/dialogs/project/NewProjectDialog.h 22 May 2008 12:55:55 -0000      
1.5
+++ traverso/dialogs/project/NewProjectDialog.h 22 May 2008 15:14:17 -0000      
1.6
@@ -26,7 +26,10 @@
 #include <QDialog>
 
 class AudioFileCopyConvert;
+class ExportFormatOptionsWidget;
 class QProgressDialog;
+struct ExportSpecification;
+
 
 class NewProjectDialog : public QDialog, protected Ui::NewProjectDialog
 {
@@ -39,6 +42,8 @@
 private:
        AudioFileCopyConvert* m_converter;
        QProgressDialog* m_progressDialog;
+       ExportSpecification* m_exportSpec;
+       ExportFormatOptionsWidget* m_formatOptionsWidget;
 
        void load_all_files();
        void copy_files();




reply via email to

[Prev in Thread] Current Thread [Next in Thread]