↔️ pamiq-io
pamiq-io is a versatile I/O library for Python, providing easy access to audio, video, and input device capabilities for interactive applications, simulations, and AI projects, made for P-AMI<Q>.
✨ Features
- 🎤 Audio input/output via SoundCard
- 📹 Video input via OpenCV
- 🎛️ OSC (Open Sound Control) communication
- ⌨️ Keyboard simulation (Linux and Windows)
- 🖱️ Mouse simulation (Linux and Windows)
🔧 Requirements
- Python 3.12+
- Platform-specific dependencies:
- Linux: Inputtino (for keyboard/mouse simulation)
- OBS Studio (for video capture)
📦 Installation
Using pip
# Install the base package
pip install pamiq-io
# Install with optional dependencies as needed
pip install pamiq-io[opencv] # For video input (all platforms)
pip install pamiq-io[osc] # For OSC communication (all platforms)
pip install pamiq-io[soundcard] # For audio input/output (all platforms)
# Platform-specific input simulation:
# For Linux:
pip install pamiq-io[inputtino] # For keyboard and mouse output on Linux
# For Windows:
pip install pamiq-io[windows] # For keyboard and mouse output on Windows
# For running demo scripts
pip install pamiq-io[demo]
Linux-specific setup
For keyboard and mouse output on Linux, you must first install inputtino.
Development installation
# Clone and setup
git clone https://github.com/MLShukai/pamiq-io.git
cd pamiq-io
make venv # Sets up virtual environment with all dependencies
🧰 Command-Line Tools
pamiq-io includes several helpful command-line tools:
# List available video input devices
pamiq-io-show-opencv-available-input-devices
# List available audio input devices
pamiq-io-show-soundcard-available-input-devices
# List available audio output devices
pamiq-io-show-soundcard-available-output-devices
🛠️ Setup
OBS Virtual Camera
-
Install OBS Studio following the official installation instructions:
- Visit https://obsproject.com
- Follow the installation guide for your platform (Windows or Linux)
-
In OBS, start the virtual camera (Tools → Start Virtual Camera)
-
Linux-specific: If the virtual camera functionality is not available after installing OBS on Linux, you may need to install v4l2loopback:
sudo apt install v4l2loopback-dkms sudo modprobe v4l2loopback
To find the virtual camera device, you can install v4l-utils:
sudo apt install v4l-utils v4l2-ctl --list-devices | grep -A 1 'OBS Virtual Camera' | grep -oP '\t\K/dev.*'
🐳 Docker
A Docker configuration is provided for easy development and deployment on Linux.
Basic usage:
# Build a basic image with required dependencies
FROM ubuntu:latest
# Install dependencies
RUN apt-get update && apt-get install -y --no-install-recommends \
python3 python3-pip \
git cmake build-essential pkg-config libevdev-dev clang \
libopencv-dev \
libsndfile1 \
pulseaudio \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
# Install pamiq-io with desired optional dependencies
RUN pip install "git+https://github.com/games-on-whales/inputtino.git#subdirectory=bindings/python&branch=stable" && \
pip install pamiq-io[inputtino,opencv,osc,soundcard,demo]
# For development, you may want to check our devcontainer configuration:
# https://github.com/MLShukai/pamiq-io/blob/main/.devcontainer/Dockerfile
When running the container, you need privileged access for hardware devices:
docker run --privileged -it your-pamiq-image
[!IMPORTANT] ⚠️ Note: The
--privilegedflag is required for hardware access to input devices.
PulseAudio in Docker (Linux host only)
To use audio inside Docker, you need to set up PulseAudio properly:
docker run --privileged -it \
-v ${XDG_RUNTIME_DIR}/pulse/native:${XDG_RUNTIME_DIR}/pulse/native \
-v $HOME/.config/pulse/cookie:/root/.config/pulse/cookie \
-e PULSE_SERVER=unix:${XDG_RUNTIME_DIR}/pulse/native \
-e PULSE_COOKIE=/root/.config/pulse/cookie \
your-pamiq-image
📚 Usage
Video Input
# If OpenCV is installed:
from pamiq_io.video import OpenCVVideoInput
from pamiq_io.video.input.opencv import show_video_devices
# List available video devices
show_video_devices()
# Capture from camera using default parameters
video_input = OpenCVVideoInput(camera=0)
frame = video_input.read()
# Capture with specific resolution
video_input = OpenCVVideoInput(camera=0, width=640, height=480, fps=30.0)
frame = video_input.read()
# Capture with mixed parameters (use default width, but specify height)
video_input = OpenCVVideoInput(camera=0, width=None, height=720, fps=None)
frame = video_input.read()
Audio Input/Output
# If SoundCard is installed:
from pamiq_io.audio import SoundcardAudioInput, SoundcardAudioOutput
from pamiq_io.audio.input.soundcard import show_all_input_devices
from pamiq_io.audio.output.soundcard import show_all_output_devices
# List available devices
show_all_input_devices()
show_all_output_devices()
# Capture audio
audio_input = SoundcardAudioInput(sample_rate=44100, channels=2)
audio_data = audio_input.read(frame_size=1024)
# Play audio
import numpy as np
sample_rate = 44100
duration = 1.0 # seconds
t = np.linspace(0, duration, int(sample_rate * duration), endpoint=False)
sine_wave = np.sin(2 * np.pi * 440 * t).reshape(-1, 1).astype(np.float32) # 440Hz
audio_output = SoundcardAudioOutput(sample_rate=sample_rate, channels=1)
audio_output.write(sine_wave)
OSC Communication
# If python-osc is installed:
from pamiq_io.osc import OscOutput, OscInput
# Send OSC messages
osc_output = OscOutput(host="127.0.0.1", port=9001)
osc_output.send("/test/address", 42)
# Receive OSC messages
def handler(addr, value):
print(f"Received {value} from {addr}")
osc_input = OscInput(host="127.0.0.1", port=9001)
osc_input.add_handler("/test/address", handler)
osc_input.start(blocking=False)
Keyboard Simulation
Linux (Inputtino)
# Linux only - if inputtino is installed:
from pamiq_io.keyboard import Key, InputtinoKeyboardOutput
# Using the InputtinoKeyboardOutput implementation
keyboard = InputtinoKeyboardOutput()
keyboard.press(Key.CTRL, Key.C) # Press Ctrl+C
keyboard.release(Key.CTRL, Key.C) # Release Ctrl+C
Windows
from pamiq_io.keyboard import Key, WindowsKeyboardOutput
# Using the WindowsKeyboardOutput implementation
keyboard = WindowsKeyboardOutput()
keyboard.press(Key.CTRL, Key.C) # Press Ctrl+C
keyboard.release(Key.CTRL, Key.C) # Release Ctrl+C
Mouse Simulation
Linux (Inputtino)
# Linux only - if inputtino is installed:
from pamiq_io.mouse import MouseButton, InputtinoMouseOutput
# Using the InputtinoMouseOutput implementation
mouse = InputtinoMouseOutput(fps=100)
mouse.move(100, 50) # Move 100 pixels/sec right, 50 pixels/sec down
mouse.press(MouseButton.LEFT)
mouse.release(MouseButton.LEFT)
Windows
from pamiq_io.mouse import MouseButton, WindowsMouseOutput
# Using the WindowsMouseOutput implementation
mouse = WindowsMouseOutput()
mouse.move(100, 50) # Move 100 pixels/sec right, 50 pixels/sec down
mouse.press(MouseButton.LEFT)
mouse.release(MouseButton.LEFT)
🧪 Demo Scripts
The repo includes several demo scripts to help you get started:
# Audio demos (requires pamiq-io[soundcard,demo])
python demos/soundcard_audio_input.py --list-devices
python demos/soundcard_audio_output.py --frequency 440 --duration 3
# Video demos (requires pamiq-io[opencv,demo])
python demos/opencv_video_input.py --camera 0 --output frame.png
# OSC demos (requires pamiq-io[osc])
python demos/osc_io.py
# Input simulation demos
# Linux, requires pamiq-io[inputtino]
python demos/inputtino_keyboard_output.py
python demos/inputtino_mouse_output.py --radius 100 --duration 5
# Windows, requires pamiq-io[windows]
python demos/windows_keyboard_output.py
python demos/windows_mouse_output.py --radius 100 --duration 5
📝 License
This project is licensed under the MIT License - see the LICENSE file for details.
🤝 Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature) - Run tests (
make test) - Commit your changes (
git commit -m 'Add some amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
Metadata
Release files for pamiq-io 0.6.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| pamiq_io-0.6.1.tar.gz | 65.8 kB | With provenance | Details for pamiq_io-0.6.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| pamiq_io-0.6.1-py3-none-any.whl | Python 3 | none | any | Details for pamiq_io-0.6.1-py3-none-any.whl |
Total release size: 93.7 kB
Release files / pamiq_io-0.6.1.tar.gz
| Download URL | pamiq_io-0.6.1.tar.gz |
|---|---|
| Size | 65.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
e2db1ec2cf3332d33880a5f461bca0be1ae20695211b940cf03dc61caddbb879
|
|
BLAKE2b-256 checksum How to use checksums |
2a3207d8508304e59e34b9b4f7b5104fa59d92a5f0d635b1dd702eb73a05e050
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.12.9
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on May 29, 2025.
Transparency logRelease files / pamiq_io-0.6.1-py3-none-any.whl
| Download URL | pamiq_io-0.6.1-py3-none-any.whl |
|---|---|
| Size | 27.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
98078dfe2306cab7cd36b2a09d05312f01ba78078a5115836a246fbbd835d5d9
|
|
BLAKE2b-256 checksum How to use checksums |
00e4fd127d9f0ea4917bb588afe6bfc0f5d77b2bffd15c24568adf0443541f3f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.12.9
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on May 29, 2025.
Transparency logSecurity for pamiq-io 0.6.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
All 2 files in this release have been uploaded with provenance metadata.
Attestation for pamiq_io-0.6.1.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on May 29, 2025.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.