csong@1: ''' csong@1: Author: Chunyang Song csong@1: Institution: Centre for Digital Music, Queen Mary University of London csong@1: csong@1: ''' csong@1: csong@1: from basic_functions import ceiling, find_divisor, get_min_timeSpan csong@1: csong@1: # This function calculates the syncopation value for TOB model. csong@1: def get_syncopation(seq): csong@1: syncopation = 0 csong@1: bseq_ts = get_min_timeSpan(ceiling(seq)) # converting to binary and mininum time-span sequence csong@1: divisors = find_divisor(len(bseq_ts)) # find all the divisors other than 1 and the length of this sequence csong@1: del divisors[0] csong@1: del divisors[-1] csong@1: csong@1: offbeatness = [1]*len(bseq_ts) csong@1: for index in range(len(bseq_ts)): csong@1: for d in divisors: csong@1: if index % d == 0: csong@1: offbeatness[index] = 0 csong@1: break csong@1: syncopation += bseq_ts[index]*offbeatness[index] csong@1: return syncopation