comparison synpy/parameter_setter.py @ 76:90b68f259541 tip

updated parameter_setter to be able to find the TimeSignature.pkl file without putting it in the pwd
author christopherh <christopher.harte@eecs.qmul.ac.uk>
date Wed, 13 May 2015 09:27:36 +0100
parents ef891481231e
children
comparison
equal deleted inserted replaced
75:0c744fb4c202 76:90b68f259541
4 ''' 4 '''
5 5
6 # Set the parameters: time-signature, subdivision-sequence, strong-beat-level; Lmax; weight-sequence 6 # Set the parameters: time-signature, subdivision-sequence, strong-beat-level; Lmax; weight-sequence
7 # Important condition: Lmax needs to be no less than the length of subdivision-sequence and the length of weight-sequence 7 # Important condition: Lmax needs to be no less than the length of subdivision-sequence and the length of weight-sequence
8 8
9 def getScriptPath():
10 import os
11 return os.path.dirname(os.path.realpath(__file__))
9 12
10 # {'key': time-signature} : 13 # {'key': time-signature} :
11 # {'value': [subdivision-sequence, theoretical beat-level represented by index in the subdivision-sequence list]} 14 # {'value': [subdivision-sequence, theoretical beat-level represented by index in the subdivision-sequence list]}
12 timeSignatureBase = { 15 timeSignatureBase = {
13 '2/2': [[1,2,2,2,2,2,2,2,2,2,2,2,2,2],1], 16 '2/2': [[1,2,2,2,2,2,2,2,2,2,2,2,2,2],1],
54 isValid = True 57 isValid = True
55 return isValid 58 return isValid
56 59
57 def write_time_signature(): 60 def write_time_signature():
58 import cPickle as pickle 61 import cPickle as pickle
59 timeSigFile = open('TimeSignature.pkl', 'wb') 62 timeSigFile = open(getScriptPath()+'/TimeSignature.pkl', 'wb')
60 pickle.dump(timeSignatureBase, timeSigFile) 63 pickle.dump(timeSignatureBase, timeSigFile)
61 timeSigFile.close() 64 timeSigFile.close()
62 65
63 def read_time_signature(): 66 def read_time_signature():
64 import cPickle as pickle 67 import cPickle as pickle
65 timeSigFile = open('TimeSignature.pkl','rb') 68 timeSigFile = open(getScriptPath()+'/TimeSignature.pkl','rb')
66 data = pickle.load(timeSigFile) 69 data = pickle.load(timeSigFile)
67 return data 70 return data
68 timeSigFile.close() 71 timeSigFile.close()
69 72
70 def print_time_signature_base(): 73 def print_time_signature_base():