This directory contains example scripts demonstrating how to use the LabSound Python bindings.
You can run the examples directly using Python:
# Run the simple oscillator example
python examples/simple_oscillator.py
# Run the NumPy processing example
python examples/numpy_processing.py
This example demonstrates the basic usage of LabSoundPy. It creates a sine wave oscillator, connects it to a gain node, and plays it for 2 seconds.
Key concepts demonstrated:
- Creating an AudioContext
- Creating and configuring nodes (OscillatorNode, GainNode)
- Connecting nodes
- Starting and stopping audio playback
- Using the context manager for resource management
This example demonstrates how to use NumPy for audio processing with LabSoundPy. It creates a function node that applies a sine wave modulation to the input signal.
Key concepts demonstrated:
- Creating a FunctionNode for custom audio processing
- Converting audio buffers to NumPy arrays
- Applying NumPy-based signal processing
- Updating audio buffers in-place
- Maintaining state between processing callbacks
When creating your own examples, follow these guidelines:
- Start with an AudioContext using the context manager (
with
statement) - Create and configure the necessary nodes
- Connect the nodes to form a processing chain
- Start audio playback
- Wait for the desired duration
- Stop audio playback
- Clean up resources (handled automatically by the context manager)
The examples require:
- Python 3.7+
- LabSoundPy installed (either in development mode or from a package)
- NumPy (for the NumPy processing example)