コード例 #1
0
ファイル: __init__.py プロジェクト: andrwj/brainworkshop
    def __init__(self):
        self._dsound = lib.IDirectSound()
        lib.DirectSoundCreate(None, ctypes.byref(self._dsound), None)

        # A trick used by mplayer.. use desktop as window handle since it
        # would be complex to use pyglet window handles (and what to do when
        # application is audio only?).
        hwnd = _user32.GetDesktopWindow()
        self._dsound.SetCooperativeLevel(hwnd, lib.DSSCL_NORMAL)

        # Create primary buffer with 3D and volume capabilities
        self._buffer = lib.IDirectSoundBuffer()
        dsbd = lib.DSBUFFERDESC()
        dsbd.dwSize = ctypes.sizeof(dsbd)
        dsbd.dwFlags = (lib.DSBCAPS_CTRL3D | lib.DSBCAPS_CTRLVOLUME
                        | lib.DSBCAPS_PRIMARYBUFFER)
        self._dsound.CreateSoundBuffer(dsbd, ctypes.byref(self._buffer), None)

        # Create listener
        self._listener = lib.IDirectSound3DListener()
        self._buffer.QueryInterface(lib.IID_IDirectSound3DListener,
                                    ctypes.byref(self._listener))

        # Create worker thread
        self.worker = DirectSoundWorker()
        self.worker.start()
コード例 #2
0
ファイル: interface.py プロジェクト: prepare/pyglet
    def __init__(self):
        self._native_dsound = lib.IDirectSound()
        _check(
            lib.DirectSoundCreate(None, ctypes.byref(self._native_dsound),
                                  None))

        # A trick used by mplayer.. use desktop as window handle since it
        # would be complex to use pyglet window handles (and what to do when
        # application is audio only?).
        hwnd = _user32.GetDesktopWindow()
        _check(self._native_dsound.SetCooperativeLevel(hwnd, lib.DSSCL_NORMAL))

        self._buffer_factory = DirectSoundBufferFactory(
            self, self._native_dsound)
        self._primary_buffer = self._buffer_factory.create_primary_buffer()
コード例 #3
0
def driver_init():
    global dsound
    dsound = lib.IDirectSound()
    lib.DirectSoundCreate(None, ctypes.byref(dsound), None)

    # A trick used by mplayer.. use desktop as window handle since it would
    # be complex to use pyglet window handles (and what to do when application
    # is audio only?).
    hwnd = _user32.GetDesktopWindow()
    dsound.SetCooperativeLevel(hwnd, lib.DSSCL_NORMAL)

    driver_listener._init()

    # Force a context switch, as some Windows audio drivers don't get time
    # to process short sounds if Python hogs all the CPU.  See issue #163.
    from pyglet import clock
    clock.Clock._force_sleep = True