Mercurial > hg > syncopation-dataset
diff Syncopation models/syncopation.py @ 21:b6daddeefda9
working on KTH
author | csong <csong@eecs.qmul.ac.uk> |
---|---|
date | Tue, 07 Apr 2015 23:16:13 +0100 |
parents | 4fb9c00e4ef0 |
children | df1e7c378ee0 |
line wrap: on
line diff
--- a/Syncopation models/syncopation.py Tue Apr 07 19:05:07 2015 +0100 +++ b/Syncopation models/syncopation.py Tue Apr 07 23:16:13 2015 +0100 @@ -4,73 +4,77 @@ ''' +def sync_perbar_permodel (model, bar, parameters): + return model.get_syncopation(bar, parameters) -def sync_perbar_permodel(seq, model, timesig = None, subdivision_seq = None, weight_seq = None, L_max = 5, prebar_seq = None, postbar_seq = None, strong_beat_level = None): - syncopation = None +# def syncopation_barlist_permodel(model, barlist, parameters): - if seq == None or model == None: - print 'Error: please indicate rhythm sequence and syncopation model.' +# def sync_perbar_permodel(seq, model, timesig = None, subdivision_seq = None, weight_seq = None, L_max = 5, prebar_seq = None, postbar_seq = None, strong_beat_level = None): +# syncopation = None - elif timesig == None and subdivision_seq == None: - print 'Error: please indicate either time signature or subdivision sequence.' +# if seq == None or model == None: +# print 'Error: please indicate rhythm sequence and syncopation model.' + +# elif timesig == None and subdivision_seq == None: +# print 'Error: please indicate either time signature or subdivision sequence.' - else: - while subdivision_seq == None: - from basic_functions import get_subdivision_seq - subdivision_seq = get_subdivision_seq(timesig, L_max) +# else: +# while subdivision_seq == None: +# from basic_functions import get_subdivision_seq +# subdivision_seq = get_subdivision_seq(timesig, L_max) - # 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 - def get_rhythm_category(): - rhythm_category = 'mono' - from basic_functions import get_min_timeSpan, find_prime_factors - for f in find_prime_factors(len(get_min_timeSpan(seq))): - if not (f in subdivision_seq): - rhythm_category = 'poly' - break - return rhythm_category +# # 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 +# def get_rhythm_category(): +# rhythm_category = 'mono' +# from basic_functions import get_min_timeSpan, find_prime_factors +# for f in find_prime_factors(len(get_min_timeSpan(seq))): +# if not (f in subdivision_seq): +# rhythm_category = 'poly' +# break +# return rhythm_category - rhythm_category = get_rhythm_category() +# rhythm_category = get_rhythm_category() - if model == 'LHL': - import LHL - if weight_seq == None: - weight_seq = range(0,-L_max,-1) - syncopation = LHL.get_syncopation(seq, subdivision_seq, weight_seq, prebar_seq, rhythm_category) - elif model == 'PRS': - import PRS - syncopation = PRS.get_syncopation(seq, subdivision_seq, postbar_seq, rhythm_category) - elif model == 'TMC': - import TMC - if weight_seq == None: - weight_seq = range(L_max+1,0,-1) - syncopation = TMC.get_syncopation(seq, subdivision_seq, weight_seq, L_max, rhythm_category) - elif model == 'SG': - import SG - if weight_seq == None: - weight_seq = range(L_max+1) - syncopation = SG.get_syncopation(seq, subdivision_seq, weight_seq, L_max, rhythm_category) - elif model == 'KTH': - import KTH - syncopation = KTH.get_syncopation(seq, timesig, postbar_seq) - elif model == 'TOB': - import TOB - syncopation = TOB.get_syncopation(seq) - elif model == 'WNBD': - import WNBD - if strong_beat_level == None: - if timesig == '4/4': - strong_beat_level = 2 - else: - strong_beat_level = 1 - syncopation = WNBD.get_syncopation(seq, subdivision_seq, strong_beat_level, postbar_seq) +# if model == 'LHL': +# import LHL +# if weight_seq == None: +# weight_seq = range(0,-L_max,-1) +# syncopation = LHL.get_syncopation(seq, subdivision_seq, weight_seq, prebar_seq, rhythm_category) +# elif model == 'PRS': +# import PRS +# syncopation = PRS.get_syncopation(seq, subdivision_seq, postbar_seq, rhythm_category) +# elif model == 'TMC': +# import TMC +# if weight_seq == None: +# weight_seq = range(L_max+1,0,-1) +# syncopation = TMC.get_syncopation(seq, subdivision_seq, weight_seq, L_max, rhythm_category) +# elif model == 'SG': +# import SG +# if weight_seq == None: +# weight_seq = range(L_max+1) +# syncopation = SG.get_syncopation(seq, subdivision_seq, weight_seq, L_max, rhythm_category) +# elif model == 'KTH': +# import KTH +# syncopation = KTH.get_syncopation(seq, timesig, postbar_seq) +# elif model == 'TOB': +# import TOB +# syncopation = TOB.get_syncopation(seq) +# elif model == 'WNBD': +# import WNBD +# if strong_beat_level == None: +# if timesig == '4/4': +# strong_beat_level = 2 +# else: +# strong_beat_level = 1 +# syncopation = WNBD.get_syncopation(seq, subdivision_seq, strong_beat_level, postbar_seq) - else: - print 'Error: undefined syncopation model.' +# else: +# print 'Error: undefined syncopation model.' - return syncopation +# return syncopation # def syncopation_all(rhythm, model, timesig, subdivision_seq = None, weight_seq = None, L_max = 5, strong_beat_level = None): # syncopation = 0