https://github.com/qiniu/audio
Audio support for Go language.
https://github.com/qiniu/audio
audio decoder encoder go golang
Last synced: 4 months ago
JSON representation
Audio support for Go language.
- Host: GitHub
- URL: https://github.com/qiniu/audio
- Owner: qiniu
- License: apache-2.0
- Created: 2020-04-12T14:47:59.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2023-09-01T06:10:43.000Z (almost 3 years ago)
- Last Synced: 2025-05-05T20:18:43.343Z (about 1 year ago)
- Topics: audio, decoder, encoder, go, golang
- Language: Go
- Size: 58.6 KB
- Stars: 81
- Watchers: 4
- Forks: 6
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Audio support for Go language
[](https://github.com/qiniu/audio/blob/master/LICENSE)
[](https://github.com/qiniu/audio/actions/workflows/go.yml)
[](https://goreportcard.com/report/github.com/qiniu/audio)
[](https://github.com/qiniu/audio/releases)
[](https://codecov.io/gh/qiniu/audio)
[](https://pkg.go.dev/mod/github.com/qiniu/audio)
[](http://www.qiniu.com/)
The package `github.com/qiniu/audio` is an extensible audio library with simple API for multi platforms in the Go programming language.
## Platforms
* Windows
* macOS
* Linux
* FreeBSD
* Android
* iOS
* Web browsers (Chrome, Firefox, Safari and Edge)
* GopherJS
* WebAssembly (Experimental)
## Features
* Pluggable audio decoders. And now it supports the following formats:
* wav/pcm: `import _ "github.com/qiniu/audio/wav"`
* wav/adpcm: `import _ "github.com/qiniu/audio/wav/adpcm"`
* mp3: `import _ "github.com/qiniu/audio/mp3"`
* Audio encoders (TODO).
* Convert decoded audio stream.
## Example
```
import (
"io"
"os"
"github.com/hajimehoshi/oto"
"github.com/qiniu/audio"
_ "github.com/qiniu/audio/mp3"
_ "github.com/qiniu/audio/wav"
_ "github.com/qiniu/audio/wav/adpcm"
)
func playAudio(file string) error {
f, err := os.Open(file)
if err != nil {
return err
}
defer f.Close()
d, _, err := audio.Decode(f)
if err != nil {
return err
}
c, err := oto.NewContext(d.SampleRate(), d.Channels(), d.BytesPerSample(), 8192)
if err != nil {
return err
}
defer c.Close()
p := c.NewPlayer()
defer p.Close()
_, err = io.Copy(p, d)
return err
}
```
## Document
* See https://godoc.org/github.com/qiniu/audio