diff Syncopation models/music_objects.py @ 38:cc38b3047ed9

updated syncopation.y to allow output of sync for a bar list also fixed some problems in models and other modules
author christopherh <christopher.harte@eecs.qmul.ac.uk>
date Mon, 13 Apr 2015 23:06:49 +0100
parents 3a878de00d19
children 6371e8f21f7d
line wrap: on
line diff
--- a/Syncopation models/music_objects.py	Mon Apr 13 22:36:51 2015 +0100
+++ b/Syncopation models/music_objects.py	Mon Apr 13 23:06:49 2015 +0100
@@ -115,7 +115,8 @@
 		velocitySequence += [0]*(noteSequence[-1].duration-1)
 
 	# normalising velocity sequence between 0-1
-	velocitySequence = VelocitySequence([float(v)/max(velocitySequence) for v in velocitySequence])
+	if max(velocitySequence)>0:
+		velocitySequence = VelocitySequence([float(v)/max(velocitySequence) for v in velocitySequence])
 
 	return velocitySequence
 
@@ -162,7 +163,7 @@
 
 	def get_velocity_sequence(self):
 		if self.velocitySequence == None:
-			self.velocitySequence = note_sequence_to_velocity_sequence(self.noteSequence)
+			self.velocitySequence = note_sequence_to_velocity_sequence(self.noteSequence, self.get_bar_ticks())
 		return self.velocitySequence
 
 	def get_binary_sequence(self):
@@ -193,11 +194,23 @@
 	def get_bar_ticks(self):
 		return calculate_bar_ticks(self.timeSignature.get_numerator(),self.timeSignature.get_denominator(), self.tpq)
 
+	def is_empty(self):
+		if max(self.get_velocity_sequence())>0:
+			return False
+		else:
+			return True
+
 	def to_string(self, sequenceType=None):
+		output = "t{"+self.timeSignature.to_string()+"}"
+		prev = self.get_previous_bar()
+		if prev!=None:
+			if prev.get_time_signature()==self.get_time_signature():
+				output=""
+
 		if sequenceType==None or sequenceType=="v":
-			output = "v{"+self.get_velocity_sequence().to_string()+"}"
+			output += "v{"+self.get_velocity_sequence().to_string()+"}"
 		else:
-			output = "y{"+self.get_note_sequence().to_string()+"}"
+			output += "y{"+self.get_note_sequence().to_string()+"}"
 		return output