https://github.com/matdombrock/moonforge
An experimental synthesizer that uses Lua scripts to generate sound.
https://github.com/matdombrock/moonforge
audio c live-coding lua music portaudio synthesizer
Last synced: about 2 months ago
JSON representation
An experimental synthesizer that uses Lua scripts to generate sound.
- Host: GitHub
- URL: https://github.com/matdombrock/moonforge
- Owner: matdombrock
- License: gpl-3.0
- Created: 2025-03-13T09:39:53.000Z (over 1 year ago)
- Default Branch: master
- Last Pushed: 2025-04-01T09:03:26.000Z (about 1 year ago)
- Last Synced: 2025-04-01T10:22:27.395Z (about 1 year ago)
- Topics: audio, c, live-coding, lua, music, portaudio, synthesizer
- Language: C
- Homepage:
- Size: 1.46 MB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# ☾ M O O N F O R G E ☽

MoonForge is a minimalist modular synthesis lab written in C. It's scripted via it's built-in Lua interpreter using the [MF Lua API](doc/API.md).
While MoonForge can be used as a semi-traditional synthesizer and tracker, it's built for experimental, evolving, generative audio soundscapes and procedural compositions.
**Features & Goals**
✅ Fully controlled by Lua
✅ Simple API
✅ Wavetable sythesis engine
✅ Dynamic FX chain / routing
✅ Proceduaral / generative audio
✅ Music tracker
✅ Data sonification
⛔ 2D wavetables
⛔ MIDI support (live playing)
✅ Designed for embedded linux
✅ Automatic built-in recording
✅ Fun toy for audio nerds
**Available FX**
✅ All effects are written in C and controlled by Lua.
✅ Lowpass
✅ Delay
⛔ Highpass
⛔ Reverb
⛔ Waveshaping distortion
⛔ Bitcrusher
⛔ Downsample
Note: MoonForge is not in any way a scientific instrument and generally is not intended to be used as such. Lua is only able to affect the audio data at block boundaries and thus is not capable of particularly precise, low-level DSP.
## Lua Scripting
All Lua scripts must contain a `Loop(tick)` function. The `tick` value represents the current iteration of the main loop.
A basic script might look like this:
```lua
-- Setup
amp_set(1, 1) -- Set the amp of the first osc to 1
local base_freq = 440 -- Base frequency in Hz
local lfo_range = 229 -- LFO range in Hz
local lfo_time = 1000 -- Speed of the LFO in ticks
-- Main loop
-- Runs at about 1 KHz (1000 times per second)
function Loop(tick)
local lfo = math.sin(tick / lfo_time) * 0.5 + 0.5 -- Sine wave normalized to 0->1
freq_set(1, base_freq + lfo * lfo_range) -- Set the frequncy of the first osc using the LFO
end
```
For scripting examples see the [examples](examples) directory.
## Lua API
See the [MF Lua API Docs](doc/API.md) for core API functions.
## Higher Level Libraries
This project also includes [`mflib.lua`](lua_include/mflib.lua) which contains wrapper functions around the core API which make it easier to work with.
The `mflib.lua` library is written in pure Lua, so anything it does can be done manually. Users are encouraged to write their own wrapper libraries (for fun).
## Build & Package
### Requirements:
- [Portaudio](https://www.portaudio.com/)
- [Lua](https://www.lua.org/)
- [A unix system](https://btxx.org/public/images/unix.gif)
- A C compiler for your OS
### Windows?
[No.](https://c.tenor.com/5N9derc9UcgAAAAC/no-bugs-bunny.gif)
### Build
```bash
./pkg.sh
```
Final packaged build files will be in `./dist`.
## Run
### Run Syntax:
```bash
./mf
```
### Run Example:
```bash
./mf examples/test.lua
```
### Recording
MoonForge has built-in support for recording to WAV format. When a track is ended with the `exit()` API call a recording of your audio will be saved to your current directory.
The default max recording length is 240 seconds. When this limit is reached, the current recording will be written and a new one will start automatically.