diff Syncopation models/basic_functions.py @ 28:5de1cb45c145

Parameters setting implemented.
author csong <csong@eecs.qmul.ac.uk>
date Sun, 12 Apr 2015 22:34:35 +0100
parents d9d22e6f396d
children 7a1730bbf15a
line wrap: on
line diff
--- a/Syncopation models/basic_functions.py	Sun Apr 12 15:55:12 2015 +0100
+++ b/Syncopation models/basic_functions.py	Sun Apr 12 22:34:35 2015 +0100
@@ -81,10 +81,11 @@
 
 # upsample a velocity sequence to certain length, e.g. [1,1] to [1,0,0,0,1,0,0,0]
 def upsample_velocity_sequence(velocitySequence, length):
-	upsampledVelocitySequence = [0]*length
+	upsampledVelocitySequence = None
 	if length%len(velocitySequence) != 0:
 		print 'Error: the velocity sequence can only be upsampled to the interger times of its length.'
 	else:
+		upsampledVelocitySequence = [0]*length
 		scalingFactor = length/len(velocitySequence)
 		for index in range(len(velocitySequence)):
 			upsampledVelocitySequence[index*scalingFactor] = velocitySequence[index]
@@ -214,35 +215,3 @@
 	
 # 	return subdivision_seq
 
-
- # The split_by_bar function seperates the score representation of rhythm by bar lines, 
- # resulting in a list representingbar-by-bar rhythm sequence,
- # e.g. rhythm = ['|',[ts1,td1,v1], [ts2,td2,v2], '|',[ts3,td3,v3],'|'...]
- # rhythm_bybar = [ [ [ts1,td1,v1], [ts2,td2,v2] ], [ [ts3,td3,v3] ], [...]]
-# def split_by_bar(rhythm):
-# 	rhythm_bybar = []
-# 	bar_index = []
-# 	for index in range(len(rhythm)):
-# 		if rhythm[index] == '|':
-
-# 	return rhythm_bybar
-
-# def yseq_to_vseq(yseq):
-# 	vseq = []
-
-# 	return vseq
-
-
-# # testing
-# print find_prime_factors(10)
-# print find_prime_factors(2)
-# print find_prime_factors(12)
-
-
-# print is_prime(1)       # False
-# print is_prime(2)       # True
-# print is_prime(3)       # True
-# print is_prime(29)      # True
-# print is_prime(345)     # False
-# print is_prime(999979)  # True
-# print is_prime(999981)  # False
\ No newline at end of file