Skip to content

Commit b5a17af

Browse files
author
grey
committed
- added docs
- added sentry
1 parent 7e6cc8c commit b5a17af

File tree

4 files changed

+42
-4
lines changed

4 files changed

+42
-4
lines changed

README.MD

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,21 @@ This is the basic json configuration file layout:
2828
# Usage
2929
Drop your sounds into the /sounds. You can play them by sending a GET request to the /v1/play endpoint.
3030
You need to know the base64 encoded file name of the sound you want to play. You can get started by querying /v1/list. It will return a list of all sounds with their respective base64 encoded file name.
31-
Use that base64 as the `file` parameter in the request.
31+
Use that base64 as the `file` parameter in the request. The response also includes sample request urls.
32+
33+
## Vanity IDs
34+
When playing a sound file it will get an incrementing ID. You can use that ID to stop the sound. These are not really predictable and can change at any time. You can also use a vanity ID. This is an integer that you can use to identify the sound. You can set the vanity ID by adding a `id` parameter to the request. The response will include the vanity ID. You can then use that ID to stop the sound.
35+
36+
# Endpoints
37+
> All endpoints are prefixed with `/v1/`
38+
39+
`GET /list` - Returns a list of all sounds with their respective base64 encoded file name. <br>
40+
`GET /play` - Plays a sound. The `file` parameter is required. It is the base64 encoded file name of the sound you want to play. Also supports `loop` to be either `true` or `false` (default). It also supports the `id` parameter to set a vanity ID.<br>
41+
`GET /stop` - Stops a sound. The `id` parameter is required. It is the ID of the sound you want to stop.<br>
42+
`GET /stopAll` - Stops all sounds.<br>
43+
`GET /buffer` - Buffers a sound. The `file` parameter is required. It is the base64 encoded file name of the sound you want to buffer.<br>
44+
`GET /bufferAll` - Buffers all sounds. **Note**: This may take a while. And should probably be run before a show.<br>
45+
`GET /current` - Returns a list of all currently playing sounds.<br>
46+
`GET /remaining` - Takes a `id` parameter. Returns the remaining time of the sound with the given ID.<br>
3247

3348
**Note**: The sounds must be in the format `*.mp3`, `*.wav`, `*.flac` or `*.ogg` (`flac` files may take longer time to buffer).

go.mod

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ go 1.18
44

55
require (
66
github.com/faiface/beep v1.1.0 // indirect
7+
github.com/getsentry/sentry-go v0.19.0 // indirect
78
github.com/h2non/filetype v1.1.3 // indirect
89
github.com/hajimehoshi/go-mp3 v0.3.3 // indirect
910
github.com/hajimehoshi/oto v1.0.1 // indirect
@@ -17,5 +18,6 @@ require (
1718
golang.org/x/exp/shiny v0.0.0-20220428152302-39d4317da171 // indirect
1819
golang.org/x/image v0.0.0-20220413100746-70e8d0d3baa9 // indirect
1920
golang.org/x/mobile v0.0.0-20220504144722-50dca8fc073d // indirect
20-
golang.org/x/sys v0.0.0-20220513210249-45d2b4557a2a // indirect
21+
golang.org/x/sys v0.0.0-20220928140112-f11e5e49a4ec // indirect
22+
golang.org/x/text v0.3.8 // indirect
2123
)

go.sum

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ github.com/faiface/beep v1.1.0 h1:A2gWP6xf5Rh7RG/p9/VAW2jRSDEGQm5sbOb38sf5d4c=
55
github.com/faiface/beep v1.1.0/go.mod h1:6I8p6kK2q4opL/eWb+kAkk38ehnTunWeToJB+s51sT4=
66
github.com/gdamore/encoding v1.0.0/go.mod h1:alR0ol34c49FCSBLjhosxzcPHQbf2trDkoo5dl+VrEg=
77
github.com/gdamore/tcell v1.3.0/go.mod h1:Hjvr+Ofd+gLglo7RYKxxnzCBmev3BzsS67MebKS4zMM=
8+
github.com/getsentry/sentry-go v0.19.0 h1:BcCH3CN5tXt5aML+gwmbFwVptLLQA+eT866fCO9wVOM=
9+
github.com/getsentry/sentry-go v0.19.0/go.mod h1:y3+lGEFEFexZtpbG1GUE2WD/f9zGyKYwpEqryTOC/nE=
810
github.com/go-audio/audio v1.0.0/go.mod h1:6uAu0+H2lHkwdGsAY+j2wHPNPpPoeg5AaEFh9FlA+Zs=
911
github.com/go-audio/riff v1.0.0/go.mod h1:l3cQwc85y79NQFCRB7TiPoNiaijp6q8Z0Uv38rVG498=
1012
github.com/go-audio/wav v1.0.0/go.mod h1:3yoReyQOsiARkvPl3ERCi8JFjihzG6WhjYpZCf5zAWE=
@@ -70,9 +72,13 @@ golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7w
7072
golang.org/x/sys v0.0.0-20210809222454-d867a43fc93e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
7173
golang.org/x/sys v0.0.0-20220513210249-45d2b4557a2a h1:N2T1jUrTQE9Re6TFF5PhvEHXHCguynGhKjWVsIUt5cY=
7274
golang.org/x/sys v0.0.0-20220513210249-45d2b4557a2a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
75+
golang.org/x/sys v0.0.0-20220928140112-f11e5e49a4ec h1:BkDtF2Ih9xZ7le9ndzTA7KJow28VbQW3odyk/8drmuI=
76+
golang.org/x/sys v0.0.0-20220928140112-f11e5e49a4ec/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
7377
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
7478
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
7579
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
80+
golang.org/x/text v0.3.8 h1:nAL+RVCQ9uMn3vJZbV+MRnydTJFPf8qqY42YiA6MrqY=
81+
golang.org/x/text v0.3.8/go.mod h1:E6s5w1FMmriuDzIBO73fBruAKo1PCIq6d2Q6DHfQ8WQ=
7682
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
7783
golang.org/x/tools v0.0.0-20190312151545-0bb0c0a6e846/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
7884
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=

soundr.go

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import (
99
"os"
1010

1111
"github.com/faiface/beep"
12+
"github.com/getsentry/sentry-go"
1213
)
1314

1415
type playback struct {
@@ -34,7 +35,8 @@ type streamBuf struct {
3435
}
3536

3637
type Configuration struct {
37-
Port int
38+
Port int
39+
AllowSentry bool
3840
}
3941

4042
var playbacks map[int]playback
@@ -68,7 +70,8 @@ func main() {
6870
fmt.Println("Writing to conf.json")
6971
// Write the default config to the file
7072
json.NewEncoder(file).Encode(Configuration{
71-
Port: 8080,
73+
Port: 8080,
74+
AllowSentry: true,
7275
})
7376
fmt.Println("Wrote to conf.json")
7477
}
@@ -78,6 +81,18 @@ func main() {
7881
configuration := Configuration{}
7982
err := decoder.Decode(&configuration)
8083

84+
if configuration.AllowSentry {
85+
err := sentry.Init(sentry.ClientOptions{
86+
Dsn: "https://0eae4896cb23446b99a8a5b9f9da75f1@sentry.thegreydiamond.de/8",
87+
// Enable printing of SDK debug messages.
88+
// Useful when getting started or trying to figure something out.
89+
// Debug: true,
90+
})
91+
if err != nil {
92+
log.Fatalf("sentry.Init: %s", err)
93+
}
94+
}
95+
8196
if err != nil {
8297
fmt.Println("error:", err)
8398
}

0 commit comments

Comments
 (0)