{"id":5070,"library":"standard-sunau","title":"Standard Library SunAU Redistribution","description":"The `standard-sunau` library is a redistribution of the `sunau` module, which was formerly part of the Python standard library. It provides an interface for reading and writing Sun AU audio files (`.au` format). The original `sunau` module was deprecated in Python 3.11 and completely removed in Python 3.13 as part of PEP 594. This package allows legacy projects or those needing Sun AU file support to continue using the module by installing it as a PyPI dependency. It is currently at version 3.13.0 and is part of the 'dead battery' project, focused on redistributing removed standard library modules with minimal maintenance.","status":"active","version":"3.13.0","language":"en","source_language":"en","source_url":"https://github.com/youknowone/python-deadlib","tags":["audio","sunau","standard library","dead batteries","deprecated","audio processing"],"install":[{"cmd":"pip install standard-sunau","lang":"bash","label":"Install `standard-sunau`"}],"dependencies":[],"imports":[{"note":"The `sunau` module was removed from the standard library in Python 3.13. On Python 3.13 and newer, it must be installed via pip.","wrong":"import sunau (without prior installation on Python >= 3.13)","symbol":"sunau","correct":"import sunau"}],"quickstart":{"code":"import sunau\nimport io\n\n# Create a dummy in-memory AU file for demonstration\noutput_buffer = io.BytesIO()\nwith sunau.open(output_buffer, 'wb') as w:\n    w.setnchannels(1)\n    w.setsampwidth(2) # 2 bytes = 16-bit\n    w.setframerate(8000)\n    # Write 100 frames of silence (two zero bytes per frame)\n    w.writeframes(b'\\x00\\x00' * 100)\n\n# Rewind the buffer to read from the beginning\noutput_buffer.seek(0)\n\n# Now read the dummy AU file\nwith sunau.open(output_buffer, 'rb') as r:\n    print(f\"Number of channels: {r.getnchannels()}\")\n    print(f\"Sample width (bytes): {r.getsampwidth()}\")\n    print(f\"Frame rate (Hz): {r.getframerate()}\")\n    print(f\"Number of frames: {r.getnframes()}\")\n    print(f\"Compression type: {r.getcomptype()}\")\n    print(f\"Compression name: {r.getcompname()}\")\n    \n    # Read some frames (e.g., 50 frames)\n    frames = r.readframes(50)\n    print(f\"Read {len(frames) // r.getsampwidth()} frames of audio data.\")","lang":"python","description":"This quickstart demonstrates how to create an in-memory Sun AU audio file and then read its properties using the `sunau` module. The `sunau.open()` function is used for both writing and reading, similar to standard file I/O operations."},"warnings":[{"fix":"Add `standard-sunau` to your project's dependencies (`pip install standard-sunau`).","message":"The `sunau` module was officially removed from the Python standard library in Python 3.13 (after being deprecated in 3.11) as per PEP 594. Applications relying on `sunau` in Python 3.13 or newer must explicitly install `standard-sunau` via pip.","severity":"breaking","affected_versions":"Python 3.11+, especially 3.13+"},{"fix":"Evaluate if an alternative, actively developed audio library better suits your project's long-term needs.","message":"This `standard-sunau` package is a redistribution of a module removed from the standard library, primarily intended for compatibility. It is not actively developed for new features or significant improvements. For advanced or modern audio processing needs, consider more actively maintained Python audio libraries.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Open the file once for reading and separately for writing, or manage file pointer manually if using a file-like object.","message":"The `sunau.open()` function does not support simultaneous read/write ('r+' or 'w+') modes. You must open the file explicitly in either read ('r' or 'rb') or write ('w' or 'wb') mode.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Avoid using `getmarkers()` or `getmark()` as they do not provide functionality for Sun AU files.","message":"The `sunau` module's `getmarkers()` method always returns `None`, and `getmark()` raises an error. These methods are present for compatibility with the `aifc` module but are not implemented for Sun AU files.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"last_verified":"2026-04-12T00:00:00.000Z","next_check":"2026-07-11T00:00:00.000Z"}