Skip to content

Commit 44722f0

Browse files
docs: demo
1 parent 919989e commit 44722f0

File tree

4 files changed

+46
-11
lines changed

4 files changed

+46
-11
lines changed

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
/.idea
2+
/wasm/wasm_exec.js
23
jimi
3-
jimi.exe
4+
jimi.exe
5+
jimi.wasm

README.md

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@ A command line utility written in Go to display guitar fretboard, scales and cho
44

55
Because I love Go, CLIs and guitar (and Hendrix obviously!)
66

7+
## Demo
8+
9+
Try Jimi in your browser with a [live demo](https://maximegosselin.github.io/jimi-wasm-demo/) made with WebAssembly.
10+
711
## Build
812

913
[![Go](https://github.com/maximegosselin/jimi/actions/workflows/go.yml/badge.svg)](https://github.com/maximegosselin/jimi/actions/workflows/go.yml)
@@ -93,20 +97,20 @@ Specify the root note with `-r` and the chord pattern with `-p`.
9397

9498
Chord preset patterns are:
9599

96-
- `5th`
97-
- `aug`
98-
- `dim`
99-
- `m7b5`
100-
- `major-6th`
101-
- `major-7th`
100+
- `5th`
101+
- `aug`
102+
- `dim`
103+
- `m7b5`
104+
- `major-6th`
105+
- `major-7th`
102106
- `major-maj7`
103107
- `major-triad`
104-
- `minor-6th`
105-
- `minor-7th`
108+
- `minor-6th`
109+
- `minor-7th`
106110
- `minor-maj7`
107111
- `minor-triad`
108-
- `sus`
109-
- `sus2`
112+
- `sus`
113+
- `sus2`
110114
- `sus4`
111115

112116
```

wasm/build.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/bin/sh
2+
3+
GOOS=js GOARCH=wasm go build -o jimi.wasm ../.
4+
cp $(go env GOROOT)/misc/wasm/wasm_exec.js .

wasm/index.html

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<script src="wasm_exec.js"></script>
5+
<script>
6+
const go = new Go();
7+
WebAssembly.instantiateStreaming(fetch("jimi.wasm"), go.importObject).then((result) => {
8+
let outputBuf = '';
9+
const decoder = new TextDecoder("utf-8");
10+
globalThis.fs.writeSync = function(fd, buf) {
11+
outputBuf += decoder.decode(buf);
12+
const nl = outputBuf.lastIndexOf("\n");
13+
if (nl != -1) {
14+
alert(outputBuf.substr(0, nl + 1));
15+
outputBuf = outputBuf.substr(nl + 1);
16+
}
17+
return buf.length;
18+
};
19+
20+
go.argv = ['jimi', '-r=C', '-p=major-triad'];
21+
go.run(result.instance);
22+
});
23+
</script>
24+
</head>
25+
</html>

0 commit comments

Comments
 (0)