Skip to content

Commit d6bc0af

Browse files
committed
Fix melody loading on GitHub Pages deployment
- Change MELODY_PATH from absolute '/assets/melodies/' to relative 'assets/melodies/' so it resolves correctly under /picosynth/ subpath - Add copy-melodies target to include melody files in web/ during build - Update wasm-clean to remove copied assets directory - Remove destination directory before copying to avoid 'same file' error when running make wasm multiple times or in CI environments.
1 parent f723fca commit d6bc0af

File tree

10 files changed

+288
-4
lines changed

10 files changed

+288
-4
lines changed

Makefile

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ WASM_FLAGS = -O2 -s WASM=1 \
3939
-DSAMPLE_RATE=$(WASM_SAMPLE_RATE) \
4040
-I include -I .
4141

42-
.PHONY: all clean distclean indent list-melodies wasm wasm-clean serve tools check
42+
.PHONY: all clean distclean indent list-melodies wasm wasm-clean serve tools check copy-melodies
4343

4444
all: $(TARGET)
4545

@@ -74,14 +74,22 @@ clean:
7474
tools: $(MIDI2C)
7575

7676
# WebAssembly build
77-
wasm: $(WASM_OUT)
77+
wasm: $(WASM_OUT) copy-melodies
7878

7979
$(WASM_OUT): $(WASM_SRCS) $(HDRS)
8080
$(EMCC) $(WASM_FLAGS) $(WASM_SRCS) -o $@
8181
@echo "WebAssembly build complete: $(WASM_DIR)/"
8282

83+
# Copy melody files to web directory for deployment
84+
copy-melodies:
85+
@rm -rf $(WASM_DIR)/assets
86+
@mkdir -p $(WASM_DIR)/assets
87+
@cp -r assets/melodies $(WASM_DIR)/assets/
88+
@echo "Copied melody files to $(WASM_DIR)/assets/melodies/"
89+
8390
wasm-clean:
8491
$(RM) $(WASM_DIR)/picosynth.js $(WASM_DIR)/picosynth.wasm
92+
$(RM) -r $(WASM_DIR)/assets
8593

8694
# Remove all generated files
8795
distclean: clean wasm-clean

web/app.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@ function loadMelody(text, name) {
228228
}
229229

230230
/* Melody list - discovered from assets/melodies/ */
231-
const MELODY_PATH = '/assets/melodies/';
231+
const MELODY_PATH = 'assets/melodies/';
232232
const MELODIES = [
233233
{ id: 'happy_birthday', name: 'Happy Birthday' },
234234
{ id: 'twinkle', name: 'Twinkle' },

web/assets

Lines changed: 0 additions & 1 deletion
This file was deleted.
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
# Frere Jacques (Are You Sleeping)
2+
# Format: NOTE BEATS (4=quarter, 8=eighth, 2=half)
3+
4+
# Frere Jacques
5+
C4 4
6+
D4 4
7+
E4 4
8+
C4 4
9+
10+
# Frere Jacques
11+
C4 4
12+
D4 4
13+
E4 4
14+
C4 4
15+
16+
# Dormez vous
17+
E4 4
18+
F4 4
19+
G4 2
20+
21+
# Dormez vous
22+
E4 4
23+
F4 4
24+
G4 2
25+
26+
# Sonnez les matines
27+
G4 8
28+
A4 8
29+
G4 8
30+
F4 8
31+
E4 4
32+
C4 4
33+
34+
# Sonnez les matines
35+
G4 8
36+
A4 8
37+
G4 8
38+
F4 8
39+
E4 4
40+
C4 4
41+
42+
# Din dan don
43+
C4 4
44+
G3 4
45+
C4 2
46+
47+
# Din dan don
48+
C4 4
49+
G3 4
50+
C4 2
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# Happy Birthday to You
2+
# Traditional melody in G major
3+
# Beat values: higher = shorter (2000/beat ms)
4+
# 1=very long, 2=long, 3=medium, 4=quarter, 6=short
5+
6+
# "Hap-py birth-day to you"
7+
D4 6
8+
D4 6
9+
E4 4
10+
D4 4
11+
G4 4
12+
F#4 2
13+
- 4
14+
15+
# "Hap-py birth-day to you"
16+
D4 6
17+
D4 6
18+
E4 4
19+
D4 4
20+
A4 4
21+
G4 2
22+
- 4
23+
24+
# "Hap-py birth-day dear ___"
25+
D4 6
26+
D4 6
27+
D5 4
28+
B4 4
29+
G4 4
30+
F#4 4
31+
E4 2
32+
- 4
33+
34+
# "Hap-py birth-day to you"
35+
C5 6
36+
C5 6
37+
B4 4
38+
G4 4
39+
A4 4
40+
G4 1
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# Jingle Bells - Chorus
2+
# Format: NOTE BEATS (4=quarter, 8=eighth, 2=half, 1=whole)
3+
4+
E4 4
5+
E4 4
6+
E4 2
7+
E4 4
8+
E4 4
9+
E4 2
10+
E4 4
11+
G4 4
12+
C4 4
13+
D4 4
14+
E4 1
15+
16+
F4 4
17+
F4 4
18+
F4 4
19+
F4 4
20+
F4 4
21+
E4 4
22+
E4 4
23+
E4 8
24+
E4 8
25+
E4 4
26+
D4 4
27+
D4 4
28+
E4 4
29+
D4 2
30+
G4 2
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# London Bridge Is Falling Down
2+
# Format: NOTE BEATS (4=quarter, 8=eighth, 3=dotted quarter, 2=half)
3+
4+
# London Bridge is falling down
5+
G4 3
6+
A4 8
7+
G4 4
8+
F4 4
9+
E4 4
10+
F4 4
11+
G4 2
12+
13+
# Falling down
14+
D4 4
15+
E4 4
16+
F4 2
17+
18+
# Falling down
19+
E4 4
20+
F4 4
21+
G4 2
22+
23+
# London Bridge is falling down
24+
G4 3
25+
A4 8
26+
G4 4
27+
F4 4
28+
E4 4
29+
F4 4
30+
G4 2
31+
32+
# My fair lady
33+
D4 2
34+
G4 4
35+
E4 4
36+
C4 2

web/assets/melodies/mary_lamb.txt

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# Mary Had a Little Lamb
2+
# Format: NOTE BEATS (4=quarter, 2=half)
3+
4+
E4 4
5+
D4 4
6+
C4 4
7+
D4 4
8+
E4 4
9+
E4 4
10+
E4 2
11+
12+
D4 4
13+
D4 4
14+
D4 2
15+
E4 4
16+
G4 4
17+
G4 2
18+
19+
E4 4
20+
D4 4
21+
C4 4
22+
D4 4
23+
E4 4
24+
E4 4
25+
E4 4
26+
E4 4
27+
D4 4
28+
D4 4
29+
E4 4
30+
D4 4
31+
C4 2

web/assets/melodies/ode_to_joy.txt

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# Ode to Joy - Beethoven
2+
# Format: NOTE BEATS (4=quarter, 8=eighth, 2=half)
3+
4+
E4 4
5+
E4 4
6+
F4 4
7+
G4 4
8+
G4 4
9+
F4 4
10+
E4 4
11+
D4 4
12+
C4 4
13+
C4 4
14+
D4 4
15+
E4 4
16+
E4 3
17+
D4 8
18+
D4 2
19+
20+
E4 4
21+
E4 4
22+
F4 4
23+
G4 4
24+
G4 4
25+
F4 4
26+
E4 4
27+
D4 4
28+
C4 4
29+
C4 4
30+
D4 4
31+
E4 4
32+
D4 3
33+
C4 8
34+
C4 2

web/assets/melodies/twinkle.txt

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
# Twinkle Twinkle Little Star
2+
# Format: NOTE BEATS
3+
4+
C4 4
5+
C4 4
6+
G4 4
7+
G4 4
8+
A4 4
9+
A4 4
10+
G4 2
11+
- 2
12+
13+
F4 4
14+
F4 4
15+
E4 4
16+
E4 4
17+
D4 4
18+
D4 4
19+
C4 2
20+
- 2
21+
22+
G4 4
23+
G4 4
24+
F4 4
25+
F4 4
26+
E4 4
27+
E4 4
28+
D4 2
29+
- 2
30+
31+
G4 4
32+
G4 4
33+
F4 4
34+
F4 4
35+
E4 4
36+
E4 4
37+
D4 2
38+
- 2
39+
40+
C4 4
41+
C4 4
42+
G4 4
43+
G4 4
44+
A4 4
45+
A4 4
46+
G4 2
47+
- 2
48+
49+
F4 4
50+
F4 4
51+
E4 4
52+
E4 4
53+
D4 4
54+
D4 4
55+
C4 2
56+
- 2

0 commit comments

Comments
 (0)