def test_Sequence_superpose_01(): instances = [0, 1, 2, 3] durations = [0.5, 0.5, 0.5, 0.5] sound_points_generator = pang.ManualSoundPointsGenerator( instances=instances, durations=durations, ) sequence_0 = pang.Sequence( sound_points_generator=sound_points_generator, sequence_duration=4, ) instances = [0.5, 1.5, 2.5, 3.5] durations = [0.6, 0.6, 0.7, 0.7] pitches = [1, 1, 1, 1] sound_points_generator = pang.ManualSoundPointsGenerator( instances=instances, durations=durations, pitches=pitches, ) sequence_1 = pang.Sequence(sound_points_generator=sound_points_generator, ) sequence_0.superpose(sequence_1) assert sequence_0.instances == [0, 0.5, 1, 1.5, 2, 2.5, 3, 3.5] assert sequence_0.durations == [0.5, 0.6, 0.5, 0.6, 0.5, 0.7, 0.5, 0.7] assert sequence_0.pitches == [0, 1, 0, 1, 0, 1, 0, 1]
def generate_sequence_manually(instances, durations, pitches): sound_points_generator = pang.ManualSoundPointsGenerator( instances=instances, durations=durations, pitches=pitches, ) return pang.Sequence(sound_points_generator=sound_points_generator)
def test_Sequence_simulate_queue_00(): instances = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] durations = [0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5] sound_points_generator = pang.ManualSoundPointsGenerator( instances=instances, durations=durations, ) sequence_duration = 10 sequence = pang.Sequence( sound_points_generator=sound_points_generator, sequence_duration=sequence_duration, ) sequence.simulate_queue() np.testing.assert_almost_equal( sequence.servers[0].durations, [ 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, ], ) assert sequence.servers[0].pitches == [ 0, None, 0, None, 0, None, 0, None, 0, None, 0, None, 0, None, 0, None, 0, None, 0, ]
def test_Sequence___init___02(): instances = [0, 1, 2, 3] durations = [0.5, 0.5, 0.5, 0.5] sound_points_generator = pang.ManualSoundPointsGenerator( instances=instances, durations=durations, ) sequence = pang.Sequence(sound_points_generator=sound_points_generator, ) assert sequence.instances == instances assert sequence.durations == durations assert sequence.pitches == [0, 0, 0, 0] assert sequence.sequence_duration == 3.5
def test_ManualSequence_extend_01(): instances = [0, 1, 2, 3] durations = [0.5, 0.5, 0.5, 0.5] sound_points_generator = pang.ManualSoundPointsGenerator( instances=instances, durations=durations, ) sequence_0 = pang.Sequence( sound_points_generator=sound_points_generator, sequence_duration=4, ) sequence_1 = pang.Sequence(sound_points_generator=sound_points_generator, ) sequence_0.extend(sequence_1) assert sequence_0.instances == [0, 1, 2, 3, 4, 5, 6, 7] assert sequence_0.durations == [0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5] assert sequence_0.pitches == [0, 0, 0, 0, 0, 0, 0, 0]
def test_sequencesimulate_queue_04(): instances = [1, 1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 1.7, 1.8, 1.9] durations = [0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5] sound_points_generator = pang.ManualSoundPointsGenerator( instances=instances, durations=durations, ) sequence_duration = 10 sequence = pang.Sequence( sound_points_generator=sound_points_generator, sequence_duration=sequence_duration, ) sequence.simulate_queue() np.testing.assert_almost_equal( sequence.servers[0].durations, [ 1, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, ], ) assert sequence.servers[0].pitches == [ None, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, ]
def test_ProcessQuantizedSequenceCommand__segment_target_by_tag_00(): instances = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] durations = [0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5] sound_points_generator = pang.ManualSoundPointsGenerator( instances=instances, durations=durations, ) sequence_duration = 10 sequence = pang.Sequence( sound_points_generator=sound_points_generator, sequence_duration=sequence_duration, ) for event in sequence[:5]: event.tag = 0 for event in sequence[5:]: event.tag = 1 # The sequence is just a dummy to init the command and to provide the tags command = pang.ProcessQuantizedSequenceCommand(sequence) voice = abjad.Voice("c'4 c'4~ c'8 cs'8 cs'4") segments = command._segment_target_by_tag(target=voice) assert segments[0] == abjad.select(voice[:3]).logical_ties() assert segments[1] == abjad.select(voice[3:]).logical_ties()
def test_Sequence_simulate_queue_05(): instances = [1, 1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 1.7, 1.8, 1.9] durations = [0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5] sound_points_generator = pang.ManualSoundPointsGenerator( instances=instances, durations=durations, ) sequence_duration = 10 sequence = pang.Sequence( sound_points_generator=sound_points_generator, sequence_duration=sequence_duration, tag=10, ) sequence.extend( pang.Sequence( sound_points_generator=sound_points_generator, sequence_duration=sequence_duration, tag=11, )) sequence.simulate_queue(tag_as_pitch=True) np.testing.assert_almost_equal( sequence.servers[0].durations, [ 1, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, ], ) assert sequence.servers[0].pitches == [ None, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, None, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, ]