Overview
LoFi Engine is a cross-platform desktop application that generates procedural LoFi music in real-time. The application combines modern web technologies with native desktop capabilities to deliver a rich, customizable audio experience.Tech Stack
The project is built with the following technologies:Frontend
- Svelte 3.54 - Reactive UI framework
- TypeScript 4.9 - Type-safe JavaScript
- Vite 4.2 - Fast build tool and dev server
Desktop
- Tauri 2.6 - Lightweight native shell
- Rust - Native backend runtime
Audio
- Tone.js 14.7 - Web Audio framework
- Web Audio API - Low-level audio processing
Package Manager
- pnpm - Fast, efficient package management
Project Structure
The codebase is organized into clear, functional modules:Key Directories
src/lib/engine/
src/lib/engine/
Contains the procedural music generation system:
- Chords/ - Musical theory and chord progression logic
- Drums/ - Drum pattern synthesis (Kick, Hat, Snare, Noise)
- Piano/ - Piano sample management and playback
src/lib/components/
src/lib/components/
Svelte UI components organized by feature:
- Controls/ - Effect controls (Rain, Thunder, CampFire, Jungle)
- Settings/ - Volume, background, Auto DJ configuration
- TopBar/ - Platform-specific window controls
- TrackList/ - Ambient track selection UI
src-tauri/
src-tauri/
Native desktop functionality:
- Window management
- File system access
- System tray integration
- Native menus
Architecture Layers
Audio Engine Layer
The audio engine (src/lib/engine/) is the core of LoFi Engine. It generates music procedurally using Tone.js:
Chord Progression Generation
Generate harmonic structure using music theory rulesSee:
src/lib/engine/Chords/ChordProgression.ts:5Instrument Synthesis
Create drum patterns and piano voicingsSee:
src/lib/engine/Drums/, src/lib/engine/Piano/UI Layer
The UI layer is built with Svelte components that provide:- Real-time audio controls
- Visual feedback (waveform visualization)
- Ambient sound mixing
- Customizable backgrounds
- Keyboard shortcut support
Native Layer
Tauri provides the native desktop functionality:- Cross-platform window management (Linux, macOS, Windows)
- Native system integration
- Offline operation
- Small bundle size (~10MB)
Build Configuration
The Vite configuration (vite.config.ts) is optimized for Tauri:
vite.config.ts
The fixed port (1420) is required by Tauri for communication between the web frontend and native backend.
Key Features
Procedural Generation
Music is generated on-the-fly using music theory principles:- Major scale harmonization
- Weighted chord progressions
- Dynamic voicing generation
- Randomized patterns for variety
Effects Pipeline
Audio effects are implemented using Tone.js nodes:Ambient Soundscapes
The Auto DJ system automatically manages soundscapes:- Music: Beat and chords only
- Atmosphere: Music + weather/nature effects
- World: Full immersion with environmental sounds
- Manual: Full user control
Performance Considerations
Small Bundle Size
Tauri apps are ~10MB compared to 100MB+ Electron apps
Low CPU Usage
Efficient audio scheduling with Web Audio API
Fast Startup
Native binary with minimal initialization
Offline First
All audio generation happens client-side
Cross-Platform Support
LoFi Engine runs on:- Linux (AppImage, deb, rpm)
- macOS (dmg, app bundle)
- Windows (msi, exe)
- Web (browser deployment at lofi-engine.vercel.app)
Mobile support (iOS, Android) is planned for future releases.
Next Steps
Music Generation
Learn how the procedural music system works
Development Setup
Set up your local development environment