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 it’s 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 we’ve 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