Mercurial > hg > syncopation-dataset
view Syncopation models/TOB.py @ 8:2c5df6a4a22f
updated music objects, removed old bar definition from rhythm
parser
author | christopherh <christopher.harte@eecs.qmul.ac.uk> |
---|---|
date | Thu, 02 Apr 2015 00:06:57 +0100 |
parents | 031e2ccb1fb6 |
children | b959c2acb927 |
line wrap: on
line source
''' Author: Chunyang Song Institution: Centre for Digital Music, Queen Mary University of London ''' from BasicFuncs import ceiling, find_divisor, get_min_timeSpan # This function calculates the syncopation value for TOB model. def get_syncopation(seq): syncopation = 0 bseq_ts = get_min_timeSpan(ceiling(seq)) # converting to binary and mininum time-span sequence divisors = find_divisor(len(bseq_ts)) # find all the divisors other than 1 and the length of this sequence del divisors[0] del divisors[-1] offbeatness = [1]*len(bseq_ts) for index in range(len(bseq_ts)): for d in divisors: if index % d == 0: offbeatness[index] = 0 break syncopation += bseq_ts[index]*offbeatness[index] return syncopation