def _pre145_cleanExtraAux(self): """correct a possible error where, when going from a larger to a smaller aux value, extra Q keys exist that should not by the aux count this causes errors elsewhere, and his been fixed this method looks a the aux and removes any extra aux like things""" t = self.tData for tName in list(t['textureLib'].keys()): auxNo = t['textureLib'][tName]['auxNo'] # store all valid auxLabelValid = basePmtr.auxLabel(auxNo) for pmtrKey in list(t['textureLib'][tName]['pmtrQDict'].keys()): if pmtrKey not in auxLabelValid: # not a valid auxq if pmtrKey[:4] == 'auxQ': # if it looks like an auxq del t['textureLib'][tName]['pmtrQDict'][pmtrKey] environment.printDebug( ['removed extra auxQ:', pmtrKey]) # clear extra clone aux as well for cName in list(t['cloneLib'].keys()): auxNo = t['cloneLib'][cName]['auxNo'] # store all valid auxLabelValid = basePmtr.auxLabel(auxNo) for pmtrKey in list(t['cloneLib'][cName]['pmtrQDict'].keys()): if pmtrKey not in auxLabelValid: # not a valid auxq if pmtrKey[:4] == 'auxQ': # if it looks like an auxq del t['cloneLib'][cName]['pmtrQDict'][pmtrKey] environment.printDebug( ['removed extra auxQ:', pmtrKey])
def getAux(self, valueArrayList, tEvalArray, refDict): """ get the value list from texture aux parameter valueArrayList is a list of aux values for each event this needs to be converted into a list of values for each aux then converted back """ auxEventList = [] # seperate val for each aux for i, auxLabel in basePmtr.auxLabel(self.auxNo, 1): auxEventList.append([]) # add a list for each aux # go through values and split each aux into separate list, chanelize for event in valueArrayList: assert len(event) == self.auxNo for i, auxLabel in basePmtr.auxLabel(self.auxNo, 1): auxEventList[i].append(event[i]) # process dataArray in each aux independently for i, auxLabel in basePmtr.auxLabel(self.auxNo, 1): valArray = auxEventList[i] # dataArray for one aux value auxArray = self.pmtrObjDict[auxLabel](valArray, tEvalArray, refDict) auxEventList[i] = auxArray # restore to format where each event has all array values auxiliary = [] for e in range(0, len(valueArrayList)): # go through each event eventData = [] # get data for each aux in this event, put into one list for i, auxLabel in basePmtr.auxLabel(self.auxNo, 1): eventData.append(auxEventList[i][e]) auxiliary.append(eventData) return auxiliary
def getAux(self, valueArrayList, tEvalArray, refDict): """ get the value list from texture aux parameter valueArrayList is a list of aux values for each event this needs to be converted into a list of values for each aux then converted back """ auxEventList = [] # seperate val for each aux for i, auxLabel in basePmtr.auxLabel(self.auxNo, 1): auxEventList.append([]) # add a list for each aux # go through values and split each aux into separate list, chanelize for event in valueArrayList: assert len(event) == self.auxNo for i, auxLabel in basePmtr.auxLabel(self.auxNo, 1): auxEventList[i].append(event[i]) # process dataArray in each aux independently for i, auxLabel in basePmtr.auxLabel(self.auxNo, 1): valArray = auxEventList[i] # dataArray for one aux value auxArray = self.pmtrObjDict[auxLabel](valArray, tEvalArray, refDict) auxEventList[i] = auxArray # restore to format where each event has all array values auxiliary = [] for e in range(0,len(valueArrayList)): # go through each event eventData = [] # get data for each aux in this event, put into one list for i, auxLabel in basePmtr.auxLabel(self.auxNo, 1): eventData.append(auxEventList[i][e]) auxiliary.append(eventData) return auxiliary
def _pre145_cleanExtraAux(self): """correct a possible error where, when going from a larger to a smaller aux value, extra Q keys exist that should not by the aux count this causes errors elsewhere, and his been fixed this method looks a the aux and removes any extra aux like things""" t = self.tData for tName in t["textureLib"].keys(): auxNo = t["textureLib"][tName]["auxNo"] # store all valid auxLabelValid = basePmtr.auxLabel(auxNo) for pmtrKey in t["textureLib"][tName]["pmtrQDict"].keys(): if pmtrKey not in auxLabelValid: # not a valid auxq if pmtrKey[:4] == "auxQ": # if it looks like an auxq del t["textureLib"][tName]["pmtrQDict"][pmtrKey] environment.printDebug(["removed extra auxQ:", pmtrKey]) # clear extra clone aux as well for cName in t["cloneLib"].keys(): auxNo = t["cloneLib"][cName]["auxNo"] # store all valid auxLabelValid = basePmtr.auxLabel(auxNo) for pmtrKey in t["cloneLib"][cName]["pmtrQDict"].keys(): if pmtrKey not in auxLabelValid: # not a valid auxq if pmtrKey[:4] == "auxQ": # if it looks like an auxq del t["cloneLib"][cName]["pmtrQDict"][pmtrKey] environment.printDebug(["removed extra auxQ:", pmtrKey])
def _updateInstPmtr(self, refDict): """when a texture's instrument is changed, aux numbers may change this change must be represented in the clone updates the parameter dict to that of a new instrument does not reload objects; must be done with updatePmtrObj used for converting/refreshing instruments """ oldAuxNo = self.auxNo # store old self.auxNo = refDict['auxNo'] # aux no passed in ref dict self.auxFmt = refDict['auxFmt'] # aux no passed in ref dict oldPmtrDict = copy.deepcopy(self.pmtrQDict) #print _MOD, 'clone: oldAuxNo, self.AuxNo', oldAuxNo, self.auxNo print lang.WARN, 'new Clone auxiliary value %s' % self.auxNo # remove old aux values for auxLabel in basePmtr.auxLabel(oldAuxNo): del self.pmtrQDict[auxLabel] if auxLabel in self.pmtrObjDict.keys( ): # remove objects if they exist del self.pmtrObjDict[auxLabel] # insert new values from defaults for auxLabel in basePmtr.auxLabel(self.auxNo): self.pmtrQDict[auxLabel] = self._defaultPmtrArg()
def _reprView(self, extData={}): """privide standard TIv display""" headList = [] headList.append('TC: %s, TI: %s\n' % (self.name, self.nameParent)) tStrAbs = typeset.timeRangeAsStr(self.timeRangeAbs) headList.append('%s%s: %s, duration: %s\n' % (lang.TAB, lang.MUTELABEL, self._getMuteStr(), tStrAbs)) entryLines = [] for p in ('time', 'sus', 'acc'): if p not in self.pmtrActive: continue attr, label = self.decodePmtrName(p) entryLines.append([label, self.pmtrObjDict[attr].repr()]) for p in ('fieldQ', 'octQ', 'ampQ', 'panQ'): if p not in self.pmtrActive: continue attr, label = self.decodePmtrName(p) entryLines.append([label, self.pmtrObjDict[attr].repr()]) if self.auxNo == 0: entryLines.append([self.decodePmtrName('x')[1], 'none']) else: entryLines.append([self.decodePmtrName('x')[1], '']) for i, auxLabel in basePmtr.auxLabel(self.auxNo, 1): valueStr = self.pmtrObjDict[auxLabel].repr() entryLines.append([(lang.TAB + 'x%i'% i), valueStr]) if self.clonePmtrNo == 0: entryLines.append([self.decodePmtrName('s')[1], 'none']) else: entryLines.append([self.decodePmtrName('s')[1], '']) for i, textLabel in basePmtr.cloneLabel(self.clonePmtrNo, 1): valueStr = self.pmtrObjDict[textLabel].repr() entryLines.append([(lang.TAB + 's%i'% i), valueStr]) return headList, entryLines
def _reprView(self, extData={}): """privide standard TIv display""" headList = [] headList.append('TC: %s, TI: %s\n' % (self.name, self.nameParent)) tStrAbs = typeset.timeRangeAsStr(self.timeRangeAbs) headList.append( '%s%s: %s, duration: %s\n' % (lang.TAB, lang.MUTELABEL, self._getMuteStr(), tStrAbs)) entryLines = [] for p in ('time', 'sus', 'acc'): if p not in self.pmtrActive: continue attr, label = self.decodePmtrName(p) entryLines.append([label, self.pmtrObjDict[attr].repr()]) for p in ('fieldQ', 'octQ', 'ampQ', 'panQ'): if p not in self.pmtrActive: continue attr, label = self.decodePmtrName(p) entryLines.append([label, self.pmtrObjDict[attr].repr()]) if self.auxNo == 0: entryLines.append([self.decodePmtrName('x')[1], 'none']) else: entryLines.append([self.decodePmtrName('x')[1], '']) for i, auxLabel in basePmtr.auxLabel(self.auxNo, 1): valueStr = self.pmtrObjDict[auxLabel].repr() entryLines.append([(lang.TAB + 'x%i' % i), valueStr]) if self.clonePmtrNo == 0: entryLines.append([self.decodePmtrName('s')[1], 'none']) else: entryLines.append([self.decodePmtrName('s')[1], '']) for i, textLabel in basePmtr.cloneLabel(self.clonePmtrNo, 1): valueStr = self.pmtrObjDict[textLabel].repr() entryLines.append([(lang.TAB + 's%i' % i), valueStr]) return headList, entryLines
def editPmtrObj(self, pmtrName, pmtrValue, refDict, esObj=None, refresh=1): """refresh: turn off score generation clearing a clone may be good; texture should not be cleared clearing the esObj of a clone causes a problem when trying to using the TCmap comamnd; for now, do not clear score self.clearScore() # dont store all this data, but pmtrs updated """ p = pmtrName newData = pmtrValue if (p in self.pmtrCommon and p not in self.pmtrActive): return None, 'no %s parameter in TC %s.' % (p, self.name) elif (p in ('time', 'sus', 'acc', 'ampQ', 'panQ', 'fieldQ', 'octQ',) or p[:4]=='auxQ' or p[:6]=='cloneQ'): if p[:4] == 'auxQ': if p not in basePmtr.auxLabel(self.auxNo): return 0, 'no such auxiliary label' if p[:6] == 'cloneQ': if p not in basePmtr.cloneLabel(self.clonePmtrNo): return 0, 'no such clone label' attrName = 'pmtrQDict' oldData = self.pmtrQDict # attrReference newData = copy.deepcopy(self.pmtrQDict) # copy old dict newData[p] = pmtrValue else: return 0, 'incorrect parameter label access.' setattr(self, attrName, newData) # make change try: # try to refresh objects editPhase = 'object creation:' ok, msg = self.updatePmtrObj(p, refDict) if not ok: self._editRestore(attrName, p, oldData, refDict) return ok, msg if refresh and esObj != None: # test w/ an esObj editPhase = 'score creation:' ok = self.score(esObj, refDict) if not ok: self._editRestore(attrName, p, oldData, refDict) return ok, 'score creation returned an error.' except error.ParameterObjectSyntaxError as msg: # standard init errors from pmtr obj msg = '%s %s' % (editPhase, msg) ok = 0 except IndexError as msg: msg = '%s incorrect number of arguments. %s.' % (editPhase, msg) ok = 0 except TypeError as msg: msg = '%s incorrect data-type in arguments. %s' % (editPhase, msg) ok = 0 except UnboundLocalError as msg: msg = '%s incorrect paramater type in arguments. %s' % (editPhase, msg) ok = 0 except ValueError as msg: msg = '%s value error: an inappropriate data type used.' % editPhase ok = 0 except ZeroDivisionError: msg = '%s zero division error: zero cannot be a divisor.' % editPhase ok = 0 if not ok: self._editRestore(attrName, p, oldData, refDict) return ok, msg return 1, '' # success
def _reprDocAuxArgs(self): """documentation for aix args; does not include title in the list""" entryLines = [] if self.auxNo != 0: for i, auxLabel in basePmtr.auxLabel(self.auxNo, 1): valueStr = self.pmtrObjDict[auxLabel].reprDoc('argsMax') #labelStr = '%sx%i'% (lang.TAB, i) entryLines.append(['', valueStr]) return entryLines
def _updateInstPmtr(self, refDict): """when a texture's instrument is changed, aux numbers may change this change must be represented in the clone updates the parameter dict to that of a new instrument does not reload objects; must be done with updatePmtrObj used for converting/refreshing instruments """ oldAuxNo = self.auxNo # store old self.auxNo = refDict['auxNo'] # aux no passed in ref dict self.auxFmt = refDict['auxFmt'] # aux no passed in ref dict oldPmtrDict = copy.deepcopy(self.pmtrQDict) #print _MOD, 'clone: oldAuxNo, self.AuxNo', oldAuxNo, self.auxNo print lang.WARN, 'new Clone auxiliary value %s' % self.auxNo # remove old aux values for auxLabel in basePmtr.auxLabel(oldAuxNo): del self.pmtrQDict[auxLabel] if auxLabel in self.pmtrObjDict.keys(): # remove objects if they exist del self.pmtrObjDict[auxLabel] # insert new values from defaults for auxLabel in basePmtr.auxLabel(self.auxNo): self.pmtrQDict[auxLabel] = self._defaultPmtrArg()
def loadDefault(self, auxNo, auxFmt): """create an empty clone dict note: no refershing of event is done here; just loads parameters obs >>> a = Clone() >>> a.loadDefault(3, 'num') """ # defaults do not come from anywhere else... self.auxNo = auxNo pmtrQDict = {} pmtrQDict['time'] = ('filterAdd', ('l',(1,) )) pmtrQDict['sus'] = self._defaultPmtrArg() pmtrQDict['acc'] = self._defaultPmtrArg() pmtrQDict['ampQ'] = self._defaultPmtrArg() pmtrQDict['panQ'] = self._defaultPmtrArg() pmtrQDict['octQ'] = self._defaultPmtrArg() pmtrQDict['fieldQ'] = self._defaultPmtrArg() for auxLabel in basePmtr.auxLabel(self.auxNo): pmtrQDict[auxLabel] = self._defaultPmtrArg() self.load(pmtrQDict, auxNo, auxFmt)
def loadDefault(self, auxNo, auxFmt): """create an empty clone dict note: no refershing of event is done here; just loads parameters obs >>> a = Clone() >>> a.loadDefault(3, 'num') """ # defaults do not come from anywhere else... self.auxNo = auxNo pmtrQDict = {} pmtrQDict['time'] = ('filterAdd', ('l', (1, ))) pmtrQDict['sus'] = self._defaultPmtrArg() pmtrQDict['acc'] = self._defaultPmtrArg() pmtrQDict['ampQ'] = self._defaultPmtrArg() pmtrQDict['panQ'] = self._defaultPmtrArg() pmtrQDict['octQ'] = self._defaultPmtrArg() pmtrQDict['fieldQ'] = self._defaultPmtrArg() for auxLabel in basePmtr.auxLabel(self.auxNo): pmtrQDict[auxLabel] = self._defaultPmtrArg() self.load(pmtrQDict, auxNo, auxFmt)
def editPmtrObj(self, pmtrName, pmtrValue, refDict, esObj=None, refresh=1): """refresh: turn off score generation clearing a clone may be good; texture should not be cleared clearing the esObj of a clone causes a problem when trying to using the TCmap comamnd; for now, do not clear score self.clearScore() # dont store all this data, but pmtrs updated """ p = pmtrName newData = pmtrValue if (p in self.pmtrCommon and p not in self.pmtrActive): return None, 'no %s parameter in TC %s.' % (p, self.name) elif (p in ('time', 'sus', 'acc', 'ampQ', 'panQ', 'fieldQ', 'octQ',) or p[:4]=='auxQ' or p[:6]=='cloneQ'): if p[:4] == 'auxQ': if p not in basePmtr.auxLabel(self.auxNo): return 0, 'no such auxiliary label' if p[:6] == 'cloneQ': if p not in basePmtr.cloneLabel(self.clonePmtrNo): return 0, 'no such clone label' attrName = 'pmtrQDict' oldData = self.pmtrQDict # attrReference newData = copy.deepcopy(self.pmtrQDict) # copy old dict newData[p] = pmtrValue else: return 0, 'incorrect parameter label access.' setattr(self, attrName, newData) # make change try: # try to refresh objects editPhase = 'object creation:' ok, msg = self.updatePmtrObj(p, refDict) if not ok: self._editRestore(attrName, p, oldData, refDict) return ok, msg if refresh and esObj != None: # test w/ an esObj editPhase = 'score creation:' ok = self.score(esObj, refDict) if not ok: self._editRestore(attrName, p, oldData, refDict) return ok, 'score creation returned an error.' except error.ParameterObjectSyntaxError, msg: # standard init errors from pmtr obj msg = '%s %s' % (editPhase, msg) ok = 0
def load(self, pmtrQDict, auxNo, auxFmt, mute=0): """load clone data tRef is time reference, either clone or texture time load, unlike texture, does not automatically score""" self.mute = mute self.auxNo = auxNo self.auxFmt = auxFmt #as cloneStatic parameterObject #self.timeRef = timeRef self.pmtrObjDict = {} self.pmtrQDict = copy.deepcopy(pmtrQDict) self.pmtrObjDict['time'] = parameter.factory(self.pmtrQDict['time'], 'filterPmtrObjs') self.pmtrObjDict['sus'] = parameter.factory(self.pmtrQDict['sus'], 'filterPmtrObjs') self.pmtrObjDict['acc'] = parameter.factory(self.pmtrQDict['acc'], 'filterPmtrObjs') self.pmtrObjDict['fieldQ'] = parameter.factory(self.pmtrQDict['fieldQ'], 'filterPmtrObjs') self.pmtrObjDict['octQ'] = parameter.factory(self.pmtrQDict['octQ'], 'filterPmtrObjs') self.pmtrObjDict['ampQ'] = parameter.factory(self.pmtrQDict['ampQ'], 'filterPmtrObjs') self.pmtrObjDict['panQ'] = parameter.factory(self.pmtrQDict['panQ'], 'filterPmtrObjs') for auxLabel in basePmtr.auxLabel(self.auxNo): self.pmtrObjDict[auxLabel] = parameter.factory( self.pmtrQDict[auxLabel], 'filterPmtrObjs') self._updateClonePmtrDefaults() for cloneLabel in self.cloneLabels: # load object into textPmtr object args = self.pmtrQDict[cloneLabel] self.pmtrObjDict[cloneLabel] = parameter.factory(args, 'clonePmtrObjs', self.refDict)
def load(self, pmtrQDict, auxNo, auxFmt, mute=0): """load clone data tRef is time reference, either clone or texture time load, unlike texture, does not automatically score""" self.mute = mute self.auxNo = auxNo self.auxFmt = auxFmt #as cloneStatic parameterObject #self.timeRef = timeRef self.pmtrObjDict = {} self.pmtrQDict = copy.deepcopy(pmtrQDict) self.pmtrObjDict['time'] = parameter.factory(self.pmtrQDict['time'], 'filterPmtrObjs') self.pmtrObjDict['sus'] = parameter.factory(self.pmtrQDict['sus'], 'filterPmtrObjs') self.pmtrObjDict['acc'] = parameter.factory(self.pmtrQDict['acc'], 'filterPmtrObjs') self.pmtrObjDict['fieldQ'] = parameter.factory( self.pmtrQDict['fieldQ'], 'filterPmtrObjs') self.pmtrObjDict['octQ'] = parameter.factory(self.pmtrQDict['octQ'], 'filterPmtrObjs') self.pmtrObjDict['ampQ'] = parameter.factory(self.pmtrQDict['ampQ'], 'filterPmtrObjs') self.pmtrObjDict['panQ'] = parameter.factory(self.pmtrQDict['panQ'], 'filterPmtrObjs') for auxLabel in basePmtr.auxLabel(self.auxNo): self.pmtrObjDict[auxLabel] = parameter.factory( self.pmtrQDict[auxLabel], 'filterPmtrObjs') self._updateClonePmtrDefaults() for cloneLabel in self.cloneLabels: # load object into textPmtr object args = self.pmtrQDict[cloneLabel] self.pmtrObjDict[cloneLabel] = parameter.factory( args, 'clonePmtrObjs', self.refDict)