Files
SoulX-Singer/preprocess/tools/midi_editor/README.md
T

171 lines
5.3 KiB
Markdown
Raw Normal View History

2026-02-06 20:31:14 +08:00
# 🎹 MIDI Editor - Web-based Singing MIDI Editor
[English](README.md) | [简体中文](README_CN.md)
A full-featured web MIDI editor for singing voice preprocess. It supports real-time drag editing of MIDI notes, lyric editing, audio waveform alignment, and importing/exporting MIDI files with lyrics.
2026-02-06 20:31:14 +08:00
![MIDI Editor](https://img.shields.io/badge/React-19.2-blue) ![TypeScript](https://img.shields.io/badge/TypeScript-5.9-blue) ![Vite](https://img.shields.io/badge/Vite-7.2-purple)
## ✨ Features
### 🎼 Piano Roll Editing
2026-02-11 20:32:44 +08:00
- **Visual note editing**: Full range from C1 to C8 with intuitive piano key layout
2026-02-06 20:31:14 +08:00
- **Drag operations**:
- Move notes: drag note blocks to adjust position and pitch
- Resize start: drag the left edge to adjust start time
- Resize end: drag the right edge to adjust end time
2026-02-11 20:32:44 +08:00
- **Quick pitch adjust**:
- Command/Ctrl + Up/Down to nudge selected note pitch
- Use the Transpose control in the toolbar to shift all notes at once
2026-02-06 20:31:14 +08:00
- **Double-click to add**: Add new notes quickly in empty areas
2026-02-11 20:32:44 +08:00
- **Piano key preview**: Click a key on the left to audition the pitch
2026-02-06 20:31:14 +08:00
### 🔍 Zoom & Navigation
- **Horizontal zoom**
- **Vertical zoom**
- **Dynamic snapping**: finer snap granularity at higher zoom (min 0.01s)
- **Auto scroll**: keep the playhead visible during playback
### 📝 Lyric Editing
- **Inline editing**: edit lyrics for each note in the side list
2026-02-11 20:32:44 +08:00
- **Batch fill**: enter lyrics and auto-fill notes in order
- **Fill from selection**: start batch fill from the currently selected note
2026-02-06 20:31:14 +08:00
- **Precise fields**: edit PITCH, START, and END directly
2026-02-11 20:32:44 +08:00
- **Confirm edits**: press Enter or click ✓ to confirm, avoiding accidental changes
2026-02-06 20:31:14 +08:00
### 🎵 Audio Alignment
2026-02-11 20:32:44 +08:00
- **Waveform display**: import audio to display waveform, synced with the MIDI timeline
2026-02-06 20:31:14 +08:00
- **Formats**: MP3, WAV, OGG, FLAC, M4A, AAC
- **Sync playback**: play audio and MIDI together with independent volume control
2026-02-06 20:31:14 +08:00
- **Click to seek**: click waveform or timeline to seek
### ⚠️ Overlap Detection
- **Visual highlight**: overlapping notes blink in red
- **One-click fix**: remove all overlaps automatically
### 📥 Import & Export
2026-02-11 20:32:44 +08:00
- **MIDI import**: parse standard MIDI files with automatic lyric metadata extraction
- **MIDI export**: export MIDI files with lyric information
2026-02-06 20:31:14 +08:00
### 🎨 UI & UX
- **Theme toggle**: light and dark modes
- **Responsive layout**: adapts to window size
- **SVG grid**: cross-browser grid rendering
- **Status feedback**: real-time state and error tips
## 🚀 Quick Start
### Requirements
- Node.js 18+
- npm or yarn
### Install
```bash
# Install dependencies
npm install
# Start dev server
npm run dev
# Expose to LAN
npm run dev -- --host 0.0.0.0
```
### Build
```bash
# Build for production
npm run build
# Preview build
npm run preview
```
## 📖 Usage
### Basic Workflow
1. **Import MIDI**: click Import MIDI and select a .mid file
2. **Edit notes**: drag notes in the piano roll to adjust time and pitch
2026-02-11 20:32:44 +08:00
3. **Add lyrics**: edit lyrics in the right-side list, or use batch fill
4. **Align audio** (optional): import reference audio for side-by-side editing
5. **Export**: click Export MIDI to save
2026-02-06 20:31:14 +08:00
### Shortcuts
| Action | Description |
|------|------|
| Double-click piano roll | Add a new note |
| Double-click note | Edit lyric |
| Drag note | Move note and pitch |
| Drag note edges | Resize note |
| Backspace / Delete | Delete selected note |
| Enter | Confirm value edits |
| Escape | Cancel value edits |
| Ctrl(Command) + Wheel | Horizontal zoom |
| Ctrl(Command) + Shift(Option) + Wheel | Vertical zoom |
### Playback Controls
| Button | Description |
|------|------|
| ⏮ | Go to start |
2026-02-11 20:32:44 +08:00
| ⏪ | Back 2 seconds |
2026-02-06 20:31:14 +08:00
| ▶ / ⏸ | Play / Pause |
2026-02-11 20:32:44 +08:00
| ⏩ | Forward 2 seconds |
2026-02-06 20:31:14 +08:00
| ⏭ | Go to end |
| Selection | Play selected region |
2026-02-06 20:31:14 +08:00
## 🛠 Tech Stack
- **Frontend**: React 19 + TypeScript
- **Build**: Vite 7
- **State**: Zustand
- **Audio**: Tone.js
- **Waveform**: WaveSurfer.js
- **MIDI**: @tonejs/midi
- **Styles**: CSS with custom variables
## 📁 Project Structure
```
.
├── eslint.config.js
├── index.html
├── package.json
├── postcss.config.js
├── README.md
├── README_CN.md
├── tailwind.config.js
├── tsconfig.app.json
├── tsconfig.json
├── tsconfig.node.json
├── vite.config.ts
├── public/
└── src/
2026-02-11 20:32:44 +08:00
├── App.css # Main styles (theme variables, layout, components)
├── App.tsx # Main app component (transport, import/export, transpose)
├── constants.ts # Constants (grid width, row height, pitch range)
├── i18n.ts # Internationalization (zh/en translations, smart lyric tokenizer)
├── index.css # Global styles (Tailwind, root font, theme gradients)
├── main.tsx # React entry point
├── types.ts # Type definitions (NoteEvent, TimeSignature, etc.)
2026-02-06 20:31:14 +08:00
├── components/
2026-02-11 20:32:44 +08:00
│ ├── AudioTrack.tsx # Audio waveform display component
│ ├── LyricTable.tsx # Lyric editing table component
│ └── PianoRoll.tsx # Piano roll editor component
2026-02-06 20:31:14 +08:00
├── lib/
2026-02-11 20:32:44 +08:00
│ └── midi.ts # MIDI import/export utilities (UTF-8 lyric encoding)
2026-02-06 20:31:14 +08:00
└── store/
2026-02-11 20:32:44 +08:00
└── useMidiStore.ts # Zustand state management
```