traverso-commit
[Top][All Lists]
Advanced

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

[Traverso-commit] traverso src/traverso/songcanvas/AudioClipView....


From: Remon Sijrier
Subject: [Traverso-commit] traverso src/traverso/songcanvas/AudioClipView....
Date: Fri, 14 Dec 2007 21:37:32 +0000

CVSROOT:        /sources/traverso
Module name:    traverso
Changes by:     Remon Sijrier <r_sijrier>       07/12/14 21:37:32

Modified files:
        src/traverso/songcanvas: AudioClipView.cpp AudioClipView.h 
        .              : TODO 

Log message:
        * very simplistic caching for waveform data.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/traverso/src/traverso/songcanvas/AudioClipView.cpp?cvsroot=traverso&r1=1.120&r2=1.121
http://cvs.savannah.gnu.org/viewcvs/traverso/src/traverso/songcanvas/AudioClipView.h?cvsroot=traverso&r1=1.34&r2=1.35
http://cvs.savannah.gnu.org/viewcvs/traverso/TODO?cvsroot=traverso&r1=1.17&r2=1.18

Patches:
Index: src/traverso/songcanvas/AudioClipView.cpp
===================================================================
RCS file: /sources/traverso/traverso/src/traverso/songcanvas/AudioClipView.cpp,v
retrieving revision 1.120
retrieving revision 1.121
diff -u -b -r1.120 -r1.121
--- src/traverso/songcanvas/AudioClipView.cpp   7 Dec 2007 06:56:12 -0000       
1.120
+++ src/traverso/songcanvas/AudioClipView.cpp   14 Dec 2007 21:37:32 -0000      
1.121
@@ -190,7 +190,9 @@
                        painter->drawText(r, Qt::AlignVCenter, buildProcess);
                
                } else if (m_clip->recording_state() == 
AudioClip::NO_RECORDING) {
+//                     PROFILE_START;
                        draw_peaks(painter, xstart, pixelcount);
+//                     PROFILE_END("draw peaks");
                }
        }
        
@@ -264,8 +266,37 @@
        int channels = m_clip->get_channels();
        int peakdatacount = microView ? pixelcount : pixelcount * 2;
 
+       if (m_pathCache.size() != channels) {
+               m_pathCache.clear();
+               for(int i=0; i<channels; ++i) {
+                       PainterPathCache* cache =  new PainterPathCache;
+                       cache->length = -1;
+                       cache->xstart = -1;
+                       m_pathCache.append(cache);
+               }
+       }
+       
+       bool validPathCache = false;
+       if (m_pathCache.first()->xstart == xstart && 
m_pathCache.first()->length == pixelcount) {
+               validPathCache = true;
+       } else {
+               m_pathCache.first()->xstart = xstart;
+               m_pathCache.first()->length = pixelcount;
+               m_pathCache.first()->path = QPainterPath();
+       }
+               
+       
        float* pixeldata[channels];
+       float curveDefaultValue = 1.0;
+       int mixcurvedata = 0;
+       mixcurvedata |= curveView->has_nodes();
+       int offset = (int)(m_clip->get_source_start_location() / 
m_sv->timeref_scalefactor);
        
+       if (!mixcurvedata) {
+               curveDefaultValue = curveView->get_default_value();
+       }
+       
+       if (!validPathCache) {
        // Load peak data for all channels, if no peakdata is returned
        // for a certain Peak object, schedule it for loading.
        for (int chan=0; chan < channels; ++chan) {
@@ -277,7 +308,7 @@
                                microView ? peakdatacount : peakdatacount / 2 + 
2);
                
                if (peakdatacount != availpeaks) {
-//                     PWARN("peakdatacount != availpeaks (%d, %d)", 
peakdatacount, availpeaks);
+       //                      PWARN("peakdatacount != availpeaks (%d, %d)", 
peakdatacount, availpeaks);
                }
 
                if (availpeaks == Peak::NO_PEAK_FILE) {
@@ -292,20 +323,13 @@
                        return;
                }               
                
-//             pixelcount = std::min(pixelcount, availpeaks);
+       //              pixelcount = std::min(pixelcount, availpeaks);
        }
        
        
        float curvemixdown[peakdatacount];
-       int mixcurvedata = 0;
-       float curveDefaultValue = 1.0;
-       int offset = (int)(m_clip->get_source_start_location() / 
m_sv->timeref_scalefactor);
-       mixcurvedata |= curveView->has_nodes();
-       
        if (mixcurvedata) {
                mixcurvedata |= curveView->get_vector(xstart + offset, 
pixelcount, curvemixdown);
-       } else {
-               curveDefaultValue = curveView->get_default_value();
        }
        
        for (int i = 0; i < m_fadeViews.size(); ++i) {
@@ -372,6 +396,8 @@
                }
        }
        
+       }
+               
        
        for (int chan=0; chan < channels; chan++) {
                p->save();
@@ -477,30 +503,38 @@
                        int bufferpos = 0;
 
                        if (m_classicView) {
+                               
+                               if (m_mergedView) {
+                                       ytrans = (height / 2) * channels;
+                               } else {
+                                       ytrans = (height / 2) + (chan * height);
+                               }
+                       
+                               p->setMatrix(matrix().translate(xstart + 
adjustforevenpixel, ytrans).scale(1, scaleFactor), true);
+                               
                                QPainterPath pathtop;
                                QPainterPath pathbottom;
                                
+                               if (!validPathCache) {
                                m_polygonbottom.clear();
                                m_polygonbottom.reserve(pixelcount + 3);
                                
                                for (int x = 0; x < pixelcount; x+=2) {
-                                       m_polygontop.append( QPointF(x, 
-scaleFactor * pixeldata[chan][bufferpos++]) );
-                                       m_polygonbottom.append( QPointF(x, 
scaleFactor * pixeldata[chan][bufferpos++]) );
+                                               m_polygontop.append( QPointF(x, 
-1 * pixeldata[chan][bufferpos++]) );
+                                               m_polygonbottom.append( 
QPointF(x, 1 * pixeldata[chan][bufferpos++]) );
                                }
                                
                                pathtop.addPolygon(m_polygontop);
                                pathbottom.addPolygon(m_polygonbottom);
                                pathtop.connectPath(pathbottom.toReversed());
                                
-                               if (m_mergedView) {
-                                       ytrans = (height / 2) * channels;
+                                       m_pathCache.at(chan)->path = pathtop;
                                } else {
-                                       ytrans = (height / 2) + (chan * height);
+//                                     printf("using existing path for 
painting\n");
                                }
                        
-                               p->setMatrix(matrix().translate(xstart + 
adjustforevenpixel, ytrans), true);
+                               p->drawPath(m_pathCache.at(chan)->path);
                                
-                               p->drawPath(pathtop);
                                // Draw 'the' -INF line
                                p->setPen(minINFLineColor);
                                p->drawLine(0, 0, pixelcount, 0);
@@ -760,6 +794,11 @@
        m_boundingRect = QRectF(0, 0, (m_clip->get_length() / 
m_sv->timeref_scalefactor), m_height);
        update_start_pos();
        ViewItem::calculate_bounding_rect();
+       
+       foreach(PainterPathCache* cache, m_pathCache) {
+               cache->xstart = -1;
+               cache->length = -1;
+       }
 }
 
 

Index: src/traverso/songcanvas/AudioClipView.h
===================================================================
RCS file: /sources/traverso/traverso/src/traverso/songcanvas/AudioClipView.h,v
retrieving revision 1.34
retrieving revision 1.35
diff -u -b -r1.34 -r1.35
--- src/traverso/songcanvas/AudioClipView.h     12 Nov 2007 18:52:14 -0000      
1.34
+++ src/traverso/songcanvas/AudioClipView.h     14 Dec 2007 21:37:32 -0000      
1.35
@@ -83,6 +83,14 @@
        QPolygonF m_polygonbottom;
        QPolygonF m_polygontop;
 
+       struct PainterPathCache {
+               QPainterPath path;
+               int xstart;
+               int length;
+       };
+       
+       QList<PainterPathCache* > m_pathCache;
+
        QTimer m_recordingTimer;
 
        float m_progress;

Index: TODO
===================================================================
RCS file: /sources/traverso/traverso/TODO,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -b -r1.17 -r1.18
--- TODO        11 Dec 2007 17:30:11 -0000      1.17
+++ TODO        14 Dec 2007 21:37:32 -0000      1.18
@@ -1,6 +1,5 @@
 TOBEDONE FOR 0.4x.x
 
-* fix compile warnings with g++ >= 4.2.1
 * Loading Project with 0 sheets crashes when spectrum/correlation meters are 
shown
 * http://traverso-daw.org/forum/index.php/topic,60.msg161.html#msg161
        (random crashes on mac os x, unable to reproduce locally)




reply via email to

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