Mercurial > hg > syncopation-dataset
changeset 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 | 6b6f8e3d7262 |
files | Syncopation models/basic_functions.py |
diffstat | 1 files changed, 14 insertions(+), 7 deletions(-) [+] |
line wrap: on
line diff
--- a/Syncopation models/basic_functions.py Fri Apr 03 16:02:10 2015 +0100 +++ b/Syncopation models/basic_functions.py Fri Apr 03 16:18:00 2015 +0100 @@ -142,16 +142,23 @@ 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(',')) + return map(int, inputString.split(',')) + # The split_by_bar function seperates the score representation of rhythm by bar lines, # resulting in a list representingbar-by-bar rhythm sequence,