Skip to main content

A comprehensive Wwise Authoring API wrapper - fully documented, with auto-completion in mind.

Project description

PyWwise

PyWwise is an open-source Python wrapper around the Wwise Authoring Application Programming Interface (WAAPI). PyWwise is meant to make Wwise scripting (e.g. automation, data validation, etc.) much easier to achieve. There are multiple benefits in using PyWwise; the three main highlights are:

  • Pythonic Architecture
  • Object-Oriented
  • Fully Documented

Installation

PyWwise is available on the Python Package Index, and so it is recommended to install it via pip. Using CMD, Terminal, PowerShell, or any command-line interface of your choice, run the command pip install pywwise to install the latest version of PyWwise.

PyWwise is intended to be used with Wwise versions 2021 and above.

Usage

Getting started with PyWwise is easy: the first step is always to import pywwise and initialize a WAAPI connection to an instance of Wwise using the factory function new_waapi_connection. PyWwise is fully documented, so each function or topic will let you know what will be needed. Using an IDE like JetBrains PyCharm Community is recommended.

Since PyWwise is based on WAAPI and the waapi-client package, you may also use the official Wwise Authoring API Reference, which is maintained by Audiokinetic. Their documentation provides a complete list of functions and topics which are all supported and reflected by PyWwise.

Modules

The root module pywwise is where the factory function new_waapi_connection exists; this functions establishes a connection with an instance of Wwise. When working with a single connection, the PyWwise convention is to name the connection "ak". Here is a simple example:

import pywwise

ak = pywwise.new_waapi_connection()  # the default URL is "ws://127.0.0.1:8080/waapi"
path = pywwise.SystemPath("C:/Users/leozin/Documents/WwiseTests/TestTone.wav")  # SystemPath is an alias of pathlib.Path
ak.wwise.debug.generate_tone_wav(path)  # this will output a WAV file containing a tone!
ak.disconnect()

Alternatively, you may use a with statement for context management, so the connection to Wwise is automatically closed once the with block is done. Here is a variation on the previous example:

from pywwise import new_waapi_connection, SystemPath

with new_waapi_connection() as ak:  # the default URL is "ws://127.0.0.1:8080/waapi"
    path = SystemPath("C:/Users/leozin/Documents/WwiseTests/TestTone.wav")  # SystemPath is an alias of pathlib.Path
    ak.wwise.debug.generate_tone_wav(path)  # this will output a WAV file containing a tone!

Inside the root module pywwise, you will find any PyWwise core type, enum, etc. meant for end-users. It is also possible to import those directly from PyWwise's submodules, but that is not necessary.

Examples

The examples below are a brief introduction on using PyWwise. For more information, refer to the wiki on the GitHub repo.

Getting the active State from the sound engine

As you get familiar with PyWwise, you will notice that many functions use specialized PyWwise types for params/args instead of primitives such as str. This is to maximize readability, allow type-matched behaviours, and deploy some error checking (e.g. the constructor in GUID checks to see if the provided value is a valid GUID, in terms of format). Here is an example showcasing GUID:

from pywwise import new_waapi_connection, GUID

with new_waapi_connection() as ak:  # the default URL is "ws://127.0.0.1:8080/waapi"
    wwise_obj_guid = GUID("{3182E70A-1CD2-4ABD-8652-EEA2E600E4A7}")  # if the GUID is invalid, a ValueError is thrown
    active_state: tuple[str, str] = ak.soundengine.get_state(wwise_obj_guid)  # the type hint is for readability only
    print(active_state)

Other common primitive-like types are Name, ShortID, ProjectPath, PlayingID, and GameObjectID. Some of those have member functions to check validity or get common "default" values.

Generating a tone WAV

PyWwise has many enumerations that help WAAPI users obey certain constraints of Wwise (e.g. "quantized" parameters; in other words, parameters that only accept certain values). Here is an example showcasing EBitDepth and ESampleRate:

from pywwise import new_waapi_connection, EBitDepth, ESampleRate, SystemPath

with new_waapi_connection() as ak:  # the default URL is "ws://127.0.0.1:8080/waapi"
    
    output_path = SystemPath("C:/Users/leozin/Documents/WwiseTests/TestTone.wav")
    bit_depth = EBitDepth.INT_16  # Wwise only supports 16-bit integer and 32-bit float; EBitDepth enumerates those options.
    sample_rate = ESampleRate.SR_44100  # Wwise only supports certain sample rates; ESampleRate enumerates all options.
    
    ak.wwise.debug.generate_tone_wav(output_path, bit_depth, sample_rate)

Setting the position of a GameObject in the sound engine

PyWwise also has tons of dataclasses - classes that are primarily containers of data. Good examples are Vector3 (commonly used to represent a point in 3D space) and PlatformInfo (represents a platform entry in Wwise's Platform Manager). Here is example using Vector3:

from pywwise import new_waapi_connection, GameObjectID, Vector3

with new_waapi_connection() as ak:  # the default URL is "ws://127.0.0.1:8080/waapi"
    
    # Position the Transport (Wwise Authoring's default game object) at the world's origin (centre) point.
    ak.soundengine.set_position(GameObjectID.get_transport(), Vector3.get_zero(), Vector3.get_zero())

Setting properties on a Wwise object

PyWwise supports getters and setters for common Wwise object types. To get and set properties on a Wwise object, you will first need to fetch information about the object from Wwise first, before instantiating a WwiseObject (which contains the WwiseProperty members with a getter and setter each):

from pywwise import EObjectType, new_waapi_connection, WaqlQuery, WwiseObjectInfo, Sound

with new_waapi_connection() as ak:  # the default URL is "ws://127.0.0.1:8080/waapi"
    
    # Get object using a WAQL query
    sound_info = ak.wwise.core.object.get(f"$ from type Sound where Name = \"MySound\" take 1")[0]
    sound_obj = Sound(sound_info, ak)  # GUID is cached, but all other properties are "connected" to Wwise.
    
    # Get and set Volume property
    property_name = Sound.volume  # Accessing the property from the class instead of instance returns the property name
    print(f"Current {property_name}: {sound_obj.volume}")  # 0.0
    sound_obj.volume = -6.0  # Will call either ak.wwise.core.object.set_property or ak.wwise.core.object.set_reference
    print(f"New {property_name}: {sound_obj.volume}")  # -6.0

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pywwise-0.2.4.tar.gz (144.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pywwise-0.2.4-py3-none-any.whl (227.8 kB view details)

Uploaded Python 3

File details

Details for the file pywwise-0.2.4.tar.gz.

File metadata

  • Download URL: pywwise-0.2.4.tar.gz
  • Upload date:
  • Size: 144.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.23

File hashes

Hashes for pywwise-0.2.4.tar.gz
Algorithm Hash digest
SHA256 4167f92d319595cdae2ccb525f965e6c10c3c129eda46e372932d1c2b286a94c
MD5 8faa006e217727abfb04260d56f92207
BLAKE2b-256 8cd6a05a2c108a70035c8f81a984cb93599c375be8b721edf2082d1e0866b544

See more details on using hashes here.

File details

Details for the file pywwise-0.2.4-py3-none-any.whl.

File metadata

  • Download URL: pywwise-0.2.4-py3-none-any.whl
  • Upload date:
  • Size: 227.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.23

File hashes

Hashes for pywwise-0.2.4-py3-none-any.whl
Algorithm Hash digest
SHA256 2bffb31ced8f241cd63a960e264168499f1711fd0bb90fb9191b98b57978d144
MD5 cf4ce8c522f92ce5950350931e72b659
BLAKE2b-256 6552c3dd1213d48b9ba14df4142257f1957eb3d6e4f96bfd5c874c018b21a98f

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page