def __init__(self, name=None, cast=None, cdata=None): if name is not None: b_name = name.encode('utf-8') obj = lib.HardSIDBuilder_new(b_name) obj = ffi.gc(obj, lib.HardSIDBuilder_destroy) elif cast is not None: obj = ffi.cast('HardSIDBuilder*', cast.obj) else: obj = ffi.cast('HardSIDBuilder*', cdata) super().__init__(obj)
def getter(self): func = getattr(lib, 'sidbuilder_{}'.format(name)) obj = ffi.cast('sidbuilder*', self.obj) if result_wrapper is None: return func(obj) else: return result_wrapper(func(obj))
def __init__(self, filename=None, source_buffer=None): if source_buffer is not None: obj = lib.SidTune_new_from_buffer( ffi.from_buffer(source_buffer), len(source_buffer)) elif filename is None: raise ValueError( 'either filename or source_buffer must not be None') else: filename_exts = ffi.cast('char**', 0) sep_is_slash = os.sep == '/' obj = lib.SidTune_new_from_filename( filename, filename_exts, sep_is_slash) self.obj = ffi.gc(obj, lib.SidTune_destroy) if not self.status: raise SidTuneError(self.status_string)
def filter(self, enable): obj = ffi.cast('sidbuilder*', self.obj) lib.sidbuilder_filter(obj, enable)
def create(self, sids): obj = ffi.cast('sidbuilder*', self.obj) return lib.sidbuilder_create(obj, sids)
def sid_emulation(self, value): builder_ptr = ffi.cast('sidbuilder*', value.obj) lib.SidConfig_set_sidEmulation(self.obj, builder_ptr) self._builder = value
def handle_buffer(buff): if buff is None: buff = ffi.new('uint8_t[]', 0) else: buff = ffi.cast('uint8_t*', ffi.from_buffer(buff)) return buff
def play(self, buffer, length=None): buf = ffi.from_buffer(buffer) buf = ffi.cast('short*', buf) if length is None: length = len(buffer) // 2 # 2 byte = 1 short return lib.sidplayfp_play(self.obj, buf, length)