Ejemplo n.º 1
0
    def __init__(self, args, refDict):
        basePmtr.RhythmParameter.__init__(self, args, refDict) # call base init
        self.type = 'markovPulse'
        self.doc = lang.docPoMp
        self.argTypes = ['str', 'list']
        self.argNames = ['transitionString', 'parameterObject: order value']
        # note: restringulator can hand commas in braces...

        # TODO: accept single value for order value!

        self.argDefaults = ['a{3,1,1}b{2,1,1}c{3,2,0}:{a=3|b=4|c=1}', 
                                 ('c', 0)]
        # check raw arguments for number, type
        ok, msg = self._checkRawArgs()
        if ok == 0: raise error.ParameterObjectSyntaxError(msg) # report error
        
        self.markovObj = markov.Transition() # creat obj w/o loading
        try:
            self.markovObj.loadTransition(self.args[0])
        except error.TransitionSyntaxError as e: 
            raise error.ParameterObjectSyntaxError('Markov transition creation failed: %s' % e)
        # will raise error
        self.orderObj = self._loadSub(self.args[1], 'genPmtrObjs')
        # need to store accumulated values
        self.accum = []
        # create a dictionary to store pulse objects, w/ string
        self.pulseRef = {}
        # we only need unique signified; even if more than one symbol refers
        # to the same signified, this does not matter
        for key in self.markovObj.getSignified():
            try:
                pulseObj = rhythm.Pulse(key) # let guess pulse type
            except error.PulseSyntaxError as e:
                raise error.ParameterObjectSyntaxError('failed pulse object definition: %s' % e)
            self.pulseRef[key] = pulseObj # store objs
Ejemplo n.º 2
0
 def _updateAnalysis(self):
     # note: this may raise an error if po is expecting values in the refDict
     self.analysisSeries = []
     for i in range(self.pulseCount):
         refDict = {'bpm':60} # this bpm value is not relevant, but needed
         q = self.srcObj(i, refDict) # call object to get next value
         self.analysisSeries.append(str(self.srcObj.currentPulse))
     # create object with source values
     self.markovObj.loadList(self.analysisSeries, self.maxAnalysisOrder)
     for key in self.markovObj.getSignified(): # get pulse strings
         # this should never raise an error, as generate by rhythm pmtr obj
         self.pulseRef[key] =     rhythm.Pulse(key, 'triple')    # store objs
Ejemplo n.º 3
0
    def __init__(self, args, refDict):
        basePmtr.RhythmParameter.__init__(self, args, refDict) # call base init
        self.type = 'pulseSieve'
        self.doc = lang.docPoPs
        self.argTypes = [['str', 'num','list'], 'num', 'list', 'str', 'str']
        
        self.argNames = ['logicalString', 'sieveLength', 'pulse',
                              'selectionString', 'articulationString']
        self.argDefaults = ['3|4|5@2', 60, (3,1,1), 'oc', 'a']
        self.argDemos = [['3|4|5@2', 60, (4,1,1), 'rc', 's'],
                             ]
                             
        self.priority = 9 # rhythm gets top priority
        # check raw arguments for number, type
        ok, msg = self._checkRawArgs()
        if ok == 0: raise error.ParameterObjectSyntaxError(msg) # report error
        
        self.currentPulse = None # init value, used in getCurrentRhythm     
        self.length = abs(int(round(self.args[1])))
        self.z = list(range(0, self.length))
        try:
            self.sieveObj = sieve.Sieve(self.args[0], self.z)
        except AttributeError: 
            raise error.ParameterObjectSyntaxError("incorrect sieve syntax.")

        try:
            self.pulseObj = rhythm.Pulse(self.args[2])
        except error.PulseSyntaxError:
            raise error.ParameterObjectSyntaxError("incorrect sieve syntax.")
        self.pulseObj.setSus(.94) # no sustain

        self.pulseOn = self.pulseObj.copy()
        self.pulseOn.setAcc(1)  # force on
        self.pulseOff = self.pulseObj.copy()
        self.pulseOff.setAcc(0) # force off
        # gets a list if numbers, like 0,3,4,6,9,10
        # interpret as equal dur time points

        # get format based on ariticulation
        self.articulation = self._articulationParser(self.args[4])
        if self.articulation == 'sustain': fmt = 'wid'
        elif self.articulation == 'attack': fmt = 'bin'
        self.sieveObj.segFmtSet(fmt)
        self.sieveSeg = self.sieveObj(0, self.z)
        # set z as list from which selector draws
        self.control = self._selectorParser(self.args[3]) # raises exception
        self.selector = basePmtr.Selector(self.sieveSeg, self.control)
Ejemplo n.º 4
0
 def __call__(self, t=None, refDict=None):
     """all rhythm objects must use self.beatT in the 'call' method 
     in order to account for changes in tempo
     """
     self.bpm = refDict['bpm'] # bpm is not used to calc values
     # these are calculated values, not raw pulse values
     d = abs(drawer.floatToInt(self.divObj(t, refDict), 'weight'))
     if d == 0: d = 1
     m = abs(drawer.floatToInt(self.multObj(t, refDict), 'weight'))
     if m == 0: m = 1
     # used to be round; this is no longer done, as acc are implemented
     acc = abs(self.accObj(t, refDict))
     if acc <= 0: acc = 0 # must limit b/n 0 and 1
     elif acc >= 1: acc = 1
     sus = abs(self.susObj(t, refDict)) # dont round or weight
     if sus == 0: sus = 1 # sus of 0 is an error
     # create pulse object
     self.currentPulse = rhythm.Pulse((d, m, acc), 'triple')
     self.currentPulse.setSus(sus)
     self.currentValue = self.currentPulse(self.bpm) # call w/ bpm
     return self.currentValue
Ejemplo n.º 5
0
    def __init__(self, ps, dur, tie=None, dyn=None):
        """pitch format is standard atheanCL ps units, where midi 60 is 0
        duration is given as pulse triple
        may add dynmaics
        if ps == None, this is a rest"""
        # modify to accept objects as well
        self._ps = ps  # athenacl pitch space value

        if hasattr(dur, 'triple'):  # its a pulse triple
            self._dur = dur
        else:
            self._dur = rhythm.Pulse(dur)  # convert to pulse object

        self._tie = tie  # a number code for various formats
        self._dyn = dyn  # provude a dynamic value

        self._psName = None
        self._psAlter = None
        self._psOctave = None

        if self._ps != None:
            self._psName, self._psAlter, self._psOctave = pitchTools.psToMusicXml(
                self._ps)