Overview
Pd-lua enables:- ✅ Rapid prototyping of custom objects
- ✅ No compilation required
- ✅ Access to Pure Data’s messaging system
- ✅ Signal processing capabilities
- ✅ Dynamic inlet/outlet creation
Quick Start
Simple Message Object
Create a file namedreverse.pd_lua:
reverse.pd_lua
The [lua] Object
Plugdata includes a special[lua] object for inline Lua code:
[lua] Object Syntax
-in <n>- Number of data inlets-out <n>- Number of data outlets-sigin <n>- Number of signal inlets-sigout <n>- Number of signal outlets
- Separate from options with
; - Use
;as newline separator - Escape commas in function arguments with
\,
Inline Code Examples
[lua] object source code: Resources/Patches/lua.pd_lua:1-155
Creating .pd_lua Files
Basic Structure
myobject.pd_lua
Inlet/Outlet Configuration
Message Handlers
Naming Convention
<inlet>: Inlet number (1-based)<selector>: Message type (bang, float, symbol, list, etc.)
Standard Selectors
Multiple Inlets
Sending Messages
Output Methods
Atoms Table
Atoms must be passed as a table, even for single values:
- ✅
{3.14} - ❌
3.14
Signal Processing
DSP Setup
Signal Buffer Access
Advanced Features
Creation Arguments
[myobject 880 square]
Clock (Timing)
Table Access
Sending to Named Receivers
Utility Functions
Complete Example: Random Sequencer
randomseq.pd_lua
Loading Lua Externals
Place.pd_lua files in:
- Same directory as your patch
~/Documents/plugdata/externals/- Any path in Pd’s search paths
[lua] object’s load message:
Debugging Tips
Limitations
- GUI objects require C/C++ implementation
- Performance-critical DSP better in C
- Limited access to internal Pd structures
- No direct access to audio hardware
Resources
- pd-lua API implementation: Source/Pd/Setup.cpp:1317-1321, 1399-1408
- [lua] object source: Resources/Patches/lua.pd_lua
- Example externals in
Libraries/pd-lua/directory
Next Steps
Adding Externals
Compile C externals into plugdata
Performance Optimization
Optimize your patches
