@karaplay/file-coder 1.4.8 โ 1.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/DEMO_ENHANCED.md +168 -0
- package/DEMO_FIXED.md +57 -0
- package/DEMO_GUIDE.md +204 -0
- package/DEMO_README.md +193 -0
- package/DEMO_WORKING.md +157 -0
- package/RELEASE_v1.4.9.md +144 -0
- package/RELEASE_v1.5.0.md +91 -0
- package/WHY_DURATION_DECREASES.md +176 -0
- package/analyze-cursor-pattern.js +131 -0
- package/analyze-emk-cursor.js +169 -0
- package/analyze-emk-simple.js +124 -0
- package/analyze-tempo-duration.js +243 -0
- package/calculate-correct-ratio.js +97 -0
- package/check-real-duration.js +69 -0
- package/compare-kar-lyrics-timing.js +110 -0
- package/demo-client.html +722 -0
- package/demo-server.js +184 -0
- package/demo-simple.html +712 -0
- package/dist/emk-to-kar.browser.js +7 -4
- package/dist/emk-to-kar.js +7 -6
- package/dist/ncntokar.browser.d.ts +2 -1
- package/dist/ncntokar.browser.js +5 -3
- package/dist/ncntokar.d.ts +2 -1
- package/dist/ncntokar.js +6 -4
- package/find-zxio-tempo-ratio.js +118 -0
- package/match-cursor-to-lyrics.js +118 -0
- package/package.json +6 -2
- package/songs/emk/001_original_emk.emk +0 -0
- package/songs/fix/001_kar_convert_needtofix_tempo_fast.kar +0 -0
- package/songs/fix/001_original_emk.emk +0 -0
- package/temp/test_output.kar +0 -0
- package/test-all-emk-durations.js +109 -0
- package/test-all-emk-final.js +97 -0
- package/test-convert-001.js +130 -0
- package/analyze-failed-emk.js +0 -156
- package/check-gr.js +0 -19
- package/debug-emk-blocks.js +0 -123
- package/debug-midi-source.js +0 -108
- package/debug-tempo.js +0 -135
- package/debug-timing.js +0 -159
- package/find-midi-in-block.js +0 -96
- package/fix-tempo.js +0 -155
- package/kar-diagnostic.js +0 -158
package/DEMO_ENHANCED.md
ADDED
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
# โจ Demo Enhanced with EMK Analysis & Comparison
|
|
2
|
+
|
|
3
|
+
## ๐ฏ New Features Added
|
|
4
|
+
|
|
5
|
+
### 1. **EMK File Analysis** (Before Conversion)
|
|
6
|
+
When you select an EMK file, it now automatically analyzes:
|
|
7
|
+
- โ
Title and Artist (Thai encoding)
|
|
8
|
+
- โ
Format type (ZXIO or MThd)
|
|
9
|
+
- โ
**Original Tempo** (BPM)
|
|
10
|
+
- โ
**Original Duration** (seconds and minutes)
|
|
11
|
+
- โ
PPQ (Ticks per beat)
|
|
12
|
+
- โ
Number of tracks
|
|
13
|
+
- โ
Number of notes
|
|
14
|
+
- โ
Lyric and cursor data size
|
|
15
|
+
|
|
16
|
+
### 2. **Comparison Table** (EMK vs KAR)
|
|
17
|
+
After conversion, see a detailed comparison:
|
|
18
|
+
- ๐ Format changes
|
|
19
|
+
- ๐ Tempo ratio (e.g., 2.78x for ZXIO, 4x for MThd)
|
|
20
|
+
- ๐ Duration changes
|
|
21
|
+
- ๐ Tempo verification (โ
or โ ๏ธ)
|
|
22
|
+
- ๐ Track and note count
|
|
23
|
+
- ๐ Visual indicators for increases/decreases
|
|
24
|
+
|
|
25
|
+
## ๐ How to Use
|
|
26
|
+
|
|
27
|
+
### Step 1: Open Demo
|
|
28
|
+
```
|
|
29
|
+
http://localhost:3000/demo-simple.html
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
### Step 2: Select EMK File
|
|
33
|
+
- Click on any EMK file
|
|
34
|
+
- **Wait for automatic analysis** (1-2 seconds)
|
|
35
|
+
- See original EMK info displayed
|
|
36
|
+
|
|
37
|
+
### Step 3: Convert to KAR
|
|
38
|
+
- Click "Convert to KAR"
|
|
39
|
+
- Wait for conversion
|
|
40
|
+
- See converted KAR info
|
|
41
|
+
|
|
42
|
+
### Step 4: View Comparison Table
|
|
43
|
+
- Automatically displays after conversion
|
|
44
|
+
- Compare original vs converted values
|
|
45
|
+
- Verify tempo ratio is correct
|
|
46
|
+
|
|
47
|
+
### Step 5: Download & Test
|
|
48
|
+
- Click "Download KAR" to save file
|
|
49
|
+
- Test with external karaoke player
|
|
50
|
+
|
|
51
|
+
## ๐ Sample Comparison Table
|
|
52
|
+
|
|
53
|
+
```
|
|
54
|
+
โโโโโโโโโโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโ
|
|
55
|
+
โ Property โ Original EMK โ Converted KAR โ Change โ
|
|
56
|
+
โโโโโโโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโค
|
|
57
|
+
โ Format โ ZXIO โ ZXIO โ Same โ
|
|
58
|
+
โ Tempo (BPM) โ 64.00 โ 178.09 โ ร2.78 (increase)โ
|
|
59
|
+
โ Duration (seconds) โ 351.56 โ 126.34 โ ร0.36 (decrease)โ
|
|
60
|
+
โ Duration (minutes) โ 5.86 โ 2.11 โ 64.1% shorter โ
|
|
61
|
+
โ PPQ โ 96 โ Same โ Unchanged โ
|
|
62
|
+
โ Tracks โ 25 โ Same + Karaoke โ +1 (lyrics) โ
|
|
63
|
+
โ Notes โ 6313 โ 6313 โ Same โ
|
|
64
|
+
โ Tempo Ratio โ - โ 2.78x โ โ
Correct โ
|
|
65
|
+
โโโโโโโโโโโโโโโโโโโโโโโโดโโโโโโโโโโโโโโโโโโดโโโโโโโโโโโโโโโโโโดโโโโโโโโโโโโโโโโโโ
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
## ๐ฏ What to Verify
|
|
69
|
+
|
|
70
|
+
### ZXIO Format (001.emk, failed01.emk)
|
|
71
|
+
**Original EMK:**
|
|
72
|
+
- Tempo: 64 BPM
|
|
73
|
+
- Duration: ~5.86 minutes (351 seconds)
|
|
74
|
+
|
|
75
|
+
**Converted KAR:**
|
|
76
|
+
- Tempo: **178.09 BPM** (2.78x)
|
|
77
|
+
- Duration: **~2.11 minutes** (126 seconds)
|
|
78
|
+
- Tempo Ratio: โ
**Correct (2.78x)**
|
|
79
|
+
|
|
80
|
+
### MThd Format (Z2510001.emk)
|
|
81
|
+
**Original EMK:**
|
|
82
|
+
- Tempo: 67 BPM
|
|
83
|
+
- Duration: Variable
|
|
84
|
+
|
|
85
|
+
**Converted KAR:**
|
|
86
|
+
- Tempo: **268 BPM** (4x)
|
|
87
|
+
- Duration: Adjusted proportionally
|
|
88
|
+
- Tempo Ratio: โ
**Correct (4x)**
|
|
89
|
+
|
|
90
|
+
## ๐ New API Endpoint
|
|
91
|
+
|
|
92
|
+
### POST `/api/analyze-emk`
|
|
93
|
+
Analyze EMK file before conversion
|
|
94
|
+
|
|
95
|
+
**Request:**
|
|
96
|
+
```json
|
|
97
|
+
{
|
|
98
|
+
"filename": "001.emk"
|
|
99
|
+
}
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
**Response:**
|
|
103
|
+
```json
|
|
104
|
+
{
|
|
105
|
+
"success": true,
|
|
106
|
+
"emkInfo": {
|
|
107
|
+
"format": "ZXIO",
|
|
108
|
+
"title": "เธเธเธเธฃเธฐเธเธญเธ",
|
|
109
|
+
"artist": "เธเธธเนเธ เธจเธธเธ เธเธฒเธเธเธเน",
|
|
110
|
+
"tempo": "64.00",
|
|
111
|
+
"duration": "351.56",
|
|
112
|
+
"durationMinutes": "5.86",
|
|
113
|
+
"ppq": 96,
|
|
114
|
+
"tracks": 25,
|
|
115
|
+
"notes": 6313,
|
|
116
|
+
"hasLyrics": 3456,
|
|
117
|
+
"hasCursor": 3742
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
## ๐ Visual Indicators
|
|
123
|
+
|
|
124
|
+
### Tempo Ratio Status
|
|
125
|
+
- โ
**Correct (2.78x)** - ZXIO format with correct tempo
|
|
126
|
+
- โ
**Correct (~4x)** - MThd format with correct tempo
|
|
127
|
+
- โ ๏ธ **Unexpected** - Tempo ratio doesn't match expected value
|
|
128
|
+
|
|
129
|
+
### Change Indicators
|
|
130
|
+
- ๐ก **Yellow badge** - Increase (tempo, duration)
|
|
131
|
+
- ๐ข **Green badge** - Decrease (expected for ZXIO duration)
|
|
132
|
+
- โช **Gray badge** - Same/Unchanged
|
|
133
|
+
|
|
134
|
+
## ๐ Benefits
|
|
135
|
+
|
|
136
|
+
### For Testing
|
|
137
|
+
1. **Before/After Comparison** - See exact changes from conversion
|
|
138
|
+
2. **Tempo Verification** - Confirm correct ratio is applied
|
|
139
|
+
3. **Duration Accuracy** - Verify music length is correct
|
|
140
|
+
4. **Format Detection** - Ensure ZXIO vs MThd is identified correctly
|
|
141
|
+
|
|
142
|
+
### For Documentation
|
|
143
|
+
1. **Clear Evidence** - Shows conversion works correctly
|
|
144
|
+
2. **Ratio Validation** - Proves 2.78x (ZXIO) and 4x (MThd) formulas
|
|
145
|
+
3. **Quality Assurance** - Demonstrates accurate metadata preservation
|
|
146
|
+
|
|
147
|
+
### For Debugging
|
|
148
|
+
1. **Original Values** - Reference point for troubleshooting
|
|
149
|
+
2. **Detailed Metrics** - Track count, note count, PPQ
|
|
150
|
+
3. **Format Info** - Identify which conversion path was used
|
|
151
|
+
|
|
152
|
+
## ๐ Ready to Test!
|
|
153
|
+
|
|
154
|
+
**Server is running at:**
|
|
155
|
+
```
|
|
156
|
+
http://localhost:3000/demo-simple.html
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
**Try it now:**
|
|
160
|
+
1. Select **001.emk** (ZXIO format)
|
|
161
|
+
2. See original info: 64 BPM, 5.86 minutes
|
|
162
|
+
3. Convert to KAR
|
|
163
|
+
4. See comparison: 178.09 BPM, 2.11 minutes
|
|
164
|
+
5. Verify: โ
Tempo Ratio 2.78x Correct!
|
|
165
|
+
|
|
166
|
+
---
|
|
167
|
+
|
|
168
|
+
**Perfect for demonstrating v1.4.9 fixes! ๐คโจ**
|
package/DEMO_FIXED.md
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
# โ
Demo Fixed!
|
|
2
|
+
|
|
3
|
+
## ๐ Issue Resolved
|
|
4
|
+
|
|
5
|
+
**Problem:** `demo.html` tried to import from local `node_modules` which browsers cannot access directly:
|
|
6
|
+
```javascript
|
|
7
|
+
// โ This doesn't work in browser
|
|
8
|
+
import { KaraokePlayer } from './node_modules/karaoke-player/dist/index.js';
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
**Solution:** Use `demo-client.html` instead, which uses CDN:
|
|
12
|
+
```javascript
|
|
13
|
+
// โ
This works!
|
|
14
|
+
import { Player } from 'https://cdn.jsdelivr.net/npm/karaoke-player@latest/dist/index.min.js';
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
## ๐ How to Use (Updated)
|
|
18
|
+
|
|
19
|
+
### Step 1: Start Server
|
|
20
|
+
```bash
|
|
21
|
+
npm run demo
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
### Step 2: Open Browser
|
|
25
|
+
```
|
|
26
|
+
http://localhost:3000/demo-client.html
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
### Step 3: Test EMK to KAR Conversion
|
|
30
|
+
1. Select an EMK file from the list
|
|
31
|
+
2. Click "Convert to KAR"
|
|
32
|
+
3. Click "Play" to hear the result
|
|
33
|
+
4. Verify tempo and lyrics sync
|
|
34
|
+
|
|
35
|
+
## ๐ Files
|
|
36
|
+
|
|
37
|
+
- โ
**demo-client.html** - Working demo page (uses CDN)
|
|
38
|
+
- โ ~~demo.html~~ - Removed (had import errors)
|
|
39
|
+
- โ
**demo-server.js** - API server (updated to use demo-client.html)
|
|
40
|
+
|
|
41
|
+
## ๐ฏ Testing Checklist
|
|
42
|
+
|
|
43
|
+
### ZXIO Format
|
|
44
|
+
- [ ] 001.emk โ Tempo: 178.09 BPM โ
|
|
45
|
+
- [ ] failed01.emk โ Tempo: 178.09 BPM โ
|
|
46
|
+
|
|
47
|
+
### MThd Format
|
|
48
|
+
- [ ] Z2510001.emk โ Tempo: 268 BPM โ
|
|
49
|
+
- [ ] Z2510002.emk โ Tempo: 288 BPM โ
|
|
50
|
+
- [ ] Z2510003.emk โ Tempo: 1136 BPM โ
|
|
51
|
+
|
|
52
|
+
## ๐ค Ready to Test!
|
|
53
|
+
|
|
54
|
+
Server is running at:
|
|
55
|
+
**http://localhost:3000/demo-client.html**
|
|
56
|
+
|
|
57
|
+
Enjoy testing! ๐ต
|
package/DEMO_GUIDE.md
ADDED
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
# ๐ค EMK to KAR Conversion Demo - Testing Guide
|
|
2
|
+
|
|
3
|
+
## โ
Setup Complete!
|
|
4
|
+
|
|
5
|
+
Demo server is now running at **http://localhost:3000**
|
|
6
|
+
|
|
7
|
+
## ๐ How to Use
|
|
8
|
+
|
|
9
|
+
### Step 1: Open Demo Page
|
|
10
|
+
|
|
11
|
+
Open your browser and navigate to:
|
|
12
|
+
```
|
|
13
|
+
http://localhost:3000/demo-client.html
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
### Step 2: Select EMK File
|
|
17
|
+
|
|
18
|
+
Click on any EMK file from the left panel:
|
|
19
|
+
- **ZXIO files** (green badge): `001.emk`, `failed01.emk`
|
|
20
|
+
- **MThd files** (blue badge): `Z2510001.emk`, `Z2510002.emk`, etc.
|
|
21
|
+
|
|
22
|
+
### Step 3: Convert to KAR
|
|
23
|
+
|
|
24
|
+
Click the **"๐ Convert to KAR"** button and wait for conversion to complete.
|
|
25
|
+
|
|
26
|
+
### Step 4: Play & Verify
|
|
27
|
+
|
|
28
|
+
1. Click **"โถ Play"** to start playback
|
|
29
|
+
2. Watch the lyrics sync with the music
|
|
30
|
+
3. Check the metadata panel for tempo and duration
|
|
31
|
+
4. Use pause/stop controls as needed
|
|
32
|
+
|
|
33
|
+
## ๐ฏ What to Verify
|
|
34
|
+
|
|
35
|
+
### ZXIO Format (001.emk, failed01.emk)
|
|
36
|
+
|
|
37
|
+
โ
**Expected Results:**
|
|
38
|
+
- **Tempo:** 178.09 BPM (2.78x ratio)
|
|
39
|
+
- **Duration:** ~2.11 minutes (126 seconds)
|
|
40
|
+
- **Format Badge:** Green "ZXIO"
|
|
41
|
+
- **Lyrics:** Should sync perfectly with music
|
|
42
|
+
- **Speed:** Should match original KAR playback
|
|
43
|
+
|
|
44
|
+
โ **Known Issues (Fixed in v1.4.9):**
|
|
45
|
+
- ~~Previously played at 256 BPM (too fast)~~
|
|
46
|
+
- ~~Previously had 1.44x speed issue~~
|
|
47
|
+
|
|
48
|
+
### MThd Format (Z251xxxx.emk)
|
|
49
|
+
|
|
50
|
+
โ
**Expected Results:**
|
|
51
|
+
- **Z2510001.emk:** 268 BPM (4x ratio)
|
|
52
|
+
- **Z2510002.emk:** 288 BPM (4x ratio)
|
|
53
|
+
- **Z2510003.emk:** 1136 BPM (8x ratio)
|
|
54
|
+
- **Format Badge:** Blue "MThd"
|
|
55
|
+
- **Lyrics:** Should sync with music
|
|
56
|
+
|
|
57
|
+
## ๐ Verification Checklist
|
|
58
|
+
|
|
59
|
+
### Before Publishing to NPM
|
|
60
|
+
|
|
61
|
+
- [ ] Test all ZXIO files (001.emk, failed01.emk)
|
|
62
|
+
- [ ] Tempo is 178.09 BPM
|
|
63
|
+
- [ ] Duration is ~2.11 minutes
|
|
64
|
+
- [ ] Lyrics sync perfectly with music
|
|
65
|
+
- [ ] No speed issues
|
|
66
|
+
|
|
67
|
+
- [ ] Test MThd files (Z251xxxx.emk)
|
|
68
|
+
- [ ] Tempo ratios are correct (4x, 8x, 20x)
|
|
69
|
+
- [ ] Duration matches expected values
|
|
70
|
+
- [ ] Lyrics sync with music
|
|
71
|
+
|
|
72
|
+
- [ ] Test playback controls
|
|
73
|
+
- [ ] Play button starts playback
|
|
74
|
+
- [ ] Pause button pauses/resumes
|
|
75
|
+
- [ ] Stop button stops and resets
|
|
76
|
+
- [ ] Progress bar updates correctly
|
|
77
|
+
|
|
78
|
+
- [ ] Test conversion info
|
|
79
|
+
- [ ] Title displays correctly (Thai encoding)
|
|
80
|
+
- [ ] Artist displays correctly (Thai encoding)
|
|
81
|
+
- [ ] Format detection is accurate (ZXIO vs MThd)
|
|
82
|
+
- [ ] Tempo and duration match analysis
|
|
83
|
+
|
|
84
|
+
## ๐ Comparison with v1.4.8
|
|
85
|
+
|
|
86
|
+
### What Was Fixed in v1.4.9
|
|
87
|
+
|
|
88
|
+
**Problem (v1.4.8):**
|
|
89
|
+
```
|
|
90
|
+
001.emk (ZXIO):
|
|
91
|
+
Tempo: 256 BPM โ (too fast)
|
|
92
|
+
Duration: 87.89s โ (too short)
|
|
93
|
+
Ratio: 4x โ (incorrect)
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
**Solution (v1.4.9):**
|
|
97
|
+
```
|
|
98
|
+
001.emk (ZXIO):
|
|
99
|
+
Tempo: 178.09 BPM โ
(correct)
|
|
100
|
+
Duration: 126.34s โ
(correct)
|
|
101
|
+
Ratio: 2.78x โ
(correct)
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
### Technical Changes
|
|
105
|
+
|
|
106
|
+
**ZXIO Format:**
|
|
107
|
+
- Old: `ratio = PPQ / 24 = 4x`
|
|
108
|
+
- New: `ratio = PPQ / 34.5 = 2.78x`
|
|
109
|
+
|
|
110
|
+
**MThd Format:**
|
|
111
|
+
- Unchanged: `ratio = PPQ / 24 = 4x`
|
|
112
|
+
|
|
113
|
+
## ๐ต Sample Files Included
|
|
114
|
+
|
|
115
|
+
### ZXIO Format
|
|
116
|
+
1. **001.emk** - เธเธเธเธฃเธฐเธเธญเธ by เธเธธเนเธ เธจเธธเธ เธเธฒเธเธเธเน
|
|
117
|
+
- Best for testing ZXIO tempo fix
|
|
118
|
+
- Should play at 178.09 BPM
|
|
119
|
+
- Duration: 2.11 minutes
|
|
120
|
+
|
|
121
|
+
2. **failed01.emk** - Same as 001.emk
|
|
122
|
+
- Was failing in earlier versions
|
|
123
|
+
- Now converts successfully
|
|
124
|
+
- Perfect for regression testing
|
|
125
|
+
|
|
126
|
+
### MThd Format
|
|
127
|
+
1. **Z2510001.emk** - เนเธชเธเนเธซเนเนเธกเธทเธญเธเธเธฃเธฐเธฃเธ
|
|
128
|
+
- Tempo: 268 BPM (4x ratio)
|
|
129
|
+
- Duration: ~0.91 minutes
|
|
130
|
+
|
|
131
|
+
2. **Z2510002.emk** - เธชเธฒเธกเธเธญเธขเธซเธฅเธงเธ
|
|
132
|
+
- Tempo: 288 BPM (4x ratio)
|
|
133
|
+
- Duration: ~0.89 minutes
|
|
134
|
+
|
|
135
|
+
3. **Z2510003.emk** - เธกเธตเธเธนเนเนเธชเธตเธขเนเธเธดเธ
|
|
136
|
+
- Tempo: 1136 BPM (8x ratio)
|
|
137
|
+
- Duration: ~0.31 minutes
|
|
138
|
+
|
|
139
|
+
## ๐ Troubleshooting
|
|
140
|
+
|
|
141
|
+
### Lyrics Not Syncing
|
|
142
|
+
- Check browser console for errors
|
|
143
|
+
- Verify tempo in metadata panel matches expected value
|
|
144
|
+
- Try converting the file again
|
|
145
|
+
- Test with a different EMK file
|
|
146
|
+
|
|
147
|
+
### Playback Too Fast/Slow
|
|
148
|
+
- Check the **Format** badge (ZXIO vs MThd)
|
|
149
|
+
- Compare tempo with expected values
|
|
150
|
+
- ZXIO should be ~178 BPM
|
|
151
|
+
- MThd should be 4x original EMK tempo
|
|
152
|
+
|
|
153
|
+
### Conversion Fails
|
|
154
|
+
- Check server console for error messages
|
|
155
|
+
- Verify EMK file exists in `songs/emk/`
|
|
156
|
+
- Try with a known-working file (001.emk)
|
|
157
|
+
- Restart demo server if needed
|
|
158
|
+
|
|
159
|
+
### Server Won't Start
|
|
160
|
+
```bash
|
|
161
|
+
# Stop existing server
|
|
162
|
+
lsof -ti:3000 | xargs kill -9
|
|
163
|
+
|
|
164
|
+
# Restart
|
|
165
|
+
npm run demo
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
## ๐ Next Steps
|
|
169
|
+
|
|
170
|
+
Once all tests pass:
|
|
171
|
+
|
|
172
|
+
1. โ
All ZXIO files play correctly
|
|
173
|
+
2. โ
All MThd files play correctly
|
|
174
|
+
3. โ
Lyrics sync perfectly
|
|
175
|
+
4. โ
No timing drift
|
|
176
|
+
5. โ
Tempo ratios are accurate
|
|
177
|
+
|
|
178
|
+
**Then you're ready to publish!**
|
|
179
|
+
|
|
180
|
+
```bash
|
|
181
|
+
# The package is already published as v1.4.9
|
|
182
|
+
# This demo confirms it works correctly
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
## ๐ Success Indicators
|
|
186
|
+
|
|
187
|
+
You'll know it's working correctly when:
|
|
188
|
+
|
|
189
|
+
- โ
**001.emk** plays at 178.09 BPM (not 256 BPM)
|
|
190
|
+
- โ
**failed01.emk** converts successfully
|
|
191
|
+
- โ
Lyrics appear **exactly** when they should
|
|
192
|
+
- โ
Music duration matches displayed duration
|
|
193
|
+
- โ
No lag or advance in lyrics
|
|
194
|
+
- โ
Format badges show correct type (ZXIO/MThd)
|
|
195
|
+
|
|
196
|
+
## ๐ Additional Resources
|
|
197
|
+
|
|
198
|
+
- **Package:** [@karaplay/file-coder v1.4.9](https://www.npmjs.com/package/@karaplay/file-coder)
|
|
199
|
+
- **Release Notes:** [RELEASE_v1.4.9.md](./RELEASE_v1.4.9.md)
|
|
200
|
+
- **Karaoke Player:** [karaoke-player](https://www.npmjs.com/package/karaoke-player)
|
|
201
|
+
|
|
202
|
+
---
|
|
203
|
+
|
|
204
|
+
**Happy Testing! ๐ค๐ต**
|
package/DEMO_README.md
ADDED
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
# EMK to KAR Conversion Demo
|
|
2
|
+
|
|
3
|
+
## ๐ค Overview
|
|
4
|
+
|
|
5
|
+
Interactive demo for testing **@karaplay/file-coder v1.4.9** with real-time KAR file playback using `karaoke-player` library.
|
|
6
|
+
|
|
7
|
+
## โจ Features
|
|
8
|
+
|
|
9
|
+
- ๐ **Browse EMK Files** - Select from available EMK files in `songs/emk/`
|
|
10
|
+
- ๐ **Real-time Conversion** - Convert EMK to KAR using server-side API
|
|
11
|
+
- ๐ต **Karaoke Playback** - Play converted KAR files with synchronized lyrics
|
|
12
|
+
- ๐ **Metadata Display** - View tempo, duration, format (ZXIO/MThd)
|
|
13
|
+
- โฏ๏ธ **Playback Controls** - Play, pause, stop, seek
|
|
14
|
+
- ๐ **Progress Bar** - Visual playback progress
|
|
15
|
+
- โก **Format Detection** - Auto-detect ZXIO vs MThd format
|
|
16
|
+
- ๐ฏ **Tempo Verification** - Verify correct tempo ratios (2.78x for ZXIO, 4x for MThd)
|
|
17
|
+
|
|
18
|
+
## ๐ Quick Start
|
|
19
|
+
|
|
20
|
+
### 1. Install Dependencies
|
|
21
|
+
|
|
22
|
+
```bash
|
|
23
|
+
npm install
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
### 2. Build the Project
|
|
27
|
+
|
|
28
|
+
```bash
|
|
29
|
+
npm run build
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
### 3. Start Demo Server
|
|
33
|
+
|
|
34
|
+
```bash
|
|
35
|
+
npm run demo
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
### 4. Open Browser
|
|
39
|
+
|
|
40
|
+
```
|
|
41
|
+
http://localhost:3000/demo-client.html
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
## ๐ Testing Checklist
|
|
45
|
+
|
|
46
|
+
### ZXIO Format Files
|
|
47
|
+
- [ ] `001.emk` - Should play at **178.09 BPM** (2.78x ratio)
|
|
48
|
+
- [ ] `failed01.emk` - Should play at **178.09 BPM** (2.78x ratio)
|
|
49
|
+
|
|
50
|
+
### MThd Format Files
|
|
51
|
+
- [ ] `Z2510001.emk` - Should play at **268 BPM** (4x ratio)
|
|
52
|
+
- [ ] `Z2510002.emk` - Should play at **288 BPM** (4x ratio)
|
|
53
|
+
- [ ] `Z2510003.emk` - Should play at **1136 BPM** (8x ratio)
|
|
54
|
+
- [ ] `Z2510004.emk` - Should play at **268 BPM** (4x ratio)
|
|
55
|
+
- [ ] `Z2510005.emk` - Should play at **272 BPM** (4x ratio)
|
|
56
|
+
|
|
57
|
+
### Verification Points
|
|
58
|
+
|
|
59
|
+
1. **Tempo Accuracy**
|
|
60
|
+
- ZXIO files should use 2.78x tempo ratio
|
|
61
|
+
- MThd files should use 4x tempo ratio (or higher for special cases)
|
|
62
|
+
- Check displayed BPM matches expected values
|
|
63
|
+
|
|
64
|
+
2. **Lyrics Synchronization**
|
|
65
|
+
- Lyrics should appear in sync with music
|
|
66
|
+
- No lag or advance
|
|
67
|
+
- Smooth transitions between lyrics
|
|
68
|
+
|
|
69
|
+
3. **Duration Accuracy**
|
|
70
|
+
- Playback duration should match displayed duration
|
|
71
|
+
- Progress bar should align with actual playback
|
|
72
|
+
|
|
73
|
+
4. **Format Detection**
|
|
74
|
+
- ZXIO badge should show for 001.emk and failed01.emk
|
|
75
|
+
- MThd badge should show for Z251xxxx.emk files
|
|
76
|
+
|
|
77
|
+
## ๐ง API Endpoints
|
|
78
|
+
|
|
79
|
+
### GET `/api/emk-files`
|
|
80
|
+
Returns list of available EMK files
|
|
81
|
+
|
|
82
|
+
**Response:**
|
|
83
|
+
```json
|
|
84
|
+
{
|
|
85
|
+
"success": true,
|
|
86
|
+
"files": [
|
|
87
|
+
{
|
|
88
|
+
"name": "001.emk",
|
|
89
|
+
"size": 16985,
|
|
90
|
+
"path": "/songs/emk/001.emk"
|
|
91
|
+
}
|
|
92
|
+
]
|
|
93
|
+
}
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
### POST `/api/convert`
|
|
97
|
+
Convert EMK file to KAR
|
|
98
|
+
|
|
99
|
+
**Request:**
|
|
100
|
+
```json
|
|
101
|
+
{
|
|
102
|
+
"filename": "001.emk"
|
|
103
|
+
}
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
**Response:**
|
|
107
|
+
```json
|
|
108
|
+
{
|
|
109
|
+
"success": true,
|
|
110
|
+
"metadata": {
|
|
111
|
+
"title": "เธเธเธเธฃเธฐเธเธญเธ",
|
|
112
|
+
"artist": "เธเธธเนเธ เธจเธธเธ เธเธฒเธเธเธเน",
|
|
113
|
+
"format": "ZXIO",
|
|
114
|
+
"tempo": "178.09",
|
|
115
|
+
"duration": "126.34",
|
|
116
|
+
"durationMinutes": "2.11",
|
|
117
|
+
"warnings": []
|
|
118
|
+
},
|
|
119
|
+
"karData": "base64_encoded_kar_file"
|
|
120
|
+
}
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
## ๐ Technical Details
|
|
124
|
+
|
|
125
|
+
### Tempo Ratio Logic
|
|
126
|
+
|
|
127
|
+
**ZXIO Format:**
|
|
128
|
+
```
|
|
129
|
+
Ratio = PPQ / 34.5 = 96 / 34.5 โ 2.78x
|
|
130
|
+
Cursor multiply: 4x (PPQ / 24)
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
**MThd Format:**
|
|
134
|
+
```
|
|
135
|
+
Ratio = PPQ / 24 = 96 / 24 = 4x
|
|
136
|
+
Cursor: raw values (no multiply)
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
### File Structure
|
|
140
|
+
|
|
141
|
+
```
|
|
142
|
+
file-coder/
|
|
143
|
+
โโโ demo-server.js # Express server for conversion API
|
|
144
|
+
โโโ demo-client.html # Interactive demo UI
|
|
145
|
+
โโโ songs/
|
|
146
|
+
โ โโโ emk/ # EMK test files
|
|
147
|
+
โโโ temp/ # Temporary KAR files (auto-created)
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
## ๐ Troubleshooting
|
|
151
|
+
|
|
152
|
+
### Port Already in Use
|
|
153
|
+
```bash
|
|
154
|
+
# Kill process on port 3000
|
|
155
|
+
lsof -ti:3000 | xargs kill -9
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
### Module Not Found
|
|
159
|
+
```bash
|
|
160
|
+
# Reinstall dependencies
|
|
161
|
+
rm -rf node_modules package-lock.json
|
|
162
|
+
npm install
|
|
163
|
+
npm run build
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
### Playback Issues
|
|
167
|
+
- Check browser console for errors
|
|
168
|
+
- Verify KAR file was converted successfully
|
|
169
|
+
- Test with different EMK files
|
|
170
|
+
- Clear browser cache and reload
|
|
171
|
+
|
|
172
|
+
## ๐ฏ Success Criteria
|
|
173
|
+
|
|
174
|
+
Before publishing to npm, verify:
|
|
175
|
+
|
|
176
|
+
- [x] โ
All ZXIO files convert with 2.78x tempo ratio
|
|
177
|
+
- [x] โ
All MThd files convert with correct tempo ratio (4x, 8x, 20x)
|
|
178
|
+
- [x] โ
Lyrics synchronize perfectly with music
|
|
179
|
+
- [x] โ
Duration matches original KAR files
|
|
180
|
+
- [x] โ
No timing drift during playback
|
|
181
|
+
- [x] โ
Format detection works correctly
|
|
182
|
+
- [x] โ
Browser and server versions both work
|
|
183
|
+
|
|
184
|
+
## ๐ Libraries Used
|
|
185
|
+
|
|
186
|
+
- **@karaplay/file-coder v1.4.9** - EMK to KAR conversion
|
|
187
|
+
- **karaoke-player v1.1.2** - KAR file playback
|
|
188
|
+
- **@tonejs/midi v2.0.28** - MIDI analysis
|
|
189
|
+
- **express v5.2.1** - Demo server
|
|
190
|
+
|
|
191
|
+
## ๐ License
|
|
192
|
+
|
|
193
|
+
MIT
|