# npid7/bcstm-player architecture

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

- Interactive diagram: https://gitdiagram.com/npid7/bcstm-player
- Repository: https://github.com/npid7/bcstm-player

## Overview

BCSTM-Player is a Nintendo 3DS audio player. Its visible entry flow starts the app loop, initializes the file browser at the SD-card root, and enters the initial UI stage; a background loop streams audio through a selectable decoder. The tree and README support additional BCWAV/BCSTM inspection, settings, themes, and localization branches, though their wiring is not shown in the excerpts. Those branches are included without speculative connections. Edges are limited to relationships visible in excerpts or explicitly documented capabilities.

Main entry points: [`source/main.cpp`](https://github.com/npid7/bcstm-player/blob/main/source/main.cpp) (Player controller), [`source/app.cpp`](https://github.com/npid7/bcstm-player/blob/main/source/app.cpp) (App loop), [`source/bcstm/ctrff_decode.cpp`](https://github.com/npid7/bcstm-player/blob/main/source/bcstm/ctrff_decode.cpp) (CTRFF decoder), [`source/bcstm/bcstmv2.cpp`](https://github.com/npid7/bcstm-player/blob/main/source/bcstm/bcstmv2.cpp) (Legacy BCSTM decoder)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["App runtime"]
  node_app["App loop<br/>[app.cpp]"]
  node_main["Player controller<br/>[main.cpp]"]
  node_stages["Stage manager<br/>[stagemgr.cpp]"]
end

subgraph group_playback["Audio playback"]
  node_ctrff_decoder["CTRFF decoder<br/>[ctrff_decode.cpp]"]
  node_legacy_decoder["Legacy BCSTM decoder<br/>[bcstmv2.cpp]"]
end

subgraph group_interface["Browse and inspect"]
  node_browser["File browser<br/>[filebrowser.cpp]"]
  node_bcstm_inspector["BCSTM inspector<br/>[inspector_view.cpp]"]
  node_bcwav_inspector["BCWAV inspector"]
  node_messages["Notifications<br/>[msg_handler.cpp]"]
end

subgraph group_resources["UI resources"]
  node_config["Player settings<br/>[config.hpp]"]
  node_language["Localization<br/>[lang.cpp]"]
  node_themes["Themes"]
  node_translations["Translations"]
end

node_user(("3DS user"))
node_audio_output["3DS audio output"]

node_user -->|"starts"| node_app
node_app -->|"calls Main"| node_main
node_main -->|"creates and scans"| node_browser
node_main -->|"sets stage"| node_stages
node_main -->|"streams audio"| node_ctrff_decoder
node_ctrff_decoder -->|"queues audio"| node_audio_output
node_legacy_decoder -->|"queues audio"| node_audio_output

click node_app "https://github.com/npid7/bcstm-player/blob/main/source/app.cpp"
click node_main "https://github.com/npid7/bcstm-player/blob/main/source/main.cpp"
click node_stages "https://github.com/npid7/bcstm-player/blob/main/source/stagemgr.cpp"
click node_browser "https://github.com/npid7/bcstm-player/blob/main/source/filebrowser.cpp"
click node_bcstm_inspector "https://github.com/npid7/bcstm-player/blob/main/source/inspector_view.cpp"
click node_bcwav_inspector "https://github.com/npid7/bcstm-player/blob/main/source/inspector_view_bcwav.cpp"
click node_messages "https://github.com/npid7/bcstm-player/blob/main/source/msg_handler.cpp"
click node_ctrff_decoder "https://github.com/npid7/bcstm-player/blob/main/source/bcstm/ctrff_decode.cpp"
click node_legacy_decoder "https://github.com/npid7/bcstm-player/blob/main/source/bcstm/bcstmv2.cpp"
click node_config "https://github.com/npid7/bcstm-player/blob/main/source/config.hpp"
click node_language "https://github.com/npid7/bcstm-player/blob/main/source/lang.cpp"
click node_themes "https://github.com/npid7/bcstm-player/tree/main/romfs/themes"
click node_translations "https://github.com/npid7/bcstm-player/tree/main/romfs/lang"

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_app,node_main,node_stages,node_user toneBlue
class node_ctrff_decoder,node_legacy_decoder toneAmber
class node_browser,node_bcstm_inspector,node_bcwav_inspector,node_messages toneMint
class node_config,node_language,node_themes,node_translations toneRose
class node_audio_output toneIndigo
```

## Components

### App runtime

- [App loop](https://github.com/npid7/bcstm-player/blob/main/source/app.cpp): `source/app.cpp`
- [Player controller](https://github.com/npid7/bcstm-player/blob/main/source/main.cpp): `source/main.cpp`
- [Stage manager](https://github.com/npid7/bcstm-player/blob/main/source/stagemgr.cpp): `source/stagemgr.cpp`

### Audio playback

- [CTRFF decoder](https://github.com/npid7/bcstm-player/blob/main/source/bcstm/ctrff_decode.cpp): `source/bcstm/ctrff_decode.cpp`
- [Legacy BCSTM decoder](https://github.com/npid7/bcstm-player/blob/main/source/bcstm/bcstmv2.cpp): `source/bcstm/bcstmv2.cpp`

### Browse and inspect

- [File browser](https://github.com/npid7/bcstm-player/blob/main/source/filebrowser.cpp): `source/filebrowser.cpp`
- [BCSTM inspector](https://github.com/npid7/bcstm-player/blob/main/source/inspector_view.cpp): `source/inspector_view.cpp`
- [BCWAV inspector](https://github.com/npid7/bcstm-player/blob/main/source/inspector_view_bcwav.cpp): `source/inspector_view_bcwav.cpp`
- [Notifications](https://github.com/npid7/bcstm-player/blob/main/source/msg_handler.cpp): `source/msg_handler.cpp`

### UI resources

- [Player settings](https://github.com/npid7/bcstm-player/blob/main/source/config.hpp): `source/config.hpp`
- [Localization](https://github.com/npid7/bcstm-player/blob/main/source/lang.cpp): `source/lang.cpp`
- [Themes](https://github.com/npid7/bcstm-player/tree/main/romfs/themes): `romfs/themes`
- [Translations](https://github.com/npid7/bcstm-player/tree/main/romfs/lang): `romfs/lang`

### Other components

- **3DS user**
- **3DS audio output**

## Connections

- 3DS user → App loop: starts
- App loop → Player controller: calls Main (evidence: `source/app.cpp`)
- Player controller → File browser: creates and scans (evidence: `source/main.cpp`)
- Player controller → Stage manager: sets stage (evidence: `source/main.cpp`)
- Player controller → CTRFF decoder: streams audio (evidence: `source/main.cpp`)
- CTRFF decoder → 3DS audio output: queues audio (evidence: `source/bcstm/ctrff_decode.cpp`)
- Legacy BCSTM decoder → 3DS audio output: queues audio (evidence: `source/bcstm/bcstmv2.cpp`)
