# ReXynth

A lightweight cross-platform sampler DAW built on ImGui, OpenGL 3.3, GLFW,
Miniaudio (audio I/O), stb_vorbis, libFLAC, libvorbis, and LAME.

## Features

- **Sampler tracks** with 16-bit WAV / FLAC / OGG / MP3 sample import, mip-based
  preview waveforms, clip slicing, move/resize/fade/pitch editing, a
  velocity-based one-shot preview, per-clip colors/notes, and a **search
  filter** in the sample browser.
- **Per-clip sample reversal** (non-destructive toggle; mirrored waveform and
  `↔` badge) and **fade curves** (linear / cosine / S-curve) with per-sample
  default fades applied on insert.
- **FX rack** per track — reverb, feedback delay, bass boost, lo-fi crusher,
  distortion, speaker, and wide chorus — with an explicit reorderable chain
  (order numbers + up/down), whole-chain bypass, and a track selector.
- **Knife tool** (F2): a click slices every clip under the line; hold
  Shift to split a single clip.
- **Built-in synthesizers** — *Nipon* (decaying pluck) and *Class* (detuned
  saws + sub through a one-pole lowpass) with smooth 128-step program scaling.
- **SoundFont 2 (.sf2)** import: full RIFF `sfbk` parse into flattened
  preset → instrument → sample regions with key/vel ranges, loop modes, and a
  streaming per-voice renderer. Samples flagged IMA-ADPCM/ROM are skipped with
  a warning rather than distorted.
- **MIDI tracks** with a full **piano roll** (add/move/resize notes, velocity
  lane editing, snap, keyboard roll, note selection, ghost placement preview,
  note clipboard with Ctrl+C/V, `Q` quantize, `Ctrl+D` duplicate) and a
  frame-exact note scheduler that never drops notes shorter than a frame —
  notes drive both the built-in synths and loaded SoundFonts.
- **Patterns as gestures**: every MIDI lane draws its pattern as a draggable
  block (notes in miniature + name). Click opens the piano roll; drag shifts
  every note with grid snap and undo; the pattern audition sweeps whole bars.
- **Synth knobs (Phase 4)**: per-track cutoff, resonance, attack and release
  for the built-in instruments, drawn as primitive rotary controls; defaults
  leave the patch sound bit-identical.
- **Pointer calibration**: `--mouse-scale <f>` / `XS_MOUSE_SCALE` and
  `--mouse-offset x,y` / `XS_MOUSE_OFFSET` compensate odd display scaling.
  The live overlay appears on the first run (and with `F12`): `[` `]` scale,
  arrow keys offset, `0` resets, `Enter` saves and closes — every change
  persists in the config file. If clicks/drags land beside the pointer
  (typical on XWayland with fractional scaling), this is the fix.
- **Arrangement view** with track lanes, pulse-style grid, loop region, playhead,
  time ruler, zoom/scroll, and clip context menus.
- **Render/Export**: offline WAV / FLAC / OGG / MP3 mixdown (16/24-bit, dither,
  ID3/`INFO` tags, cover art), plus `.rxp` packages bundling the project and its
  samples into a zip archive.
- **Save/Load** project text (`.xsmp`) including MIDI tracks and piano-roll
  notes, undo/redo history, drag-and-drop import, and a dashboard help overlay.

## Build

```sh
cmake -S . -B build -DCMAKE_BUILD_TYPE=Release
cmake --build build -j4
./build/rexynth
```

## Self-test

```sh
./build/rexynth --selftest
```

Runs headless unit tests over the timing grid, project model, history, pitch
modeling, mixdown round-trips (WAV/FLAC/OGG/MP3 + metadata/cover), .rxp
packaging, SF2 parsing/render (including ADPCM-skip), MIDI-only mixdown, FX
chain order/bypass, clip reversal, slice-all, sample default fades, and project
serialization. Exit status reflects pass/fail.