comparison Syncopation models/SG.py @ 32:273450d5980a

tested parameter setting.
author csong <csong@eecs.qmul.ac.uk>
date Sun, 12 Apr 2015 23:23:32 +0100
parents 5de1cb45c145
children f5abd2e8cafe
comparison
equal deleted inserted replaced
30:d9ac6e0d1daf 32:273450d5980a
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, velocity_sequence_to_min_timespan, get_rhythm_category, upsample_velocity_sequence 7 from basic_functions import get_H, velocity_sequence_to_min_timespan, get_rhythm_category, upsample_velocity_sequence
8 from parameter_setter import are_parameters_valid
8 9
9 def get_syncopation(bar, parameters = None): 10 def get_syncopation(bar, parameters = None):
10 syncopation = None 11 syncopation = None
11 velocitySequence = bar.get_velocity_sequence() 12 velocitySequence = bar.get_velocity_sequence()
12 subdivisionSequence = bar.get_subdivision_sequence() 13 subdivisionSequence = bar.get_subdivision_sequence()
79 h = H[index] 80 h = H[index]
80 # Syncopation potential according to its metrical level, which is equal to the metrical weight 81 # Syncopation potential according to its metrical level, which is equal to the metrical weight
81 potential = 1 - pow(0.5,h) 82 potential = 1 - pow(0.5,h)
82 level = h # Metrical weight is equal to its metrical level 83 level = h # Metrical weight is equal to its metrical level
83 syncopation += min(ave_dif_neighbours(index, level))*potential 84 syncopation += min(ave_dif_neighbours(index, level))*potential
84 85 else:
86 print 'Try giving a bigger Lmax so that the rhythm sequence can be measured by the matching metrical weights sequence (H).'
85 return syncopation 87 return syncopation