commit 895b3a29c5b382f53ee26494676d7b93f7579cdc
parent 10025629ef7bfecd4b0a0ed827d5390fddeac520
Author: Jack Mordaunt <jackmordaunt.dev@gmail.com>
Date: Tue, 26 Oct 2021 21:55:00 +0800
example: small example showcasing api
Signed-off-by: Jack Mordaunt <jackmordaunt.dev@gmail.com>
Diffstat:
1 file changed, 23 insertions(+), 0 deletions(-)
diff --git a/internal/example/main.go b/internal/example/main.go
@@ -0,0 +1,23 @@
+package main
+
+import (
+ "fmt"
+ "os"
+
+ "git.sr.ht/~jackmordaunt/nativeaudio"
+)
+
+func main() {
+ by, err := os.ReadFile(os.Args[1])
+ if err != nil {
+ panic(fmt.Errorf("reading file: %w", err))
+ }
+ data, format, err := nativeaudio.Decode(by)
+ if err != nil {
+ panic(fmt.Errorf("decoding audio: %w", err))
+ }
+ fmt.Printf("%+v\n", format)
+ if err := os.WriteFile("raw.pcm", data, 0644); err != nil {
+ panic(fmt.Errorf("dumping pcm: %w", err))
+ }
+}