Exemplo n.º 1
0
 def _parse(self, data):
     self._fx_type_val = data[0]
     self._fx_type = helpers.pretty_fx_type(self._fx_type_val)
     self._fx_level = data[1]
     self._delay_left = helpers.parse_dword(data[2:4])
     self._delay_right = helpers.parse_dword(data[4:6])
     self._feedback_left = data[6]
     self._feedback_right = data[7]
     self._depth = data[8]
     self._rate = data[9]
     self._damping = helpers.parse_signed_byte(data[10])
     mystery_byte = data[11]
     """
Exemplo n.º 2
0
 def _parse_header(self, data):
     """
         Header is 52 bytes
         KIT followed by SPC terminator
         4 byte little endian integer declaring header length? 0x2c/44 in every file we've found.
         What follows isn't much.
     """
     kit_header = data[0:4]
     header_length = helpers.parse_dword(data[4:8])
     raw_header = data[8:8 + header_length]
     raw_settings = raw_header[8:24]
     self._kit_settings = StrikeKitSettings(raw_settings)
Exemplo n.º 3
0
    def _parse(self, data):
        """
        Sample table is at the end of file. This makes things a little easier
        starts with a "str" type indicator, followed by space.
        
        The following 4 bytes are a 32-bit integer with the bytes stored in reverse order
        Since we get them as whole bytes, we can reverse them and parse the resulting hex.
        This number is our string length.

        Read that size til end of string. Alesis was nice and split them all on NUL boundaries
        """

        str_header = data[0:4]
        size_bytes = data[4:8]
        # Hey one of our more complicated functions, we only get to use it once

        table_size = helpers.parse_dword(size_bytes)
        raw_samples = data[8:]
        split_samples = map(lambda x: x.decode("utf-8"),
                            raw_samples.split(b"\0"))
        self._sample_table = list([str(x) for x in split_samples if x != ""])
Exemplo n.º 4
0
 def test_parse_dword_3_bytes_pads(self):
     # a4 1 03 00 = 420
     value = b"\xa4\x01\x03"
     expected = 12708
     actual = target.parse_dword(value)
     self.assertEqual(expected, actual)
Exemplo n.º 5
0
 def test_parse_dword_2_bytes(self):
     # a4 01 = 420
     value = b"\xa4\x01"
     expected = 420
     actual = target.parse_dword(value, 2)
     self.assertEqual(expected, actual)
Exemplo n.º 6
0
 def test_parse_word_hexcases(self):
     # this is read in as C002E... ?
     raw = b"2e00000c"
     trans = binascii.a2b_hex(raw)
     actual = target.parse_dword(trans)
     self.assertEqual(786478, actual)
Exemplo n.º 7
0
 def test_parse_dword_reverses_bytepairs(self):
     # 4096  + 2 = 4098
     value = b"\x02\x00\x00\x01"
     expected = 4098
     actual = target.parse_dword(value)
     self.assertEqual(expected, actual)
Exemplo n.º 8
0
 def test_parse_dword_invalid_returns_zero(self):
     expected = 0
     # h isn't a valid hex character.
     actual = target.parse_dword("habcd")
     self.assertEqual(expected, actual)