ym2151-log-editor

YM2151 Log Editor - Implementation Plan

Project Overview

A TUI-based JSON editor for YM2151 event logs, written in Rust for Windows. The application provides visualization and editing capabilities for YM2151 synthesizer event data.

Goals (Jumpstart)

  1. ✅ Create foundational project structure (reference: ym2151-tone-editor)
  2. ✅ Create implementation plan document (this document)
  3. ✅ Implement simple initial Rust implementation

Features Implemented (v0.1.0)

Core Functionality

UI Components

Technology Stack

Architecture

Module Structure

src/
├── main.rs          - Entry point, terminal setup, event loop
├── app.rs           - Application state and business logic
├── models.rs        - Data structures (Ym2151Event, Ym2151Log)
└── ui.rs            - UI rendering logic

Data Models

Ym2151Event

Ym2151Log

TimeDisplayMode

Key Features Detail

1. KeyON Display Conversion

Events with address 0x08 are displayed as “KeyON” instead of the register address to improve readability. This register controls note on/off operations in YM2151.

Format: {time} KeyON {data}

2. Time Display Toggle (T Key)

Two modes for time visualization:

Cumulative Mode (default):

Timestamp Mode:

Toggle with T key during runtime.

3. JSON File Operations

Loading:

ym2151-log-editor path/to/file.json

Saving:

User Interface

Keyboard Controls

| Key | Action | |—–|——–| | ↑/↓ | Navigate through events | | / or ENTER | Insert new event before current line | | DELETE | Delete current event | | 0-9 | Set wait time (0-9ms, Cumulative mode only) | | P | Preview playback from start to current event | | T | Toggle time display mode | | S | Save current file | | Q/ESC | Quit application |

Display Layout

┌─────────────────────────────────────┐
│ YM2151 Log Editor - filename        │
│ Time: Cumulative/Timestamp          │
├─────────────────────────────────────┤
│ Event list (scrollable)             │
│ > 0.000000  20  4F                  │
│   0.010000  KeyON  78               │
│   ...                               │
├─────────────────────────────────────┤
│ ↑/↓: Navigate | T: Toggle | S: Save│
└─────────────────────────────────────┘

Future Enhancements (Not Yet Implemented)

Phase 2: Editing Capabilities

Phase 3: Advanced Features

Phase 4: Quality of Life

Phase 5: Integration

Build and Run

Prerequisites

Build

cargo build --release

Run

# With file argument
cargo run -- path/to/file.json

# Or run compiled binary
./target/release/ym2151-log-editor path/to/file.json

Development

# Run in development mode
cargo run -- test_data/sample.json

# Run tests (when implemented)
cargo test

# Check code
cargo clippy
cargo fmt

Testing Strategy

Current Test Data

Future Test Coverage

Known Limitations

  1. No Time Editing: Current version only displays, cannot edit time values
  2. Read-only Data: Cannot modify register addresses or data values
  3. No Undo: No undo/redo functionality
  4. Single File: Can only work with one file at a time
  5. No Audio Preview: No integration with YM2151 playback server yet

Dependencies

Core Dependencies

ratatui = "0.29"      # TUI framework
crossterm = "0.29"    # Terminal backend
serde = "1.0"         # Serialization framework
serde_json = "1.0"    # JSON support

References

Version History

v0.1.0 (Current - Jumpstart)

Conclusion

This jumpstart implementation provides a solid foundation for the YM2151 Log Editor. The core visualization and file handling features are working, and the architecture is designed to easily accommodate future enhancements for editing capabilities.

The main use case of “JSON visualization and easier time field editing” has a strong foundation with the time toggle feature, though actual editing of time values will be added in Phase 2.