# artistro08/sony-control architecture

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

- Interactive diagram: https://gitdiagram.com/artistro08/sony-control
- Repository: https://github.com/artistro08/sony-control

## Overview

Sony Control is a Windows 11 tray application for discovering and managing supported Sony headphones through a WinUI flyout. Its main workflow tracks Windows Bluetooth devices, identifies headsets, connects according to saved preferences, and exposes battery, noise-control, equalizer, and other device controls. Presentation view models mediate between the tray UI and headset management; native code bridges to transport and Sony protocol handling. The README documents broader model support; source excerpts show key ownership boundaries but not every UI or protocol call, so uncertain wiring is omitted.

Main entry points: [`src/SonyControl.Presentation/Devices/HeadsetManager.cs`](https://github.com/artistro08/sony-control/blob/main/src/SonyControl.Presentation/Devices/HeadsetManager.cs) (Headset manager), [`native/SonyProtocol/src/HeadsetController.cpp`](https://github.com/artistro08/sony-control/blob/main/native/SonyProtocol/src/HeadsetController.cpp) (Headset controller), [`src/SonyControl.App/App.xaml.cs`](https://github.com/artistro08/sony-control/blob/main/src/SonyControl.App/App.xaml.cs) (App startup and composition), [`src/SonyControl.Presentation/ViewModels/FlyoutViewModel.cs`](https://github.com/artistro08/sony-control/blob/main/src/SonyControl.Presentation/ViewModels/FlyoutViewModel.cs) (Flyout view model)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_app["Tray application"]
  node_app["App startup and composition<br/>[App.xaml.cs]"]
  node_tray["Tray and flyout UI<br/>[TrayIcon.cs]"]
  node_settingsui["Settings UI<br/>[Settings]"]
  node_notify["Windows notifications"]
end

subgraph group_presentation["Presentation"]
  node_flyoutvm["Flyout view model<br/>[FlyoutViewModel.cs]"]
  node_headsetvm["Headset view model"]
  node_settingsvm["Settings view model"]
  node_manager["Headset manager<br/>[HeadsetManager.cs]"]
  node_watcher["Bluetooth device watcher"]
  node_managed["Managed headset<br/>[ManagedHeadset.cs]"]
  node_settings["App settings<br/>[AppSettings.cs]"]
  node_battery["Low battery monitor"]
  node_winrt["WinRT headset adapter<br/>[WinRtHeadset.cs]"]
end

subgraph group_native["Headset control"]
  node_client["Native headset client<br/>[HeadsetClient.cpp]"]
  node_audio["Bluetooth audio control<br/>[BluetoothAudio.cpp]"]
end

subgraph group_protocol["Sony protocol"]
  node_controller["Headset controller"]
  node_session["Protocol session"]
  node_codec["Frame codec<br/>[FrameCodec.cpp]"]
  node_protocols["Protocol generations<br/>[ProtocolV1.cpp]"]
  node_profiles["Device profiles"]
  node_events["Device event dispatcher"]
end

subgraph group_transport["Bluetooth transport"]
  node_transport["Windows RFCOMM transport"]
end

node_user(("Windows user"))
node_device(("Sony Bluetooth headset"))

node_user -->|"uses"| node_tray
node_app -->|"creates"| node_manager
node_app -->|"creates"| node_flyoutvm
node_app -->|"creates"| node_settingsvm
node_app -->|"registers"| node_notify
node_tray -->|"presents"| node_flyoutvm
node_settingsui -->|"edits settings"| node_settingsvm
node_flyoutvm -->|"observes devices"| node_manager
node_flyoutvm -->|"creates"| node_headsetvm
node_manager -->|"starts watching"| node_watcher
node_watcher -->|"reports devices"| node_manager
node_manager -->|"tracks"| node_managed
node_manager -->|"reads preferences"| node_settings
node_manager -->|"connects headset"| node_winrt
node_headsetvm -->|"controls headset"| node_winrt
node_headsetvm -->|"monitors level"| node_battery
node_battery -->|"shows alert"| node_notify
node_settingsvm -->|"updates preferences"| node_settings
node_winrt -->|"calls native API"| node_client
node_client -->|"runs commands"| node_controller
node_client -->|"controls audio link"| node_audio
node_controller -->|"opens session"| node_session
node_controller -->|"dispatches commands"| node_protocols
node_controller -->|"selects profile"| node_profiles
node_controller -->|"publishes state"| node_events
node_session -->|"encodes frames"| node_codec
node_session -->|"transfers bytes"| node_transport
node_transport -->|"Bluetooth link"| node_device

click node_app "https://github.com/artistro08/sony-control/blob/main/src/SonyControl.App/App.xaml.cs"
click node_tray "https://github.com/artistro08/sony-control/blob/main/src/SonyControl.App/TrayIcon.cs"
click node_settingsui "https://github.com/artistro08/sony-control/tree/main/src/SonyControl.App/Views/Settings"
click node_notify "https://github.com/artistro08/sony-control/blob/main/src/SonyControl.App/AppNotificationService.cs"
click node_flyoutvm "https://github.com/artistro08/sony-control/blob/main/src/SonyControl.Presentation/ViewModels/FlyoutViewModel.cs"
click node_headsetvm "https://github.com/artistro08/sony-control/blob/main/src/SonyControl.Presentation/ViewModels/HeadsetViewModel.cs"
click node_settingsvm "https://github.com/artistro08/sony-control/blob/main/src/SonyControl.Presentation/ViewModels/SettingsViewModel.cs"
click node_manager "https://github.com/artistro08/sony-control/blob/main/src/SonyControl.Presentation/Devices/HeadsetManager.cs"
click node_watcher "https://github.com/artistro08/sony-control/blob/main/src/SonyControl.Presentation/Devices/BluetoothDeviceWatcher.cs"
click node_managed "https://github.com/artistro08/sony-control/blob/main/src/SonyControl.Presentation/Devices/ManagedHeadset.cs"
click node_settings "https://github.com/artistro08/sony-control/blob/main/src/SonyControl.Presentation/Settings/AppSettings.cs"
click node_battery "https://github.com/artistro08/sony-control/blob/main/src/SonyControl.Presentation/Notifications/LowBatteryMonitor.cs"
click node_winrt "https://github.com/artistro08/sony-control/blob/main/src/SonyControl.Presentation/Headsets/WinRtHeadset.cs"
click node_client "https://github.com/artistro08/sony-control/blob/main/native/SonyControl.Core/HeadsetClient.cpp"
click node_audio "https://github.com/artistro08/sony-control/blob/main/native/SonyControl.Core/BluetoothAudio.cpp"
click node_controller "https://github.com/artistro08/sony-control/blob/main/native/SonyProtocol/src/HeadsetController.cpp"
click node_session "https://github.com/artistro08/sony-control/blob/main/native/SonyProtocol/src/SonyProtocolSession.cpp"
click node_codec "https://github.com/artistro08/sony-control/blob/main/native/SonyProtocol/src/FrameCodec.cpp"
click node_protocols "https://github.com/artistro08/sony-control/blob/main/native/SonyProtocol/src/ProtocolV1.cpp"
click node_profiles "https://github.com/artistro08/sony-control/blob/main/native/SonyProtocol/src/DeviceProfileRegistry.cpp"
click node_events "https://github.com/artistro08/sony-control/blob/main/native/SonyProtocol/src/DeviceEventDispatcher.cpp"
click node_transport "https://github.com/artistro08/sony-control/blob/main/native/SonyTransport/src/WindowsRfcommTransport.cpp"

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_tray,node_settingsui,node_notify,node_user toneBlue
class node_flyoutvm,node_headsetvm,node_settingsvm,node_manager,node_watcher,node_managed,node_settings,node_battery,node_winrt toneAmber
class node_client,node_audio toneMint
class node_controller,node_session,node_codec,node_protocols,node_profiles,node_events toneRose
class node_transport,node_device toneIndigo
```

## Components

### Tray application

- [App startup and composition](https://github.com/artistro08/sony-control/blob/main/src/SonyControl.App/App.xaml.cs): `src/SonyControl.App/App.xaml.cs`
- [Tray and flyout UI](https://github.com/artistro08/sony-control/blob/main/src/SonyControl.App/TrayIcon.cs): `src/SonyControl.App/TrayIcon.cs`
- [Settings UI](https://github.com/artistro08/sony-control/tree/main/src/SonyControl.App/Views/Settings): `src/SonyControl.App/Views/Settings`
- [Windows notifications](https://github.com/artistro08/sony-control/blob/main/src/SonyControl.App/AppNotificationService.cs): `src/SonyControl.App/AppNotificationService.cs`

### Presentation

- [Flyout view model](https://github.com/artistro08/sony-control/blob/main/src/SonyControl.Presentation/ViewModels/FlyoutViewModel.cs): `src/SonyControl.Presentation/ViewModels/FlyoutViewModel.cs`
- [Headset view model](https://github.com/artistro08/sony-control/blob/main/src/SonyControl.Presentation/ViewModels/HeadsetViewModel.cs): `src/SonyControl.Presentation/ViewModels/HeadsetViewModel.cs`
- [Settings view model](https://github.com/artistro08/sony-control/blob/main/src/SonyControl.Presentation/ViewModels/SettingsViewModel.cs): `src/SonyControl.Presentation/ViewModels/SettingsViewModel.cs`
- [Headset manager](https://github.com/artistro08/sony-control/blob/main/src/SonyControl.Presentation/Devices/HeadsetManager.cs): `src/SonyControl.Presentation/Devices/HeadsetManager.cs`
- [Bluetooth device watcher](https://github.com/artistro08/sony-control/blob/main/src/SonyControl.Presentation/Devices/BluetoothDeviceWatcher.cs): `src/SonyControl.Presentation/Devices/BluetoothDeviceWatcher.cs`
- [Managed headset](https://github.com/artistro08/sony-control/blob/main/src/SonyControl.Presentation/Devices/ManagedHeadset.cs): `src/SonyControl.Presentation/Devices/ManagedHeadset.cs`
- [App settings](https://github.com/artistro08/sony-control/blob/main/src/SonyControl.Presentation/Settings/AppSettings.cs): `src/SonyControl.Presentation/Settings/AppSettings.cs`
- [Low battery monitor](https://github.com/artistro08/sony-control/blob/main/src/SonyControl.Presentation/Notifications/LowBatteryMonitor.cs): `src/SonyControl.Presentation/Notifications/LowBatteryMonitor.cs`
- [WinRT headset adapter](https://github.com/artistro08/sony-control/blob/main/src/SonyControl.Presentation/Headsets/WinRtHeadset.cs): `src/SonyControl.Presentation/Headsets/WinRtHeadset.cs`

### Headset control

- [Native headset client](https://github.com/artistro08/sony-control/blob/main/native/SonyControl.Core/HeadsetClient.cpp): `native/SonyControl.Core/HeadsetClient.cpp`
- [Bluetooth audio control](https://github.com/artistro08/sony-control/blob/main/native/SonyControl.Core/BluetoothAudio.cpp): `native/SonyControl.Core/BluetoothAudio.cpp`

### Sony protocol

- [Headset controller](https://github.com/artistro08/sony-control/blob/main/native/SonyProtocol/src/HeadsetController.cpp): `native/SonyProtocol/src/HeadsetController.cpp`
- [Protocol session](https://github.com/artistro08/sony-control/blob/main/native/SonyProtocol/src/SonyProtocolSession.cpp): `native/SonyProtocol/src/SonyProtocolSession.cpp`
- [Frame codec](https://github.com/artistro08/sony-control/blob/main/native/SonyProtocol/src/FrameCodec.cpp): `native/SonyProtocol/src/FrameCodec.cpp`
- [Protocol generations](https://github.com/artistro08/sony-control/blob/main/native/SonyProtocol/src/ProtocolV1.cpp): `native/SonyProtocol/src/ProtocolV1.cpp`
- [Device profiles](https://github.com/artistro08/sony-control/blob/main/native/SonyProtocol/src/DeviceProfileRegistry.cpp): `native/SonyProtocol/src/DeviceProfileRegistry.cpp`
- [Device event dispatcher](https://github.com/artistro08/sony-control/blob/main/native/SonyProtocol/src/DeviceEventDispatcher.cpp): `native/SonyProtocol/src/DeviceEventDispatcher.cpp`

### Bluetooth transport

- [Windows RFCOMM transport](https://github.com/artistro08/sony-control/blob/main/native/SonyTransport/src/WindowsRfcommTransport.cpp): `native/SonyTransport/src/WindowsRfcommTransport.cpp`

### Other components

- **Windows user**
- **Sony Bluetooth headset**

## Connections

- Windows user → Tray and flyout UI: uses
- App startup and composition → Headset manager: creates
- App startup and composition → Flyout view model: creates
- App startup and composition → Settings view model: creates
- App startup and composition → Windows notifications: registers
- Tray and flyout UI → Flyout view model: presents
- Settings UI → Settings view model: edits settings
- Flyout view model → Headset manager: observes devices
- Flyout view model → Headset view model: creates
- Headset manager → Bluetooth device watcher: starts watching
- Bluetooth device watcher → Headset manager: reports devices
- Headset manager → Managed headset: tracks
- Headset manager → App settings: reads preferences
- Headset manager → WinRT headset adapter: connects headset
- Headset view model → WinRT headset adapter: controls headset
- Headset view model → Low battery monitor: monitors level
- Low battery monitor → Windows notifications: shows alert
- Settings view model → App settings: updates preferences
- WinRT headset adapter → Native headset client: calls native API
- Native headset client → Headset controller: runs commands
- Native headset client → Bluetooth audio control: controls audio link
- Headset controller → Protocol session: opens session
- Headset controller → Protocol generations: dispatches commands
- Headset controller → Device profiles: selects profile
- Headset controller → Device event dispatcher: publishes state
- Protocol session → Frame codec: encodes frames
- Protocol session → Windows RFCOMM transport: transfers bytes
- Windows RFCOMM transport → Sony Bluetooth headset: Bluetooth link
