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 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
def get_formats() -> List[str]: """return the supported module formats""" fmts = lib.xmp_get_format_list() result = [] for i in range(9999): fmt = fmts[i] if fmt == ffi.NULL: break result.append(ffi.string(fmt).decode()) return result
Author: Irmen de Jong ([email protected]) Software license: "MIT software license". See http://opensource.org/licenses/MIT """ import os import sys import inspect from typing import Tuple, List, Optional from collections import namedtuple from _libxmplite import lib, ffi from _libxmplite.lib import XMP_FORMAT_8BIT, XMP_FORMAT_UNSIGNED, XMP_FORMAT_MONO __version__ = "1.3" xmp_version = ffi.string(lib.xmp_version).decode() XEvent = namedtuple("Event", ["note", "ins", "vol", "fxt", "fxp", "f2t", "f2p"]) class XmpError(Exception): pass class ChannelInfo: period = 0 position = 0 pitchbend = 0 note = 0 instrument = 0