def frame_info(self) -> FrameInfo: xinfo = ffi.new("struct xmp_frame_info *") lib.xmp_get_frame_info(self._context, xinfo) info = FrameInfo() for name, value in inspect.getmembers(xinfo): setattr(info, name, value) info.buffer = memoryview(ffi.buffer(xinfo.buffer, xinfo.buffer_size)) info.channel_info = [self._make_channelinfo(cinfo) for cinfo in xinfo.channel_info] return info
def test_module(filename: str) -> Tuple[str, str]: """investigate a module file and return its name and type""" testinfo = ffi.new("struct xmp_test_info *") fbytes = _get_filename_bytes(filename) result = lib.xmp_test_module(fbytes, testinfo) if result != 0: raise XmpError("cannot successfully check module", result) name = ffi.string(testinfo.name).decode() mtype = ffi.string(testinfo.type).decode() return name, mtype
def inject_event(self, channel: int, event: XEvent) -> None: xevent = ffi.new("struct xmp_event*") xevent.note = event.note xevent.ins = event.ins xevent.vol = event.vol xevent.fxt = event.fxt xevent.fxp = event.fxp xevent.f2t = event.f2t xevent.f2p = event.f2p lib.xmp_inject_event(self._context, channel, xevent)
def module_info(self) -> ModuleInfo: xinfo = ffi.new("struct xmp_module_info *") lib.xmp_get_module_info(self._context, xinfo) info = ModuleInfo() info.name = ffi.string(xinfo.mod.name).decode() info.comment = "" if xinfo.comment == ffi.NULL else ffi.string(xinfo.comment).decode() info.type = ffi.string(xinfo.mod.type).decode() info.pat = xinfo.mod.pat info.trk = xinfo.mod.trk info.chn = xinfo.mod.chn info.ins = xinfo.mod.ins info.smp = xinfo.mod.smp info.spd = xinfo.mod.spd info.bpm = xinfo.mod.bpm info.rst = xinfo.mod.rst info.gvl = min(xinfo.mod.gvl, xinfo.vol_base) info.vol_base = xinfo.vol_base return info