How plasticgaming99/pg99pro works
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: sf2abst.go SF2 abst · synth.go Synth · cmd.go cmd · gui.go GUI
Components 14
Entry points
Executable and command wiring
UI layer
Desktop interface and embedded assets
Synthesis core
Shared orchestration and audio engine
SoundFont layer
SoundFont parsing and abstraction
- SF2 · SoundFont 2 domain representation
synth/sf2/sf2.go - SF2 abst · Normalizes SoundFont data for the synth
synth/sf2abst/sf2abst.go - Parse · Input parsing for SF2 structures
synth/sf2abst/parse.go - Generator · Builds playable abstractions from parsed data
synth/sf2abst/generator.go - Instrument · Instrument-side abstraction types
synth/sf2abst/instrument.go - Sample · Sample-side abstraction types
synth/sf2abst/sample.go - Ops consts · Operator and SF2-related constants
synth/sf2abst/operatorConst.go
Connections 16
- 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