comparison Syncopation models/basic_functions.py @ 32:273450d5980a

tested parameter setting.
author csong <csong@eecs.qmul.ac.uk>
date Sun, 12 Apr 2015 23:23:32 +0100
parents 7a1730bbf15a
children 6371e8f21f7d
comparison
equal deleted inserted replaced
30:d9ac6e0d1daf 32:273450d5980a
80 return isPrime 80 return isPrime
81 81
82 # upsample a velocity sequence to certain length, e.g. [1,1] to [1,0,0,0,1,0,0,0] 82 # upsample a velocity sequence to certain length, e.g. [1,1] to [1,0,0,0,1,0,0,0]
83 def upsample_velocity_sequence(velocitySequence, length): 83 def upsample_velocity_sequence(velocitySequence, length):
84 upsampledVelocitySequence = None 84 upsampledVelocitySequence = None
85 if length%len(velocitySequence) != 0: 85 if length < len(velocitySequence):
86 print 'Error: the velocity sequence can only be upsampled to the interger times of its length.' 86 print 'Error: the requested upsampling length needs to be longer than velocity sequence.'
87 elif length % len(velocitySequence) != 0:
88 print 'Error: velocity sequence can only be upsampled to a interger times of its own length.'
87 else: 89 else:
88 upsampledVelocitySequence = [0]*length 90 upsampledVelocitySequence = [0]*length
89 scalingFactor = length/len(velocitySequence) 91 scalingFactor = length/len(velocitySequence)
90 for index in range(len(velocitySequence)): 92 for index in range(len(velocitySequence)):
91 upsampledVelocitySequence[index*scalingFactor] = velocitySequence[index] 93 upsampledVelocitySequence[index*scalingFactor] = velocitySequence[index]