comparison Syncopation models/TOB.py @ 1:b2da092dc2e0

The consolidated syncopation software. Have finished individual model and basic functions. Need to revise the coding in main.py, and add rhythm-input interface.
author Chunyang Song <csong@eecs.qmul.ac.uk>
date Sun, 05 Oct 2014 21:52:41 +0100
parents
children 031e2ccb1fb6
comparison
equal deleted inserted replaced
0:76ce27beba95 1:b2da092dc2e0
1 '''
2 Author: Chunyang Song
3 Institution: Centre for Digital Music, Queen Mary University of London
4
5 '''
6
7 from basic_functions import ceiling, find_divisor, get_min_timeSpan
8
9 # This function calculates the syncopation value for TOB model.
10 def get_syncopation(seq):
11 syncopation = 0
12 bseq_ts = get_min_timeSpan(ceiling(seq)) # converting to binary and mininum time-span sequence
13 divisors = find_divisor(len(bseq_ts)) # find all the divisors other than 1 and the length of this sequence
14 del divisors[0]
15 del divisors[-1]
16
17 offbeatness = [1]*len(bseq_ts)
18 for index in range(len(bseq_ts)):
19 for d in divisors:
20 if index % d == 0:
21 offbeatness[index] = 0
22 break
23 syncopation += bseq_ts[index]*offbeatness[index]
24 return syncopation