MPRAmpController is a Swift Vapor web application that controls the Monoprice "6 Zone Home Audio Multizone Controller and Amplifier Kit". In theory this should also work for the Dayton Audio DAX66 but has not been tested.
Control is done using the RS-232 port with either a Raspberry Pi or Mac and a serial to USB cable. I'm using this one.
This implementation uses ORSSerialPort which is currently unavailable on Linux. As such, this is a Mac only Vapor application.
I did put my previous implementation using the Mac and Linux Compatible SwiftSerial in this repository if you are interested in something that can be potentially run on a Raspberry Pi or similar inexpensive hardware. The implementation using SwiftSerial was working reasonably well on my Mac mini but does have some trouble when used with a Raspberry Pi for some reason. That's the main reason I chose to switch over to using ORSSerialPort.
This application is designed for deployment to an Intel Mac mini running macOS 10.15.7 (Catalina). The build system creates a standalone binary with embedded templates for maximum compatibility.
# Build for Intel x86_64 deployment
./build-x86.sh
# Deploy to Mac mini
scp binary/Run user@macmini:./
# Run on Mac mini
./RunAccess the web interface at http://localhost:8080
- Automated Template Embedding: Leaf templates are automatically embedded into the binary
- Intel x86_64 Target: Cross-compiles for Intel Mac mini deployment
- Standalone Binary: No external template files required
- macOS 10.15.7 Compatible: Works on older Mac hardware
The application uses automated template embedding for maximum deployment compatibility:
- Edit Templates: Modify
.leaffiles inSources/App/Resources/Views/ - Build: Run
./build-x86.sh(templates are automatically embedded) - Deploy: Transfer
binary/Runto target Mac mini
- Source Templates:
Sources/App/Resources/Views/*.leaf - Auto-Generated:
Sources/App/Models/EmbeddedTemplates.swift(created during build) - Embedded Binary: Templates bundled into
binary/Runfor standalone deployment
EmbeddedTemplates.swift manually - it's regenerated on each build!
zones.leaf- Main zone controller interface with modern CSS/JavaScripttest.leaf- Simple test page for debugging
- Architecture: Intel x86_64 (not ARM/Apple Silicon)
- OS: macOS 10.15.7 (Catalina) and newer
- Hardware: Intel Mac mini with USB serial connection
- Backend: Swift Vapor 4
- Database: SQLite (for zone names)
- Serial: ORSSerial framework (with protocol-based abstraction)
- Frontend: Leaf templates with embedded CSS/JavaScript
- Deployment: Standalone binary with embedded templates
The application uses a protocol-based architecture that supports both real hardware and mock implementations:
ZoneControllerProtocol: Defines the interface for zone controlSerialController: Real hardware implementation using ORSSerialMockZoneController: Simulated hardware for local development- Environment-based selection: Automatic switching via
USE_MOCK_CONTROLLERenvironment variable
- USB serial device with "usbserial" in the device name
- Multi-zone amplifier controller connected via USB
For faster development and testing without hardware:
# Run locally with simulated hardware
./run-local.shThis starts the application with a Mock Zone Controller that:
- Simulates realistic zone states and responses
- Allows full UI testing without serial hardware
- Includes configurable delays and error simulation
- Persists changes in memory during development
Access the local development server at http://localhost:8001
# Incremental build (fast)
./build-x86.sh
# Clean build (slower, but guaranteed fresh)
./build-x86.sh --clean# Edit templates
vim Sources/App/Resources/Views/zones.leaf
# Templates are automatically embedded during build
./build-x86.sh
# Deploy updated binary
scp binary/Run user@macmini:./Sources/App/Controllers/ZoneControllerProtocol.swift- Zone controller interface and base classSources/App/Controllers/SerialController.swift- Real hardware implementationSources/App/Controllers/MockZoneController.swift- Mock hardware for developmentSources/App/Resources/Views/- Leaf templates (edit these)Sources/App/Models/EmbeddedTemplates.swift- Auto-generated (don't edit)generate-embedded-templates.sh- Template embedding scriptbuild-x86.sh- Main build scriptrun-local.sh- Local development with mock controller
Sources/App/Resources/Views/*.leaf- Edit these template filesSources/App/Controllers/SerialController.swift- Main controllerbuild-x86.sh- Build script with automated template embedding
Sources/App/Models/EmbeddedTemplates.swift- Auto-generated, don't editbinary/Run- Standalone executable for deploymentbinary/Resources/- Resource files for development/fallback
This project includes an embedded template system for compatibility with older macOS versions that don't support Swift Package Manager resource bundling. The templates are automatically embedded as strings during the build process, creating a truly standalone binary.
For detailed information about the embedded template system, see EMBEDDED_TEMPLATES.md.