A Python tool to convert text event encodings in MIDI files. Supports conversion between various character encodings such as Shift_JIS, GBK, UTF-8, and more.
- 🎵 Convert text encodings in MIDI files (lyrics, track names, markers, etc.)
- 🔍 Auto-detect source file encoding (requires
chardet) - 🌐 Bilingual interface (Chinese/English)
- 🎨 Modern dark theme GUI
- 📁 Drag & drop file support
- 💻 Pure Python implementation - no external dependencies required for basic usage
- 📦 Pre-built Windows executable available
Download the latest MIDI_Encoder.exe from Releases page. Just double-click to run - no Python installation required.
# Clone repository
git clone https://github.com/mason369/midi-encoding-converter.git
cd midi-encoding-converter
# Install dependencies (optional, for encoding detection)
pip install chardet
# Install GUI dependencies
pip install PyQt6
# Run GUI
python midi_converter_standalone.py- Run the program, drag & drop a MIDI file or click "Browse" to select
- The program will auto-detect source encoding
- Select target encoding (default: UTF-8)
- Click "Convert"
- Choose save location
# Basic usage: Convert from Shift_JIS to UTF-8
python midi_encoding_converter.py input.mid
# Specify output file
python midi_encoding_converter.py input.mid -o output.mid
# Convert from GBK to UTF-8
python midi_encoding_converter.py input.mid -f gbk -t utf-8
# Detect encoding only
python midi_encoding_converter.py input.mid --detect
# Verbose output
python midi_encoding_converter.py input.mid -v| Option | Description |
|---|---|
input |
Input MIDI file (required) |
-o, --output |
Output MIDI file (default: input_converted.mid) |
-f, --from-encoding |
Source encoding (default: shift_jis) |
-t, --to-encoding |
Target encoding (default: utf-8) |
-d, --detect |
Detect encoding only, do not convert |
-v, --verbose |
Show verbose output |
--version |
Show version number |
from midi_encoding_converter import MidiEncodingConverter, detect_encoding
# Detect encoding
encodings = detect_encoding('input.mid')
for encoding, confidence in encodings:
print(f"{encoding}: {confidence:.1%}")
# Convert encoding
converter = MidiEncodingConverter(from_encoding='shift_jis', to_encoding='utf-8')
result = converter.convert('input.mid', 'output.mid')
print(f"Converted {result['converted']} text events")| Encoding | Common Use |
|---|---|
utf-8 |
Universal |
shift_jis / cp932 |
Japanese |
gbk / gb2312 / gb18030 |
Chinese (Simplified) |
big5 |
Chinese (Traditional) |
euc-kr / cp949 |
Korean |
iso-8859-1 / latin-1 |
Western European |
cp1252 |
Windows Western |
The converter handles the following MIDI meta event types:
| Type | Hex | Description |
|---|---|---|
| Text Event | 0x01 | General text |
| Copyright | 0x02 | Copyright notice |
| Track Name | 0x03 | Track/sequence name |
| Instrument | 0x04 | Instrument name |
| Lyric | 0x05 | Song lyrics |
| Marker | 0x06 | Marker text |
| Cue Point | 0x07 | Cue point text |
- Parse MIDI file binary structure
- Identify text meta events
- Auto-detect or use specified source encoding to decode text
- Re-encode to target encoding
- Recalculate track lengths
- Write converted MIDI file
- MIDI Encoding Test Repository - MIDI encoding test resources
- MidiShow Community Discussion - Discussion about MIDI encoding issues
- Added auto-detect source encoding
- Added bilingual interface (Chinese/English)
- Improved GUI design
- Added GitHub Actions auto-release
- Initial release
- Support for all text meta events
- Encoding detection feature
- Command line interface
MIT License
Issues and Pull Requests are welcome!
Inspired by midiiconv (Go implementation).