traverso-commit
[Top][All Lists]
Advanced

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

[Traverso-commit] traverso/src core/Export.cpp core/Export.h core...


From: Remon Sijrier
Subject: [Traverso-commit] traverso/src core/Export.cpp core/Export.h core...
Date: Thu, 03 May 2007 18:12:07 +0000

CVSROOT:        /sources/traverso
Module name:    traverso
Changes by:     Remon Sijrier <r_sijrier>       07/05/03 18:12:07

Modified files:
        src/core       : Export.cpp Export.h Project.cpp Song.cpp 
        src/traverso/dialogs/project: OpenProjectDialog.cpp 
        src/traverso   : ExportWidget.cpp 
        src/traverso/ui: ExportWidget.ui 

Log message:
        * ExportSpec has 2 passes now, normalize, and write to hard disk.
        Used to calculate and apply the norm factor to exported audio

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/traverso/src/core/Export.cpp?cvsroot=traverso&r1=1.3&r2=1.4
http://cvs.savannah.gnu.org/viewcvs/traverso/src/core/Export.h?cvsroot=traverso&r1=1.4&r2=1.5
http://cvs.savannah.gnu.org/viewcvs/traverso/src/core/Project.cpp?cvsroot=traverso&r1=1.34&r2=1.35
http://cvs.savannah.gnu.org/viewcvs/traverso/src/core/Song.cpp?cvsroot=traverso&r1=1.83&r2=1.84
http://cvs.savannah.gnu.org/viewcvs/traverso/src/traverso/dialogs/project/OpenProjectDialog.cpp?cvsroot=traverso&r1=1.2&r2=1.3
http://cvs.savannah.gnu.org/viewcvs/traverso/src/traverso/ExportWidget.cpp?cvsroot=traverso&r1=1.9&r2=1.10
http://cvs.savannah.gnu.org/viewcvs/traverso/src/traverso/ui/ExportWidget.ui?cvsroot=traverso&r1=1.3&r2=1.4

Patches:
Index: core/Export.cpp
===================================================================
RCS file: /sources/traverso/traverso/src/core/Export.cpp,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -b -r1.3 -r1.4
--- core/Export.cpp     22 Apr 2007 20:05:38 -0000      1.3
+++ core/Export.cpp     3 May 2007 18:12:07 -0000       1.4
@@ -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.3 2007/04/22 20:05:38 n_doebelin Exp $
+    $Id: Export.cpp,v 1.4 2007/05/03 18:12:07 r_sijrier Exp $
 */
 
 #include "Export.h"
@@ -62,6 +62,10 @@
        exportdir = "";
        name = "";
        writeToc = false;
+       normalize = false;
+       renderpass = WRITE_TO_HARDDISK;
+       normvalue = 1.0;
+       peakvalue = 0.0;
 }
 
 int ExportSpecification::is_valid()

Index: core/Export.h
===================================================================
RCS file: /sources/traverso/traverso/src/core/Export.h,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -b -r1.4 -r1.5
--- core/Export.h       22 Apr 2007 20:05:38 -0000      1.4
+++ core/Export.h       3 May 2007 18:12:07 -0000       1.5
@@ -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.4 2007/04/22 20:05:38 n_doebelin Exp $
+$Id: Export.h,v 1.5 2007/05/03 18:12:07 r_sijrier Exp $
 */
 
 #ifndef EXPORT_H
@@ -40,6 +40,11 @@
        
        int is_valid();
        
+       enum RenderPass {
+               CALC_NORM_FACTOR,
+               WRITE_TO_HARDDISK
+       };
+       
        int             sample_rate;
        int             src_quality;
        int             channels;
@@ -70,6 +75,10 @@
        QString         exportdir;
        QString         name;
        bool            writeToc;
+       bool            normalize;
+       int             renderpass;
+       float           peakvalue;
+       float           normvalue;
 };
 
 

Index: core/Project.cpp
===================================================================
RCS file: /sources/traverso/traverso/src/core/Project.cpp,v
retrieving revision 1.34
retrieving revision 1.35
diff -u -b -r1.34 -r1.35
--- core/Project.cpp    3 May 2007 14:04:59 -0000       1.34
+++ core/Project.cpp    3 May 2007 18:12:07 -0000       1.35
@@ -464,6 +464,31 @@
                PMESG("Starting export for song %lld", song->get_id());
                emit exportStartedForSong(song);
 
+               if (spec->normalize) {
+                       spec->peakvalue = 0.0;
+                       spec->renderpass = 
ExportSpecification::CALC_NORM_FACTOR;
+                       
+                       
+                       if (song->prepare_export(spec) < 0) {
+                               PERROR("Failed to prepare song for export");
+                               continue;
+                       }
+                       
+                       while(song->render(spec) > 0) {}
+                       
+                       spec->normvalue = 1.0 / spec->peakvalue;
+                       
+                       if (spec->peakvalue > (1.0 + FLT_EPSILON)) {
+                               info().critical(tr("Detected clipping in 
exported audio! (%1)")
+                                               
.arg(coefficient_to_dbstring(spec->peakvalue)));
+                               spec->normvalue = 1.0;
+                       }
+                       
+                       info().information(tr("calculated norm factor: 
%1").arg(coefficient_to_dbstring(spec->normvalue)));
+               }
+
+               spec->renderpass = ExportSpecification::WRITE_TO_HARDDISK;
+               
                if (song->prepare_export(spec) < 0) {
                        PERROR("Failed to prepare song for export");
                        continue;

Index: core/Song.cpp
===================================================================
RCS file: /sources/traverso/traverso/src/core/Song.cpp,v
retrieving revision 1.83
retrieving revision 1.84
diff -u -b -r1.83 -r1.84
--- core/Song.cpp       24 Apr 2007 18:56:38 -0000      1.83
+++ core/Song.cpp       3 May 2007 18:12:07 -0000       1.84
@@ -377,7 +377,9 @@
                write_cdrdao_toc(spec);
        }
 
+       if (spec->renderpass == ExportSpecification::WRITE_TO_HARDDISK) {
        m_exportSource = new WriteSource(spec);
+       }
 
        return 1;
 }
@@ -404,7 +406,11 @@
                                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 */
@@ -436,13 +442,34 @@
        }
 
 
+       int bufsize = spec->blocksize * spec->channels;
+       if (spec->normalize) {
+               if (spec->renderpass == ExportSpecification::CALC_NORM_FACTOR) {
+                       spec->peakvalue = Mixer::compute_peak(spec->dataF, 
bufsize, spec->peakvalue);
+               }
+       }
+       
+       if (spec->renderpass == ExportSpecification::WRITE_TO_HARDDISK) {
+               if (spec->normalize) {
+                       Mixer::apply_gain_to_buffer(spec->dataF, bufsize, 
spec->normvalue);
+               }
        if (m_exportSource->process (nframes)) {
                goto out;
        }
+       }
+       
 
        spec->pos += nframes;
 
+       if (! spec->normalize ) {
        progress = (int) (( 100.0 * (float)(spec->pos) ) / spec->total_frames);
+       } else {
+               progress = (int) (( 100.0 * (float)(spec->pos) ) / 
(spec->total_frames * 2));
+               if (spec->renderpass == ExportSpecification::WRITE_TO_HARDDISK) 
{
+                       progress += 50;
+               }
+       }
+       
        if (progress > spec->progress) {
                spec->progress = progress;
                m_project->set_song_export_progress(progress);

Index: traverso/dialogs/project/OpenProjectDialog.cpp
===================================================================
RCS file: 
/sources/traverso/traverso/src/traverso/dialogs/project/OpenProjectDialog.cpp,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -b -r1.2 -r1.3
--- traverso/dialogs/project/OpenProjectDialog.cpp      23 Apr 2007 11:57:39 
-0000      1.2
+++ traverso/dialogs/project/OpenProjectDialog.cpp      3 May 2007 18:12:07 
-0000       1.3
@@ -233,7 +233,9 @@
                QMessageBox::information( this, tr("Traverso - Information"), 
tr("Created new Project directory for you here: %1\n").arg(newPath), "OK", 0 );
        }
        
-       config().set_property("Project", "directory", newPath);
+       QDir newdir(newPath);
+       
+       config().set_property("Project", "directory", newdir.canonicalPath());
        
        update_projects_list();
 }

Index: traverso/ExportWidget.cpp
===================================================================
RCS file: /sources/traverso/traverso/src/traverso/ExportWidget.cpp,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -b -r1.9 -r1.10
--- traverso/ExportWidget.cpp   3 May 2007 14:05:00 -0000       1.9
+++ traverso/ExportWidget.cpp   3 May 2007 18:12:07 -0000       1.10
@@ -219,6 +219,8 @@
                 spec->allSongs = false;
        }
        
+       spec->normalize = normalizeCheckBox->isChecked();
+       
        spec->isRecording = false;
 
         m_project->export_project(spec);

Index: traverso/ui/ExportWidget.ui
===================================================================
RCS file: /sources/traverso/traverso/src/traverso/ui/ExportWidget.ui,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -b -r1.3 -r1.4
--- traverso/ui/ExportWidget.ui 3 May 2007 14:05:00 -0000       1.3
+++ traverso/ui/ExportWidget.ui 3 May 2007 18:12:07 -0000       1.4
@@ -6,7 +6,7 @@
     <x>0</x>
     <y>0</y>
     <width>529</width>
-    <height>592</height>
+    <height>557</height>
    </rect>
   </property>
   <property name="windowTitle" >
@@ -17,8 +17,8 @@
     <rect>
      <x>9</x>
      <y>9</y>
-     <width>463</width>
-     <height>339</height>
+     <width>511</width>
+     <height>367</height>
     </rect>
    </property>
    <layout class="QVBoxLayout" >
@@ -179,6 +179,13 @@
          <item>
           <widget class="QComboBox" name="channelComboBox" />
          </item>
+         <item>
+          <widget class="QCheckBox" name="normalizeCheckBox" >
+           <property name="text" >
+            <string>Normalize</string>
+           </property>
+          </widget>
+         </item>
         </layout>
        </item>
        <item>
@@ -217,6 +224,19 @@
          <item>
           <widget class="QComboBox" name="sampleRateComboBox" />
          </item>
+         <item>
+          <spacer>
+           <property name="orientation" >
+            <enum>Qt::Vertical</enum>
+           </property>
+           <property name="sizeHint" >
+            <size>
+             <width>20</width>
+             <height>40</height>
+            </size>
+           </property>
+          </spacer>
+         </item>
         </layout>
        </item>
       </layout>
@@ -238,8 +258,8 @@
    <property name="geometry" >
     <rect>
      <x>9</x>
-     <y>354</y>
-     <width>294</width>
+     <y>382</y>
+     <width>511</width>
      <height>166</height>
     </rect>
    </property>




reply via email to

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