# HG changeset patch # User christopherh # Date 1428074280 -3600 # Node ID 7d94ba423c04849445ea99d45ae7ea292970c79f # Parent a3ed7d2b57d85f9b7ca3ed27dc54f450a5195007 update basic_functions to merge diff -r a3ed7d2b57d8 -r 7d94ba423c04 Syncopation models/basic_functions.py --- 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,