# Path: pylsdj/utils.py
# def assert_index_sane(index, upper_bound_exclusive):
#     assert type(index) == int, "Indices should be integers; '%s' is not" % (
#         index)
#     assert 0 <= index < upper_bound_exclusive, (
#         "Index %d out of range [%d, %d)" % (index, 0, upper_bound_exclusive))


from .utils import assert_index_sane
import json
    def name(self):
        """the instrument's name (5 characters, zero-padded)"""
        instr_name = self.song.song_data.instrument_names[self.index]

        if type(instr_name) == bytes:
            instr_name = instr_name.decode('utf-8')

        return instr_name

    @name.setter
    def name(self, val):
        if type(val) != bytes:
            val = val.encode('utf-8')

        self.song.song_data.instrument_names[self.index] = val

    @property
    def type(self):
        """the instrument's type (``pulse``, ``wave``, ``kit`` or ``noise``)"""
        return self.data.instrument_type

    @type.setter
    def type(self, value):
        self.data.instrument_type = value

    @property
    def table(self):
        """a ```pylsdj.Table``` referencing the instrument's table, or None
        if the instrument doesn't have a table"""
        if hasattr(self.data, 'table_on') and self.data.table_on:

# Path: pylsdj/utils.py
# def assert_index_sane(index, upper_bound_exclusive):
#     assert type(index) == int, "Indices should be integers; '%s' is not" % (
#         index)
#     assert 0 <= index < upper_bound_exclusive, (
#         "Index %d out of range [%d, %d)" % (index, 0, upper_bound_exclusive))


# Path: pylsdj/instrument.py
from .utils import assert_index_sane
import json

    def name(self):
        """the instrument's name (5 characters, zero-padded)"""
        instr_name = self.song.song_data.instrument_names[self.index]

        if type(instr_name) == bytes:
            instr_name = instr_name.decode('utf-8')

        return instr_name

    @name.setter
    def name(self, val):
        if type(val) != bytes:
            val = val.encode('utf-8')

        self.song.song_data.instrument_names[self.index] = val

    @property
    def type(self):
        """the instrument's type (``pulse``, ``wave``, ``kit`` or ``noise``)"""
        return self.data.instrument_type

    @type.setter
    def type(self, value):
        self.data.instrument_type = value

    @property
    def table(self):
        """a ```pylsdj.Table``` referencing the instrument's table, or None
        if the instrument doesn't have a table"""
        if hasattr(self.data, 'table_on') and self.data.table_on:

            assert_index_sane(self.data.table, len(self.song.tables))