aquahika / volume-go

Audio volume control in Go (Windows not tested)

Home Page:https://pkg.go.dev/github.com/itchyny/volume-go?tab=doc

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

volume-go CI Status Go Report Card MIT License GoDoc

Volume control in Go

This is a Go language package for controlling audio volume.

CLI tool usage

install

go get github.com/itchyny/volume-go/cmd/volume

get

Gets current volume.

 $ volume get 
20

set

Set volume to specified amount.

 $ volume set 40
 $ volume status
volume: 40
muted: false

up/down

Increase/decrease volume by specified amount, default 6.

 $ volume get
40
 $ volume up
 $ volume get
46

 $ volume up 4
 $ volume get
50

 $ volume down
 $ volume get
44
 $ volume down 4
 $ volume get
40

status

Get current volume and is muted.

 $ volume status
volume: 20
muted: false

mute/unmute

 $ volume mute
 $ volume status
volume: 20
muted: true

 $ volume unmute
 $ volume status
volume: 20
muted: false

Package usage

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.

Author

itchyny (https://github.com/itchyny)

License

This software is released under the MIT License, see LICENSE.

About

Audio volume control in Go (Windows not tested)

https://pkg.go.dev/github.com/itchyny/volume-go?tab=doc

License:MIT License


Languages

Language:Go 92.4%Language:Makefile 7.6%