Skip to content

kako-jun/xsg

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

46 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

XSG - Signal Generator

XSG is a professional test pattern generator for display calibration and testing. It provides accurate color bars, grayscale, checkerboard, and other patterns typically found in expensive broadcast signal generators.

๐Ÿ“ฆ Architecture

XSG is built with a modern frontend/backend architecture:

  • Frontend: Vite + React + TypeScript + Tailwind CSS
  • Backend: FastAPI + PyWebView (desktop application wrapper)
  • Deployment: Static export for web, or packaged desktop app with PyInstaller
xsg/
โ”œโ”€โ”€ frontend/          # Vite + React application
โ”‚   โ”œโ”€โ”€ src/
โ”‚   โ”‚   โ”œโ”€โ”€ components/  # React components
โ”‚   โ”‚   โ”œโ”€โ”€ lib/         # Utilities and types
โ”‚   โ”‚   โ””โ”€โ”€ main.tsx     # Application entry
โ”‚   โ”œโ”€โ”€ public/          # Static assets
โ”‚   โ””โ”€โ”€ vite.config.ts
โ””โ”€โ”€ backend/           # FastAPI + PyWebView wrapper
    โ”œโ”€โ”€ app/
    โ”‚   โ””โ”€โ”€ main.py      # Desktop application
    โ”œโ”€โ”€ pyproject.toml   # uv dependencies
    โ””โ”€โ”€ build.bat/sh     # Build scripts

โœจ Features

  • ๐ŸŽจ Accurate Test Patterns: SMPTE color bars, grayscale, checkerboard, and more
  • ๐Ÿ–ฅ๏ธ Fullscreen Desktop App: Frameless, fullscreen window (PyWebView)
  • ๐Ÿ“บ Multi-Display Support: Display patterns across multiple monitors with flexible selection
  • ๐ŸŒ Web Version: Also runs in browser for quick testing
  • ๐Ÿ”ง Flexible Configuration: YAML-based pattern definitions
  • ๐Ÿ” Pixel Defect Simulation: Unique testing capability
  • โšก REST API: Control patterns via FastAPI backend
  • ๐Ÿ”’ Single Instance: Only one instance runs; duplicate launches change pattern in existing window
  • ๐ŸŽฏ Professional Grade: Designed to replace costly hardware signal generators

๐ŸŽฏ Supported Patterns

Color Bars

Pattern Description Query Parameter
SMPTE Color Bars Standard color bars (75%) ?pattern=colorbar or ?pattern=smpte
EBU Color Bars European Broadcasting Union bars ?pattern=ebu
ARIB Color Bars Japanese standard (ARIB) bars ?pattern=arib

Grayscale & Gradients

Pattern Description Query Parameter
Grayscale 16-step grayscale ?pattern=grayscale
Staircase 21-step staircase (0-100% in 5% steps) ?pattern=staircase
Vertical Gradient Smooth vertical gradient (256 steps default) ?pattern=verticalgradient or ?pattern=vgradient
Horizontal Gradient Smooth horizontal gradient (256 steps default) ?pattern=horizontalgradient or ?pattern=hgradient

Note: Gradient patterns support ?steps=N parameter (e.g., ?pattern=vgradient&steps=16)

Solid Colors

Pattern Description Query Parameter
White Pure white field ?pattern=white
Black Pure black field ?pattern=black
Red Pure red field ?pattern=red
Green Pure green field ?pattern=green
Blue Pure blue field ?pattern=blue
Cyan Pure cyan field ?pattern=cyan
Magenta Pure magenta field ?pattern=magenta
Yellow Pure yellow field ?pattern=yellow

Note: Use ?pattern=solid&color=HEXCODE for custom colors (e.g., ?pattern=solid&color=%23FF5733)

Geometric Patterns

Pattern Description Query Parameter
Checkerboard Black & white checkerboard (50px) ?pattern=checker
Cross-hatch Grid pattern (50px, 1px lines) ?pattern=crosshatch
Cross-hatch 2px Grid pattern (50px, 2px lines) ?pattern=crosshatch2px
Convergence Alignment grid with center crosshair ?pattern=convergence

Professional Test Patterns

Pattern Description Query Parameter
PLUGE Black level adjustment pattern ?pattern=pluge
Multiburst Frequency response test ?pattern=multiburst
Pixel Defect Simulated dead/stuck pixels ?pattern=pixeldefect

๐Ÿš€ Quick Start

Web Version (Development)

cd frontend
npm install
npm run dev

Open http://localhost:3000 in your browser.

Display Patterns

Quick Access:

  • Desktop: Press 'M' key to toggle the pattern selection menu (ESC to close)
  • Mobile: Tap the menu button (โ˜ฐ) in the bottom-right corner

Navigate to the URL with the desired pattern:

Color Bars:

Grayscale & Gradients:

Solid Colors:

Geometric Patterns:

Professional Test Patterns:

Desktop Application (Development)

# Terminal 1: Start frontend dev server
cd frontend
npm run dev

# Terminal 2: Start backend with PyWebView
cd backend
uv sync
uv run python -m app.main --dev

Or use the dev scripts:

# Windows
cd backend
dev.bat

# Linux/macOS
cd backend
chmod +x dev.sh
./dev.sh

Production Build

# Build frontend
cd frontend
npm run build

# Package desktop application
cd ../backend
uv sync
uv pip install pyinstaller

# Windows
build.bat

# Linux/macOS
chmod +x build.sh
./build.sh

The packaged application will be in backend/dist/.

๐ŸŽฎ Command Line Options

Pattern Selection

You can specify the initial pattern when launching XSG:

# Start with a specific pattern
uv run python -m app.main --dev --pattern checker
uv run python -m app.main --dev --pattern colorbar
uv run python -m app.main --dev --pattern vgradient

Available options:

  • --dev: Development mode (uses Vite dev server at http://localhost:3000)
  • --pattern PATTERN: Initial pattern to display (default: colorbar)
  • --port PORT: API server port (default: 8000)
  • --display SPEC: Display selection (default: all) - see Multi-Display Support section
  • --list-displays: List all available displays and exit
  • --api-only: Run API server only without GUI

Single Instance Control

XSG runs only one instance at a time. If you try to launch a second instance:

  1. The new process detects the existing instance
  2. Sends the --pattern argument to the running instance via API
  3. The existing window changes to display the new pattern
  4. The new process exits

Example:

# Terminal 1: Launch XSG with colorbar
uv run python -m app.main --dev --pattern colorbar

# Terminal 2: Try to launch with checker
uv run python -m app.main --dev --pattern checker
# โ†’ The window from Terminal 1 switches to checker pattern
# โ†’ Terminal 2 process exits after sending the command

This ensures only one fullscreen window is displayed at a time.

๐Ÿ–ฅ๏ธ Multi-Display Support

XSG supports displaying test patterns across multiple monitors simultaneously or on selected displays.

Listing Available Displays

Before selecting displays, you can list all available monitors:

uv run python -m app.main --list-displays

Example output:

[INFO] Available displays:

  Display 1: 2560x1440 at (0, 0) (Primary)
  Display 2: 2560x1440 at (-2560, 0)
  Display 3: 1920x1080 at (2560, 0)

Position-based groups:
  Left-to-right: 3 groups
    left-1: 2560x1440
    left-2: 2560x1440
    left-3: 1920x1080
  Top-to-bottom: 1 groups
    top-1: 2560x1440, 2560x1440, 1920x1080

Display Selection

Use the --display option to select which displays to use:

# Display on all monitors (default)
uv run python -m app.main --dev --display all

# Display on primary monitor only
uv run python -m app.main --dev --display primary

# Display on leftmost monitor(s)
uv run python -m app.main --dev --display left

# Display on second monitor from left
uv run python -m app.main --dev --display left-2

# Display on rightmost monitor(s)
uv run python -m app.main --dev --display right

# Display on topmost monitor(s)
uv run python -m app.main --dev --display top

# Display on second monitor from top
uv run python -m app.main --dev --display top-2

# Display on bottommost monitor(s)
uv run python -m app.main --dev --display bottom

# Multiple selections (comma-separated)
uv run python -m app.main --dev --display "left,right"

Display Grouping

Monitors are grouped by their position:

  • Left-to-right groups: Monitors with the same X coordinate form one group
  • Top-to-bottom groups: Monitors with the same Y coordinate form one group

Example:

If you have monitors arranged like this:

[Monitor 1: 1920x1080 at (0, 0)]
[Monitor 2: 1920x1080 at (0, 1080)]  <- Same X as Monitor 1
[Monitor 3: 2560x1440 at (1920, 0)]

Groups would be:

  • left-1: Monitor 1, Monitor 2 (both at X=0)
  • left-2: Monitor 3 (at X=1920)
  • top-1: Monitor 1, Monitor 3 (both at Y=0)
  • top-2: Monitor 2 (at Y=1080)

Important: When you specify top-2, it will create windows on all monitors in that group (e.g., both Monitor 1 and Monitor 2 if they share the same Y coordinate).

โš™๏ธ Configuration

Patterns can be customized using YAML configuration files in public/patterns/. See public/patterns/default.yaml for examples.

Example YAML Configuration

patterns:
  - name: colorbar
    type: colorbar
    description: SMPTE Color Bars
    colors:
      - "#C0C0C0" # White (75%)
      - "#C0C000" # Yellow
      - "#00C0C0" # Cyan
      - "#00C000" # Green
      - "#C000C0" # Magenta
      - "#C00000" # Red
      - "#0000C0" # Blue

  - name: pixeldefect
    type: pixeldefect
    description: Simulated pixel defects
    defectCount: 50

๐Ÿ› ๏ธ Tech Stack

Frontend

Backend

๐ŸŽจ Use Cases

  • Display calibration and color accuracy testing
  • Dead pixel detection
  • Monitor burn-in testing
  • Video signal troubleshooting
  • Broadcast equipment testing
  • Cost-effective alternative to hardware signal generators

๐ŸŒ Why XSG?

Professional signal generators can cost thousands of dollars. XSG provides the same functionality in a free application that works as a browser app or desktop application.

Our pixel defect simulation feature is unique - even expensive hardware generators don't offer this capability, making XSG a valuable tool for quality assurance and testing.

๐Ÿ”Œ API Endpoints

XSG includes a FastAPI backend with the following endpoints:

  • GET / - API information
  • GET /api/patterns - List all available patterns
  • GET /api/patterns/{pattern_id} - Get specific pattern info
  • POST /api/gamma - Set gamma correction settings
  • GET /api/gamma - Get current gamma settings

Example:

curl http://localhost:8000/api/patterns

๐Ÿ“ Future Plans

  • โœ… Vite + React frontend
  • โœ… FastAPI backend
  • โœ… PyWebView desktop wrapper
  • โœ… Multi-display support
  • โœ… Single instance control
  • ๐Ÿ”„ OS-level gamma correction control
  • ๐Ÿ”„ Custom pattern editor
  • ๐Ÿ”„ Pattern animation support
  • ๐Ÿ”„ More advanced patterns (Zone Plate, Needle, etc.)

๐Ÿ“„ License

MIT License - see LICENSE file for details

๐Ÿ‘ค Author

kako-jun

๐Ÿค Contributing

Contributions, issues, and feature requests are welcome!

โญ Show Your Support

Give a โญ๏ธ if this project helped you!

About

Test pattern generator for display calibration with SMPTE color bars, grayscale, and pixel defect simulation

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors