示例#1
0
 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)
示例#2
0
 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))
示例#3
0
    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)
示例#4
0
 def filter(self, enable):
     obj = ffi.cast('sidbuilder*', self.obj)
     lib.sidbuilder_filter(obj, enable)
示例#5
0
 def create(self, sids):
     obj = ffi.cast('sidbuilder*', self.obj)
     return lib.sidbuilder_create(obj, sids)
示例#6
0
 def sid_emulation(self, value):
     builder_ptr = ffi.cast('sidbuilder*', value.obj)
     lib.SidConfig_set_sidEmulation(self.obj, builder_ptr)
     self._builder = value
示例#7
0
 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
示例#8
0
 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)