PyObjC Framework: PHASE
`pyobjc-framework-phase` provides Python wrappers for Apple's PHASE (Physical Audio Spatialization Engine) framework on macOS. It is part of the larger PyObjC project, allowing Python applications to interact with Objective-C APIs and leverage native macOS functionalities. The current version is 12.1, with releases typically aligning with macOS SDK updates and Python version support changes.
Warnings
- breaking PyObjC 12.0, which includes `pyobjc-framework-phase`, dropped support for Python 3.9. Projects targeting Python 3.9 must use `pyobjc` versions prior to 12.0.
- breaking PyObjC 11.0, which includes `pyobjc-framework-phase`, dropped support for Python 3.8. Projects targeting Python 3.8 must use `pyobjc` versions prior to 11.0.
- gotcha From PyObjC 11.1, the core bridge aligns with `clang`'s documentation for Automatic Reference Counting (ARC) in Objective-C initializer methods. Methods in the 'init' family now correctly model stealing a reference to `self` and returning a new one. This might subtly affect custom Objective-C classes exposed to Python or complex memory management if your code relied on older PyObjC reference counting behavior for initializers.
- gotcha Changes in PyObjC 10.3 and 10.3.1 affect how Python's `__init__` and `__new__` methods interact with bridged Objective-C classes. While 10.3.1 partially reverted 10.3's stricter behavior, if a class or its superclass defines a custom `__new__` in Python, its `__init__` can be called. However, `__init__` cannot be used if relying on the `__new__` provided by PyObjC directly for class instantiation.
Install
-
pip install pyobjc-framework-phase
Imports
- PHASEEngine
from PHASE import PHASEEngine
- objc
import objc
Quickstart
import objc
from Foundation import NSObject, NSLog
from PHASE import PHASEEngine, PHASE_ENGINE_SOUND_EVENT_TYPE_NONE
def quick_phase_check():
NSLog("Attempting to create a PHASEEngine instance...")
try:
# PHASEEngine requires an identifier for instantiation
engine = PHASEEngine.alloc().initWithIdentifier_("MyPythonPHASEEngine")
if engine:
NSLog("Successfully created PHASEEngine instance: %@", engine)
# A real PHASE application would continue with configuration and playback.
# This example only verifies the binding's accessibility.
else:
NSLog("Failed to create PHASEEngine instance.")
except Exception as e:
NSLog("Error creating PHASEEngine: %@", str(e))
if __name__ == "__main__":
quick_phase_check()