abjad.tools.quantizationtools.QGrid

Here are the examples of the python api abjad.tools.quantizationtools.QGrid taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

3 Examples 7

Example 1

Project: abjad Source File: DistanceHeuristic.py
Function: process
    def _process(self, q_target_beats):
        from abjad.tools import quantizationtools
        for q_target_beat in q_target_beats:
            q_grids = q_target_beat.q_grids
            if q_grids:
                sorted_q_grids = sorted(
                    q_grids, key=lambda x: (x.distance, len(x.leaves)))
                q_target_beat._q_grid = sorted_q_grids[0]
            else:
                q_target_beat._q_grid = quantizationtools.QGrid()
        return q_target_beats

Example 2

Project: abjad Source File: SearchTree.py
Function: call
    def __call__(self, q_grid):
        r'''Calls search tree.
        '''
        from abjad.tools import quantizationtools
        assert isinstance(q_grid, quantizationtools.QGrid)
        new_q_grids = []
        commands = self._generate_all_subdivision_commands(q_grid)
        for command in commands:
            new_q_grid = copy.copy(q_grid)
            q_events = new_q_grid.subdivide_leaves(command)
            new_q_grid.fit_q_events(q_events)
            new_q_grids.append(new_q_grid)
        return new_q_grids

Example 3

Project: abjad Source File: QuantizationJob.py
Function: call
    def __call__(self):
        r'''Calls quantization job.

        Returns none.
        '''
        from abjad.tools import quantizationtools
        #print('XXX')
        #print(format(self.q_event_proxies[0]))

        q_grid = quantizationtools.QGrid()
        q_grid.fit_q_events(self.q_event_proxies)

        #print(format(q_grid))

        old_q_grids = []
        new_q_grids = [q_grid]

        while new_q_grids:
            q_grid = new_q_grids.pop()
            search_results = self.search_tree(q_grid)
            #print q_grid.rtm_format
            #for x in search_results:
            #    print '\t', x.rtm_format
            new_q_grids.extend(search_results)
            old_q_grids.append(q_grid)

        #for q_grid in old_q_grids:
        #    print('\t', q_grid)
        #print()

        self._q_grids = tuple(old_q_grids)