comparison Syncopation models/rhythm_parser.py @ 35:3a878de00d19

made some small changes to files
author csong <csong@eecs.qmul.ac.uk>
date Mon, 13 Apr 2015 17:43:18 +0100
parents 7a1730bbf15a
children cc38b3047ed9
comparison
equal deleted inserted replaced
34:82496b4e2f96 35:3a878de00d19
1 ''' 1 '''
2 Author: Chunyang Song 2 Authors: Chunyang Song, Christopher Harte
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 # Parse the rhythm file and return a list of Bar objects 6 # Parse the rhythm file and return a list of Bar objects
7 #Piece = [] 7 #Piece = []
17 17
18 def discard_spaces(line): 18 def discard_spaces(line):
19 line = line.replace(" ", '').replace("\t", '') 19 line = line.replace(" ", '').replace("\t", '')
20 return line 20 return line
21 21
22 def extractInfo(line): 22 # def extractInfo(line):
23 try: 23 # try:
24 if '{' not in line and '}' not in line: 24 # if '{' not in line and '}' not in line:
25 raise RhythmSyntaxError(line) 25 # raise RhythmSyntaxError(line)
26 else: 26 # else:
27 return line[line.find('{')+1 : line.find('}')] 27 # return line[line.find('{')+1 : line.find('}')]
28 except RhythmSyntaxError: 28 # except RhythmSyntaxError:
29 print 'Rhythmic information needs to be enclosed by "{" and "}"' 29 # print 'Rhythmic information needs to be enclosed by "{" and "}"'
30
31 30
32 31
33 def read_rhythm(fileName): 32 def read_rhythm(fileName):
34 fileContent = file(fileName) 33 fileContent = file(fileName)
35 34
67 barList.concat(newbarlist) 66 barList.concat(newbarlist)
68 67
69 return barList 68 return barList
70 69
71 def is_comment(line): 70 def is_comment(line):
72 if discard_spaces(line)[0]=="#": 71 if discard_spaces(line)[0]==comment_sign:
73 return True 72 return True
74 else: 73 else:
75 return False 74 return False
76 75
77 def parse_line(line, timeSignature=None, tempo=None, ticksPerQuarter=None): 76 def parse_line(line, timeSignature=None, tempo=None, ticksPerQuarter=None):