Example #1
0
    def visit(self, node):
        #if hasattr(node, 'kind') and node.kind('Leaf'):
        if hasattr(node, 'kind') and node.kind('_Leaf'):
            self.i += 1

        # TIDE stop
        if self.i in self.tide['stop']:

            #result = note.Note(0, node.duration.n, node.duration.d)
            result = Note(0, node.duration.pair)
            #result.left.append(r'\transparent')
            result.formatter.left.append(r'\transparent')
            result.pitch = klang.mapping('release')
            #termination = note.Note(0, 1, 16)
            termination = Note(0, (1, 16))
            termination.pitch = klang.mapping('release')
            #termination.left.append(r'\square')
            termination.notehead.shape = 'square'
            #result.grace = [termination]
            result.grace.after = [termination]
            return [result]

        # FLAT
        elif self.i in self.flat['termination']:

            #result = note.Note(0, node.duration.n, node.duration.d)
            result = Note(0, node.duration.pair)
            result.pitch = klang.mapping('release')
            #result.before.append(r"\once \override Stem #'transparent = ##t")
            #result.before.append(r"\once \override NoteHead #'transparent = ##t")
            #result.before.append(r"\once \override Dots #'transparent = ##t")
            result.stem.transparent = True
            result.notehead.transparent = True
            result.dots.transparent = True
            #termination = note.Note(0, 1, 16)
            termination = Note(0, (1, 16))
            termination.pitch = klang.mapping('release')
            # cycle ahead by one attack type
            if self.strata['stops'][self.i - 1] == 't':
                #termination.left.append(r'\square')
                termination.notehead.shape = 'square'
            if self.strata['stops'][self.i - 1] == 'p':
                #termination.left.append(r'\semicircle')
                termination.notehead.shape = 'semicircle'
            if self.strata['stops'][self.i - 1] == 'k':
                #termination.left.append(r'\triangle')
                termination.notehead.shape = 'triangle'
            #result.grace = [termination]
            result.grace.after = [termination]
            return [result]

        else:
            return [node]
Example #2
0
    def visit(self, node):
        #if hasattr(node, 'kind') and node.kind('Leaf'):
        if hasattr(node, 'kind') and node.kind('_Leaf'):
            self.i += 1

        # TIDE
        if self.i in self.tide['attacks'] + self.tide['stop']:
            if self.i in self.tide['attacks']:
                #result = note.Note(0, node.duration.n, node.duration.d)
                result = Note(0, node.duration.pair)
                result.pitch = klang.mapping('attack')
                #result.duration.write(1, 16)
                result.duration.rewrite((1, 16))
                #result.left.append(r'\triangle')
                result.notehead.shape = 'triangle'
                if self.i in self.tide['stop']:
                    #result.right.append(r'\breathe')
                    result.formatter.right.append(r'\breathe')
                return [result]
            elif self.i in self.tide['stop']:
                #node.right.append(r'\breathe')
                node.formatter.right.append(r'\breathe')
                return [node]

        # STREAK
        if self.i in self.streak['s']:
            #result = note.Note(0, node.duration.n, node.duration.d)
            try:
                result = Note(0, node.duration.pair)
            except ValueError:
                result = Note(0, (1, 1))
                result.duration.multiplier = node.duration.pair
            #result.duration.write(1, 16)
            result.duration.rewrite((1, 16))
            result.pitch = klang.mapping('attack')
            #result.left.append(r'\semicircle')
            result.notehead.shape = 'semicircle'
            if self.i in self.streak['termination']:
                #result.right.append(r'\breathe')
                result.formatter.right.append(r'\breathe')
            return [result]

        elif self.i in self.streak['sh'] + self.streak['sr'] and \
            self.i in self.streak['termination']:
            #node.right.append(r'\breathe')
            node.formatter.right.append(r'\breathe')

        # PUNCTUATE
        if self.i in (self.punctuate['tongued normale'] +
            self.punctuate['tongued fricatives']):
            #result = note.Note(0, node.duration.n, node.duration.d)
            result = Note(0, node.duration.pair)
            result.pitch = klang.mapping('attack')
            #result.duration.write(1, 16)
            result.duration.rewrite((1, 16))
            stop = self.strata['stops'][self.i]
            if stop == 't':
                #result.left.append(r'\triangle')
                result.notehead.shape = 'triangle'
            elif stop == 'p':
                #result.left.append(r'\square')
                result.notehead.shape = 'square'
            elif stop == 'k':
                #result.left.append(r'\semicircle')
                result.notehead.shape = 'semicircle'
            else:
                raise ValueError('Unknown stop %s.' % stop)
            return [result]
        elif self.i in (self.punctuate['affricate normale'] +
            self.punctuate['affricate fricatives']):
            #result = note.Note(0, node.duration.n, node.duration.d)
            result = Note(0, node.duration.pair)
            result.pitch = klang.mapping(self.strata['sibilants'][self.i])
            #result.duration.write(1, 16)
            result.duration.rewrite((1, 16))
            stop = self.strata['stops'][self.i]
            if stop == 't':
                #result.left.append(r'\triangle')
                result.notehead.shape = 'triangle'
            elif stop == 'p':
                #result.left.append(r'\square')
                result.notehead.shape = 'square'
            elif stop == 'k':
                #result.left.append(r'\semicircle')
                result.notehead.shape = 'semicircle'
            else:
                raise ValueError('Unknown stop %s.' % stop)
            return [result]

        elif self.i in self.swell['stop']:
            #node.right.append(r'\breathe')
            node.formatter.right.append(r'\breathe')

        # FLAT
        elif self.i in self.flat['body']:
            #result = note.Note(0, node.duration.n, node.duration.d)
            result = Note(0, node.duration.pair)
            #result.duration.write(1, 16)
            result.duration.rewrite((1, 16))
            stop = self.strata['stops'][self.i]
            if stop == 't':
                #result.left.append(r'\triangle')
                result.notehead.shape = 'triangle'
            elif stop == 'p':
                #result.left.append(r'\square')
                result.notehead.shape = 'square'
            elif stop == 'k':
                #result.left.append(r'\semicircle')
                result.notehead.shape = 'semicircle'
            else:
                raise ValueError('Unknown stop %s.' % stop)
            result.pitch = klang.mapping(self.strata['sibilants'][self.i])
            #if (self.i + 1) not in self.flat:
            #   result.right.append(r'\breathe')
            if self.i in self.flat['termination']:
                #result.right.append(r'\breathe')
                result.formatter.right.append(r'\breathe')
            return [result]

        return [node]
Example #3
0
    def visit(self, node):
        #if hasattr(node, 'kind') and node.kind('Leaf'):
        if hasattr(node, 'kind') and node.kind('_Leaf'):
            self.i += 1

        # TIDE
        if self.i in self.tide['attacks'] + self.tide['middle'] + \
            self.tide['stop']:
            #result = note.Note(0, node.duration.n, node.duration.d)
            result = Note(0, node.duration.pair)
            #result.left.append(r'\harmonic')
            result.notehead.style = 'harmonic'
            #result.right.append(r'\glissando')
            result.glissando = True
            if self.i in self.tide['attacks']:
                result.pitch = klang.mapping('th')
            elif self.i in self.tide['middle']:
                result.pitch = klang.mapping('f')
            if self.i in self.tide['stop']:
                #termination = note.Note(0, 1, 16)
                termination = Note(0, (1, 16))
                #termination.left.append(r'\blackdiamond')
                termination.notehead.style = 'harmonic-black'
                if (self.i - 1) in self.tide['middle']:
                    result.pitch = klang.mapping('th')
                    termination.pitch = klang.mapping('f')
                else:
                    result.pitch = klang.mapping('f')
                    termination.pitch = klang.mapping('th')
                #result.grace = [termination]
                result.grace.after = [termination]
            return [result]

        # STREAK
        if self.i not in self.streak['termination']:
            if self.i in self.streak['s']:
                #result = note.Note(0, node.duration.n, node.duration.d)
                result = Note(0, node.duration.pair)
                result.pitch = klang.mapping('s')
                #result.left.append(r'\harmonic')
                #result.right.append(r'\glissando')
                result.notehead.style = 'harmonic'
                result.glissando = True
                return [result]
            elif self.i in self.streak['sh']:
#            result = note.Note(0, node.duration.n, node.duration.d)
#            result.pitch = klang.mapping('sh')
#            result.left.append(r'\harmonic')
#            result.right.append(r'\glissando')
                result = Note(0, node.duration.pair)
                result.pitch = klang.mapping('sh')
                result.notehead.style = 'harmonic'
                result.glissando = True
                return [result]
            elif self.i in self.streak['sr']:
#            result = note.Note(0, node.duration.n, node.duration.d)
#            result.pitch = klang.mapping('sr')
#            result.left.append(r'\harmonic')
#            result.right.append(r'\glissando')
                result = Note(0, node.duration.pair)
                result.pitch = klang.mapping('sr')
                result.notehead.style = 'harmonic'
                result.glissando = True
                return [result]
        elif self.i in self.streak['termination']:
#         result = note.Note(0, node.duration.n, node.duration.d)
#         termination = note.Note(0, 1, 16)
#         termination.left.append(r'\blackdiamond')
            result = Note(0, node.duration.pair)
            termination = Note(0, (1, 16))
            termination.notehead.style = 'harmonic-black'
            if self.i in self.streak['s']:
                result.pitch = klang.mapping('s')
                #result.left.append(r'\harmonic')
                #result.right.append(r'\glissando')
                result.notehead.style = 'harmonic'
                result.glissando = True
                termination.pitch = klang.mapping('sh')
            elif self.i in self.streak['sh']:
                result.pitch = klang.mapping('sh')
                #result.left.append(r'\harmonic')
                #result.right.append(r'\glissando')
                result.notehead.style = 'harmonic'
                result.glissando = True
                termination.pitch = klang.mapping('sr')
            elif self.i in self.streak['sr']:
                result.pitch = klang.mapping('sr')
                #result.left.append(r'\harmonic')
                #result.right.append(r'\glissando')
                result.notehead.style = 'harmonic'
                result.glissando = True
                termination.pitch = klang.mapping('sr')
            else:
                raise ValueError(
                    'self.i %s not in self.streak for s, sh or sr.' % self.i)
            #result.grace = [termination]
            result.grace.after = [termination]
            return [result]

        if self.i in (self.punctuate['tongued normale'] +
            self.punctuate['affricate normale']):
            #result = note.Note(0, node.duration.n, node.duration.d)
            result = Note(0, node.duration.pair)
            result.pitch = klang.mapping('normale')
            if self.i in self.punctuate['sustained']:
                #result.left.append(r'\white')
                #result.right.append(r'\glissando')
                result.notehead.duration_log = 1
                result.glissando = True
            elif self.i in self.punctuate['detached']:
                pass
            else:
                raise ValueError('Neither sustained nor detached.')
            return [result]
        elif self.i in (self.punctuate['tongued fricatives'] +
            self.punctuate['affricate fricatives']):
            #result = note.Note(0, node.duration.n, node.duration.d)
            result = Note(0, node.duration.pair)
            result.pitch = klang.mapping(self.strata['fricatives'][self.i])
            if self.i in self.punctuate['sustained']:
                #result.left.append(r'\harmonic')
                #result.right.append(r'\glissando')
                result.notehead.style = 'harmonic'
                result.glissando = True
            elif self.i in self.punctuate['detached']:
                #result.left.append(r'\blackdiamond')
                result.notehead.style = 'harmonic-black'
            else:
                raise ValueError('Neither sustained nor detached.')
            return [result]

        # SWELL - start, middle
        if self.i in self.swell['start'] + self.swell['middle'] and \
            self.i not in self.swell['stop']:
            #result = note.Note(0, node.duration.n, node.duration.d)
            result = Note(0, node.duration.pair)
            result.pitch = klang.mapping('normale')
            #result.left.append(r'\white')
            #result.right.append(r'\glissando')
            result.notehead.duration_log = 1
            result.glissando = True
            return [result]

        # SWELL - stop
        elif self.i in self.swell['stop']:
            #result = note.Note(0, node.duration.n, node.duration.d)
            result = Note(0, node.duration.pair)
            result.pitch = klang.mapping('normale')
            #result.left.append(r'\white')
            #result.right.append(r'\glissando')
            result.notehead.duration_log = 1
            result.glissando = True
            #termination = note.Note(0, 1, 16)
            termination = Note(0, (1, 16))
            termination.pitch = klang.mapping('normale')
            #result.grace = [termination]
            result.grace.after = [termination]
            return [result]

        # FLAT
        elif self.i in self.flat['body']:
            #result = note.Note(0, node.duration.n, node.duration.d)
            result = Note(0, node.duration.pair)
            result.pitch = klang.mapping('normale')
            #result.left.append(r'\white')
            #result.right.append(r'\glissando')
            result.notehead.duration_log = 1
            result.glissando = True
            if self.i in self.flat['termination']:
                #termination = note.Note(0, 1, 16)
                termination = Note(0, (1, 16))
                termination.pitch = klang.mapping('normale')
                #result.grace = [termination]
                result.grace.after = [termination]
            return [result]

        return [node]