Mercurial > hg > syncopation-dataset
comparison Syncopation models/TMC.py @ 23:df1e7c378ee0
fixed KTH, and WNBD
author | csong <csong@eecs.qmul.ac.uk> |
---|---|
date | Sun, 12 Apr 2015 13:06:17 +0100 |
parents | b959c2acb927 |
children | 5de1cb45c145 |
comparison
equal
deleted
inserted
replaced
22:2dbc09ca8013 | 23:df1e7c378ee0 |
---|---|
2 Author: Chunyang Song | 2 Author: Chunyang Song |
3 Institution: Centre for Digital Music, Queen Mary University of London | 3 Institution: Centre for Digital Music, Queen Mary University of London |
4 | 4 |
5 ''' | 5 ''' |
6 | 6 |
7 from basic_functions import get_H, ceiling, get_min_timeSpan, get_rhythm_category | 7 from basic_functions import get_H, ceiling, velocity_sequence_to_min_timespan, get_rhythm_category |
8 | 8 |
9 # The get_metricity function calculates the metricity for a binary sequence with given sequence of metrical weights in a certain metrical level. | 9 # The get_metricity function calculates the metricity for a binary sequence with given sequence of metrical weights in a certain metrical level. |
10 def get_metricity(binarySequence, H): | 10 def get_metricity(binarySequence, H): |
11 metricity = 0 | 11 metricity = 0 |
12 for m in range(len(binarySequence)): | 12 for m in range(len(binarySequence)): |
53 subdivisionSequence = bar.get_subdivision_sequence() | 53 subdivisionSequence = bar.get_subdivision_sequence() |
54 | 54 |
55 if get_rhythm_category(binarySequence, subdivisionSequence) == 'poly': | 55 if get_rhythm_category(binarySequence, subdivisionSequence) == 'poly': |
56 print 'Warning: TMC model detects polyrhythms so returning None.' | 56 print 'Warning: TMC model detects polyrhythms so returning None.' |
57 else: | 57 else: |
58 binarySequence = get_min_timeSpan(binarySequence) # converting to the minimum time-span format | 58 binarySequence = velocity_sequence_to_min_timespan(binarySequence) # converting to the minimum time-span format |
59 | 59 |
60 # If the parameters are not given, use the default settings | 60 # If the parameters are not given, use the default settings |
61 if parameters == None: | 61 if parameters == None: |
62 Lmax = 5 | 62 Lmax = 5 |
63 weightSequence = range(Lmax+1,0,-1) # i.e. [6,5,4,3,2,1] | 63 weightSequence = range(Lmax+1,0,-1) # i.e. [6,5,4,3,2,1] |