def _evalPmtrObj(self, pmtrName, refDict): """called for editing a single parameter object handle all exceptions of parameter creation """ args = self.pmtrQDict[pmtrName] if pmtrName[:6] == 'cloneQ': # check texture options try: self.pmtrObjDict[pmtrName] = parameter.factory(args, 'clonePmtrObjs', refDict) except error.ParameterObjectSyntaxError as msg: # initialization errors return 0, 'incorrect arguments: %s' % msg else: try: self.pmtrObjDict[pmtrName] = parameter.factory(args, 'filterPmtrObjs', refDict) except error.ParameterObjectSyntaxError as msg: # initialization errors return 0, 'incorrect arguments: %s' % msg # check for errors if self.pmtrObjDict[pmtrName] == None: # failure to match object type return 0, 'there is no parameterObject with that name.' # check for proper types elif pmtrName[:6] == 'cloneQ': if self.pmtrObjDict[pmtrName].parent != 'cloneStatic': return 0, 'only a clone parameterObject can be used here.' else: #print _MOD, 'parent', self.pmtrObjDict[pmtrName].parent if self.pmtrObjDict[pmtrName].parent != 'cloneFilter': return 0, 'a clone filter parameterObject must be used here.' # everything good, check args ok, msg = self.pmtrObjDict[pmtrName].checkArgs() return ok, msg
def _loadMinMax(self, min, max): ''' >>> a = Parameter([]) >>> post = a._loadMinMax(45, 34) >>> post[0].type, post[1].type ('constant', 'constant') >>> post = a._loadMinMax(45, ['ru', 0, 1]) >>> post[0].type, post[1].type ('constant', 'randomUniform') >>> post = a._loadMinMax(['ru', 0, 1], ['ru', 0, 1]) >>> post[0].type, post[1].type ('randomUniform', 'randomUniform') ''' if drawer.isNum(min): minArgs = ('c', min) elif drawer.isList(min): minArgs = min # check max if drawer.isNum(max): maxArgs = ('c', max) elif drawer.isList(max): maxArgs = max # create a parameter object from athenaCL.libATH.libPmtr import parameter try: minObj = parameter.factory(minArgs) except error.ParameterObjectSyntaxError as msg: raise error.ParameterObjectSyntaxError('failed sub-parameter: %s' % msg) try: maxObj = parameter.factory(maxArgs) except error.ParameterObjectSyntaxError as msg: raise error.ParameterObjectSyntaxError('failed sub-parameter: %s' % msg) return minObj, maxObj
def _loadMinMax(self, min, max): ''' >>> a = Parameter([]) >>> post = a._loadMinMax(45, 34) >>> post[0].type, post[1].type ('constant', 'constant') >>> post = a._loadMinMax(45, ['ru', 0, 1]) >>> post[0].type, post[1].type ('constant', 'randomUniform') >>> post = a._loadMinMax(['ru', 0, 1], ['ru', 0, 1]) >>> post[0].type, post[1].type ('randomUniform', 'randomUniform') ''' if drawer.isNum(min): minArgs = ('c', min) elif drawer.isList(min): minArgs = min # check max if drawer.isNum(max): maxArgs = ('c', max) elif drawer.isList(max): maxArgs = max # create a parameter object from athenaCL.libATH.libPmtr import parameter try: minObj = parameter.factory(minArgs) except error.ParameterObjectSyntaxError, msg: raise error.ParameterObjectSyntaxError, 'failed sub-parameter: %s' % msg
def __init__(self, args, refDict): basePmtr.RhythmParameter.__init__(self, args, refDict) # call base init self.type = 'iterateRhythmWindow' self.doc = lang.docPoIrw self.argTypes = ['list', 'list', 'str'] self.argNames = ['parameterObjectList: a list of Rhythm Generators', 'parameterObject: generate or skip control Generator', 'selectionString'] self.argDefaults = [( ('l', ((4,3,1),(4,3,1),(4,2,0),(8,1,1),(4,2,1),(4,2,1)),'oc'), ('cs', ('ru', 1.5, 4)), ), ('bg','rc',(-3,6,-1,15)), 'oc'] # check raw arguments for number, type ok, msg = self._checkRawArgs() if ok == 0: raise error.ParameterObjectSyntaxError(msg) # report error self.valueBuffer = [] # values g selected from athenaCL.libATH.libPmtr import parameter self.objArray = [] for argList in self.args[0]: try: pmtrObj = parameter.factory(argList, 'rthmPmtrObjs') except error.ParameterObjectSyntaxError, msg: raise error.ParameterObjectSyntaxError, 'failed sub-parameter: %s' % msg self.objArray.append(pmtrObj)
def __init__(self, args, refDict): basePmtr.FilterParameter.__init__(self, args, refDict) # call base init self.type = None self.argTypes = ['str', 'list'] self.argNames = [ 'anchorString', 'parameterObject: operator value generator' ] self.argDefaults = ['lower', ('wc', 'e', 30, 0, 0, 1)] # check raw arguments for number, type ok, msg = self._checkRawArgs() if ok == 0: raise error.ParameterObjectSyntaxError(msg) # report error # will raise exception on error self.outputFmt = 'num' # declare outputFmt as num by default self.inputFmt = 'num' # declare outputFmt as num by default self.anchor = self._anchorParser(self.args[0]) #print _MOD, 'anchor set to', self.anchor from athenaCL.libATH.libPmtr import parameter try: self.pmtrObj = parameter.factory(self.args[1], ['genPmtrObjs', 'rthmPmtrObjs']) except error.ParameterObjectSyntaxError as msg: raise error.ParameterObjectSyntaxError('failed sub-parameter: %s' % msg)
def __init__(self, args, refDict): basePmtr.FilterParameter.__init__(self, args, refDict) # call base init self.type = 'pipeLine' self.doc = lang.docPoPl self.argTypes = ['list'] self.argNames = [ 'filterParameterObjectList: a list of sequential Filter ParameterObjects' ] self.argDefaults = [[['or', 40], ['ob']]] # check raw arguments for number, type ok, msg = self._checkRawArgs() if ok == 0: raise error.ParameterObjectSyntaxError(msg) # report error # will raise exception on error self.outputFmt = 'num' # declare outputFmt as num by default self.inputFmt = ['num', 'str'] # declare outputFmt as num by default from athenaCL.libATH.libPmtr import parameter self.objArray = [] for argList in self.args[0]: try: pmtrObj = parameter.factory(argList, 'filterPmtrObjs') except error.ParameterObjectSyntaxError, msg: raise error.ParameterObjectSyntaxError, 'failed sub-parameter: %s' % msg self.objArray.append(pmtrObj)
def __init__(self, pmtrObjDict, temperamentObj): self.pmtrObjDict = pmtrObjDict # reference self.temperamentObj = temperamentObj # reference self._ornLibrary() # updates self.ornLib w/ new values self.ornKeys = list(self.ornLib.keys()) # mu, sigma, min, max; want a range from -1 to 1 self.gaussPmtrObj = parameter.factory(('randomGauss', .5, .1, -1, 1))
def __init__(self, pmtrObjDict, temperamentObj): self.pmtrObjDict = pmtrObjDict # reference self.temperamentObj = temperamentObj # reference self._ornLibrary() # updates self.ornLib w/ new values self.ornKeys = self.ornLib.keys() # mu, sigma, min, max; want a range from -1 to 1 self.gaussPmtrObj = parameter.factory(('randomGauss', .5, .1, -1, 1))
def _updateClonePmtrDefaults(self): """this only supplies names, which wil load defaults""" for i, cloneLabel in basePmtr.cloneLabel(self.clonePmtrNo, 1): # add arg list default if missing to pmtrQdict if not cloneLabel in self.pmtrQDict.keys(): args = [self.clonePmtrNames[i],] dummyObj = parameter.factory(args, 'clonePmtrObjs', self.refDict) self.pmtrQDict[cloneLabel] = dummyObj.getArgs()
def _updateClonePmtrDefaults(self): """this only supplies names, which wil load defaults""" for i, cloneLabel in basePmtr.cloneLabel(self.clonePmtrNo, 1): # add arg list default if missing to pmtrQdict if not cloneLabel in list(self.pmtrQDict.keys()): args = [self.clonePmtrNames[i],] dummyObj = parameter.factory(args, 'clonePmtrObjs', self.refDict) self.pmtrQDict[cloneLabel] = dummyObj.getArgs()
def _loadSub(self, arg, lib, idStr=''): from athenaCL.libATH.libPmtr import parameter try: obj = parameter.factory(arg, lib) except error.ParameterObjectSyntaxError, msg: if idStr == '': raise error.ParameterObjectSyntaxError, 'failed sub-parameter: %s' % msg else: raise error.ParameterObjectSyntaxError, 'failed %s sub-parameter: %s' % (idStr, msg)
def _loadSub(self, arg, lib, idStr=''): from athenaCL.libATH.libPmtr import parameter try: obj = parameter.factory(arg, lib) except error.ParameterObjectSyntaxError, msg: if idStr == '': raise error.ParameterObjectSyntaxError, 'failed sub-parameter: %s' % msg else: raise error.ParameterObjectSyntaxError, 'failed %s sub-parameter: %s' % ( idStr, msg)
def _evalPmtrObj(self, pmtrName, refDict): """called for editing a single parameter object handle all exceptions of parameter creation """ args = self.pmtrQDict[pmtrName] if pmtrName[:6] == 'cloneQ': # check texture options try: self.pmtrObjDict[pmtrName] = parameter.factory( args, 'clonePmtrObjs', refDict) except error.ParameterObjectSyntaxError, msg: # initialization errors return 0, 'incorrect arguments: %s' % msg
def _evalPmtrObj(self, pmtrName, refDict): """called for editing a single parameter object handle all exceptions of parameter creation """ args = self.pmtrQDict[pmtrName] if pmtrName[:6] == 'cloneQ': # check texture options try: self.pmtrObjDict[pmtrName] = parameter.factory(args, 'clonePmtrObjs', refDict) except error.ParameterObjectSyntaxError, msg: # initialization errors return 0, 'incorrect arguments: %s' % msg
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 __init__(self, args, refDict): basePmtr.FilterParameter.__init__(self, args, refDict) # call base init self.type = 'replace' self.doc = lang.docPoR self.argTypes = ['list'] self.argNames = ['parameterObject: generator to replace original values'] self.argDefaults = [('ru', 0, 1)] # check raw arguments for number, type ok, msg = self._checkRawArgs() if ok == 0: raise error.ParameterObjectSyntaxError(msg) # report error # will raise exception on error self.outputFmt = 'num' # declare outputFmt as num by default self.inputFmt = ['num', 'str'] # declare outputFmt as num by default from athenaCL.libATH.libPmtr import parameter try: self.pmtrObj = parameter.factory(self.args[0]) except error.ParameterObjectSyntaxError, msg: raise error.ParameterObjectSyntaxError, 'failed sub-parameter: %s' % msg
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 __init__(self, args, refDict): basePmtr.FilterParameter.__init__(self, args, refDict) # call base init self.type = None self.argTypes = ['list'] self.argNames = ['parameterObject: operator value generator'] self.argDefaults = [('ws', 'e', 30, 0, 0, 1)] # check raw arguments for number, type ok, msg = self._checkRawArgs() if ok == 0: raise error.ParameterObjectSyntaxError(msg) # report error # will raise exception on error self.outputFmt = 'num' # declare outputFmt as num by default self.inputFmt = 'num' # declare outputFmt as num by default from athenaCL.libATH.libPmtr import parameter try: # note: can be eithe gen or filter parameter object self.pmtrObj = parameter.factory(self.args[0], [ 'genPmtrObjs','rthmPmtrObjs']) except error.ParameterObjectSyntaxError, msg: raise error.ParameterObjectSyntaxError, 'failed sub-parameter: %s' % msg
def __init__(self, args, refDict): basePmtr.FilterParameter.__init__(self, args, refDict) # call base init self.type = None self.argTypes = ['list'] self.argNames = ['parameterObject: operator value generator'] self.argDefaults = [('ws', 'e', 30, 0, 0, 1)] # check raw arguments for number, type ok, msg = self._checkRawArgs() if ok == 0: raise error.ParameterObjectSyntaxError(msg) # report error # will raise exception on error self.outputFmt = 'num' # declare outputFmt as num by default self.inputFmt = 'num' # declare outputFmt as num by default from athenaCL.libATH.libPmtr import parameter try: # note: can be eithe gen or filter parameter object self.pmtrObj = parameter.factory(self.args[0], ['genPmtrObjs', 'rthmPmtrObjs']) except error.ParameterObjectSyntaxError, msg: raise error.ParameterObjectSyntaxError, 'failed sub-parameter: %s' % msg
def _loadAutoConstantStr(self, arg, ref, lib='genPmtrObjs'): """accept a number, a list parameter object, or a string from within a dfeind string group""" # ref = {'0' : ['tn', 't', 't n' '0'], # } if drawer.isNum(arg): pmtrArgs = ('c', arg) elif drawer.isStr(arg): post = drawer.selectionParse(arg, ref, 0) # autosearch off if post == None: raise error.ParameterObjectSyntaxError, 'no such preset name known.' pmtrArgs = ('c', post) # a constant pmtr obj else: # its a list to create a ParameterObject pmtrArgs = arg # create a ParameterObject from athenaCL.libATH.libPmtr import parameter try: obj = parameter.factory(pmtrArgs, lib) except error.ParameterObjectSyntaxError, msg: raise error.ParameterObjectSyntaxError, 'failed sub-parameter: %s' % msg
def __init__(self, args, refDict): basePmtr.FilterParameter.__init__(self, args, refDict) # call base init self.type = 'replace' self.doc = lang.docPoR self.argTypes = ['list'] self.argNames = [ 'parameterObject: generator to replace original values' ] self.argDefaults = [('ru', 0, 1)] # check raw arguments for number, type ok, msg = self._checkRawArgs() if ok == 0: raise error.ParameterObjectSyntaxError(msg) # report error # will raise exception on error self.outputFmt = 'num' # declare outputFmt as num by default self.inputFmt = ['num', 'str'] # declare outputFmt as num by default from athenaCL.libATH.libPmtr import parameter try: self.pmtrObj = parameter.factory(self.args[0]) except error.ParameterObjectSyntaxError, msg: raise error.ParameterObjectSyntaxError, 'failed sub-parameter: %s' % msg
def _loadAutoConstant(self, arg, lib='genPmtrObjs'): """take args and if a number, returns as a constant value parameterObj otherwise, keep as is >>> a = Parameter([]) >>> post = a._loadAutoConstant(45) >>> post.type 'constant' >>> post = a._loadAutoConstant(['ru', 0, 1]) >>> post.type 'randomUniform' """ if drawer.isNum(arg): pmtrArgs = ('c', arg) # fit within a constant else: # its a list to create a ParameterObject pmtrArgs = arg # create a ParameterObject from athenaCL.libATH.libPmtr import parameter try: obj = parameter.factory(pmtrArgs, lib) except error.ParameterObjectSyntaxError, msg: raise error.ParameterObjectSyntaxError, 'failed sub-parameter: %s' % msg
def __init__(self, args, refDict): basePmtr.FilterParameter.__init__(self, args, refDict) # call base init self.type = None self.argTypes = ['str', 'list'] self.argNames = ['anchorString', 'parameterObject: operator value generator'] self.argDefaults = ['lower', ('wc', 'e', 30, 0, 0, 1)] # check raw arguments for number, type ok, msg = self._checkRawArgs() if ok == 0: raise error.ParameterObjectSyntaxError(msg) # report error # will raise exception on error self.outputFmt = 'num' # declare outputFmt as num by default self.inputFmt = 'num' # declare outputFmt as num by default self.anchor = self._anchorParser(self.args[0]) #print _MOD, 'anchor set to', self.anchor from athenaCL.libATH.libPmtr import parameter try: self.pmtrObj = parameter.factory(self.args[1], ['genPmtrObjs', 'rthmPmtrObjs']) except error.ParameterObjectSyntaxError, msg: raise error.ParameterObjectSyntaxError, 'failed sub-parameter: %s' % msg
def __init__(self, args, refDict): basePmtr.FilterParameter.__init__(self, args, refDict) # call base init self.type = 'pipeLine' self.doc = lang.docPoPl self.argTypes = ['list'] self.argNames = ['filterParameterObjectList: a list of sequential Filter ParameterObjects'] self.argDefaults = [[['or', 40], ['ob']]] # check raw arguments for number, type ok, msg = self._checkRawArgs() if ok == 0: raise error.ParameterObjectSyntaxError(msg) # report error # will raise exception on error self.outputFmt = 'num' # declare outputFmt as num by default self.inputFmt = ['num', 'str'] # declare outputFmt as num by default from athenaCL.libATH.libPmtr import parameter self.objArray = [] for argList in self.args[0]: try: pmtrObj = parameter.factory(argList, 'filterPmtrObjs') except error.ParameterObjectSyntaxError, msg: raise error.ParameterObjectSyntaxError, 'failed sub-parameter: %s' % msg self.objArray.append(pmtrObj)
minArgs = ('c', min) elif drawer.isList(min): minArgs = min # check max if drawer.isNum(max): maxArgs = ('c', max) elif drawer.isList(max): maxArgs = max # create a parameter object from athenaCL.libATH.libPmtr import parameter try: minObj = parameter.factory(minArgs) except error.ParameterObjectSyntaxError, msg: raise error.ParameterObjectSyntaxError, 'failed sub-parameter: %s' % msg try: maxObj = parameter.factory(maxArgs) except error.ParameterObjectSyntaxError, msg: raise error.ParameterObjectSyntaxError, 'failed sub-parameter: %s' % msg return minObj, maxObj #-----------------------------------------------------------------------||-- def _scrubList(self, data, min=None, max=None): """for presenting list data used to apply scalar to uncalculated values""" msg = [] for element in data: if min != None and max != None: element = unit.denorm(element, min, max) msg.append(typeset.anyDataToStr(element)) dataStr = ','.join(msg)
def _scoreMain(self): """creates score >>> from athenaCL.libATH.libTM import texture >>> ti = texture.factory('LiteralVertical') >>> ti.tmName == 'LiteralVertical' True >>> ti.loadDefault() >>> ti.score() == True True """ # texture-wide PATH/PITCH elements # texture-wide time elements inst = self.getInst() tStart, tEnd = self.getTimeRange() tCurrent = tStart #texture-wide TEXTURE (self.textQ amd)options #used for optional parallel voices textRepeatToggle = self.getTextStatic('lws', 'onOff') textMaxTimeOffset = self.getTextStatic('mto', 'time') # get field, octave selection method value textFieldLevel = self.getTextStatic('lfp', 'level') textOctaveLevel = self.getTextStatic('lop', 'level') # when off, the number of sets in the path completely # determines the number of events in the texture pathDurationFraction = self.getTextStatic('pdf', 'onOff') # create range of offsets to draw from # scale base by distribution from -1 to # this gives a range from -1 to 1 self.gaussPmtrObj = parameter.factory(('randomGauss', .5, .1, -1, 1)) # used below now # create a list of chords from the appropriate pitch mode for pathPos in self.getPathPos(): chordCurrent = self.getPitchGroup(pathPos) multisetCurrent = self.getMultiset(pathPos) tStartSet, tEndSet = self.clockPoints() chordLength = len(chordCurrent) muteSet = 'off' pcTest = 'noNote' # set one note found to filter out rests tStartSetReal = copy.deepcopy(tCurrent) self.stateUpdate(tCurrent, chordCurrent, None, multisetCurrent, None, None) if textFieldLevel == 'set': transCurrent = self.getField(tCurrent) # choose PITCHFIELD if textOctaveLevel == 'set': octCurrent = self.getOct(tCurrent) # choose OCTAVE while 1: # dur of each path # to do one chord per event this needs to be controlled # not by time per set, but simply by if a single chord # has been executed if pathDurationFraction == 'off': if tCurrent > tStartSetReal: break else: # sustain entire path over desired dur fraction if tCurrent >= tEndSet: break # no ps yet found, give as None, get default self.stateUpdate(tCurrent, chordCurrent, None, multisetCurrent, None, None) if textFieldLevel == 'event': transCurrent = self.getField(tCurrent) # choose PITCHFIELD if textOctaveLevel == 'event': octCurrent = self.getOct(tCurrent) # choose OCTAVE # choose RHYTHM bpm, pulse, dur, sus, acc = self.getRhythm(tCurrent) if muteSet == 'on': # make all rests acc = 0 # everything is a rest after chord inex reset if acc != 0: # this is a note pcTest = 'noteFound' #only set first time note found if acc == 0 and not self.silenceMode: # this is a rest tCurrent = tCurrent + dur continue # amp and pan per chord, not voice amp = self.getAmp(tCurrent) * acc pan = self.getPan(tCurrent) tThisChord = copy.deepcopy(tCurrent) for ps in chordCurrent: self.stateUpdate(tCurrent, chordCurrent, ps, multisetCurrent, None, None) if textFieldLevel == 'voice': transCurrent = self.getField(tCurrent) # choose PITCHFIELD if textOctaveLevel == 'voice': octCurrent = self.getOct(tCurrent) # choose OCTAVE psReal = pitchTools.psToTempered(ps, octCurrent, self.temperamentObj, transCurrent) self.stateUpdate(tCurrent, chordCurrent, None, multisetCurrent, None, psReal) # aux per voice, post psReal definition auxiliary = self.getAux(tCurrent) # offset value is between -textMaxOffset, 0, and +textMaxOffset offset = self.gaussPmtrObj(0.0) * textMaxTimeOffset tCurrent = tCurrent + offset if tCurrent < 0: # cant start before 0 tCurrent = tThisChord # reset eventDict = self.makeEvent(tCurrent, bpm, pulse, dur, sus, acc, amp, psReal, pan, auxiliary) self.storeEvent(eventDict) # restore time to tCurrent before processing offset again tCurrent = tThisChord # turn of further notes if all gotten if textRepeatToggle == 'off' and pcTest == 'noteFound': muteSet = 'on' # move clocks forward by dur unit tCurrent = tCurrent + dur self.clockForward() # advances path positon return 1
def _scoreMain(self): """creates score >>> from athenaCL.libATH.libTM import texture >>> ti = texture.factory('DroneArticulate') >>> ti.tmName == 'DroneArticulate' True >>> ti.loadDefault() >>> ti.score() == True True """ # texture-wide PATH/PITCH elements # texture-wide time elements inst = self.getInst() tStart, tEnd = self.getTimeRange() tCurrent = tStart tCumulative = copy.deepcopy(tStart) # store fake time for pmtr gen #texture-wide TEXTURE (self.textQ amd)options #used for optional parallel voices textMaxTimeOffset = self.getTextStatic('mto', 'time') # get field, octave selection method value textFieldLevel = self.getTextStatic('lfm', 'level') textOctaveLevel = self.getTextStatic('lom', 'level') # create range of offsets to dray from # scale base by distribution from -1 to # this gives a range from -1 to 1 self.gaussPmtrObj = parameter.factory(('randomGauss', .5, .1, -1, 1)) # create a list of chords from the appropriate pitch mode for pathPos in self.getPathPos(): chordCurrent = self.getPitchGroup(pathPos) multisetCurrent = self.getMultiset(pathPos) tStartSet, tEndSet = self.clockPoints() chordLength = len(chordCurrent) muteSet = 'off' #not sure what this was used for #pcTest = 'noNote' # set one note found to filter out rests tStartSetReal = copy.deepcopy(tCurrent) self.stateUpdate(tCurrent, chordCurrent, None, multisetCurrent, None, None) if textFieldLevel == 'set': transCurrent = self.getField(tCurrent) # choose PITCHFIELD if textOctaveLevel == 'set': octCurrent = self.getOct(tCurrent) # choose OCTAVE # create a clock for each voice tVoice = [] for x in range(0,len(chordCurrent)): tVoice.append(copy.deepcopy(tCurrent)) i = 0 # voice count for ps in chordCurrent: # psReal values in chord self.stateUpdate(tVoice[i], chordCurrent, ps, multisetCurrent, None, None) while tVoice[i] < tEndSet: self.stateUpdate(tVoice[i], chordCurrent, ps, multisetCurrent, None, None) bpm, pulse, dur, sus, acc = self.getRhythm(tCumulative) if acc == 0 and not self.silenceMode: # this is a rest tVoice[i] = tVoice[i] + dur tCumulative = tCumulative + dur continue if textFieldLevel == 'event': transCurrent = self.getField(tCumulative) # choose PITCHFIELD if textOctaveLevel == 'event': octCurrent = self.getOct(tCumulative) # choose OCTAVE psReal = pitchTools.psToTempered(ps, octCurrent, self.temperamentObj, transCurrent) self.stateUpdate(tVoice[i], chordCurrent, ps, multisetCurrent, None, psReal) amp = self.getAmp(tCumulative) * acc pan = self.getPan(tCumulative) auxiliary = self.getAux(tCumulative) # offset value is b/n -textMaxOffset, 0, and +textMaxOffset offset = self.gaussPmtrObj(0.0) * textMaxTimeOffset tVoice[i] = tVoice[i] + offset tCumulative = tCumulative + offset if tVoice[i] < 0: # cant start before 0 tVoice[i] = tStartSetReal # reset eventDict = self.makeEvent(tVoice[i], bpm, pulse, dur, sus, acc, amp, psReal, pan, auxiliary) self.storeEvent(eventDict) tVoice[i] = tVoice[i] + dur tCumulative = tCumulative + dur i = i + 1 # increment voice count # find longest voice tMaxVoice = 0 for i in range(0,len(chordCurrent)): if tVoice[i] >= tMaxVoice: tMaxVoice = tVoice[i] # move clocks forward by dur unit tCurrent = tMaxVoice # new current is at max length # do not chang tCumulative, is is already expanding self.clockForward() # advances path positon return 1
def _evalPmtrObj(self, pmtrName, refDict): """called for editing a single parameter object handle all exceptions of parameter creation """ args = self.pmtrQDict[pmtrName] if pmtrName[:6] == 'cloneQ': # check texture options try: self.pmtrObjDict[pmtrName] = parameter.factory(args, 'clonePmtrObjs', refDict) except error.ParameterObjectSyntaxError, msg: # initialization errors return 0, 'incorrect arguments: %s' % msg else: try: self.pmtrObjDict[pmtrName] = parameter.factory(args, 'filterPmtrObjs', refDict) except error.ParameterObjectSyntaxError, msg: # initialization errors return 0, 'incorrect arguments: %s' % msg # check for errors if self.pmtrObjDict[pmtrName] == None: # failure to match object type return 0, 'there is no parameterObject with that name.' # check for proper types elif pmtrName[:6] == 'cloneQ': if self.pmtrObjDict[pmtrName].parent != 'cloneStatic': return 0, 'only a clone parameterObject can be used here.' else: #print _MOD, 'parent', self.pmtrObjDict[pmtrName].parent if self.pmtrObjDict[pmtrName].parent != 'cloneFilter': return 0, 'a clone filter parameterObject must be used here.' # everything good, check args
def _scoreMain(self): """creates score >>> from athenaCL.libATH.libTM import texture >>> ti = texture.factory('IntervalExpansion') >>> ti.tmName == 'IntervalExpansion' True >>> ti.loadDefault() >>> ti.score() == True True """ self.ornamentObj = ornament.Ornament(self.pmtrObjDict, self.temperamentObj) # texture-wide PATH/PITCH elements # pitches do not come from here, but from below path = self.path.get("scPath") # texture-wide time elements inst = self.getInst() tStart, tEnd = self.getTimeRange() tCurrent = tStart # texture-wide TEXTURE (self.textQ amd)options textRepeatToggle = self.getTextStatic("lws", "onOff") ornamentSwitch = self.getTextStatic("ols", "libraryName") ornamentMaxDensity = self.getTextStatic("omd", "percent") # get field, octave selection method value textFieldLevel = self.getTextStatic("lfm", "level") textOctaveLevel = self.getTextStatic("lom", "level") # create a randomUniform parameter object to control ornament control # values between 0 and 1; if pmtr() <= ornamentMaxDensity ruPmtrObj = parameter.factory(("randomUniform", 0, 1)) # create a list of chords from the appropriate pitch mode for pathPos in self.getPathPos(): chordCurrent = self.getPitchGroup(pathPos) multisetCurrent = self.getMultiset(pathPos) tStartSet, tEndSet = self.clockPoints() chordLength = len(chordCurrent) chordIndex = 0 muteSet = "off" psTest = [] ornamentIndex = 0 tStartSetReal = copy.deepcopy(tCurrent) self.stateUpdate(tCurrent, chordCurrent, None, multisetCurrent, None, None) if textFieldLevel == "set": transCurrent = self.getField(tCurrent) # choose PITCHFIELD if textOctaveLevel == "set": octCurrent = self.getOct(tCurrent) # choose OCTAVE while 1: # PITCH in CHORD if tCurrent >= tEndSet: break ps = chordCurrent[chordIndex] psTest.append(ps) chordIndex = chordIndex + 1 # shift to next pitch if chordIndex >= chordLength: chordIndex = 0 self.stateUpdate(tCurrent, chordCurrent, ps, multisetCurrent, None, None) if textFieldLevel == "event": transCurrent = self.getField(tCurrent) # choose PITCHFIELD if textOctaveLevel == "event": octCurrent = self.getOct(tCurrent) # choose OCTAVE psReal = pitchTools.psToTempered(ps, octCurrent, self.temperamentObj, transCurrent) self.stateUpdate(tCurrent, chordCurrent, ps, multisetCurrent, None, psReal) bpm, pulse, dur, sus, acc = self.getRhythm(tCurrent) if muteSet == "on": # make all rests acc = 0 # everything is a rest after chord inex reset if acc == 0 and not self.silenceMode: # this is a rest chordIndex = chordIndex - 1 # dont count this note if a rest psTest = psTest[:-1] # drop off last addition tCurrent = tCurrent + dur continue # choose AMP, PAN amp = self.getAmp(tCurrent) * acc pan = self.getPan(tCurrent) auxiliary = self.getAux(tCurrent) parentEventDict = self.makeEvent(tCurrent, bpm, pulse, dur, sus, acc, amp, psReal, pan, auxiliary) refDict = self.getRefDict(tCurrent) # "rhythm" not "dur" (dur includes overlap) if ornamentSwitch != "off": # check if an ru value is <= ornament density (if 1, always) # time value is not important if ruPmtrObj(tCurrent) <= ornamentMaxDensity: repretory = self._ornGroupGet(ornamentSwitch) # a, b, c, d = repretory[ornamentIndex] # this will do in order a, b, c, d = random.choice(repretory) # choose orn at random subEventArray = self.ornamentObj.create(refDict, a, b, c, d) # process sub event array for iSub in range(len(subEventArray)): # get time from subEvent subEvent = subEventArray[iSub] val = self.getTextDynamic("ornamentShift", subEvent["time"]) subEvent["ps"] = subEvent["ps"] + val self.storePolyEvent(parentEventDict, subEventArray, "orn") ornamentIndex = ornamentIndex + 1 # increment for when ordered if ornamentIndex == len(repretory): ornamentIndex = 0 else: self.storeEvent(parentEventDict) else: # ornament == 'off': # dont do ornaments self.storeEvent(parentEventDict) # turn of further notes if all gotten if textRepeatToggle == "off" and len(psTest) >= chordLength: muteSet = "on" # move clocks forward by rhythm unit tCurrent = tCurrent + dur self.clockForward() # advances path positon return 1
def _scoreMain(self): """creates score note: octave choose for every note >>> from athenaCL.libATH.libTM import texture >>> ti = texture.factory('HarmonicAssembly') >>> ti.tmName == 'HarmonicAssembly' True >>> ti.loadDefault() >>> ti.score() == True True """ # texture-wide time elements inst = self.getInst() # needed for preliminary parameter values tStart, tEnd = self.getTimeRange() tCurrent = tStart # get field, octave selection method value textMaxTimeOffset = self.getTextStatic('mto', 'time') textFieldLevel = self.getTextStatic('lfp', 'level') textOctaveLevel = self.getTextStatic('lop', 'level') pLen = self.getPathLen() # random generator for creating offset in vetical attacks # same technique used in LiteralVertical, DroneArticulate self.gaussPmtrObj = parameter.factory(('randomGauss', .5, .1, -1, 1)) while tCurrent < tEnd: # takes absolute value, and proportionally weight toward nearest int # modulus of path length pathPos = abs(drawer.floatToInt( self.getTextDynamic('multisetPosition', tCurrent), 'weight')) % pLen chordCurrent = self.getPitchGroup(pathPos) multisetCurrent = self.getMultiset(pathPos) # get number of simultaneities from this multiset # count is probabilistic, absolute value; cannot be zero multisetCount = abs(drawer.floatToInt( self.getTextDynamic('countPerMultiset', tCurrent), 'weight')) # make zero == 1; alternatively, make zero a skib and continue if multisetCount == 0: multisetCount = 1 if textFieldLevel == 'set': transCurrent = self.getField(tCurrent) # choose PITCHFIELD if textOctaveLevel == 'set': octCurrent = self.getOct(tCurrent) # choose OCTAVE # number of times a simultaneity is drawn for k in range(multisetCount): if tCurrent > tEnd: break # determine how many pitches in this simultaneity # abs value, rounded to nearest integer simultaneityCount = abs(drawer.floatToInt( self.getTextDynamic('countPerSimultaneity', tCurrent), 'weight')) # if zero set to max chord size if simultaneityCount == 0: simultaneityCount = len(chordCurrent) elif simultaneityCount > len(chordCurrent): simultaneityCount = len(chordCurrent) self.stateUpdate(tCurrent, chordCurrent, None, multisetCurrent, None, None) if textFieldLevel == 'event': transCurrent = self.getField(tCurrent) # choose PITCHFIELD if textOctaveLevel == 'event': octCurrent = self.getOct(tCurrent) # choose OCTAVE # rhythm, amp, pan, aux: all chosen once per simultaneity bpm, pulse, dur, sus, acc = self.getRhythm(tCurrent) if acc == 0 and not self.silenceMode: # this is a rest tCurrent = tCurrent + dur continue amp = self.getAmp(tCurrent) * acc # choose amp, pan pan = self.getPan(tCurrent) tThisChord = copy.deepcopy(tCurrent) # get each pitch in the simultaneity for i in range(simultaneityCount): # pitch in chord # use a generator to get pitches from chord as index values # get values from generator for each pitch in simultaneity # may want to reset parameter object for each chord above # take modulus of chord length; proportional weighting to integer chordPos = abs(drawer.floatToInt( self.getTextDynamic('pitchPosition', tCurrent), 'weight')) % len(chordCurrent) # get position w/n chord ps = chordCurrent[chordPos] self.stateUpdate(tCurrent, chordCurrent, ps, multisetCurrent, None, None) if textFieldLevel == 'voice': transCurrent = self.getField(tCurrent) # choose PITCHFIELD if textOctaveLevel == 'voice': octCurrent = self.getOct(tCurrent) # choose OCTAVE psReal = pitchTools.psToTempered(ps, octCurrent, self.temperamentObj, transCurrent) self.stateUpdate(tCurrent, chordCurrent, ps, multisetCurrent, None, psReal) # aux values are drawn here once per voice; # this is common to TMs: DroneArticulate, DroneSustain auxiliary = self.getAux(tCurrent) # chooose AUX, pack into list # offset value is between -textMaxOffset, 0, and +textMaxOffset offset = self.gaussPmtrObj(0.0) * textMaxTimeOffset tCurrent = tCurrent + offset if tCurrent < 0: # cant start before 0 tCurrent = tThisChord # reset eventDict = self.makeEvent(tCurrent, bpm, pulse, dur, sus, acc, amp, psReal, pan, auxiliary) self.storeEvent(eventDict) # restore time to tCurrent before processing offset again tCurrent = tThisChord # move clocks forward by dur unit tCurrent = tCurrent + dur return 1
def _scoreMain(self): """creates score note: octave choose for every note >>> from athenaCL.libATH.libTM import texture >>> ti = texture.factory('HarmonicShuffle') >>> ti.tmName == 'HarmonicShuffle' True >>> ti.loadDefault() >>> ti.score() == True True """ # texture-wide time elements inst = self.getInst() # needed for preliminary parameter values tStart, tEnd = self.getTimeRange() tCurrent = tStart # get static texture values textMultisetSelectorControl = self.getTextStatic('msc', 'selectionString') textPitchSelectorControl = self.getTextStatic('psc', 'selectionString') textMaxTimeOffset = self.getTextStatic('mto', 'time') textFieldLevel = self.getTextStatic('lfp', 'level') textOctaveLevel = self.getTextStatic('lop', 'level') pLen = self.getPathLen() selectorMultisetPos = basePmtr.Selector(range(pLen), textMultisetSelectorControl) # random generator for creating offset in vetical attacks # same technique used in LiteralVertical, DroneArticulate self.gaussPmtrObj = parameter.factory(('randomGauss', .5, .1, -1, 1)) while tCurrent < tEnd: pathPos = selectorMultisetPos() # select path position chordCurrent = self.getPitchGroup(pathPos) multisetCurrent = self.getMultiset(pathPos) # get number of simultaneities from this multiset # count is probabilistic, absolute value; cannot be zero multisetCount = abs(drawer.floatToInt( self.getTextDynamic('countPerMultiset', tCurrent), 'weight')) # make zero == 1; alternatively, make zero a skib and continue if multisetCount == 0: multisetCount = 1 if textFieldLevel == 'set': transCurrent = self.getField(tCurrent) # choose PITCHFIELD if textOctaveLevel == 'set': octCurrent = self.getOct(tCurrent) # choose OCTAVE # number of times a simultaneity is drawn for k in range(multisetCount): if tCurrent > tEnd: break # create a selector to get pitches from chord as index values # only need to create one for each chord selectorChordPos = basePmtr.Selector(range(len(chordCurrent)), textPitchSelectorControl) # determine how many pitches in this simultaneity # abs value, rounded to nearest integer simultaneityCount = abs(drawer.floatToInt( self.getTextDynamic('countPerSimultaneity', tCurrent), 'weight')) # if zero set to max chord size if simultaneityCount == 0: simultaneityCount = len(chordCurrent) elif simultaneityCount > len(chordCurrent): simultaneityCount = len(chordCurrent) self.stateUpdate(tCurrent, chordCurrent, None, multisetCurrent, None, None) if textFieldLevel == 'event': transCurrent = self.getField(tCurrent) # choose PITCHFIELD if textOctaveLevel == 'event': octCurrent = self.getOct(tCurrent) # choose OCTAVE # rhythm, amp, pan, aux: all chosen once per simultaneity bpm, pulse, dur, sus, acc = self.getRhythm(tCurrent) if acc == 0 and not self.silenceMode: # this is a rest tCurrent = tCurrent + dur continue amp = self.getAmp(tCurrent) * acc # choose amp, pan pan = self.getPan(tCurrent) tThisChord = copy.deepcopy(tCurrent) # get each pitch in the simultaneity for i in range(simultaneityCount): # pitch in chord ps = chordCurrent[selectorChordPos()] # get position w/n chord self.stateUpdate(tCurrent, chordCurrent, ps, multisetCurrent, None, None) if textFieldLevel == 'voice': transCurrent = self.getField(tCurrent) # choose PITCHFIELD if textOctaveLevel == 'voice': octCurrent = self.getOct(tCurrent) # choose OCTAVE psReal = pitchTools.psToTempered(ps, octCurrent, self.temperamentObj, transCurrent) self.stateUpdate(tCurrent, chordCurrent, ps, multisetCurrent, None, psReal) # aux values are drawn here once per voice; # this is common to TMs: DroneArticulate, DroneSustain auxiliary = self.getAux(tCurrent) # chooose AUX, pack into list # offset value is between -textMaxOffset, 0, and +textMaxOffset offset = self.gaussPmtrObj(0.0) * textMaxTimeOffset tCurrent = tCurrent + offset if tCurrent < 0: # cant start before 0 tCurrent = tThisChord # reset eventDict = self.makeEvent(tCurrent, bpm, pulse, dur, sus, acc, amp, psReal, pan, auxiliary) self.storeEvent(eventDict) # restore time to tCurrent before processing offset again tCurrent = tThisChord # move clocks forward by dur unit tCurrent = tCurrent + dur return 1
minArgs = ('c', min) elif drawer.isList(min): minArgs = min # check max if drawer.isNum(max): maxArgs = ('c', max) elif drawer.isList(max): maxArgs = max # create a parameter object from athenaCL.libATH.libPmtr import parameter try: minObj = parameter.factory(minArgs) except error.ParameterObjectSyntaxError, msg: raise error.ParameterObjectSyntaxError, 'failed sub-parameter: %s' % msg try: maxObj = parameter.factory(maxArgs) except error.ParameterObjectSyntaxError, msg: raise error.ParameterObjectSyntaxError, 'failed sub-parameter: %s' % msg return minObj, maxObj #-----------------------------------------------------------------------||-- def _scrubList(self, data, min=None, max=None): """for presenting list data used to apply scalar to uncalculated values""" msg = [] for element in data: if min != None and max != None: element = unit.denorm(element, min, max) msg.append(typeset.anyDataToStr(element)) dataStr = ','.join(msg) return '(%s)' % dataStr
def _scoreMain(self): """creates score >>> from athenaCL.libATH.libTM import texture >>> ti = texture.factory('DroneSustain') >>> ti.tmName == 'DroneSustain' True >>> ti.loadDefault() >>> ti.score() == True True """ # texture-wide PATH/PITCH elements # texture-wide time elements inst = self.getInst() tStart, tEnd = self.getTimeRange() tCurrent = tStart #texture-wide TEXTURE (self.textQ amd)options #used for optional parallel voices textMaxTimeOffset = self.getTextStatic('mto', 'time') # get field, octave selection method value textFieldLevel = self.getTextStatic('lfp', 'level') textOctaveLevel = self.getTextStatic('lop', 'level') # this gives a range from -1 to 1 self.gaussPmtrObj = parameter.factory(('randomGauss', .5, .1, -1, 1)) # create a list of chords from the appropriate pitch mode for pathPos in self.getPathPos(): chordCurrent = self.getPitchGroup(pathPos) multisetCurrent = self.getMultiset(pathPos) tStartSet, tEndSet = self.clockPoints() chordLength = len(chordCurrent) tStartSetReal = copy.deepcopy(tCurrent) self.stateUpdate(tCurrent, chordCurrent, None, multisetCurrent, None, None) if textFieldLevel == 'set': transCurrent = self.getField(tCurrent) # choose PITCHFIELD if textOctaveLevel == 'set': octCurrent = self.getOct(tCurrent) # choose OCTAVE while 1: # PITCH in CHORD if tCurrent >= tEndSet: break # no ps yet found, give as None, get default self.stateUpdate(tCurrent, chordCurrent, None, multisetCurrent, None, None) # choose RHYTHM, no parameter used dur = tEndSet - tCurrent # total time of set sus = dur acc = 1 # no rests pulse = '(1,1,1)' bpm = None if acc == 0 and not self.silenceMode: # this is a rest tCurrent = (tCurrent + dur) continue if textFieldLevel == 'event': transCurrent = self.getField(tCurrent) # choose PITCHFIELD if textOctaveLevel == 'event': octCurrent = self.getOct(tCurrent) # choose OCTAVE # amp and pan per chord, not voice amp = self.getAmp(tCurrent) * acc pan = self.getPan(tCurrent) tThisChord = copy.deepcopy(tCurrent) for ps in chordCurrent: if textFieldLevel == 'voice': transCurrent = self.getField(tThisChord) # choose PITCHFIELD if textOctaveLevel == 'voice': octCurrent = self.getOct(tThisChord) # choose OCTAVE psReal = pitchTools.psToTempered(ps, octCurrent, self.temperamentObj, transCurrent) self.stateUpdate(tCurrent, chordCurrent, ps, multisetCurrent, None, psReal) # calculate for every voice in chord auxiliary = self.getAux(tCurrent) # chooose AUX, in list # offset value is between 0, and +textMaxOffset (abs used) offset = abs(self.gaussPmtrObj(0.0)) * textMaxTimeOffset tCurrent = tCurrent + offset if tCurrent < 0: # cant start before 0 tCurrent = tThisChord # reset eventDict = self.makeEvent(tCurrent, bpm, pulse, dur, sus, acc, amp, psReal, pan, auxiliary) self.storeEvent(eventDict) # all notes start at the begninng of this chord tCurrent = tThisChord # move clocks forward by dur unit tCurrent = tCurrent + dur self.clockForward() # advances path positon # return value to check for errors return 1
def _scoreMain(self): """creates score >>> from athenaCL.libATH.libTM import texture >>> ti = texture.factory('DroneArticulate') >>> ti.tmName == 'DroneArticulate' True >>> ti.loadDefault() >>> ti.score() == True True """ # texture-wide PATH/PITCH elements # texture-wide time elements inst = self.getInst() tStart, tEnd = self.getTimeRange() tCurrent = tStart tCumulative = copy.deepcopy(tStart) # store fake time for pmtr gen #texture-wide TEXTURE (self.textQ amd)options #used for optional parallel voices textMaxTimeOffset = self.getTextStatic('mto', 'time') # get field, octave selection method value textFieldLevel = self.getTextStatic('lfm', 'level') textOctaveLevel = self.getTextStatic('lom', 'level') # create range of offsets to dray from # scale base by distribution from -1 to # this gives a range from -1 to 1 self.gaussPmtrObj = parameter.factory(('randomGauss', .5, .1, -1, 1)) # create a list of chords from the appropriate pitch mode for pathPos in self.getPathPos(): chordCurrent = self.getPitchGroup(pathPos) multisetCurrent = self.getMultiset(pathPos) tStartSet, tEndSet = self.clockPoints() chordLength = len(chordCurrent) muteSet = 'off' #not sure what this was used for #pcTest = 'noNote' # set one note found to filter out rests tStartSetReal = copy.deepcopy(tCurrent) self.stateUpdate(tCurrent, chordCurrent, None, multisetCurrent, None, None) if textFieldLevel == 'set': transCurrent = self.getField(tCurrent) # choose PITCHFIELD if textOctaveLevel == 'set': octCurrent = self.getOct(tCurrent) # choose OCTAVE # create a clock for each voice tVoice = [] for x in range(0, len(chordCurrent)): tVoice.append(copy.deepcopy(tCurrent)) i = 0 # voice count for ps in chordCurrent: # psReal values in chord self.stateUpdate(tVoice[i], chordCurrent, ps, multisetCurrent, None, None) while tVoice[i] < tEndSet: self.stateUpdate(tVoice[i], chordCurrent, ps, multisetCurrent, None, None) bpm, pulse, dur, sus, acc = self.getRhythm(tCumulative) if acc == 0 and not self.silenceMode: # this is a rest tVoice[i] = tVoice[i] + dur tCumulative = tCumulative + dur continue if textFieldLevel == 'event': transCurrent = self.getField( tCumulative) # choose PITCHFIELD if textOctaveLevel == 'event': octCurrent = self.getOct(tCumulative) # choose OCTAVE psReal = pitchTools.psToTempered(ps, octCurrent, self.temperamentObj, transCurrent) self.stateUpdate(tVoice[i], chordCurrent, ps, multisetCurrent, None, psReal) amp = self.getAmp(tCumulative) * acc pan = self.getPan(tCumulative) auxiliary = self.getAux(tCumulative) # offset value is b/n -textMaxOffset, 0, and +textMaxOffset offset = self.gaussPmtrObj(0.0) * textMaxTimeOffset tVoice[i] = tVoice[i] + offset tCumulative = tCumulative + offset if tVoice[i] < 0: # cant start before 0 tVoice[i] = tStartSetReal # reset eventDict = self.makeEvent(tVoice[i], bpm, pulse, dur, sus, acc, amp, psReal, pan, auxiliary) self.storeEvent(eventDict) tVoice[i] = tVoice[i] + dur tCumulative = tCumulative + dur i = i + 1 # increment voice count # find longest voice tMaxVoice = 0 for i in range(0, len(chordCurrent)): if tVoice[i] >= tMaxVoice: tMaxVoice = tVoice[i] # move clocks forward by dur unit tCurrent = tMaxVoice # new current is at max length # do not chang tCumulative, is is already expanding self.clockForward() # advances path positon return 1
def _scoreMain(self): """creates score note: octave choose for every note >>> from athenaCL.libATH.libTM import texture >>> ti = texture.factory('HarmonicShuffle') >>> ti.tmName == 'HarmonicShuffle' True >>> ti.loadDefault() >>> ti.score() == True True """ # texture-wide time elements inst = self.getInst() # needed for preliminary parameter values tStart, tEnd = self.getTimeRange() tCurrent = tStart # get static texture values textMultisetSelectorControl = self.getTextStatic("msc", "selectionString") textPitchSelectorControl = self.getTextStatic("psc", "selectionString") textMaxTimeOffset = self.getTextStatic("mto", "time") textFieldLevel = self.getTextStatic("lfp", "level") textOctaveLevel = self.getTextStatic("lop", "level") pLen = self.getPathLen() selectorMultisetPos = basePmtr.Selector(range(pLen), textMultisetSelectorControl) # random generator for creating offset in vetical attacks # same technique used in LiteralVertical, DroneArticulate self.gaussPmtrObj = parameter.factory(("randomGauss", 0.5, 0.1, -1, 1)) while tCurrent < tEnd: pathPos = selectorMultisetPos() # select path position chordCurrent = self.getPitchGroup(pathPos) multisetCurrent = self.getMultiset(pathPos) # get number of simultaneities from this multiset # count is probabilistic, absolute value; cannot be zero multisetCount = abs(drawer.floatToInt(self.getTextDynamic("countPerMultiset", tCurrent), "weight")) # make zero == 1; alternatively, make zero a skib and continue if multisetCount == 0: multisetCount = 1 if textFieldLevel == "set": transCurrent = self.getField(tCurrent) # choose PITCHFIELD if textOctaveLevel == "set": octCurrent = self.getOct(tCurrent) # choose OCTAVE # number of times a simultaneity is drawn for k in range(multisetCount): if tCurrent > tEnd: break # create a selector to get pitches from chord as index values # only need to create one for each chord selectorChordPos = basePmtr.Selector(range(len(chordCurrent)), textPitchSelectorControl) # determine how many pitches in this simultaneity # abs value, rounded to nearest integer simultaneityCount = abs( drawer.floatToInt(self.getTextDynamic("countPerSimultaneity", tCurrent), "weight") ) # if zero set to max chord size if simultaneityCount == 0: simultaneityCount = len(chordCurrent) elif simultaneityCount > len(chordCurrent): simultaneityCount = len(chordCurrent) self.stateUpdate(tCurrent, chordCurrent, None, multisetCurrent, None, None) if textFieldLevel == "event": transCurrent = self.getField(tCurrent) # choose PITCHFIELD if textOctaveLevel == "event": octCurrent = self.getOct(tCurrent) # choose OCTAVE # rhythm, amp, pan, aux: all chosen once per simultaneity bpm, pulse, dur, sus, acc = self.getRhythm(tCurrent) if acc == 0 and not self.silenceMode: # this is a rest tCurrent = tCurrent + dur continue amp = self.getAmp(tCurrent) * acc # choose amp, pan pan = self.getPan(tCurrent) tThisChord = copy.deepcopy(tCurrent) # get each pitch in the simultaneity for i in range(simultaneityCount): # pitch in chord ps = chordCurrent[selectorChordPos()] # get position w/n chord self.stateUpdate(tCurrent, chordCurrent, ps, multisetCurrent, None, None) if textFieldLevel == "voice": transCurrent = self.getField(tCurrent) # choose PITCHFIELD if textOctaveLevel == "voice": octCurrent = self.getOct(tCurrent) # choose OCTAVE psReal = pitchTools.psToTempered(ps, octCurrent, self.temperamentObj, transCurrent) self.stateUpdate(tCurrent, chordCurrent, ps, multisetCurrent, None, psReal) # aux values are drawn here once per voice; # this is common to TMs: DroneArticulate, DroneSustain auxiliary = self.getAux(tCurrent) # chooose AUX, pack into list # offset value is between -textMaxOffset, 0, and +textMaxOffset offset = self.gaussPmtrObj(0.0) * textMaxTimeOffset tCurrent = tCurrent + offset if tCurrent < 0: # cant start before 0 tCurrent = tThisChord # reset eventDict = self.makeEvent(tCurrent, bpm, pulse, dur, sus, acc, amp, psReal, pan, auxiliary) self.storeEvent(eventDict) # restore time to tCurrent before processing offset again tCurrent = tThisChord # move clocks forward by dur unit tCurrent = tCurrent + dur return 1
def _evalPmtrObj(self, pmtrName, refDict): """called for editing a single parameter object handle all exceptions of parameter creation """ args = self.pmtrQDict[pmtrName] if pmtrName[:6] == 'cloneQ': # check texture options try: self.pmtrObjDict[pmtrName] = parameter.factory( args, 'clonePmtrObjs', refDict) except error.ParameterObjectSyntaxError, msg: # initialization errors return 0, 'incorrect arguments: %s' % msg else: try: self.pmtrObjDict[pmtrName] = parameter.factory( args, 'filterPmtrObjs', refDict) except error.ParameterObjectSyntaxError, msg: # initialization errors return 0, 'incorrect arguments: %s' % msg # check for errors if self.pmtrObjDict[pmtrName] == None: # failure to match object type return 0, 'there is no parameterObject with that name.' # check for proper types elif pmtrName[:6] == 'cloneQ': if self.pmtrObjDict[pmtrName].parent != 'cloneStatic': return 0, 'only a clone parameterObject can be used here.' else: #print _MOD, 'parent', self.pmtrObjDict[pmtrName].parent if self.pmtrObjDict[pmtrName].parent != 'cloneFilter': return 0, 'a clone filter parameterObject must be used here.' # everything good, check args
def _scoreMain(self): """creates score >>> from athenaCL.libATH.libTM import texture >>> ti = texture.factory('IntervalExpansion') >>> ti.tmName == 'IntervalExpansion' True >>> ti.loadDefault() >>> ti.score() == True True """ self.ornamentObj = ornament.Ornament(self.pmtrObjDict, self.temperamentObj) # texture-wide PATH/PITCH elements #pitches do not come from here, but from below path = self.path.get('scPath') # texture-wide time elements inst = self.getInst() tStart, tEnd = self.getTimeRange() tCurrent = tStart #texture-wide TEXTURE (self.textQ amd)options textRepeatToggle = self.getTextStatic('lws', 'onOff') ornamentSwitch = self.getTextStatic('ols', 'libraryName') ornamentMaxDensity = self.getTextStatic('omd', 'percent') # get field, octave selection method value textFieldLevel = self.getTextStatic('lfm', 'level') textOctaveLevel = self.getTextStatic('lom', 'level') # create a randomUniform parameter object to control ornament control # values between 0 and 1; if pmtr() <= ornamentMaxDensity ruPmtrObj = parameter.factory(('randomUniform', 0, 1)) # create a list of chords from the appropriate pitch mode for pathPos in self.getPathPos(): chordCurrent = self.getPitchGroup(pathPos) multisetCurrent = self.getMultiset(pathPos) tStartSet, tEndSet = self.clockPoints() chordLength = len(chordCurrent) chordIndex = 0 muteSet = 'off' psTest = [] ornamentIndex = 0 tStartSetReal = copy.deepcopy(tCurrent) self.stateUpdate(tCurrent, chordCurrent, None, multisetCurrent, None, None) if textFieldLevel == 'set': transCurrent = self.getField(tCurrent) # choose PITCHFIELD if textOctaveLevel == 'set': octCurrent = self.getOct(tCurrent) # choose OCTAVE while 1: # PITCH in CHORD if tCurrent >= tEndSet: break ps = chordCurrent[chordIndex] psTest.append(ps) chordIndex = chordIndex + 1 # shift to next pitch if chordIndex >= chordLength: chordIndex = 0 self.stateUpdate(tCurrent, chordCurrent, ps, multisetCurrent, None, None) if textFieldLevel == 'event': transCurrent = self.getField(tCurrent) # choose PITCHFIELD if textOctaveLevel == 'event': octCurrent = self.getOct(tCurrent) # choose OCTAVE psReal = pitchTools.psToTempered(ps, octCurrent, self.temperamentObj, transCurrent) self.stateUpdate(tCurrent, chordCurrent, ps, multisetCurrent, None, psReal) bpm, pulse, dur, sus, acc = self.getRhythm(tCurrent) if muteSet == 'on': # make all rests acc = 0 # everything is a rest after chord inex reset if acc == 0 and not self.silenceMode: # this is a rest chordIndex = chordIndex - 1 # dont count this note if a rest psTest = psTest[:-1] # drop off last addition tCurrent = tCurrent + dur continue # choose AMP, PAN amp = self.getAmp(tCurrent) * acc pan = self.getPan(tCurrent) auxiliary = self.getAux(tCurrent) parentEventDict = self.makeEvent(tCurrent, bpm, pulse, dur, sus, acc, amp, psReal, pan, auxiliary) refDict = self.getRefDict(tCurrent) # "rhythm" not "dur" (dur includes overlap) if ornamentSwitch != 'off': # check if an ru value is <= ornament density (if 1, always) # time value is not important if ruPmtrObj(tCurrent) <= ornamentMaxDensity: repretory = self._ornGroupGet(ornamentSwitch) #a, b, c, d = repretory[ornamentIndex] # this will do in order a, b, c, d = random.choice( repretory) # choose orn at random subEventArray = self.ornamentObj.create( refDict, a, b, c, d) # process sub event array for iSub in range(len(subEventArray)): # get time from subEvent subEvent = subEventArray[iSub] val = self.getTextDynamic('ornamentShift', subEvent['time']) subEvent['ps'] = subEvent['ps'] + val self.storePolyEvent(parentEventDict, subEventArray, 'orn') ornamentIndex = ornamentIndex + 1 # increment for when ordered if ornamentIndex == len(repretory): ornamentIndex = 0 else: self.storeEvent(parentEventDict) else: # ornament == 'off': # dont do ornaments self.storeEvent(parentEventDict) # turn of further notes if all gotten if textRepeatToggle == 'off' and len(psTest) >= chordLength: muteSet = 'on' # move clocks forward by rhythm unit tCurrent = tCurrent + dur self.clockForward() # advances path positon return 1
def _scoreMain(self): """creates score >>> from athenaCL.libATH.libTM import texture >>> ti = texture.factory('MonophonicOrnament') >>> ti.tmName == 'MonophonicOrnament' True >>> ti.loadDefault() >>> ti.score() == True True """ self.ornamentObj = ornament.Ornament(self.pmtrObjDict, self.temperamentObj) # texture-wide PATH/PITCH elements # texture-wide time elements inst = self.getInst() tStart, tEnd = self.getTimeRange() tCurrent = tStart #texture-wide TEXTURE (self.textQ amd)options #used for optional parallel voices textRepeatToggle = self.getTextStatic('lws', 'onOff') # create a list of chords from the appropriate pitch mode ornamentSwitch = self.getTextStatic('ols', 'libraryName') ornamentMaxDensity = self.getTextStatic('omd', 'percent') # get field, octave selection method value textFieldLevel = self.getTextStatic('lfm', 'level') textOctaveLevel = self.getTextStatic('lom', 'level') # create a randomUniform parameter object to control ornament control # values between 0 and 1; if pmtr() <= ornamentMaxDensity ruPmtrObj = parameter.factory(('randomUniform', 0, 1)) for pathPos in self.getPathPos(): chordCurrent = self.getPitchGroup(pathPos) multisetCurrent = self.getMultiset(pathPos) tStartSet, tEndSet = self.clockPoints() chordLength = len(chordCurrent) chordIndex = 0 muteSet = 'off' psTest = [] ornamentIndex = 0 tStartSetReal = copy.deepcopy(tCurrent) self.stateUpdate(tCurrent, chordCurrent, None, multisetCurrent, None, None) if textFieldLevel == 'set': transCurrent = self.getField(tCurrent) # choose PITCHFIELD if textOctaveLevel == 'set': octCurrent = self.getOct(tCurrent) # choose OCTAVE while 1: # PITCH in CHORD if tCurrent >= tEndSet: break ps = chordCurrent[chordIndex] # choose PC from CHORD psTest.append(ps) chordIndex = chordIndex + 1 # shift to next pitch if chordIndex >= chordLength: chordIndex = 0 self.stateUpdate(tCurrent, chordCurrent, ps, multisetCurrent, None, None) if textFieldLevel == 'event': transCurrent = self.getField(tCurrent) # choose PITCHFIELD if textOctaveLevel == 'event': octCurrent = self.getOct(tCurrent) # choose OCTAVE psReal = pitchTools.psToTempered(ps, octCurrent, self.temperamentObj, transCurrent) self.stateUpdate(tCurrent, chordCurrent, ps, multisetCurrent, None, psReal) bpm, pulse, dur, sus, acc = self.getRhythm(tCurrent) if muteSet == 'on': # make all rests acc = 0 # everything is a rest after chord inex reset if acc == 0 and not self.silenceMode: # this is a rest chordIndex = chordIndex - 1 # dont count this note if a rest psTest = psTest[:-1] # drop off last addition tCurrent = tCurrent + dur continue # amp, pan, aux choosen per event amp = self.getAmp(tCurrent) * acc pan = self.getPan(tCurrent) auxiliary = self.getAux(tCurrent) parentEventDict = self.makeEvent(tCurrent, bpm, pulse, dur, sus, acc, amp, psReal, pan, auxiliary) refDict = self.getRefDict(tCurrent) if ornamentSwitch != 'off': # check if an ru value is <= ornament density (if 1, always) # time value is not important if ruPmtrObj(tCurrent) <= ornamentMaxDensity: repretory = self._ornGroupGet(ornamentSwitch) #a, b, c, d = repretory[ornamentIndex] # this will do in order a, b, c, d = random.choice(repretory) # choose orn at random subEventArray = self.ornamentObj.create(refDict,a,b,c,d) self.storePolyEvent(parentEventDict, subEventArray, 'orn') ornamentIndex = ornamentIndex + 1 # increment for when ordered if ornamentIndex == len(repretory): ornamentIndex = 0 else: self.storeEvent(parentEventDict) else: # ornament == 'off': # dont do ornaments self.storeEvent(parentEventDict) # turn of further notes if all gotten if textRepeatToggle == 'off' and len(psTest) >= chordLength: muteSet = 'on' # move clocks forward by dur unit tCurrent = tCurrent + dur self.clockForward() # advances path positon return 1