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.cpp


From: Remon Sijrier
Subject: [Traverso-commit] traverso/src/traverso/songcanvas AudioClipView.cpp
Date: Tue, 25 Sep 2007 17:01:33 +0000

CVSROOT:        /sources/traverso
Module name:    traverso
Changes by:     Remon Sijrier <r_sijrier>       07/09/25 17:01:33

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

Log message:
        fixed painting jitter when moving left edge

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/traverso/src/traverso/songcanvas/AudioClipView.cpp?cvsroot=traverso&r1=1.95&r2=1.96

Patches:
Index: AudioClipView.cpp
===================================================================
RCS file: /sources/traverso/traverso/src/traverso/songcanvas/AudioClipView.cpp,v
retrieving revision 1.95
retrieving revision 1.96
diff -u -b -r1.95 -r1.96
--- AudioClipView.cpp   24 Sep 2007 20:25:02 -0000      1.95
+++ AudioClipView.cpp   25 Sep 2007 17:01:33 -0000      1.96
@@ -129,7 +129,7 @@
        
        painter->save();
        
-       QRectF clipRect = m_boundingRect.adjusted(-1, -1, 1, 1);
+       QRectF clipRect = m_boundingRect.adjusted(0, -1, 1, 1);
        painter->setClipRect(clipRect);
        
        if (m_clip->is_readsource_invalid()) {
@@ -231,18 +231,6 @@
        // when using a different color for the brush then the outline.
        // Painting 2 more pixels makes it getting clipped away.....
        pixelcount += 2;
-/*     When painting skips one pixel at a time, we always have to start
-       at an even position with an even amount of pixels to paint*/
-       if (xstart % 2) {
-               xstart -= 1;
-               pixelcount++;
-       }
-       if (xstart < 0) {
-               xstart = 0;
-       }
-       if (pixelcount % 2) {
-               pixelcount += 1;
-       }
        
        bool microView = m_song->get_hzoom() > (Peak::MAX_ZOOM_USING_SOURCEFILE 
- 1) ? 0 : 1;
        // boundary checking, important for microview only, macroview needs the 
additional
@@ -262,14 +250,27 @@
                return;
        }
        
+/*     When painting skips one pixel at a time, we always have to start
+       at an even position for 'sample' accurate painting */
+       TimeRef clipstartoffset = m_clip->get_source_start_location();
+       int adjustforevenpixel = 0;
+       if (xstart % 2) {
+               xstart -= 1;
+               pixelcount += 1;
+       }
+
+       if ( (clipstartoffset.to_frame(44100) / 
Peak::zoomStep[m_song->get_hzoom()]) % 2) {
+               clipstartoffset -= m_sv->timeref_scalefactor;
+               adjustforevenpixel -= 1;
+       }
+       
        // 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) {
-               TimeRef clipstartoffset = m_clip->get_source_start_location();
                
                int availpeaks = peak->calculate_peaks( chan,
                                                        &pixeldata[chan],
-                                                       m_song->get_hzoom(),
+                                                       m_song->get_hzoom() + 1,
                                                        (xstart * 
m_sv->timeref_scalefactor) + clipstartoffset,
                                                        peakdatacount);
                
@@ -336,12 +337,12 @@
                                                pixeldata[chan][i] *= 
curvemixdown[curvemixdownpos];
                                                i++;
                                                pixeldata[chan][i] *= 
curvemixdown[curvemixdownpos];
-                                               curvemixdownpos ++;
+                                               curvemixdownpos += 2;
                                        }
                                } else {
                                        for (int i = 0; i < pixelcount; i++) {
                                                pixeldata[chan][i] *= 
curvemixdown[curvemixdownpos];
-                                               curvemixdownpos ++;
+                                               curvemixdownpos += 2;
                                        }
                                }
                        }
@@ -464,10 +465,12 @@
                                QPolygonF polygonbottom(pixelcount);
                                
                                int range = pixelcount;
-                               for (int x = 0; x < range; x++) {
+                               for (int x = 0; x < range; x+=2) {
+                                       if (x <= range) {
                                        polygontop.append( QPointF(x, 
scaleFactor * pixeldata[chan][bufferpos++]) );
                                        polygonbottom.append( QPointF(x, 
-scaleFactor * pixeldata[chan][bufferpos++]) );
                                }
+                               }
                                
                                path.addPolygon(polygontop);
                                path.lineTo(polygonbottom.last());
@@ -499,7 +502,7 @@
                                
                        }
                        
-                       p->setMatrix(matrix().translate(xstart, ytrans), true);
+                       p->setMatrix(matrix().translate(xstart + 
adjustforevenpixel, ytrans), true);
                        p->drawPath(path);
                        
                }




reply via email to

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