# 28spawn/pocket-onyx architecture

> Architecture diagram of the GitHub repository 28spawn/pocket-onyx, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-23). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/28spawn/pocket-onyx
- Repository: https://github.com/28spawn/pocket-onyx

## Overview

Onyx is guitar-effects firmware for JieLi hardware, with the same portable audio core exposed through a desktop emulator and a WebAssembly workbench. The main workflow is instrument audio through the processing chain to output, alongside front-panel control and preset management; users can also load NAM captures and cabinet IRs. The README documents the emulator and browser workbench capabilities, while the audio-core header makes the shared processing stages explicit. Some subsystem links are omitted because the sampled excerpts do not show their runtime callers.

Main entry points: [`custom-fw/src/sys/pa_audio_core.c`](https://github.com/28spawn/pocket-onyx/blob/main/custom-fw/src/sys/pa_audio_core.c) (Shared Audio Core), [`custom-fw/src/board/ui_app.c`](https://github.com/28spawn/pocket-onyx/blob/main/custom-fw/src/board/ui_app.c) (Front Panel UI), [`custom-fw/src/fx/fx_graph.c`](https://github.com/28spawn/pocket-onyx/blob/main/custom-fw/src/fx/fx_graph.c) (Effect Chain), [`custom-fw/emu/server.py`](https://github.com/28spawn/pocket-onyx/blob/main/custom-fw/emu/server.py) (Emulator Server)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_device["Device Firmware"]
  node_main["Firmware Loop<br/>[main.c]"]
  node_panel["Front Panel UI<br/>[ui_app.c]"]
  node_audioio["ALNK Audio I/O<br/>[pa_audio.h]"]
  node_usb["USB / SysEx<br/>[sysex.c]"]
  node_ota["OTA Sessions<br/>[pa_ota_session.c]"]
end

subgraph group_audio["Audio Engine"]
  node_core["Shared Audio Core<br/>[pa_audio_core.c]"]
  node_chain["Effect Chain<br/>[fx_graph.c]"]
  node_effects["Effect Processors"]
  node_nam["NAM Inference<br/>[nam_engine.c]"]
  node_tuner["Chromatic Tuner<br/>[tuner.c]"]
  node_drums["Groove Synth<br/>[drums_synth.c]"]
end

subgraph group_content["Tone and State"]
  node_preset[("Preset Store<br/>[preset.c]")]
  node_settings[("Device Settings<br/>[settings.c]")]
  node_usernam[("User NAM Registry<br/>[pa_user_nam.c]")]
  node_cab[("User Cabinet IRs<br/>[pa_user_cab.c]")]
end

subgraph group_sim["Emulation Workbenches"]
  node_emu["Desktop Emulator<br/>[emu_bridge.c]"]
  node_emuserver["Emulator Server<br/>[server.py]"]
  node_namloader["NAM Loader<br/>[nam_loader.py]"]
  node_wasm["WebAssembly Shim<br/>[pa_wasm.c]"]
end

node_player(("Instrument / User"))

node_player -->|"inputs audio"| node_audioio
node_audioio -->|"feeds blocks"| node_core
node_core -->|"processes first"| node_tuner
node_core -->|"runs chain"| node_chain
node_core -->|"mixes drums"| node_drums
node_core -->|"mixes USB audio"| node_usb
node_chain -.->|"dispatches effects"| node_effects
node_chain -.->|"uses amp model"| node_nam
node_panel -->|"edits presets"| node_preset
node_panel -->|"selects captures"| node_usernam
node_panel -->|"uses SysEx"| node_usb
node_usernam -.->|"supplies captures"| node_nam
node_main -.->|"initializes audio"| node_audioio
node_main -.->|"runs interface"| node_panel
node_emu -->|"hosts shared core"| node_core
node_emuserver -->|"loads NAM files"| node_namloader
node_emuserver -.->|"bridges emulator"| node_emu
node_wasm -->|"hosts shared core"| node_core
node_player -->|"auditions tones"| node_emuserver
node_player -->|"auditions audio"| node_wasm
node_ota -.->|"uses upgrade transport"| node_usb

click node_main "https://github.com/28spawn/pocket-onyx/blob/main/custom-fw/src/board/main.c"
click node_panel "https://github.com/28spawn/pocket-onyx/blob/main/custom-fw/src/board/ui_app.c"
click node_audioio "https://github.com/28spawn/pocket-onyx/blob/main/custom-fw/include/pa_audio.h"
click node_usb "https://github.com/28spawn/pocket-onyx/blob/main/custom-fw/src/sys/sysex.c"
click node_ota "https://github.com/28spawn/pocket-onyx/blob/main/custom-fw/src/sys/pa_ota_session.c"
click node_core "https://github.com/28spawn/pocket-onyx/blob/main/custom-fw/src/sys/pa_audio_core.c"
click node_chain "https://github.com/28spawn/pocket-onyx/blob/main/custom-fw/src/fx/fx_graph.c"
click node_effects "https://github.com/28spawn/pocket-onyx/tree/main/custom-fw/src/fx"
click node_nam "https://github.com/28spawn/pocket-onyx/blob/main/custom-fw/src/nam/nam_engine.c"
click node_tuner "https://github.com/28spawn/pocket-onyx/blob/main/custom-fw/src/dsp/tuner.c"
click node_drums "https://github.com/28spawn/pocket-onyx/blob/main/custom-fw/src/dsp/drums_synth.c"
click node_preset "https://github.com/28spawn/pocket-onyx/blob/main/custom-fw/src/sys/preset.c"
click node_settings "https://github.com/28spawn/pocket-onyx/blob/main/custom-fw/src/sys/settings.c"
click node_usernam "https://github.com/28spawn/pocket-onyx/blob/main/custom-fw/src/sys/pa_user_nam.c"
click node_cab "https://github.com/28spawn/pocket-onyx/blob/main/custom-fw/src/sys/pa_user_cab.c"
click node_emu "https://github.com/28spawn/pocket-onyx/blob/main/custom-fw/emu/emu_bridge.c"
click node_emuserver "https://github.com/28spawn/pocket-onyx/blob/main/custom-fw/emu/server.py"
click node_namloader "https://github.com/28spawn/pocket-onyx/blob/main/custom-fw/emu/nam_loader.py"
click node_wasm "https://github.com/28spawn/pocket-onyx/blob/main/custom-fw/wasm/pa_wasm.c"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_main,node_panel,node_audioio,node_usb,node_ota,node_player toneBlue
class node_core,node_chain,node_effects,node_nam,node_tuner,node_drums toneAmber
class node_preset,node_settings,node_usernam,node_cab toneMint
class node_emu,node_emuserver,node_namloader,node_wasm toneRose
```

## Components

### Device Firmware

- [Firmware Loop](https://github.com/28spawn/pocket-onyx/blob/main/custom-fw/src/board/main.c): `custom-fw/src/board/main.c`
- [Front Panel UI](https://github.com/28spawn/pocket-onyx/blob/main/custom-fw/src/board/ui_app.c): `custom-fw/src/board/ui_app.c`
- [ALNK Audio I/O](https://github.com/28spawn/pocket-onyx/blob/main/custom-fw/include/pa_audio.h): `custom-fw/include/pa_audio.h`
- [USB / SysEx](https://github.com/28spawn/pocket-onyx/blob/main/custom-fw/src/sys/sysex.c): `custom-fw/src/sys/sysex.c`
- [OTA Sessions](https://github.com/28spawn/pocket-onyx/blob/main/custom-fw/src/sys/pa_ota_session.c): `custom-fw/src/sys/pa_ota_session.c`

### Audio Engine

- [Shared Audio Core](https://github.com/28spawn/pocket-onyx/blob/main/custom-fw/src/sys/pa_audio_core.c): `custom-fw/src/sys/pa_audio_core.c`
- [Effect Chain](https://github.com/28spawn/pocket-onyx/blob/main/custom-fw/src/fx/fx_graph.c): `custom-fw/src/fx/fx_graph.c`
- [Effect Processors](https://github.com/28spawn/pocket-onyx/tree/main/custom-fw/src/fx): `custom-fw/src/fx`
- [NAM Inference](https://github.com/28spawn/pocket-onyx/blob/main/custom-fw/src/nam/nam_engine.c): `custom-fw/src/nam/nam_engine.c`
- [Chromatic Tuner](https://github.com/28spawn/pocket-onyx/blob/main/custom-fw/src/dsp/tuner.c): `custom-fw/src/dsp/tuner.c`
- [Groove Synth](https://github.com/28spawn/pocket-onyx/blob/main/custom-fw/src/dsp/drums_synth.c): `custom-fw/src/dsp/drums_synth.c`

### Tone and State

- [Preset Store](https://github.com/28spawn/pocket-onyx/blob/main/custom-fw/src/sys/preset.c): `custom-fw/src/sys/preset.c`
- [Device Settings](https://github.com/28spawn/pocket-onyx/blob/main/custom-fw/src/sys/settings.c): `custom-fw/src/sys/settings.c`
- [User NAM Registry](https://github.com/28spawn/pocket-onyx/blob/main/custom-fw/src/sys/pa_user_nam.c): `custom-fw/src/sys/pa_user_nam.c`
- [User Cabinet IRs](https://github.com/28spawn/pocket-onyx/blob/main/custom-fw/src/sys/pa_user_cab.c): `custom-fw/src/sys/pa_user_cab.c`

### Emulation Workbenches

- [Desktop Emulator](https://github.com/28spawn/pocket-onyx/blob/main/custom-fw/emu/emu_bridge.c): `custom-fw/emu/emu_bridge.c`
- [Emulator Server](https://github.com/28spawn/pocket-onyx/blob/main/custom-fw/emu/server.py): `custom-fw/emu/server.py`
- [NAM Loader](https://github.com/28spawn/pocket-onyx/blob/main/custom-fw/emu/nam_loader.py): `custom-fw/emu/nam_loader.py`
- [WebAssembly Shim](https://github.com/28spawn/pocket-onyx/blob/main/custom-fw/wasm/pa_wasm.c): `custom-fw/wasm/pa_wasm.c`

### Other components

- **Instrument / User**

## Connections

- Instrument / User → ALNK Audio I/O: inputs audio (evidence: `custom-fw/include/pa_audio.h`)
- ALNK Audio I/O → Shared Audio Core: feeds blocks (evidence: `custom-fw/src/sys/pa_audio_core.c`)
- Shared Audio Core → Chromatic Tuner: processes first
- Shared Audio Core → Effect Chain: runs chain
- Shared Audio Core → Groove Synth: mixes drums
- Shared Audio Core → USB / SysEx: mixes USB audio
- Effect Chain → Effect Processors: dispatches effects
- Effect Chain → NAM Inference: uses amp model
- Front Panel UI → Preset Store: edits presets (evidence: `custom-fw/src/board/ui_app.c`)
- Front Panel UI → User NAM Registry: selects captures (evidence: `custom-fw/src/board/ui_app.c`)
- Front Panel UI → USB / SysEx: uses SysEx (evidence: `custom-fw/src/board/ui_app.c`)
- User NAM Registry → NAM Inference: supplies captures
- Firmware Loop → ALNK Audio I/O: initializes audio (evidence: `custom-fw/src/board/main.c`)
- Firmware Loop → Front Panel UI: runs interface
- Desktop Emulator → Shared Audio Core: hosts shared core (evidence: `custom-fw/emu/emu_bridge.c`)
- Emulator Server → NAM Loader: loads NAM files (evidence: `custom-fw/emu/server.py`)
- Emulator Server → Desktop Emulator: bridges emulator
- WebAssembly Shim → Shared Audio Core: hosts shared core (evidence: `custom-fw/wasm/pa_wasm.c`)
- Instrument / User → Emulator Server: auditions tones
- Instrument / User → WebAssembly Shim: auditions audio
- OTA Sessions → USB / SysEx: uses upgrade transport
