- Version: 20261019
- Source Code Copyright: Unknown
- Redistribution Restriction: This source code is integrated by LEADERG INC. Please use it privately. Please DO NOT distribute it to internet.
Console/terminal demo of overlapping sound-effect playback with pygame for Windows 11, Ubuntu Linux 24.04 and macOS 14+ (Apple Silicon): quiet rain and louder birds play together while a frog croak repeats on top. A speaker or headphones are needed. CPU only: pygame (SDL_mixer) mixes the sounds on the CPU and has no GPU backend (no CUDA, no Apple GPU); playing three wav files needs none.
[Folder Structure]
- CLAUDE.md / AGENTS.md: Program specification (identical content).
- CHANGELOG.md: Change log.
- copyright.txt: Copyright notice.
- Sound-Play-Sound-Python.html: This document (usage page).
- data/: rain.wav, Birds.wav, ribbit.wav.
- tool/tools.py: Shared helpers.
- src/: The demo (play_sound.py), launcher scripts and requirements.txt (pygame).
- venv/: Python virtual environment, created by 02_venv_create_windows/linux/mac.
[Prerequisites]
- Python 3.13 (not 3.14: pygame 2.6.1, the current release, has no cp314 wheels), installed by 01_python_install_windows.bat / 01_python_install_linux.sh / 01_python_install_mac.sh (Windows: winget; Ubuntu: apt, or the deadsnakes PPA when the Ubuntu archive has no python3.13; macOS: Homebrew).
- 02_venv_create_windows.bat / 02_venv_create_linux.sh / 02_venv_create_mac.sh create venv/ with Python 3.13 and install pygame from src/requirements.txt (same package on every OS; the wheels bundle SDL and SDL_mixer).
- An audio output device (speaker or headphones).
- GPU: none. CPU only on every OS, because pygame has no GPU backend for audio; no NVIDIA driver or CUDA is needed.
[Launcher Scripts]
1. 01_python_install_windows.bat / 01_python_install_linux.sh / 01_python_install_mac.sh
Install Python 3.13 (winget / apt or deadsnakes PPA, needs sudo / Homebrew). Skips the install when Python 3.13 is already present. On Windows, open a new terminal afterwards.
2. 02_venv_create_windows.bat / 02_venv_create_linux.sh / 02_venv_create_mac.sh
Delete the old venv/, create a fresh one with Python 3.13, install src/requirements.txt (pygame). Aborts loudly if pip fails.
3. 03_venv_activate.bat / 03_venv_activate.sh
Activate the venv. On Linux/macOS, source it: source src/03_venv_activate.sh (bash or zsh). If the project folder was renamed after the venv was created, re-create the venv with 02_venv_create_windows/linux/mac first; the other launchers do not need activation.
4. 04_play_sound.bat / 04_play_sound.sh
Play the overlapping sound effects (extra arguments are forwarded).
5. 99_venv_clean.bat / 99_venv_clean.sh
Delete the venv/ folder.
6. 99_venv_deactivate.bat / 99_venv_deactivate.sh
Deactivate the venv in the current shell. On Linux/macOS, source it: source src/99_venv_deactivate.sh (bash or zsh).
[Python Entry Point]
src/play_sound.py
[--rain-volume 0.1] [--birds-volume 0.5] [--croak-volume 0.1] [--croaks 3]. Rain and birds start together, then the frog croaks every 2 seconds, --croaks times. A machine without an audio device exits with a clear error. Runs on the CPU (pygame has no GPU backend); there is no --device option.
[Quick Start]
Windows 11
src\01_python_install_windows.bat
REM open a new terminal
src\02_venv_create_windows.bat
src\04_play_sound.bat
Ubuntu 24.04
bash src/01_python_install_linux.sh
bash src/02_venv_create_linux.sh
bash src/04_play_sound.sh
macOS 14+ (Apple Silicon)
bash src/01_python_install_mac.sh
bash src/02_venv_create_mac.sh
bash src/04_play_sound.sh
This SDK is built in AppForAI - AI Dev Tools.