示例#1
0
    def __init__(self, smd_obj: smdl.SMDL, sample_rate=44100, loops=True):
        self.smd_obj: smdl.SMDL = smd_obj

        self.sample_rate = sample_rate
        self.loops = loops

        self.loop_start = [-1] * len(self.smd_obj.tracks)
        self.last_note_length = [0] * len(self.smd_obj.tracks)
        self.last_delay = [0] * len(self.smd_obj.tracks)
        self.bpm = 120
        self.octave = [0] * len(self.smd_obj.tracks)
        self.tracks_br = []
        self.track_lengths = []
        self.track_completed = [False] * len(self.smd_obj.tracks)

        self.event_queue = PriorityQueue()
        self.current_tick = 0
        self.completed = False

        self.PROGRAM_MAP = {}

        for track in self.smd_obj.tracks:
            track_br = binary.BinaryReader(io.BytesIO(track.track_content.event_bytes))
            self.tracks_br.append(track_br)
            track_br.seek(0, io.SEEK_END)
            track_length = track_br.tell()
            track_br.seek(0)
            self.track_lengths.append(track_length)
示例#2
0
def load_smd(path: str, rom=None) -> tuple:
    if rom is None:
        rom = RomSingleton.RomSingleton().rom
    path = path.replace("?", conf.LANG)

    smd_obj = smdl.SMDL(filename=path, rom=rom)

    swd_path = path.split(".")[0] + ".SWD"
    swd_file = binary.BinaryReader(rom.open(swd_path, "rb"))
    swd_presets = swd.swd_read_presetbank(swd_file).presets
    swd_file.close()
    return smd_obj, swd_presets
示例#3
0
    def load(self, data: bytes):
        self.original = data

        reader = binary.BinaryReader(data)
        self.map_bottom_id = reader.read_uint16()
        self.map_top_id = reader.read_uint16()

        reader.c += 2

        self.characters = []
        for _indexChar in range(8):
            self.characters.append(reader.read_uint8())
        self.characters_pos = []
        for _indexChar in range(8):
            self.characters_pos.append(reader.read_uint8())
        self.characters_shown = []
        for _indexChar in range(8):
            if reader.read_uint8() == 0:
                self.characters_shown.append(False)
            else:
                self.characters_shown.append(True)
        self.characters_anim_index = []
        for _indexChar in range(8):
            self.characters_anim_index.append(reader.read_uint8())