Mercurial > hg > syncopation-dataset
comparison Syncopation models/basic_functions.py @ 11:7d94ba423c04
update basic_functions to merge
author | christopherh <christopher.harte@eecs.qmul.ac.uk> |
---|---|
date | Fri, 03 Apr 2015 16:18:00 +0100 |
parents | a3ed7d2b57d8 |
children | 4fb9c00e4ef0 |
comparison
equal
deleted
inserted
replaced
10:a3ed7d2b57d8 | 11:7d94ba423c04 |
---|---|
140 subdivision_seq = subdivision_seq[0:L_max+1] | 140 subdivision_seq = subdivision_seq[0:L_max+1] |
141 | 141 |
142 return subdivision_seq | 142 return subdivision_seq |
143 | 143 |
144 | 144 |
145 def get_rhythm_category(sequence, subdivision_seq): | 145 def get_rhythm_category(velocitySequence, subdivisionSequence): |
146 rhythm_category = 'mono' | 146 ''' |
147 for f in find_prime_factors(len(get_min_timeSpan(sequence))): | 147 The get_rhythm_category function is used to detect rhythm category: monorhythm or polyrhythm. |
148 if not (f in subdivision_seq): | 148 For monorhythms, all prime factors of the length of minimum time-span representation of this sequence are |
149 rhythm_category = 'poly' | 149 elements of its subdivision_seq, otherwise it is polyrhythm; |
150 e.g. prime_factors of polyrhythm 100100101010 in 4/4 is [2,3] but subdivision_seq = [1,2,2] for 4/4 | |
151 ''' | |
152 rhythmCategory = 'mono' | |
153 for f in find_prime_factors(len(get_min_timeSpan(velocitySequence))): | |
154 if not (f in subdivisionSequence): | |
155 rhythmCategory = 'poly' | |
150 break | 156 break |
151 return rhythm_category | 157 return rhythmCategory |
152 | 158 |
153 def string_to_sequence(inputString): | 159 def string_to_sequence(inputString): |
154 return map(int,inputString.split(',')) | 160 return map(int, inputString.split(',')) |
161 | |
155 | 162 |
156 # The split_by_bar function seperates the score representation of rhythm by bar lines, | 163 # The split_by_bar function seperates the score representation of rhythm by bar lines, |
157 # resulting in a list representingbar-by-bar rhythm sequence, | 164 # resulting in a list representingbar-by-bar rhythm sequence, |
158 # e.g. rhythm = ['|',[ts1,td1,v1], [ts2,td2,v2], '|',[ts3,td3,v3],'|'...] | 165 # e.g. rhythm = ['|',[ts1,td1,v1], [ts2,td2,v2], '|',[ts3,td3,v3],'|'...] |
159 # rhythm_bybar = [ [ [ts1,td1,v1], [ts2,td2,v2] ], [ [ts3,td3,v3] ], [...]] | 166 # rhythm_bybar = [ [ [ts1,td1,v1], [ts2,td2,v2] ], [ [ts3,td3,v3] ], [...]] |