palace/tutorial/context.html

9.2 KiB
Raw Blame History

<html class="writer-html5" lang="en" > <head> </head>
palace

Context Creation

A context is an object that allows palace to access OpenAL, which is essential when you work with palace. Context maintains the audio environment and contains environment settings and components such as sources, buffers, and effects.

Creating a Device Object

To create a context, we must first create a device, since its a parameter of the context object.

To create an object, well, you just have to instantiate the Device class.

from palace import Device

with Device() as dev:
    # Your code goes here

This is how you declare a Device object with the default device. There can be several devices available, which can be found in device_names.

Creating a Context

Now that weve created a device, we can create the context:

from palace import Device, Context

with Device() as dev, Context(dev) as ctx:
    # Your code goes here

© Copyright 2019, 2020 Nguyễn Gia Phong et al

Built with Sphinx using a theme provided by Read the Docs.
</html>