All pastes #966889 Raw Edit

Anonymous

public text v1 · immutable
·published 2008-04-02 02:07 UTC
rendered paste body
=== modified file 'Jokosher/Event.py'
--- Jokosher/Event.py	2008-03-29 21:16:55 +0000
+++ Jokosher/Event.py	2008-03-30 00:12:36 +0000
@@ -87,6 +87,7 @@
 		
 		self.selection  = [0, 0]	# List start and end of selection (for fades, etc) measured in seconds 
 		self.levels = []			# Array of audio levels to be drawn for this event
+		self.preciseLevels = []			# Array of tuples with audio levels and timestamps
 		
 		self.id = instrument.project.GenerateUniqueID(id)  #check is id is already taken, then set it.
 		self.instrument = instrument	# The parent instrument
@@ -579,6 +580,7 @@
 			self.levels.append(newLevel)
 			
 			end = st["endtime"] / float(gst.SECOND)
+			self.preciseLevels.append( (newLevel, end) )		
 			self.loadingLength = int(end)
 			
 			# Only send events every second processed to reduce GUI load

=== modified file 'Jokosher/EventViewer.py'
--- Jokosher/EventViewer.py	2008-03-14 22:03:19 +0000
+++ Jokosher/EventViewer.py	2008-03-30 00:18:44 +0000
@@ -19,6 +19,7 @@
 import gettext
 _ = gettext.gettext
 import Globals
+import itertools
 
 #=========================================================================
 
@@ -351,29 +352,47 @@
 		context.set_source_rgb(*self._BACKGROUND_RGB)
 		context.fill()
 		
-		if self.event.levels and (self.event.duration or self.event.loadingLength):
+		if self.event.preciseLevels and (self.event.duration or self.event.loadingLength):
 			if self.event.loadingLength:
-				scale = (self.event.loadingLength * self.project.viewScale) / float(len(self.event.levels))
+				duration = self.event.loadingLength
 			else:
-				scale = (self.event.duration * self.project.viewScale) / float(len(self.event.levels))
+				duration = self.event.duration
 			
-			# Draw waveform
-			x_pos = int(rect.x/scale)
-			x = 0
-			skipFactor = max(int(self._MIN_POINT_SEPARATION / scale), 1)
 			context.move_to(0,rect.height)
 					
 			# get levels list
-			fadedLevels = self.event.GetFadeLevels()
+			#fadedLevels = self.event.GetFadeLevels()
 			
-			for peak in fadedLevels[x_pos::skipFactor]:
-				x = (x_pos * scale) - rect.x
+			levels = self.event.preciseLevels
+			length = len(levels)
+
+			starting_time = int(rect.x / self.project.viewScale)
+			starting_index = int(starting_time * length / duration)
+
+			s_time = levels[starting_index][1]
+			if s_time > starting_time:
+				while starting_index > 0 and s_time > starting_time:
+					starting_index -= 1
+					s_time = levels[starting_index][1]
+			elif s_time < starting_time:
+				while starting_index < length and s_time < starting_time:
+					starting_index += 1
+					s_time = levels[starting_index][1]
+				# we want to end up one before the beginning
+				starting_index -= 1
+
+			last_x = -2
+			iterator = itertools.islice(levels, starting_index, length)
+			for peak, time in iterator:
+				x = int((time - starting_time) * self.project.viewScale)
+				if (x - last_x) < self._MIN_POINT_SEPARATION:
+					continue
+				
 				peakOnScreen = int(peak * rect.height)
 				context.line_to(x, rect.height - peakOnScreen)
 				
 				if x > rect.width:
 					break
-				x_pos += skipFactor
 			
 			context.line_to(x, rect.height)
 			

=== modified file 'Jokosher/Project.py'
--- Jokosher/Project.py	2008-03-15 19:58:49 +0000
+++ Jokosher/Project.py	2008-03-29 16:47:59 +0000
@@ -1341,7 +1341,7 @@
 				except:
 					pass
 			Globals.debug("Output device: %s" % outdevice)
-			sinkElement.set_property("device", outdevice)
+			sinkElement.set_property("device", "default")
 			Globals.debug("Using alsasink for audio output")
 		
 		elif sinkString != "autoaudiosink":

=== modified file 'Jokosher/TransportManager.py'
--- Jokosher/TransportManager.py	2007-05-24 08:55:50 +0000
+++ Jokosher/TransportManager.py	2008-03-29 17:28:00 +0000
@@ -14,6 +14,7 @@
 pygst.require("0.10")
 import gst
 import gobject
+import Globals
 
 #=========================================================================
 
@@ -348,6 +349,7 @@
 		Reads the current playhead cursor position by querying pipeline.
 		"""
 		pos = self.pipeline.query_position(gst.FORMAT_TIME)[0]
+		Globals.debug("update position: %.9f" % (float(pos) / gst.SECOND))
 		self.SetPosition(float(pos) / gst.SECOND)
 		
 	#_____________________________________________________________________

=== modified file 'Jokosher/Utils.py'
--- Jokosher/Utils.py	2008-03-14 22:03:19 +0000
+++ Jokosher/Utils.py	2008-03-16 17:58:44 +0000
@@ -16,8 +16,8 @@
 import Globals
 
 import gst
-if gst.pygst_version >= (0, 10, 10):
-    import gst.pbutils
+#if gst.pygst_version >= (0, 10, 10):
+ #   import gst.pbutils
 
 #_____________________________________________________________________