https://github.com/itchyny/volume-go
Cross-platform audio volume control library for Go
https://github.com/itchyny/volume-go
audio golang golang-library volume volume-control
Last synced: over 1 year ago
JSON representation
Cross-platform audio volume control library for Go
- Host: GitHub
- URL: https://github.com/itchyny/volume-go
- Owner: itchyny
- License: mit
- Created: 2017-06-17T05:37:02.000Z (about 9 years ago)
- Default Branch: main
- Last Pushed: 2022-06-25T04:47:29.000Z (about 4 years ago)
- Last Synced: 2025-03-16T04:03:31.076Z (over 1 year ago)
- Topics: audio, golang, golang-library, volume, volume-control
- Language: Go
- Homepage: https://pkg.go.dev/github.com/itchyny/volume-go?tab=doc
- Size: 65.4 KB
- Stars: 111
- Watchers: 5
- Forks: 20
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# volume-go
[](https://github.com/itchyny/volume-go/actions)
[](https://goreportcard.com/report/github.com/itchyny/volume-go)
[](https://github.com/itchyny/volume-go/blob/main/LICENSE)
[](https://github.com/itchyny/volume-go/releases)
[](https://pkg.go.dev/github.com/itchyny/volume-go)
### Cross-platform audio volume control library for Go language
This is a Go language package for controlling audio volume.
## volume command
### Homebrew
```sh
brew install itchyny/tap/volume
```
### Build from source
```sh
go install github.com/itchyny/volume-go/cmd/volume@latest
```
### Basic usage
```sh
$ # Get the current audio volume.
$ volume get
20
$ # Set the audio volume.
$ volume set 40
$ volume status
volume: 40
muted: false
$ # Increase/decrease the audio volume.
$ volume get
40
$ volume up
$ volume get
46
$ volume down
$ volume get
44
$ # Get current audio volume status.
$ volume status
volume: 20
muted: false
$ # Mute and unmute.
$ volume mute
$ volume status
volume: 20
muted: true
$ volume unmute
$ volume status
volume: 20
muted: false
```
## Package usage
```go
package main
import (
"fmt"
"log"
"github.com/itchyny/volume-go"
)
func main() {
vol, err := volume.GetVolume()
if err != nil {
log.Fatalf("get volume failed: %+v", err)
}
fmt.Printf("current volume: %d\n", vol)
err = volume.SetVolume(10)
if err != nil {
log.Fatalf("set volume failed: %+v", err)
}
fmt.Printf("set volume success\n")
err = volume.Mute()
if err != nil {
log.Fatalf("mute failed: %+v", err)
}
err = volume.Unmute()
if err != nil {
log.Fatalf("unmute failed: %+v", err)
}
}
```
## Bug Tracker
Report bug at [Issues・itchyny/volume-go - GitHub](https://github.com/itchyny/volume-go/issues).
## Author
itchyny (https://github.com/itchyny)
## License
This software is released under the MIT License, see LICENSE.