Mercurial > hg > syncopation-dataset
comparison Syncopation models/basic_functions.py @ 13:bc3b9022ebc4
Merged.
author | csong <csong@eecs.qmul.ac.uk> |
---|---|
date | Fri, 03 Apr 2015 17:05:31 +0100 |
parents | c2843ef4de2c |
children | 4fb9c00e4ef0 |
comparison
equal
deleted
inserted
replaced
12:4acddc008048 | 13:bc3b9022ebc4 |
---|---|
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 |
158 | |
159 def string_to_sequence(inputString): | |
160 return map(int, inputString.split(',')) | |
152 | 161 |
153 | 162 |
154 # 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, |
155 # resulting in a list representingbar-by-bar rhythm sequence, | 164 # resulting in a list representingbar-by-bar rhythm sequence, |
156 # 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],'|'...] |