Mercurial > hg > syncopation-dataset
comparison Syncopation models/music_objects.py @ 21:b6daddeefda9
working on KTH
author | csong <csong@eecs.qmul.ac.uk> |
---|---|
date | Tue, 07 Apr 2015 23:16:13 +0100 |
parents | b959c2acb927 |
children | 2dbc09ca8013 |
comparison
equal
deleted
inserted
replaced
20:b959c2acb927 | 21:b6daddeefda9 |
---|---|
1 | 1 |
2 from basic_functions import ceiling, string_to_sequence | 2 from basic_functions import ceiling, string_to_sequence, calculate_time_span_ticks |
3 | 3 |
4 import parameter_setter | 4 import parameter_setter |
5 import rhythm_parser | 5 import rhythm_parser |
6 | 6 |
7 class Note(): | 7 class Note(): |
66 self.timeSignature = TimeSignature(timeSignature) | 66 self.timeSignature = TimeSignature(timeSignature) |
67 self.nextBar = nextBar | 67 self.nextBar = nextBar |
68 self.prevBar = prevBar | 68 self.prevBar = prevBar |
69 | 69 |
70 def get_note_sequence(self): | 70 def get_note_sequence(self): |
71 #if self.noteSequence==None: | 71 if self.noteSequence==None: |
72 # self.noteSequence = velocity_sequence_to_notes(self.velocitySequence) | 72 self.noteSequence = velocity_sequence_to_notes(self.velocitySequence) |
73 return self.noteSequence | 73 return self.noteSequence |
74 | 74 |
75 def get_velocity_sequence(self): | 75 def get_velocity_sequence(self): |
76 if self.velocitySequence==None: | 76 if self.velocitySequence==None: |
77 self.velocitySequence = note_sequence_to_velocities(self.velocitySequence) | 77 self.velocitySequence = note_sequence_to_velocities(self.noteSequence) |
78 return self.velocitySequence | 78 return self.velocitySequence |
79 | 79 |
80 def get_binary_sequence(self): | 80 def get_binary_sequence(self): |
81 return ceiling(self.get_velocity_sequence()) | 81 return ceiling(self.get_velocity_sequence()) |
82 | 82 |
99 return self.timeSignature.get_beat_level() | 99 return self.timeSignature.get_beat_level() |
100 | 100 |
101 def get_time_signature(self): | 101 def get_time_signature(self): |
102 return self.timeSignature | 102 return self.timeSignature |
103 | 103 |
104 def get_t_span(self): | 104 # return the length of a bar in time units (ticks) |
105 # return the length of a bar in time units | 105 def get_time_span(self): |
106 return None # NEED TO IMPLEMENT | 106 return calculate_time_span_ticks(self.timeSignature.get_numerator(),self.timeSignature.get_denominator(), self.ticksPerQuarter) |
107 | 107 |
108 class TimeSignature(): | 108 class TimeSignature(): |
109 def __init__(self, inputString): | 109 def __init__(self, inputString): |
110 if inputString in parameter_setter.read_time_signature(): | 110 if inputString in parameter_setter.read_time_signature(): |
111 self.tsString = inputString | 111 self.tsString = inputString |