Mercurial > hg > syncopation-dataset
diff 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 |
line wrap: on
line diff
--- a/Syncopation models/basic_functions.py Fri Apr 03 16:38:32 2015 +0100 +++ b/Syncopation models/basic_functions.py Fri Apr 03 17:05:31 2015 +0100 @@ -142,13 +142,22 @@ return subdivision_seq -def get_rhythm_category(sequence, subdivision_seq): - rhythm_category = 'mono' - for f in find_prime_factors(len(get_min_timeSpan(sequence))): - if not (f in subdivision_seq): - rhythm_category = 'poly' +def get_rhythm_category(velocitySequence, subdivisionSequence): + ''' + The get_rhythm_category function is used to detect rhythm category: monorhythm or polyrhythm. + For monorhythms, all prime factors of the length of minimum time-span representation of this sequence are + elements of its subdivision_seq, otherwise it is polyrhythm; + e.g. prime_factors of polyrhythm 100100101010 in 4/4 is [2,3] but subdivision_seq = [1,2,2] for 4/4 + ''' + rhythmCategory = 'mono' + for f in find_prime_factors(len(get_min_timeSpan(velocitySequence))): + if not (f in subdivisionSequence): + rhythmCategory = 'poly' break - return rhythm_category + return rhythmCategory + +def string_to_sequence(inputString): + return map(int, inputString.split(',')) # The split_by_bar function seperates the score representation of rhythm by bar lines,