Exemple #1
0
    def decodePmtrName(self, usrStr, style='cmd'):
        """translates user string to proper parameter key
        style = cmd uses parenthesis to show command name
            str provides simples string
            usr provides aux/text numbers w/ aprop shift

        >>> a = Clone()
        >>> a.decodePmtrName('c')
        ('acc', 'a(c)cent')
        """
        if usrStr == None: return None, ''
        p = drawer.strScrub(usrStr, 'lower')
        refNo = None  # only used for aux, texture
        if p in (
                't',
                'time',
        ):
            attrName = 'time'
            label = '(t)ime'
        elif p in ('u', 'sustain', 'sus'):
            attrName = 'sus'
            label = 's(u)stain'
        elif p in ('c', 'accent', 'acc'):
            attrName = 'acc'
            label = 'a(c)cent'
        elif p in ('f', 'field', 'fieldq'):
            attrName = 'fieldQ'
            label = 'local (f)ield'
        elif p in ('o', 'oct', 'octq'):
            attrName = 'octQ'
            label = 'local (o)ctave'
        elif p in ('a', 'amp', 'ampq'):
            attrName = 'ampQ'
            label = '(a)mplitude'
        elif p in ('n', 'pan', 'panq'):
            attrName = 'panQ'
            label = 'pan(n)ing'
        elif p[:1] == 'x' or p[:3] == 'aux':
            strNum, strLet = drawer.strExtractNum(p)
            attrName = 'auxQ' + strNum
            label = 'au(x)iliary'
            refNo = self._pmtrNumberToUsr(strNum, 0, style)
        elif p[:1] == 's' or p[:1] == 'c' or p[:5] == 'clone':
            strNum, strLet = drawer.strExtractNum(p)
            attrName = 'cloneQ' + p[1:]
            label = 'clone (s)tatic'
            refNo = self._pmtrNumberToUsr(strNum, 0, style)
        else:
            attrName = None
            label = ''

        if style == 'cmd':  # leave parenthesis in names
            pass
        elif style in ['str', 'usr']:  # remove parenthesis
            label = label.replace('(', '')
            label = label.replace(')', '')
            if style == 'usr' and refNo != None:
                label = '%s %s' % (label, refNo)
        return attrName, label
Exemple #2
0
    def decodePmtrName(self, usrStr, style='cmd'):
        """translates user string to proper parameter key
        style = cmd uses parenthesis to show command name
            str provides simples string
            usr provides aux/text numbers w/ aprop shift

        >>> a = Clone()
        >>> a.decodePmtrName('c')
        ('acc', 'a(c)cent')
        """
        if usrStr == None: return None, ''
        p = drawer.strScrub(usrStr, 'lower')
        refNo = None # only used for aux, texture
        if p in ('t', 'time',):
            attrName = 'time'
            label = '(t)ime'
        elif p in ('u', 'sustain', 'sus'):
            attrName = 'sus'
            label = 's(u)stain'
        elif p in ('c', 'accent', 'acc'):
            attrName = 'acc'
            label = 'a(c)cent'
        elif p in ('f', 'field', 'fieldq'):
            attrName = 'fieldQ'
            label = 'local (f)ield'
        elif p in ('o', 'oct', 'octq'):
            attrName = 'octQ'
            label = 'local (o)ctave'
        elif p in ('a', 'amp', 'ampq'):
            attrName = 'ampQ'
            label = '(a)mplitude'
        elif p in ('n', 'pan', 'panq'):
            attrName = 'panQ'
            label = 'pan(n)ing'
        elif p[:1] == 'x' or p[:3] == 'aux':
            strNum, strLet = drawer.strExtractNum(p)
            attrName = 'auxQ' + strNum
            label = 'au(x)iliary'
            refNo = self._pmtrNumberToUsr(strNum, 0, style)
        elif p[:1] == 's' or p[:1] == 'c' or p[:5] == 'clone':
            strNum, strLet = drawer.strExtractNum(p)
            attrName = 'cloneQ' + p[1:]
            label = 'clone (s)tatic'
            refNo = self._pmtrNumberToUsr(strNum, 0, style)
        else:
            attrName = None
            label = ''

        if style == 'cmd': # leave parenthesis in names
            pass
        elif style in ['str', 'usr']: # remove parenthesis
            label = label.replace('(','')
            label = label.replace(')', '')
            if style == 'usr' and refNo != None:
                label = '%s %s' % (label, refNo)         
        return attrName, label
Exemple #3
0
    def clear(self):
        """processes init value and replaces history with first generation
        will always add an init to the history, meaning that there will always
        be one more generation than expected in most cases

        """
        stepInit = self._getTemplate()
        if drawer.isStr(self.init):
            numStr, junk = drawer.strExtractNum(self.init)
            if self.init == 'center':
                centerIndex = self._getCenter()
                if self.dstValues == None:  # continuous case
                    if self.DECIMAL: val = decimal.Decimal(1)
                    else: val = 1.0
                    # should add one here, but need -1 for list position shift
                    stepInit[self._getCenter()] = val
                else:  # center value is dependent; must provude as variable
                    stepInit[self._getCenter()] = self.dstValues[
                        self.dstIndexCenter]
            elif self.init == 'random':
                for x in range(self.size):
                    if self.dstValues == None:  # continuous case
                        if self.DECIMAL:
                            val = decimal.Decimal(str(random.random()))
                        else:
                            val = random.random()
                        stepInit[x] = val
                    else:  # discrete
                        stepInit[x] = random.choice(self.dstValues)
            # may be number as a string; treat as a list
            elif len(numStr) == len(self.init):
                for x in range(self.size):
                    # must be integers, use force to limit at min / max
                    if self.dstValues != None:
                        min = self.dstValues[0]
                        max = self.dstValues[-1]
                    else:  # continuous, unit interval
                        min = 0
                        max = 1
                    val = drawer.strToNum(self.init[(x % len(self.init))],
                                          'int', min, max, 1)
                    stepInit[x] = val
        elif drawer.isNum(self.init):
            for x in range(self.size):
                stepInit[x] = self.init
        elif drawer.isList(self.init):
            for x in range(self.size):
                stepInit[x] = self.init[(x % len(self.init))]
        self.stepHistory = [stepInit]  # a list of arrays
Exemple #4
0
    def clear(self):
        """processes init value and replaces history with first generation
        will always add an init to the history, meaning that there will always
        be one more generation than expected in most cases

        """
        stepInit = self._getTemplate()
        if drawer.isStr(self.init):
            numStr, junk = drawer.strExtractNum(self.init)
            if self.init == 'center':
                centerIndex = self._getCenter()
                if self.dstValues == None: # continuous case
                    if self.DECIMAL: val = decimal.Decimal(1)
                    else: val = 1.0
                    # should add one here, but need -1 for list position shift
                    stepInit[self._getCenter()] = val 
                else: # center value is dependent; must provude as variable
                    stepInit[self._getCenter()] = self.dstValues[self.dstIndexCenter] 
            elif self.init == 'random':
                for x in range(self.size):
                    if self.dstValues == None: # continuous case
                        if self.DECIMAL: val = decimal.Decimal(str(random.random()))
                        else: val = random.random() 
                        stepInit[x] = val                
                    else: # discrete
                        stepInit[x] = random.choice(self.dstValues)
            # may be number as a string; treat as a list
            elif len(numStr) == len(self.init):
                for x in range(self.size):
                    # must be integers, use force to limit at min / max
                    if self.dstValues != None:
                        min = self.dstValues[0]
                        max = self.dstValues[-1]
                    else: # continuous, unit interval
                        min = 0
                        max = 1
                    val = drawer.strToNum(self.init[(x % len(self.init))], 'int', 
                                                 min, max, 1)
                    stepInit[x] = val
        elif drawer.isNum(self.init):
            for x in range(self.size):
                stepInit[x] = self.init               
        elif drawer.isList(self.init):
            for x in range(self.size):
                stepInit[x] = self.init[(x % len(self.init))]
        self.stepHistory = [stepInit] # a list of arrays        
Exemple #5
0
def caInitParser(usrStr):
    """
    >>> caInitParser('center')
    'center'
    >>> caInitParser('junk') == None
    True
    """
    usrNum, junk = drawer.strExtractNum(usrStr)
    if drawer.isNum(usrStr) or (len(usrNum) == len(usrStr)
                                or drawer.isList(usrStr)):
        return usrStr  # not a string, a data obj
    # only parse if a string
    ref = {
        'center': ['c', 'center'],
        'random': ['r', 'random'],
    }
    usrStr = drawer.selectionParse(usrStr, ref)
    return usrStr  # may be Non
Exemple #6
0
def caInitParser(usrStr):
    """
    >>> caInitParser('center')
    'center'
    >>> caInitParser('junk') == None
    True
    """
    usrNum, junk = drawer.strExtractNum(usrStr)
    if drawer.isNum(usrStr) or (len(usrNum) == len(usrStr) or 
        drawer.isList(usrStr)):
        return usrStr # not a string, a data obj
    # only parse if a string
    ref = {
        'center' : ['c', 'center'],
        'random' : ['r', 'random'],
            }
    usrStr = drawer.selectionParse(usrStr, ref)
    return usrStr # may be Non