# Path: pylsdj/bread_spec.py
# def padded_hex(pad_count):
# def hex_array(x):
# EMPTY_BLOCK = 0xff
# NUM_PHRASES = 255
# NUM_TABLES = 32
# NUM_SYNTHS = 16
# WAVES_PER_SYNTH = 16
# FRAMES_PER_WAVE = 32
# ENTRIES_PER_TABLE = 16
# NUM_INSTRUMENTS = 64
# NUM_SONG_CHAINS = 256
# NUM_CHAINS = 128
# PHRASES_PER_CHAIN = 16
# NUM_GROOVES = 32
# STEPS_PER_PHRASE = 16
# STEPS_PER_GROOVE = 16
# STEPS_PER_TABLE = 16
# WORD_LENGTH = 0x10
# NUM_WORDS = 42
# INSTRUMENT_TYPE_CODE = {
#     "pulse": 0,
#     "wave": 1,
#     "kit": 2,
#     "noise": 3
# }
# FX_COMMANDS = {
#     0: '-',
#     1: 'A',
#     2: 'C',
#     3: 'D',
#     4: 'E',
#     5: 'F',
#     6: 'G',
#     7: 'H',
#     8: 'K',
#     9: 'L',
#     10: 'M',
#     11: 'O',
#     12: 'P',
#     13: 'R',
#     14: 'S',
#     15: 'T',
#     16: 'V',
#     17: 'W',
#     18: 'Z',
#     # Arduinoboy-specific
#     19: 'N',
#     20: 'X',
#     21: 'Q',
#     22: 'Y'
# }
# NOTES = ['---']
# NOTES_DICT = {}
# NUM_ROM_KITS = 21
# SAMPLES_PER_KIT = 15
# KIT_SAMPLE_NAME_LENGTH = 3
# KIT_NAME_LENGTH = 6
# SAMPLE_START_ADDRESS = 0x4060
# MAX_SAMPLE_LENGTH = 0x3fa0
# 
# Path: pylsdj/utils.py
# def fixed_width_string(string, width, fill=' '):
#     return string[:width].ljust(fill)


import wave
import bread as b
from .vendor.six.moves import range
from .bread_spec import lsdj_rom_kits, KIT_SAMPLE_NAME_LENGTH, \
    SAMPLES_PER_KIT, KIT_NAME_LENGTH, SAMPLE_START_ADDRESS, MAX_SAMPLE_LENGTH
from .utils import fixed_width_string
    def sample_data(self, sample_data):
        # For simplicity, we'll just pack samples into their new locations and
        # overwrite the sample memory for the kit.

        new_sample_ends = []

        new_sample_data = []

        for i in range(SAMPLES_PER_KIT):
            if not self._sample_used(i) and i != self.index:
                # We've found the first unused sample; since samples are
                # presumed to be contiguous, this means we're done moving
                # samples
                break

            if i == self.index:
                new_sample_data.extend(sample_data)
            else:
                current_sample_data = self._get_sample_data(i)

                if current_sample_data is not None:
                    new_sample_data.extend(current_sample_data)

            new_sample_ends.append(int(len(new_sample_data) / 2))

        if len(new_sample_ends) < SAMPLES_PER_KIT:
            new_sample_ends.extend([0] * (SAMPLES_PER_KIT - len(new_sample_ends)))

        if len(new_sample_data) < MAX_SAMPLE_LENGTH * 2:
            new_sample_data.extend([0] * ((MAX_SAMPLE_LENGTH * 2) - len(new_sample_data)))

# Path: pylsdj/bread_spec.py
# def padded_hex(pad_count):
# def hex_array(x):
# EMPTY_BLOCK = 0xff
# NUM_PHRASES = 255
# NUM_TABLES = 32
# NUM_SYNTHS = 16
# WAVES_PER_SYNTH = 16
# FRAMES_PER_WAVE = 32
# ENTRIES_PER_TABLE = 16
# NUM_INSTRUMENTS = 64
# NUM_SONG_CHAINS = 256
# NUM_CHAINS = 128
# PHRASES_PER_CHAIN = 16
# NUM_GROOVES = 32
# STEPS_PER_PHRASE = 16
# STEPS_PER_GROOVE = 16
# STEPS_PER_TABLE = 16
# WORD_LENGTH = 0x10
# NUM_WORDS = 42
# INSTRUMENT_TYPE_CODE = {
#     "pulse": 0,
#     "wave": 1,
#     "kit": 2,
#     "noise": 3
# }
# FX_COMMANDS = {
#     0: '-',
#     1: 'A',
#     2: 'C',
#     3: 'D',
#     4: 'E',
#     5: 'F',
#     6: 'G',
#     7: 'H',
#     8: 'K',
#     9: 'L',
#     10: 'M',
#     11: 'O',
#     12: 'P',
#     13: 'R',
#     14: 'S',
#     15: 'T',
#     16: 'V',
#     17: 'W',
#     18: 'Z',
#     # Arduinoboy-specific
#     19: 'N',
#     20: 'X',
#     21: 'Q',
#     22: 'Y'
# }
# NOTES = ['---']
# NOTES_DICT = {}
# NUM_ROM_KITS = 21
# SAMPLES_PER_KIT = 15
# KIT_SAMPLE_NAME_LENGTH = 3
# KIT_NAME_LENGTH = 6
# SAMPLE_START_ADDRESS = 0x4060
# MAX_SAMPLE_LENGTH = 0x3fa0
# 
# Path: pylsdj/utils.py
# def fixed_width_string(string, width, fill=' '):
#     return string[:width].ljust(fill)


# Path: pylsdj/kits.py
import wave
import bread as b
from .vendor.six.moves import range
from .bread_spec import lsdj_rom_kits, KIT_SAMPLE_NAME_LENGTH, \
    SAMPLES_PER_KIT, KIT_NAME_LENGTH, SAMPLE_START_ADDRESS, MAX_SAMPLE_LENGTH
from .utils import fixed_width_string

    def sample_data(self, sample_data):
        # For simplicity, we'll just pack samples into their new locations and
        # overwrite the sample memory for the kit.

        new_sample_ends = []

        new_sample_data = []

        for i in range(SAMPLES_PER_KIT):
            if not self._sample_used(i) and i != self.index:
                # We've found the first unused sample; since samples are
                # presumed to be contiguous, this means we're done moving
                # samples
                break

            if i == self.index:
                new_sample_data.extend(sample_data)
            else:
                current_sample_data = self._get_sample_data(i)

                if current_sample_data is not None:
                    new_sample_data.extend(current_sample_data)

            new_sample_ends.append(int(len(new_sample_data) / 2))

        if len(new_sample_ends) < SAMPLES_PER_KIT:
            new_sample_ends.extend([0] * (SAMPLES_PER_KIT - len(new_sample_ends)))

        if len(new_sample_data) < MAX_SAMPLE_LENGTH * 2:
            new_sample_data.extend([0] * ((MAX_SAMPLE_LENGTH * 2) - len(new_sample_data)))

        elif len(new_sample_data) > MAX_SAMPLE_LENGTH * 2: