Exemple #1
0
def test_non_powers_of_eight_intX():
    intX_test = [
        ("unsigned_10b", b.intX(10, False)),
        ("unsigned_14b", b.intX(14, False)),
        ("signed_20b", b.intX(20, True)),
        ("signed_4b", b.intX(4, True)),
    ]

    in_bytes = bytearray([
        0b11010101, 0b11101010, 0b00110101, 0b11010101, 0b11101010, 0b00110101])

    result = b.parse(in_bytes, intX_test)

    assert_equal(result.unsigned_10b, 0b1101010111)
    assert_equal(result.unsigned_14b, 0b10101000110101)
    assert_equal(result.signed_20b, - 0b101010000101011101)
    assert_equal(result.signed_4b, 0b0101)

    assert_equal(b.write(result, intX_test), in_bytes)
Exemple #2
0
def test_non_powers_of_eight_intX():
    intX_test = [
        ("unsigned_10b", b.intX(10, False)),
        ("unsigned_14b", b.intX(14, False)),
        ("signed_20b", b.intX(20, True)),
        ("signed_4b", b.intX(4, True)),
    ]

    in_bytes = bytearray([
        0b11010101, 0b11101010, 0b00110101, 0b11010101, 0b11101010, 0b00110101
    ])

    result = b.parse(in_bytes, intX_test)

    assert_equal(result.unsigned_10b, 0b1101010111)
    assert_equal(result.unsigned_14b, 0b10101000110101)
    assert_equal(result.signed_20b, -0b101010000101011101)
    assert_equal(result.signed_4b, 0b0101)

    assert_equal(b.write(result, intX_test), in_bytes)
Exemple #3
0
def test_set_sub_byte_intX():
    test_struct = [("signed_nibble", b.intX(4, signed=True)), ("bit1", b.bit),
                   ("bit2", b.bit), ("seminibble", b.semi_nibble)]

    test_data = bytearray([0xdb])

    test_parsed = b.parse(test_data, test_struct)
    assert_equal(test_parsed.signed_nibble, -3)

    test_parsed.signed_nibble = -6
    test_parsed.bit1 = 0
    test_parsed.seminibble = 2

    assert_equal(bytearray([0xa2]), b.write(test_parsed))
Exemple #4
0
def test_set_sub_byte_intX():
    test_struct = [
        ("signed_nibble", b.intX(4, signed=True)),
        ("bit1", b.bit),
        ("bit2", b.bit),
        ("seminibble", b.semi_nibble)
    ]

    test_data = bytearray([0xdb])

    test_parsed = b.parse(test_data, test_struct)
    assert_equal(test_parsed.signed_nibble, -3)

    test_parsed.signed_nibble = -6
    test_parsed.bit1 = 0
    test_parsed.seminibble = 2

    assert_equal(bytearray([0xa2]), b.write(test_parsed))
Exemple #5
0
    "str_format": padded_hex(2)
}), ("wav", b.byte, {
    "str_format": padded_hex(2)
}), ("noi", b.byte, {
    "str_format": padded_hex(2)
})]

pulse_instrument = [
    ("envelope", b.byte, {
        "str_format": padded_hex(2)
    }),
    ("phase_transpose", b.byte),
    b.padding(1),
    # If false, sound length is UNLIM
    ("has_sound_length", b.boolean),
    ("sound_length", b.intX(6)),
    ("sweep", b.byte),
    b.padding(3),
    ("automate", b.boolean),
    ("automate_2", b.boolean),
    ("vibrato", [("type",
                  b.enum(2, {
                      0: "hf",
                      1: "sawtooth",
                      2: "sine",
                      3: "square"
                  })), ("direction", b.enum(1, {
                      0: "down",
                      1: "up"
                  }))]),
    b.padding(2),
Exemple #6
0
             ('pitch_mod_sensitivity', b.uint8), ('transpose', b.uint8),
             ('name', b.string(10, NAME_ENCODING))]

compressed_operator = [
    ('eg_rates', b.array(4, b.uint8)),
    ('eg_levels', b.array(4, b.uint8)),
    ('keyboard_level_scaling_break_point', b.uint8),  # C3 = 0x27
    ('keyboard_level_scaling_left_depth', b.uint8),
    ('keyboard_level_scaling_right_depth', b.uint8),
    b.padding(4),
    # Byte 11
    ('keyboard_level_scaling_right_curve', b.enum(2, enums['curves'])),
    ('keyboard_level_scaling_left_curve', b.enum(2, enums['curves'])),
    # Byte 12
    b.padding(1),
    ('osc_detune', b.intX(4), {
        'offset': -7
    }),
    ('keyboard_rate_scaling', b.intX(3)),
    # Byte 13
    b.padding(3),
    ('key_velocity_sensitivity', b.intX(3)),
    ('amp_mod_sensitivity', b.intX(2)),
    # Byte 14
    ('output_level', b.uint8),
    # Byte 15
    b.padding(2),
    ('osc_frequency_coarse', b.intX(5)),
    ('osc_mode', b.enum(1, enums['osc_mode'])),
    # Byte 16
    ('osc_frequency_fine', b.uint8)
Exemple #7
0
# Number of "words" in the speech instrument
NUM_WORDS = 42

chain = [
    ("pu1", b.byte, {"str_format": padded_hex(2)}),
    ("pu2", b.byte, {"str_format": padded_hex(2)}),
    ("wav", b.byte, {"str_format": padded_hex(2)}),
    ("noi", b.byte, {"str_format": padded_hex(2)})]

pulse_instrument = [
    ("envelope", b.byte, {"str_format": padded_hex(2)}),
    ("phase_transpose", b.byte),
    b.padding(1),
    # If false, sound length is UNLIM
    ("has_sound_length", b.boolean),
    ("sound_length", b.intX(6)),
    ("sweep", b.byte),
    b.padding(3),
    ("automate", b.boolean),
    ("automate_2", b.boolean),
    ("vibrato", [
        ("type", b.enum(2, {
            0: "hf",
            1: "sawtooth",
            2: "sine",
            3: "square"
        })),
        ("direction", b.enum(1, {
            0: "down",
            1: "up"
        }))
Exemple #8
0
# Number of "words" in the speech instrument
NUM_WORDS = 42

chain = [
    ("pu1", b.byte, {"str_format": padded_hex(2)}),
    ("pu2", b.byte, {"str_format": padded_hex(2)}),
    ("wav", b.byte, {"str_format": padded_hex(2)}),
    ("noi", b.byte, {"str_format": padded_hex(2)})]

pulse_instrument = [
    ("envelope", b.byte, {"str_format": padded_hex(2)}),
    ("phase_transpose", b.byte),
    b.padding(1),
    # If false, sound length is UNLIM
    ("has_sound_length", b.boolean),
    ("sound_length", b.intX(6)),
    ("sweep", b.byte),
    b.padding(3),
    ("automate", b.boolean),
    ("automate_2", b.boolean),
    ("vibrato", [
        ("type", b.enum(2, {
            0: "hf",
            1: "sawtooth",
            2: "sine",
            3: "square"
        })),
        ("direction", b.enum(1, {
            0: "down",
            1: "up"
        }))