def __call__( self, q_event_sequence, q_schema=None, grace_handler=None, heuristic=None, job_handler=None, attack_point_optimizer=None, attach_tempos=True, ): r'''Calls quantizer. Returns Abjad components. ''' from abjad.tools import quantizationtools q_event_sequence = quantizationtools.QEventSequence(q_event_sequence) if q_schema is None: q_schema = quantizationtools.MeasurewiseQSchema() assert isinstance(q_schema, quantizationtools.QSchema) q_target = q_schema(q_event_sequence.duration_in_ms) notation = q_target( q_event_sequence, grace_handler=grace_handler, heuristic=heuristic, job_handler=job_handler, attack_point_optimizer=attack_point_optimizer, attach_tempos=attach_tempos, ) return notation
def test_quantizationtools_MeasurewiseQSchema___init___01(): item_a = quantizationtools.MeasurewiseQSchemaItem( search_tree=abjad.quantizationtools.UnweightedSearchTree({2: None})) item_b = quantizationtools.MeasurewiseQSchemaItem(tempo=((1, 4), 76)) item_c = quantizationtools.MeasurewiseQSchemaItem(time_signature=(3, 4)) item_d = quantizationtools.MeasurewiseQSchemaItem(use_full_measure=True) schema = quantizationtools.MeasurewiseQSchema( { 2: item_a, 4: item_b, 7: item_c, 8: item_d }, search_tree=abjad.quantizationtools.UnweightedSearchTree({3: None}), tempo=((1, 8), 58), time_signature=(5, 8), use_full_measure=False, ) assert len(schema.items) == 4 assert schema.search_tree == quantizationtools.UnweightedSearchTree( {3: None}) assert schema.tempo == abjad.MetronomeMark((1, 8), 58) assert schema.time_signature == abjad.TimeSignature((5, 8)) assert schema.use_full_measure == False
def test_quantizationtools_MeasurewiseQSchema___getitem___02(): item_a = quantizationtools.MeasurewiseQSchemaItem( search_tree=abjad.quantizationtools.UnweightedSearchTree({2: None})) item_b = quantizationtools.MeasurewiseQSchemaItem(tempo=((1, 4), 76)) item_c = quantizationtools.MeasurewiseQSchemaItem(time_signature=(3, 4)) item_d = quantizationtools.MeasurewiseQSchemaItem( search_tree=abjad.quantizationtools.UnweightedSearchTree({5: None}), use_full_measure=True) schema = quantizationtools.MeasurewiseQSchema( { 2: item_a, 4: item_b, 7: item_c, 8: item_d }, search_tree=abjad.quantizationtools.UnweightedSearchTree({3: None}), tempo=((1, 8), 58), time_signature=(5, 8), use_full_measure=False, ) assert schema[0] == schema[1] == { 'search_tree': quantizationtools.UnweightedSearchTree({3: None}), 'tempo': abjad.MetronomeMark((1, 8), 58), 'time_signature': abjad.TimeSignature((5, 8)), 'use_full_measure': False, } assert schema[2] == schema[3] == { 'search_tree': quantizationtools.UnweightedSearchTree({2: None}), 'tempo': abjad.MetronomeMark((1, 8), 58), 'time_signature': abjad.TimeSignature((5, 8)), 'use_full_measure': False, } assert schema[4] == schema[5] == schema[6] == { 'search_tree': quantizationtools.UnweightedSearchTree({2: None}), 'tempo': abjad.MetronomeMark((1, 4), 76), 'time_signature': abjad.TimeSignature((5, 8)), 'use_full_measure': False, } assert schema[7] == { 'search_tree': quantizationtools.UnweightedSearchTree({2: None}), 'tempo': abjad.MetronomeMark((1, 4), 76), 'time_signature': abjad.TimeSignature((3, 4)), 'use_full_measure': False, } assert schema[8] == schema[9] == schema[1000] == { 'search_tree': quantizationtools.UnweightedSearchTree({5: None}), 'tempo': abjad.MetronomeMark((1, 4), 76), 'time_signature': abjad.TimeSignature((3, 4)), 'use_full_measure': True, }
def test_quantizationtools_MeasurewiseQSchema___init___02(): schema = quantizationtools.MeasurewiseQSchema() assert len(schema.items) == 0 assert schema.search_tree == quantizationtools.UnweightedSearchTree() assert schema.tempo == abjad.MetronomeMark((1, 4), 60) assert schema.time_signature == abjad.TimeSignature((4, 4)) assert schema.use_full_measure == False
def test_quantizationtools_MeasurewiseQSchema___getitem___01(): schema = quantizationtools.MeasurewiseQSchema() assert schema[0] == schema[1] == schema[2] == { 'search_tree': quantizationtools.UnweightedSearchTree(), 'tempo': abjad.MetronomeMark((1, 4), 60), 'time_signature': abjad.TimeSignature((4, 4)), 'use_full_measure': False, }
def test_quantizationtools_MeasurewiseQSchema___call___01(): schema = quantizationtools.MeasurewiseQSchema() target = schema(5000)