-
Notifications
You must be signed in to change notification settings - Fork 0
Home
PyWwise is an intuitive, fully-documented, Pythonic wrapper around the Wwise Authoring Application Programming Interface. It make uses of the waapi-client
package (provided by Audiokinetic) to interface with Wwise. The goal of this open source project is to empower technical designers, programmers, software engineers, and virtually anyone who is interested in Python scripting for Wwise.
For comparison, let's take a look at some example code written with waapi-client
vs pywwise
. The script is using WAAPI to generated a test tone.
A: waapi-client
from waapi import WaapiClient
from pathlib import Path
client = WaapiClient()
path = Path("C:/Users/leozin/Text_SineWave.wav")
# Many of these args have constraints (e.g. a range or a set of valid values).
args = {"path": str(path),
"bitDepth": "float32",
"sampleRate": 192000,
"channelConfig": "7.1.4",
"attackTime": 0.02,
"sustainTime": 1.0,
"sustainLevel": 0.0,
"releaseTime": 0.02,
"waveform": "sine",
"frequency": 220.0}
results = client.call("ak.wwise.debug.generateToneWAV", args)
Many of the arguments in the args
dictionary have constraints (e.g. a range or a set of valid values), which have to be manually checked (usually by visiting the WAAPI Reference) and handled. Also, notice that the code is not very Pythonic due to the names of the keys in the dictionaries.
B: pywwise
import pywwise
from pywwise.enums import EBitDepth, ESampleRate, ESpeakerBitMask, EWaveform
from pathlib import Path
ak = pywwise.new()
# All constraints are enforced and handled automatically by PyWwise.
path = Path("C:/Users/leozin/Text_SineWave.wav")
bit_depth = EBitDepth.FLOAT_32
sample_rate = ESampleRate.SR_192000
channel_config = ESpeakerBitMask.SEVEN_ONE_FOUR
attack_time = 0.02
sustain_time = 1.0
sustain_level = 0.0
release_time = 0.02
waveform = EWaveform.SINE
frequency = 220.0
results = ak.wwise.debug.generate_tone_wav(path, bit_depth, sample_rate, channel_config, attack_time, sustain_time, release_time, waveform, frequency)
Notice that the issue with constraints is fixed and the identifiers all look very Pythonic. Another advantage is that ak.wwise.debug.generate_tone_wav
actually points to a fully documented function - in comparison to the URI in the basic waapi-client
example.
Sidebar test