def _create_ugen_input_group(ugen, ugen_index): from abjad.tools import documentationtools if not ugen.inputs: return None input_group = documentationtools.GraphvizGroup( name='inputs'.format(ugen_index), ) for i, input_ in enumerate(ugen.inputs): label = '' input_name = None if i < len(ugen._ordered_input_names): input_name = ugen._ordered_input_names[i] if input_name: #input_name = r'\n'.join(input_name.split('_')) if isinstance(input_, float): label = r'{}:\n{}'.format(input_name, input_) else: label = input_name elif isinstance(input_, float): label = str(input_) label = label or None field = documentationtools.GraphvizField( label=label, name='ugen_{}_input_{}'.format(ugen_index, i), ) input_group.append(field) return input_group
def _create_ugen_output_group(synthdef, ugen, ugen_index): from abjad.tools import documentationtools from supriya.tools import ugentools if not ugen.outputs: return None output_group = documentationtools.GraphvizGroup( name='outputs'.format(ugen_index), ) for i, output in enumerate(ugen.outputs): label = str(i) if isinstance(ugen, ugentools.Control): parameter_index = ugen.special_index + i parameter = dict(synthdef.indexed_parameters)[parameter_index] parameter_name = parameter.name #parameter_name = r'\n'.join(parameter.name.split('_')) label = r'{}:\n{}'.format( parameter_name, parameter.value, ) field = documentationtools.GraphvizField( label=label, name='ugen_{}_output_{}'.format(ugen_index, i), ) output_group.append(field) return output_group
def make_offset_node( offset, leaf_one=None, leaf_two=None, is_last=False, ): if not is_last: offset_node = documentationtools.GraphvizNode( attributes={ 'shape': 'Mrecord', 'style': 'filled', 'color': 'white', 'fontname': 'Arial bold', 'fontcolor': 'white', 'fillcolor': 'black', }, ) else: offset_node = documentationtools.GraphvizNode( attributes={ 'shape': 'Mrecord', }, ) offset_field = documentationtools.GraphvizField( label=str(offset), ) weight_field = documentationtools.GraphvizField( label='+' * offsets[offset], ) group = documentationtools.GraphvizGroup() group.extend([offset_field, weight_field]) offset_node.append(group) offset_subgraph.append(offset_node) leaf_one_node = node_mapping[leaf_one] edge = documentationtools.GraphvizEdge( attributes={'style': 'dotted'}, ) edge(leaf_one_node, offset_node) if leaf_two: leaf_two_node = node_mapping[leaf_two] edge = documentationtools.GraphvizEdge( attributes={'style': 'dotted'}, ) edge(leaf_two_node, offset_node)
def _create_ugen_title_field(ugen): from abjad.tools import documentationtools from supriya.tools import synthdeftools from supriya.tools import ugentools name = type(ugen).__name__ calculation_rate = ugen.calculation_rate.name.lower() label_template = r'{name}\n({calculation_rate})' operator = None if isinstance(ugen, ugentools.BinaryOpUGen): operator = synthdeftools.BinaryOperator(ugen.special_index).name label_template = r'{name}\n[{operator}]\n({calculation_rate})' elif isinstance(ugen, ugentools.UnaryOpUGen): operator = synthdeftools.UnaryOperator(ugen.special_index).name label_template = r'{name}\n[{operator}]\n({calculation_rate})' title_field = documentationtools.GraphvizField( label=label_template.format( name=name, operator=operator, calculation_rate=calculation_rate, ), ) return title_field