Mercurial > hg > syncopation-dataset
changeset 18:43fa04812800
Added TimeSignature class
author | csong <csong@eecs.qmul.ac.uk> |
---|---|
date | Fri, 03 Apr 2015 18:38:10 +0100 |
parents | a5a26d2cff40 |
children | 9030967a05f8 |
files | Syncopation models/music_objects.py |
diffstat | 1 files changed, 24 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/Syncopation models/music_objects.py Fri Apr 03 17:28:26 2015 +0100 +++ b/Syncopation models/music_objects.py Fri Apr 03 18:38:10 2015 +0100 @@ -63,7 +63,7 @@ self.tpq = ticksPerQuarter self.qpm = qpmTempo - self.timeSignature = timeSignature + self.timeSignature = TimeSignature(timeSignature) self.nextBar = nextBar self.prevBar = prevBar @@ -93,7 +93,7 @@ self.prevBar = bar def get_subdivision_sequence(self): - return ParameterSetter.get_subdivision_seq(self.timeSignature) + return self.timeSignature.get_subdivision_sequence() def get_beat_level(self): return ParameterSetter.get_beat_level(self.timeSignature) @@ -105,3 +105,25 @@ # return the length of a bar in time units return None # NEED TO IMPLEMENT +class TimeSignature(): + def __init__(self, inputString): + if inputString in parameter_setter.readTimesig(): + self.tsString = inputString + else: + print "Error: undefined time-signature ", inputString + raise NullTimeSignatureError + + def get_subdivision_sequence(self): + return parameter_setter.timesigBase[self.tsString][0] + + def get_beat_level(self): + return parameter_setter.timesigBase[self.tsString][1] + + def get_numerator(self): + return int(self.tsString.split('/')[0]) + + def get_denominator(self): + return int(self.tsString.split('/')[1]) + + +