# plasticgaming99/pg99pro architecture

> Architecture diagram of the GitHub repository plasticgaming99/pg99pro, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-04-12). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/plasticgaming99/pg99pro
- Repository: https://github.com/plasticgaming99/pg99pro

## Overview

1. **What this repo is**
   - A Go-based “old MIDI sound module / tone generator” simulator.
   - The README explicitly says it aims to *simulate the feel* of classic hardware rather than emulate it exactly, so the architecture is centered on sound generation and SoundFont/SF2 handling, not on hardware accuracy.

2. **Top-level application shape**
   - The repository has two visible front ends: a **CLI/command layer** under `cmd/` and a **GUI layer** under `gui/`.
   - Both appear to sit on top of the same synthesis core in `synth/`, which is the main engine boundary in the project.

3. **Entry points**
   - `main.go` is the primary executable entry.
   - `cmd/cmd.go` likely wires command parsing / mode selection.
   - `cmd/bulkprintsf2.go` looks like a dedicated utility command for inspecting or dumping SF2-related data.

4. **GUI subsystem**
   - `gui/gui.go` contains the desktop UI logic.
   - `gui/resources/` and `gui/resources/embed.go` indicate the app embeds GUI assets at build time, so the UI can run as a self-contained binary without external resource files.

5. **Synthesizer core boundary**
   - `synth/synth.go` is the shared synthesis abstraction or orchestration layer.
   - This is likely the central interface between input events/configuration and actual audio generation.

6. **PCM synthesis implementation**
   - `synth/pcmsynth/pcmsynth.go` suggests one concrete synthesis backend built around PCM sample playback.
   - This is probably the low-level “sound engine” that turns instrument/sample definitions into audio output.

7. **SF2 handling**
   - `synth/sf2/sf2.go` appears to be the SoundFont 2 domain layer.
   - It likely handles SF2 parsing, representation, and access to banks, presets, instruments, and samples.

8. **SF2 abstraction layer**
   - `synth/sf2abst/` looks like a normalization/translation layer above raw SF2 data.
   - The files here suggest a pipeline:
     - `parse.go` for input parsing,
     - `generator.go` for building playable structures,
     - `instrument.go`, `sample.go`, and `operatorConst.go` for the domain model and constants,
     - `sf2abst.go` as the package entry point.
   - This layer is probably where raw SF2 metadata is converted into the simplified internal model used by the synth engine.

9. **Likely runtime data flow**
   - User action starts in either the GUI or command line.
   - The app loads or inspects an SF2 source.
   - `sf2abst` converts SF2 metadata into an internal abstraction.
   - `pcmsynth` uses that abstraction to produce PCM audio.
   - The outer app then either plays, previews, or prints results depending on the selected mode.

10. **Important architectural boundaries**
    - **UI/command boundary:** `gui` and `cmd` are presentation/interaction layers.
    - **Audio engine boundary:** `synth` is the reusable core.
    - **Format boundary:** `sf2` and `sf2abst` isolate SoundFont-specific logic from the rest of the program.
    - This separation makes it easier to add new front ends or swap synthesis behavior without rewriting the SoundFont handling.

11. **What stands out for a diagram**
    - Draw the repository as a layered Go application:
      - entry points (`main`, `cmd`)
      - optional GUI (`gui`)
      - synthesis core (`synth`)
      - format-specific adapters (`sf2`, `sf2abst`)
      - low-level PCM backend (`pcmsynth`)
    - The embedded GUI resources are a build-time asset dependency, not a runtime service.

12. **Repo characterization**
    - This is not a general web/service architecture.
    - It is a single-binary Go audio application with a split between interface layers and a synthesis pipeline focused on SoundFont-driven MIDI-style sound generation.

Main entry points: [`synth/sf2abst/sf2abst.go`](https://github.com/plasticgaming99/pg99pro/blob/main/synth/sf2abst/sf2abst.go) (SF2 abst), [`synth/synth.go`](https://github.com/plasticgaming99/pg99pro/blob/main/synth/synth.go) (Synth), [`cmd/cmd.go`](https://github.com/plasticgaming99/pg99pro/blob/main/cmd/cmd.go) (cmd), [`gui/gui.go`](https://github.com/plasticgaming99/pg99pro/blob/main/gui/gui.go) (GUI)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["Entry points"]
  node_main(("main<br/>go entrypoint<br/>[main.go]"))
  node_cmdpkg["cmd<br/>command layer<br/>[cmd.go]"]
  node_bulkprintsf2["SF2 dump<br/>utility command<br/>[bulkprintsf2.go]"]
end

subgraph group_ui["UI layer"]
  node_guiapp["GUI<br/>desktop frontend<br/>[gui.go]"]
  node_guires["Assets<br/>embedded resources<br/>[embed.go]"]
end

subgraph group_core["Synthesis core"]
  node_synthcore["Synth<br/>core orchestration<br/>[synth.go]"]
  node_pcmsynth["PCM synth<br/>audio backend<br/>[pcmsynth.go]"]
end

subgraph group_format["SoundFont layer"]
  node_sf2domain["SF2<br/>soundfont model<br/>[sf2.go]"]
  node_sf2abst["SF2 abst<br/>abstraction layer<br/>[sf2abst.go]"]
  node_parse["Parse<br/>[parse.go]"]
  node_generator["Generator<br/>build stage<br/>[generator.go]"]
  node_instrument["Instrument<br/>domain model<br/>[instrument.go]"]
  node_sample["Sample<br/>domain model<br/>[sample.go]"]
  node_ops["Ops consts<br/>constants<br/>[operatorConst.go]"]
end

node_main -->|"select mode"| node_cmdpkg
node_main -->|"launch UI"| node_guiapp
node_cmdpkg -->|"utility path"| node_bulkprintsf2
node_guiapp -->|"load assets"| node_guires
node_cmdpkg -->|"invoke"| node_synthcore
node_guiapp -->|"control"| node_synthcore
node_synthcore -->|"backend"| node_pcmsynth
node_synthcore -->|"prepare data"| node_sf2abst
node_sf2abst -->|"parse"| node_parse
node_sf2abst -->|"build"| node_generator
node_generator -->|"model"| node_instrument
node_generator -->|"model"| node_sample
node_sf2abst -->|"constants"| node_ops
node_sf2abst -->|"source format"| node_sf2domain
node_pcmsynth -->|"read sf2"| node_sf2domain
node_sf2domain -->|"normalize"| node_sf2abst

click node_main "https://github.com/plasticgaming99/pg99pro/blob/main/main.go"
click node_cmdpkg "https://github.com/plasticgaming99/pg99pro/blob/main/cmd/cmd.go"
click node_bulkprintsf2 "https://github.com/plasticgaming99/pg99pro/blob/main/cmd/bulkprintsf2.go"
click node_guiapp "https://github.com/plasticgaming99/pg99pro/blob/main/gui/gui.go"
click node_guires "https://github.com/plasticgaming99/pg99pro/blob/main/gui/resources/embed.go"
click node_synthcore "https://github.com/plasticgaming99/pg99pro/blob/main/synth/synth.go"
click node_pcmsynth "https://github.com/plasticgaming99/pg99pro/blob/main/synth/pcmsynth/pcmsynth.go"
click node_sf2domain "https://github.com/plasticgaming99/pg99pro/blob/main/synth/sf2/sf2.go"
click node_sf2abst "https://github.com/plasticgaming99/pg99pro/blob/main/synth/sf2abst/sf2abst.go"
click node_parse "https://github.com/plasticgaming99/pg99pro/blob/main/synth/sf2abst/parse.go"
click node_generator "https://github.com/plasticgaming99/pg99pro/blob/main/synth/sf2abst/generator.go"
click node_instrument "https://github.com/plasticgaming99/pg99pro/blob/main/synth/sf2abst/instrument.go"
click node_sample "https://github.com/plasticgaming99/pg99pro/blob/main/synth/sf2abst/sample.go"
click node_ops "https://github.com/plasticgaming99/pg99pro/blob/main/synth/sf2abst/operatorConst.go"

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_cmdpkg,node_bulkprintsf2 toneBlue
class node_guiapp,node_guires toneAmber
class node_synthcore,node_pcmsynth toneMint
class node_sf2domain,node_sf2abst,node_parse,node_generator,node_instrument,node_sample,node_ops toneRose
```

## Components

### Entry points

Executable and command wiring

- [main](https://github.com/plasticgaming99/pg99pro/blob/main/main.go): go entrypoint · Primary executable entry · `main.go`
- [cmd](https://github.com/plasticgaming99/pg99pro/blob/main/cmd/cmd.go): command layer · CLI command wiring and mode selection · `cmd/cmd.go`
- [SF2 dump](https://github.com/plasticgaming99/pg99pro/blob/main/cmd/bulkprintsf2.go): utility command · Bulk SF2 inspection / printing utility · `cmd/bulkprintsf2.go`

### UI layer

Desktop interface and embedded assets

- [GUI](https://github.com/plasticgaming99/pg99pro/blob/main/gui/gui.go): desktop frontend · Application UI and user interaction · `gui/gui.go`
- [Assets](https://github.com/plasticgaming99/pg99pro/blob/main/gui/resources/embed.go): embedded resources · Bundled GUI resources embedded at build time · `gui/resources/embed.go`

### Synthesis core

Shared orchestration and audio engine

- [Synth](https://github.com/plasticgaming99/pg99pro/blob/main/synth/synth.go): core orchestration · Shared synthesis boundary for the app · `synth/synth.go`
- [PCM synth](https://github.com/plasticgaming99/pg99pro/blob/main/synth/pcmsynth/pcmsynth.go): audio backend · Concrete PCM sample playback engine · `synth/pcmsynth/pcmsynth.go`

### SoundFont layer

SoundFont parsing and abstraction

- [SF2](https://github.com/plasticgaming99/pg99pro/blob/main/synth/sf2/sf2.go): soundfont model · SoundFont 2 domain representation · `synth/sf2/sf2.go`
- [SF2 abst](https://github.com/plasticgaming99/pg99pro/blob/main/synth/sf2abst/sf2abst.go): abstraction layer · Normalizes SoundFont data for the synth · `synth/sf2abst/sf2abst.go`
- [Parse](https://github.com/plasticgaming99/pg99pro/blob/main/synth/sf2abst/parse.go): sf2 parser · Input parsing for SF2 structures · `synth/sf2abst/parse.go`
- [Generator](https://github.com/plasticgaming99/pg99pro/blob/main/synth/sf2abst/generator.go): build stage · Builds playable abstractions from parsed data · `synth/sf2abst/generator.go`
- [Instrument](https://github.com/plasticgaming99/pg99pro/blob/main/synth/sf2abst/instrument.go): domain model · Instrument-side abstraction types · `synth/sf2abst/instrument.go`
- [Sample](https://github.com/plasticgaming99/pg99pro/blob/main/synth/sf2abst/sample.go): domain model · Sample-side abstraction types · `synth/sf2abst/sample.go`
- [Ops consts](https://github.com/plasticgaming99/pg99pro/blob/main/synth/sf2abst/operatorConst.go): constants · Operator and SF2-related constants · `synth/sf2abst/operatorConst.go`

## Connections

- main → cmd: select mode · Main delegates to command wiring
- main → GUI: launch UI · Main can start the GUI frontend
- cmd → SF2 dump: utility path · CLI layer exposes SF2 printing mode
- GUI → Assets: load assets · GUI uses embedded resources
- cmd → Synth: invoke · Command layer drives synthesis workflows
- GUI → Synth: control · GUI feeds user actions into the synth core
- Synth → PCM synth: backend · Core delegates audio generation to PCM backend
- Synth → SF2 abst: prepare data · Core consumes normalized SoundFont abstractions
- SF2 abst → Parse: parse · Abstraction layer starts from parsed SF2 data
- SF2 abst → Generator: build · Transforms parsed input into playable structures
- Generator → Instrument: model · Generator assembles instrument abstractions
- Generator → Sample: model · Generator assembles sample abstractions
- SF2 abst → Ops consts: constants · Uses shared operator definitions
- SF2 abst → SF2: source format · Wraps or maps raw SoundFont domain data
- PCM synth → SF2: read sf2 · PCM backend depends on SoundFont data structures
- SF2 → SF2 abst: normalize · Raw SoundFont data is adapted into the internal model
