[pitivi] waveforms: take in_point and duration into account.



commit 84f08a663d200d05ba9aacac5959d87a8920c74f
Author: Mathieu Duponchelle <mathieu duponchelle epitech eu>
Date:   Mon Aug 12 17:14:57 2013 +0200

    waveforms: take in_point and duration into account.

 pitivi/timeline/previewers.py |   17 +++++++++++++++--
 1 files changed, 15 insertions(+), 2 deletions(-)
---
diff --git a/pitivi/timeline/previewers.py b/pitivi/timeline/previewers.py
index 02f5f69..70e59d0 100644
--- a/pitivi/timeline/previewers.py
+++ b/pitivi/timeline/previewers.py
@@ -831,8 +831,21 @@ class AudioPreviewer(Clutter.Actor, PreviewGenerator, Zoomable, Loggable):
         if pixelWidth <= 0:
             return
 
-        self.start = int(start / pixelWidth * self.nbSamples)
-        self.end = int(end / pixelWidth * self.nbSamples)
+        real_duration = self.bElement.get_parent().get_asset().get_duration()
+
+        # We need to take duration and inpoint into account.
+
+        nbSamples = self.nbSamples
+        startOffsetSamples = 0
+
+        if self.bElement.props.duration != 0:
+            nbSamples = self.nbSamples / (float(real_duration) / float(self.bElement.props.duration))
+        if self.bElement.props.in_point != 0:
+            startOffsetSamples = self.nbSamples / (float(real_duration) / 
float(self.bElement.props.in_point))
+
+        self.start = int(start / pixelWidth * nbSamples + startOffsetSamples)
+        self.end = int(end / pixelWidth * nbSamples + startOffsetSamples)
+
         self.width = int(end - start)
 
         if self.width < 0:  # We've been called at a moment where size was updated but not scroll_point.


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