.....................................F.....FFFFFFFFFFFFFF.F.........F... [ 37%] ..F.....F.....F.....................F.....................FF.F....F..... [ 75%] ...........F...........FF.....F...........F.F.F [100%] =================================== FAILURES =================================== _________________________ test_the_sine_has_1024_steps _________________________ def test_the_sine_has_1024_steps(): # 20150311.txt: the period divided by the flat-segment length "is always # exactly 1024". chip = tone_chip(PLAIN_SINE, f_number=64, block=1) # one table step in 8 samples phases = [value >> 9 for value in attribute(chip, "phase", C[0], 8 * 1024 * 2)] lengths = {length for _, length in runs(phases)[1:-1]} > assert lengths == {8} E assert {4} == {8} E E Extra items in the left set: E 4 E Extra items in the right set: E 8 E Use -v to get more diff tests/test_measured.py:102: AssertionError ________________________ test_modulator_into_carrier[0] ________________________ total_level = 0 @pytest.mark.parametrize("total_level", (0, 8, 32, 37, 48, 63)) def test_modulator_into_carrier(total_level): # mod-car.txt: registers $10 = $40, block 0, both operators at half speed, so # "each of the 1024 entries in the sine table is repeated 16 times"; TL from 0 # to 63; with the final model "the graph matches _exactly_ with the measured # data ... for all values". The depth at TL 0 is "-8pi..8pi". tone = (0x20, 0x20, total_level, 0x00, 0xF0, 0xF0, 0x00, 0x00) chip = struck(tone, f_number=0x40, block=0) chip.run(SAMPLE) # damp ends: both phases are reset, both levels go to 0 got = [sample[C[0]][0] for sample in words(chip, 16 * 1024)] > assert got == two_operator_reference(total_level, 0, 16 * 1024, 32) E assert [19, 19, 19, 19, 19, 19, ...] == [0, 19, 19, 19, 19, 19, ...] E E At index 0 diff: 19 != 0 E Use -v to get more diff tests/test_measured.py:203: AssertionError ________________________ test_modulator_into_carrier[8] ________________________ total_level = 8 @pytest.mark.parametrize("total_level", (0, 8, 32, 37, 48, 63)) def test_modulator_into_carrier(total_level): # mod-car.txt: registers $10 = $40, block 0, both operators at half speed, so # "each of the 1024 entries in the sine table is repeated 16 times"; TL from 0 # to 63; with the final model "the graph matches _exactly_ with the measured # data ... for all values". The depth at TL 0 is "-8pi..8pi". tone = (0x20, 0x20, total_level, 0x00, 0xF0, 0xF0, 0x00, 0x00) chip = struck(tone, f_number=0x40, block=0) chip.run(SAMPLE) # damp ends: both phases are reset, both levels go to 0 got = [sample[C[0]][0] for sample in words(chip, 16 * 1024)] > assert got == two_operator_reference(total_level, 0, 16 * 1024, 32) E assert [10, 10, 10, 10, 10, 10, ...] == [0, 10, 10, 10, 10, 10, ...] E E At index 0 diff: 10 != 0 E Use -v to get more diff tests/test_measured.py:203: AssertionError _______________________ test_modulator_into_carrier[32] ________________________ total_level = 32 @pytest.mark.parametrize("total_level", (0, 8, 32, 37, 48, 63)) def test_modulator_into_carrier(total_level): # mod-car.txt: registers $10 = $40, block 0, both operators at half speed, so # "each of the 1024 entries in the sine table is repeated 16 times"; TL from 0 # to 63; with the final model "the graph matches _exactly_ with the measured # data ... for all values". The depth at TL 0 is "-8pi..8pi". tone = (0x20, 0x20, total_level, 0x00, 0xF0, 0xF0, 0x00, 0x00) chip = struck(tone, f_number=0x40, block=0) chip.run(SAMPLE) # damp ends: both phases are reset, both levels go to 0 got = [sample[C[0]][0] for sample in words(chip, 16 * 1024)] > assert got == two_operator_reference(total_level, 0, 16 * 1024, 32) E assert [0, 0, 0, 0, 0, 0, ...] == [0, 0, 0, 0, 0, 0, ...] E E At index 14 diff: 2 != 0 E Use -v to get more diff tests/test_measured.py:203: AssertionError _______________________ test_modulator_into_carrier[37] ________________________ total_level = 37 @pytest.mark.parametrize("total_level", (0, 8, 32, 37, 48, 63)) def test_modulator_into_carrier(total_level): # mod-car.txt: registers $10 = $40, block 0, both operators at half speed, so # "each of the 1024 entries in the sine table is repeated 16 times"; TL from 0 # to 63; with the final model "the graph matches _exactly_ with the measured # data ... for all values". The depth at TL 0 is "-8pi..8pi". tone = (0x20, 0x20, total_level, 0x00, 0xF0, 0xF0, 0x00, 0x00) chip = struck(tone, f_number=0x40, block=0) chip.run(SAMPLE) # damp ends: both phases are reset, both levels go to 0 got = [sample[C[0]][0] for sample in words(chip, 16 * 1024)] > assert got == two_operator_reference(total_level, 0, 16 * 1024, 32) E assert [0, 0, 0, 0, 0, 0, ...] == [0, 0, 0, 0, 0, 0, ...] E E At index 14 diff: 2 != 0 E Use -v to get more diff tests/test_measured.py:203: AssertionError _______________________ test_modulator_into_carrier[48] ________________________ total_level = 48 @pytest.mark.parametrize("total_level", (0, 8, 32, 37, 48, 63)) def test_modulator_into_carrier(total_level): # mod-car.txt: registers $10 = $40, block 0, both operators at half speed, so # "each of the 1024 entries in the sine table is repeated 16 times"; TL from 0 # to 63; with the final model "the graph matches _exactly_ with the measured # data ... for all values". The depth at TL 0 is "-8pi..8pi". tone = (0x20, 0x20, total_level, 0x00, 0xF0, 0xF0, 0x00, 0x00) chip = struck(tone, f_number=0x40, block=0) chip.run(SAMPLE) # damp ends: both phases are reset, both levels go to 0 got = [sample[C[0]][0] for sample in words(chip, 16 * 1024)] > assert got == two_operator_reference(total_level, 0, 16 * 1024, 32) E assert [0, 0, 0, 0, 0, 0, ...] == [0, 0, 0, 0, 0, 0, ...] E E At index 14 diff: 2 != 0 E Use -v to get more diff tests/test_measured.py:203: AssertionError _______________________ test_modulator_into_carrier[63] ________________________ total_level = 63 @pytest.mark.parametrize("total_level", (0, 8, 32, 37, 48, 63)) def test_modulator_into_carrier(total_level): # mod-car.txt: registers $10 = $40, block 0, both operators at half speed, so # "each of the 1024 entries in the sine table is repeated 16 times"; TL from 0 # to 63; with the final model "the graph matches _exactly_ with the measured # data ... for all values". The depth at TL 0 is "-8pi..8pi". tone = (0x20, 0x20, total_level, 0x00, 0xF0, 0xF0, 0x00, 0x00) chip = struck(tone, f_number=0x40, block=0) chip.run(SAMPLE) # damp ends: both phases are reset, both levels go to 0 got = [sample[C[0]][0] for sample in words(chip, 16 * 1024)] > assert got == two_operator_reference(total_level, 0, 16 * 1024, 32) E assert [0, 0, 0, 0, 0, 0, ...] == [0, 0, 0, 0, 0, 0, ...] E E At index 14 diff: 2 != 0 E Use -v to get more diff tests/test_measured.py:203: AssertionError ________ test_the_modulator_is_one_sample_out_of_step_with_the_carrier _________ def test_the_modulator_is_one_sample_out_of_step_with_the_carrier(): # mod-car.txt: "Instead of seeing the same value for 16 consecutive samples we # only see 15 samples with the same value, followed by 1 other value again # followed by 15 constant samples." tone = (0x20, 0x20, 8, 0x00, 0xF0, 0xF0, 0x00, 0x00) chip = struck(tone, f_number=0x40, block=0) chip.run(SAMPLE) got = [sample[C[0]][0] for sample in words(chip, 16 * 1024)] lengths = [length for _, length in runs(got)] pairs = sum(1 for a, b in zip(lengths, lengths[1:], strict=False) if (a, b) == (15, 1)) assert pairs > 200 > assert max(lengths) <= 16 * 12 # the flat top of the sine ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ E assert 511 <= (16 * 12) E + where 511 = max([14, 1, 15, 1, 15, 1, ...]) tests/test_measured.py:217: AssertionError _______ test_every_half_period_all_modulation_depths_cross_zero_together _______ def test_every_half_period_all_modulation_depths_cross_zero_together(): # mod-car.txt: "every half period, the waveforms for all TL-values indeed # _exactly_ overlap". crossings = [] for total_level in (0, 20, 63): tone = (0x20, 0x20, total_level, 0x00, 0xF0, 0xF0, 0x00, 0x00) chip = struck(tone, f_number=0x40, block=0) chip.run(SAMPLE) got = [sample[C[0]][0] for sample in words(chip, 16 * 1024)] crossings.append(got[8192 - 8 : 8192 + 8]) > assert crossings[0] == crossings[1] == crossings[2] E assert [-19, -19, -1...-19, -19, ...] == [-3, -3, -3, -3, -3, -3, ...] E E At index 0 diff: -19 != -3 E Use -v to get more diff tests/test_measured.py:230: AssertionError _____________________________ test_feedback[37-1] ______________________________ total_level = 37, feedback = 1 @pytest.mark.parametrize("total_level, feedback", ((37, 1), (37, 4), (37, 7), (0, 5), (0, 7), (63, 7))) def test_feedback(total_level, feedback): # fb.txt: TL 63 with FB 7, TL 37 and TL 0 with FB 0 to 7; "This model can # _exactly_ predict the measured data" once the two remembered outputs have # settled, chaos at TL 0, FB 7 included. The form is the sum of the last two # outputs; the amount is S1's Table III-6 (see test_manual). tone = (0x20, 0x20, total_level, feedback, 0xF0, 0xF0, 0x00, 0x00) chip = struck(tone, f_number=0x40, block=0) chip.run(SAMPLE) assert chip.previous[0] == chip.before_previous[0] == 0 # nothing remembered yet got = [sample[C[0]][0] for sample in words(chip, 16 * 1024)] > assert got == two_operator_reference(total_level, feedback, 16 * 1024, 32) E assert [0, 0, 0, 0, 0, 0, ...] == [0, 0, 0, 0, 0, 0, ...] E E At index 14 diff: 2 != 0 E Use -v to get more diff tests/test_measured.py:244: AssertionError _____________________________ test_feedback[37-4] ______________________________ total_level = 37, feedback = 4 @pytest.mark.parametrize("total_level, feedback", ((37, 1), (37, 4), (37, 7), (0, 5), (0, 7), (63, 7))) def test_feedback(total_level, feedback): # fb.txt: TL 63 with FB 7, TL 37 and TL 0 with FB 0 to 7; "This model can # _exactly_ predict the measured data" once the two remembered outputs have # settled, chaos at TL 0, FB 7 included. The form is the sum of the last two # outputs; the amount is S1's Table III-6 (see test_manual). tone = (0x20, 0x20, total_level, feedback, 0xF0, 0xF0, 0x00, 0x00) chip = struck(tone, f_number=0x40, block=0) chip.run(SAMPLE) assert chip.previous[0] == chip.before_previous[0] == 0 # nothing remembered yet got = [sample[C[0]][0] for sample in words(chip, 16 * 1024)] > assert got == two_operator_reference(total_level, feedback, 16 * 1024, 32) E assert [0, 0, 0, 0, 0, 0, ...] == [0, 0, 0, 0, 0, 0, ...] E E At index 14 diff: 2 != 0 E Use -v to get more diff tests/test_measured.py:244: AssertionError _____________________________ test_feedback[37-7] ______________________________ total_level = 37, feedback = 7 @pytest.mark.parametrize("total_level, feedback", ((37, 1), (37, 4), (37, 7), (0, 5), (0, 7), (63, 7))) def test_feedback(total_level, feedback): # fb.txt: TL 63 with FB 7, TL 37 and TL 0 with FB 0 to 7; "This model can # _exactly_ predict the measured data" once the two remembered outputs have # settled, chaos at TL 0, FB 7 included. The form is the sum of the last two # outputs; the amount is S1's Table III-6 (see test_manual). tone = (0x20, 0x20, total_level, feedback, 0xF0, 0xF0, 0x00, 0x00) chip = struck(tone, f_number=0x40, block=0) chip.run(SAMPLE) assert chip.previous[0] == chip.before_previous[0] == 0 # nothing remembered yet got = [sample[C[0]][0] for sample in words(chip, 16 * 1024)] > assert got == two_operator_reference(total_level, feedback, 16 * 1024, 32) E assert [0, 0, 0, 0, 0, 0, ...] == [0, 0, 0, 0, 0, 0, ...] E E At index 14 diff: 2 != 0 E Use -v to get more diff tests/test_measured.py:244: AssertionError ______________________________ test_feedback[0-5] ______________________________ total_level = 0, feedback = 5 @pytest.mark.parametrize("total_level, feedback", ((37, 1), (37, 4), (37, 7), (0, 5), (0, 7), (63, 7))) def test_feedback(total_level, feedback): # fb.txt: TL 63 with FB 7, TL 37 and TL 0 with FB 0 to 7; "This model can # _exactly_ predict the measured data" once the two remembered outputs have # settled, chaos at TL 0, FB 7 included. The form is the sum of the last two # outputs; the amount is S1's Table III-6 (see test_manual). tone = (0x20, 0x20, total_level, feedback, 0xF0, 0xF0, 0x00, 0x00) chip = struck(tone, f_number=0x40, block=0) chip.run(SAMPLE) > assert chip.previous[0] == chip.before_previous[0] == 0 # nothing remembered yet ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ E assert 6 == 0 tests/test_measured.py:242: AssertionError ______________________________ test_feedback[0-7] ______________________________ total_level = 0, feedback = 7 @pytest.mark.parametrize("total_level, feedback", ((37, 1), (37, 4), (37, 7), (0, 5), (0, 7), (63, 7))) def test_feedback(total_level, feedback): # fb.txt: TL 63 with FB 7, TL 37 and TL 0 with FB 0 to 7; "This model can # _exactly_ predict the measured data" once the two remembered outputs have # settled, chaos at TL 0, FB 7 included. The form is the sum of the last two # outputs; the amount is S1's Table III-6 (see test_manual). tone = (0x20, 0x20, total_level, feedback, 0xF0, 0xF0, 0x00, 0x00) chip = struck(tone, f_number=0x40, block=0) chip.run(SAMPLE) > assert chip.previous[0] == chip.before_previous[0] == 0 # nothing remembered yet ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ E assert 6 == 0 tests/test_measured.py:242: AssertionError _____________________________ test_feedback[63-7] ______________________________ total_level = 63, feedback = 7 @pytest.mark.parametrize("total_level, feedback", ((37, 1), (37, 4), (37, 7), (0, 5), (0, 7), (63, 7))) def test_feedback(total_level, feedback): # fb.txt: TL 63 with FB 7, TL 37 and TL 0 with FB 0 to 7; "This model can # _exactly_ predict the measured data" once the two remembered outputs have # settled, chaos at TL 0, FB 7 included. The form is the sum of the last two # outputs; the amount is S1's Table III-6 (see test_manual). tone = (0x20, 0x20, total_level, feedback, 0xF0, 0xF0, 0x00, 0x00) chip = struck(tone, f_number=0x40, block=0) chip.run(SAMPLE) assert chip.previous[0] == chip.before_previous[0] == 0 # nothing remembered yet got = [sample[C[0]][0] for sample in words(chip, 16 * 1024)] > assert got == two_operator_reference(total_level, feedback, 16 * 1024, 32) E assert [0, 0, 0, 0, 0, 0, ...] == [0, 0, 0, 0, 0, 0, ...] E E At index 14 diff: 2 != 0 E Use -v to get more diff tests/test_measured.py:244: AssertionError _________ test_each_time_the_same_note_is_played_the_wave_is_the_same __________ def test_each_time_the_same_note_is_played_the_wave_is_the_same(): # mod-car.txt: "Each time the same note is played, the wave looks exactly the # same" (spec 7.10: the phases are reset when the damp phase ends). tone = (0x21, 0x21, 0x10, 0x00, 0xF0, 0xF0, 0x00, 0x0F) chip = tone_chip(tone, f_number=0x123, block=3, key=0) takes = [] for wait in (700, 1234): press(chip, 0, 0x123, 3) takes.append(melody(chip, 500)) note(chip, 0, 0x123, 3, key=0) chip.run(SAMPLE * wait) chip.take_outputs() > assert takes[0] == takes[1] and max(takes[0]) > 200 E assert ([7, 58, 108, ...189, 218, ...] == [-227, -233, ...55, -252, ...] E E At index 0 diff: 7 != -227 E Use -v to get more diff) tests/test_measured.py:264: AssertionError ___________________ test_flat_segment_lengths[0-1-3-170.67] ____________________ multi = 0, block = 1, f_number = 3, repeats = 170.67 @pytest.mark.parametrize("multi, block, f_number, repeats", REPEATS) def test_flat_segment_lengths(multi, block, f_number, repeats): # "Whenever fnum=0 the phase doesn't change"; "ML=0,block=0,fnum=1 is the only # additional combination"; "the phase keeps it's current value, it's not reset". tone = list(PLAIN_SINE) tone[1] = 0x20 | multi chip = tone_chip(tone, f_number=f_number, block=block) chip.phase[C[0]] = 5 << 9 phases = [value >> 9 for value in attribute(chip, "phase", C[0], 512 * 7)] if repeats is None: assert set(phases) == {5} return lengths = [length for _, length in runs(phases)[1:-1]] > assert round(sum(lengths) / len(lengths), 2) == repeats E assert 170.65 == 170.67 E + where 170.65 = round((3413 / 20), 2) E + where 3413 = sum([171, 170, 171, 171, 170, 171, ...]) E + and 20 = len([171, 170, 171, 171, 170, 171, ...]) tests/test_measured.py:294: AssertionError ____________________ test_flat_segment_lengths[0-2-3-85.33] ____________________ multi = 0, block = 2, f_number = 3, repeats = 85.33 @pytest.mark.parametrize("multi, block, f_number, repeats", REPEATS) def test_flat_segment_lengths(multi, block, f_number, repeats): # "Whenever fnum=0 the phase doesn't change"; "ML=0,block=0,fnum=1 is the only # additional combination"; "the phase keeps it's current value, it's not reset". tone = list(PLAIN_SINE) tone[1] = 0x20 | multi chip = tone_chip(tone, f_number=f_number, block=block) chip.phase[C[0]] = 5 << 9 phases = [value >> 9 for value in attribute(chip, "phase", C[0], 512 * 7)] if repeats is None: assert set(phases) == {5} return lengths = [length for _, length in runs(phases)[1:-1]] > assert round(sum(lengths) / len(lengths), 2) == repeats E assert 85.32 == 85.33 E + where 85.32 = round((3498 / 41), 2) E + where 3498 = sum([85, 85, 86, 85, 85, 86, ...]) E + and 41 = len([85, 85, 86, 85, 85, 86, ...]) tests/test_measured.py:294: AssertionError ___________________ test_flat_segment_lengths[1-0-3-170.67] ____________________ multi = 1, block = 0, f_number = 3, repeats = 170.67 @pytest.mark.parametrize("multi, block, f_number, repeats", REPEATS) def test_flat_segment_lengths(multi, block, f_number, repeats): # "Whenever fnum=0 the phase doesn't change"; "ML=0,block=0,fnum=1 is the only # additional combination"; "the phase keeps it's current value, it's not reset". tone = list(PLAIN_SINE) tone[1] = 0x20 | multi chip = tone_chip(tone, f_number=f_number, block=block) chip.phase[C[0]] = 5 << 9 phases = [value >> 9 for value in attribute(chip, "phase", C[0], 512 * 7)] if repeats is None: assert set(phases) == {5} return lengths = [length for _, length in runs(phases)[1:-1]] > assert round(sum(lengths) / len(lengths), 2) == repeats E assert 170.65 == 170.67 E + where 170.65 = round((3413 / 20), 2) E + where 3413 = sum([171, 170, 171, 171, 170, 171, ...]) E + and 20 = len([171, 170, 171, 171, 170, 171, ...]) tests/test_measured.py:294: AssertionError ____________________ test_flat_segment_lengths[1-1-3-85.33] ____________________ multi = 1, block = 1, f_number = 3, repeats = 85.33 @pytest.mark.parametrize("multi, block, f_number, repeats", REPEATS) def test_flat_segment_lengths(multi, block, f_number, repeats): # "Whenever fnum=0 the phase doesn't change"; "ML=0,block=0,fnum=1 is the only # additional combination"; "the phase keeps it's current value, it's not reset". tone = list(PLAIN_SINE) tone[1] = 0x20 | multi chip = tone_chip(tone, f_number=f_number, block=block) chip.phase[C[0]] = 5 << 9 phases = [value >> 9 for value in attribute(chip, "phase", C[0], 512 * 7)] if repeats is None: assert set(phases) == {5} return lengths = [length for _, length in runs(phases)[1:-1]] > assert round(sum(lengths) / len(lengths), 2) == repeats E assert 85.32 == 85.33 E + where 85.32 = round((3498 / 41), 2) E + where 3498 = sum([85, 85, 86, 85, 85, 86, ...]) E + and 41 = len([85, 85, 86, 85, 85, 86, ...]) tests/test_measured.py:294: AssertionError __________________________ test_decay_step_lengths[9] __________________________ rate = 9 @pytest.mark.parametrize("rate", sorted(STEP_LENGTHS)) def test_decay_step_lengths(rate): cycle = STEP_LENGTHS[rate] chip = decaying_chip(rate) chip.counter = 12345 span = int(sum(cycle) * 6) + 40 trace = levels(chip, C[0], min(span, 126 * 8192)) segments = runs(trace)[1:-1] got = [] for (level, length), (after, _) in zip(segments, segments[1:], strict=False): got += [0.5] * ((after - level) // 2 - (0 if length > 1 else 0)) if after - level == 2 else [] if after - level == 1: got.append(length) elif length > 1: got[-1:] = [length - 0.5 if False else length] if 0.5 in cycle: # Two levels in one sample: describe each sample by what it did. deltas = [b - a for a, b in zip(trace, trace[1:], strict=False) if b < 127] got = [0.5 if delta == 2 else 1 for delta in deltas if delta] assert 0 not in deltas else: got = [length for (_, length) in segments] doubled = cycle * 3 size = len(cycle) > assert any(got[offset : offset + 2 * size] == doubled[: 2 * size] for offset in range(size)), got[:20] E AssertionError: [4096, 4096, 2048, 2048, 4096, 4096, ...] E assert False E + where False = any(. at 0x000000002f2b5538>) tests/test_measured.py:396: AssertionError __________________ test_first_segment_after_attack_4_decay_2 ___________________ def test_first_segment_after_attack_4_decay_2(): # adsr-transitions.txt: "for the combination AR=4/DR=2 such numbers are # '0x200, 0x600 and 0xe00' ... eventually also found a segment with width # 0xa00": (2n + 1) x L. This is what fixes the first pattern's rotation. > assert first_segment_set(4, 2, 0) == {0x200, 0x600, 0xA00, 0xE00} ^^^^^^^^^^^^^^^^^^^^^^^^^^ tests/test_measured.py:442: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ attack = 4, decay = 2, block = 0 def first_segment_set(attack: int, decay: int, block: int) -> set[int]: tone = (0x00, 0x21, 0x3F, 0x00, 0x00, attack << 4 | decay, 0x00, 0xF0) found = set() for start in range(0, 0x4000, 0x155): chip = struck(tone, f_number=0x40, block=block) chip.counter = start trace = levels(chip, C[0], 0x3800) first = trace.index(0) > length = next(i for i in range(first, len(trace)) if trace[i] != 0) - first ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ E StopIteration tests/test_measured.py:433: StopIteration ____________ test_first_segment_after_attack_5_decay_2[2-lengths0] _____________ block = 2, lengths = (1, 3, 4, 5, 7, 9, ...) @pytest.mark.parametrize( "block, lengths", ( # "5-out-of-8 ... I measured lengths: 0x100 0x300 0x400 0x500 0x700 0x900 # 0xb00 0xc00 0xd00 0xf00" (2, (1, 3, 4, 5, 7, 9, 0xB, 0xC, 0xD, 0xF)), # "6-out-of-8 ... 0x100 0x200 0x300 0x500 0x600 0x700 0xa00 0xd00 0xe00. # The model predicts 0x900 0xb00 0xf00 should also be present" (4, (1, 2, 3, 5, 6, 7, 9, 0xA, 0xB, 0xD, 0xE, 0xF)), # "7-out-of-8 ... 0x100 ... 0x700 0xb00 0xc00. The values 0x{9,a,d,e,f}00 # should also be present (only 0x800 and 0x1000 are missing)" (6, (1, 2, 3, 4, 5, 6, 7, 9, 0xA, 0xB, 0xC, 0xD, 0xE, 0xF)), ), ) def test_first_segment_after_attack_5_decay_2(block, lengths): # adsr-transitions.txt, "Extend to higher frequencies". Every length S4 # measured must occur, and none that S4's account excludes. > assert first_segment_set(5, 2, block) == {0x100 * length for length in lengths} E assert {256, 1024, 1...04, 3072, ...} == {256, 768, 10...92, 2304, ...} E E Extra items in the right set: E 768 E 2816 E Use -v to get more diff tests/test_measured.py:462: AssertionError ____________ test_first_segment_after_attack_5_decay_2[6-lengths2] _____________ block = 6, lengths = (1, 2, 3, 4, 5, 6, ...) @pytest.mark.parametrize( "block, lengths", ( # "5-out-of-8 ... I measured lengths: 0x100 0x300 0x400 0x500 0x700 0x900 # 0xb00 0xc00 0xd00 0xf00" (2, (1, 3, 4, 5, 7, 9, 0xB, 0xC, 0xD, 0xF)), # "6-out-of-8 ... 0x100 0x200 0x300 0x500 0x600 0x700 0xa00 0xd00 0xe00. # The model predicts 0x900 0xb00 0xf00 should also be present" (4, (1, 2, 3, 5, 6, 7, 9, 0xA, 0xB, 0xD, 0xE, 0xF)), # "7-out-of-8 ... 0x100 ... 0x700 0xb00 0xc00. The values 0x{9,a,d,e,f}00 # should also be present (only 0x800 and 0x1000 are missing)" (6, (1, 2, 3, 4, 5, 6, 7, 9, 0xA, 0xB, 0xC, 0xD, 0xE, 0xF)), ), ) def test_first_segment_after_attack_5_decay_2(block, lengths): # adsr-transitions.txt, "Extend to higher frequencies". Every length S4 # measured must occur, and none that S4's account excludes. > assert first_segment_set(5, 2, block) == {0x100 * length for length in lengths} E assert {256, 512, 76...80, 1536, ...} == {256, 512, 76...80, 1536, ...} E E Extra items in the right set: E 1792 E 3840 E Use -v to get more diff tests/test_measured.py:462: AssertionError _______________ test_attack_sequence_from_124_after_a_damp_phase _______________ def test_attack_sequence_from_124_after_a_damp_phase(): # attack.txt 2.9: "Each time there is a damp phase (release didn't finish # ...) attack starts from 124." chip = attacking_chip(10, release=0) chip.run(SAMPLE * 400) # up to level 0 note(chip, 0, 0x40, 0, key=0) # release rate 0: the level stays press(chip, 0, 0x40, 0) trace = levels(chip, C[0], 3000) start = trace.index(124) climb = [level for level, _ in runs(trace[start:])] assert climb[: len(FROM_124)] == FROM_124 > assert max(trace[:start]) == 124 # damp went no further ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ E assert 123 == 124 E + where 123 = max([0, 0, 0, 1, 1, 1, ...]) tests/test_measured.py:500: AssertionError ________________ test_attack_15_is_instant_only_when_damp_ends _________________ def test_attack_15_is_instant_only_when_damp_ends(): # attack.txt 2.8: "attack=15 is only checked at the end of the damp phase"; # "whenever attack rate 0 or 15 is active the attack curve is paused". chip = attacking_chip(0) assert set(levels(chip, C[0], 500)) == {127} # rate 0: no attack write(chip, 0x05, 0xF0) assert set(levels(chip, C[0], 500)) == {127} # 15 now: still stalled write(chip, 0x05, 0xC0) assert levels(chip, C[0], 100)[-1] == 0 # any other rate continues # "the very first sample after attack indeed already has maximum amplitude": # a quarter of the sample rate, so the first sample is at 90 degrees. chip = struck((0x00, 0x21, 0x3F, 0x00, 0x00, 0xF0, 0x00, 0x00), f_number=256, block=7) > assert melody(chip, 1) == [255] E assert [98] == [255] E E At index 0 diff: 98 != 255 E Use -v to get more diff tests/test_measured.py:579: AssertionError ______________ test_key_off_goes_to_release_from_any_state[decay] ______________ when = 'decay' @pytest.mark.parametrize("when", ("damp", "attack", "decay")) def test_key_off_goes_to_release_from_any_state(when): # envelope.txt e: "changing KEY-ON->OFF always goes to the (2nd or only) # release phase", from damp, attack and decay as well. tone = (0x00, 0x21, 0x3F, 0x00, 0x00, 0x51, 0x00, 0x0D) chip = struck(tone, f_number=0x40, block=0) if when == "damp": chip.run(SAMPLE) chip.level[C[0]] = 40 chip.state[C[0]] = 0 chip.run(SAMPLE * 8) elif when == "attack": chip.run(SAMPLE * 3000) assert chip.state[C[0]] == 1 else: chip.run(SAMPLE * 40_000) > assert chip.state[C[0]] == 2 E assert 3 == 2 tests/test_measured.py:732: AssertionError _______________________ test_a_modulator_has_no_release ________________________ def test_a_modulator_has_no_release(): # envelope.txt, "Modulator-envelope has no release phase?": at key-off "The # carrier envelope starts to decay, but the modulation depth remains the # same!"; and for EG_TYPE=0 it "does not go to the (2nd) release phase". tone = (0x21, 0x21, 0x00, 0x00, 0xF4, 0xF4, 0x2F, 0x2F) chip = tone_chip(tone) chip.run(SAMPLE * 3000) > assert chip.level[M[0]] == chip.level[C[0]] == 16 E assert 4 == 16 tests/test_measured.py:745: AssertionError __________________ test_confirmed_effective_rates[4-1-4-1-25] __________________ rate_field = 4, ksr = 1, block = 4, msb = 1, rate = 25 @pytest.mark.parametrize("rate_field, ksr, block, msb, rate", CONFIRMED_RATES) def test_confirmed_effective_rates(rate_field, ksr, block, msb, rate): # "a narrow step takes 512 samples ... 13 - log2(512) = 4 ... an effective # rate of 4*4+2 = 18"; "wide, narrow, narrow" when the low bits are 2. tone = (0x00, 0x20 | ksr << 4 | 0x01, 0x3F, 0x00, 0x00, 0xF0 | rate_field, 0x00, 0xF0) chip = struck(tone, f_number=msb << 8 | 0x40, block=block) chip.run(SAMPLE) narrow = 1 << (13 - (rate >> 2)) trace = levels(chip, C[0], narrow * 20) lengths = [length for _, length in runs(trace)[2:-1]] pattern = {0: [2], 1: [2, 2, 2, 1, 1], 2: [2, 1, 1]}[rate & 3] size = len(pattern) expected = [narrow * each for each in pattern * 4] > assert any(lengths[offset : offset + size * 2] == expected[: size * 2] for offset in range(size)) E assert False E + where False = any(. at 0x0000000030363ad8>) tests/test_measured.py:779: AssertionError ________ test_the_bass_drum_is_the_user_tone_with_the_measured_settings ________ def test_the_bass_drum_is_the_user_tone_with_the_measured_settings(): # rhythm.md, "Base Drum": the user tone 01 01 18 0F DF F8 6A 6D, played # "'simultaneously'" at F-number $1FF, block 0, is "a pretty good match"; "the # values shown in the above table gave the best result". In the model the two # are the same words. chip = OPLL(YM2413) user_tone(chip, (0x01, 0x01, 0x18, 0x0F, 0xDF, 0xF8, 0x6A, 0x6D)) write(chip, 0x36, 0x03) write(chip, 0x35, 0x03) for channel in (5, 6): note(chip, channel, 0x1FF, 0, key=0) write(chip, 0x0E, 0x20) chip.write(0, 0x0E) chip.write(1, 0x30) chip.write(0, 0x25) chip.write(1, 0x11) trace = words(chip, 4000) drum = [sample[15][1] for sample in trace] tone = [sample[11][0] for sample in trace] > assert drum == tone and max(drum) > 100 E assert ([0, 0, 1, 1, 2, 2, ...] == [0, 0, 1, 1, 2, 2, ...] E E Use -v to get more diff and 86 > 100) E + where 86 = max([0, 0, 1, 1, 2, 2, ...]) tests/test_measured.py:1009: AssertionError ___________ test_the_top_cymbal_is_two_peaks_and_reaches_full_scale ____________ def test_the_top_cymbal_is_two_peaks_and_reaches_full_scale(): # rhythm.md, "Top cymbal": "the amplitude only seems to take on two distinct # values (maximum positive or maximum negative)"; "at the end of the attack # phase the signal does span the full -255..+255 range"; "both the frequency # settings for channel 7 ... and for channel 8 ... influence how the TCY # waveform looks". chip = rhythm_chip(0x02, f7=0x100, block7=3, f8=0x100, block8=4) write(chip, 0x38, 0x00) takes = {} for name, f7 in (("a", 0x100), ("b", 0x180)): chip = rhythm_chip(0x02, f7=f7, block7=3, f8=0x100, block8=4) takes[name] = [sample[17][1] for sample in words(chip, 3000)] cymbal = takes["a"] assert max(cymbal) == 255 and min(cymbal) == -256 held_level = [word for word in cymbal[100:160]] > assert len({abs(word + (word < 0)) for word in held_level}) <= 3 # one level at a time ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ E assert 6 <= 3 E + where 6 = len({205, 214, 224, 234, 244, 255}) tests/test_measured.py:1040: AssertionError ____________________ test_aliases_of_the_channel_registers _____________________ def test_aliases_of_the_channel_registers(): # ksl.txt: "a write to register R#19 has the same effect as a write to R#10", # $19-$1F, $29-$2F and $39-$3F to $10-$16, $20-$26 and $30-$36. for alias in (*range(0x19, 0x20), *range(0x29, 0x30), *range(0x39, 0x40)): chip = OPLL(YM2413) write(chip, alias, 0x15) assert chip.registers[alias - 9] == 0x15 assert sum(chip.registers) == 0x15 chip = tone_chip(PLAIN_SINE, key=0) write(chip, 0x29, 0x18) > assert max(melody(chip, 600)) == 255 E assert 0 == 255 E + where 0 = max([0, 0, 0, 0, 0, 0, ...]) E + where [0, 0, 0, 0, 0, 0, ...] = melody(, 600) tests/test_measured.py:1067: AssertionError =========================== short test summary info ============================ FAILED tests/test_measured.py::test_the_sine_has_1024_steps - assert {4} == {8} FAILED tests/test_measured.py::test_modulator_into_carrier[0] - assert [19, 1... FAILED tests/test_measured.py::test_modulator_into_carrier[8] - assert [10, 1... FAILED tests/test_measured.py::test_modulator_into_carrier[32] - assert [0, 0... FAILED tests/test_measured.py::test_modulator_into_carrier[37] - assert [0, 0... FAILED tests/test_measured.py::test_modulator_into_carrier[48] - assert [0, 0... FAILED tests/test_measured.py::test_modulator_into_carrier[63] - assert [0, 0... FAILED tests/test_measured.py::test_the_modulator_is_one_sample_out_of_step_with_the_carrier FAILED tests/test_measured.py::test_every_half_period_all_modulation_depths_cross_zero_together FAILED tests/test_measured.py::test_feedback[37-1] - assert [0, 0, 0, 0, 0, 0... FAILED tests/test_measured.py::test_feedback[37-4] - assert [0, 0, 0, 0, 0, 0... FAILED tests/test_measured.py::test_feedback[37-7] - assert [0, 0, 0, 0, 0, 0... FAILED tests/test_measured.py::test_feedback[0-5] - assert 6 == 0 FAILED tests/test_measured.py::test_feedback[0-7] - assert 6 == 0 FAILED tests/test_measured.py::test_feedback[63-7] - assert [0, 0, 0, 0, 0, 0... FAILED tests/test_measured.py::test_each_time_the_same_note_is_played_the_wave_is_the_same FAILED tests/test_measured.py::test_flat_segment_lengths[0-1-3-170.67] - asse... FAILED tests/test_measured.py::test_flat_segment_lengths[0-2-3-85.33] - asser... FAILED tests/test_measured.py::test_flat_segment_lengths[1-0-3-170.67] - asse... FAILED tests/test_measured.py::test_flat_segment_lengths[1-1-3-85.33] - asser... FAILED tests/test_measured.py::test_decay_step_lengths[9] - AssertionError: [... FAILED tests/test_measured.py::test_first_segment_after_attack_4_decay_2 - St... FAILED tests/test_measured.py::test_first_segment_after_attack_5_decay_2[2-lengths0] FAILED tests/test_measured.py::test_first_segment_after_attack_5_decay_2[6-lengths2] FAILED tests/test_measured.py::test_attack_sequence_from_124_after_a_damp_phase FAILED tests/test_measured.py::test_attack_15_is_instant_only_when_damp_ends FAILED tests/test_measured.py::test_key_off_goes_to_release_from_any_state[decay] FAILED tests/test_measured.py::test_a_modulator_has_no_release - assert 4 == 16 FAILED tests/test_measured.py::test_confirmed_effective_rates[4-1-4-1-25] - a... FAILED tests/test_measured.py::test_the_bass_drum_is_the_user_tone_with_the_measured_settings FAILED tests/test_measured.py::test_the_top_cymbal_is_two_peaks_and_reaches_full_scale FAILED tests/test_measured.py::test_aliases_of_the_channel_registers - assert... 32 failed, 159 passed in 5.65s