Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lowering sound volume (effects.Volume) seems to increase it #174

Open
M4elstr0m opened this issue Dec 1, 2024 · 1 comment
Open

Lowering sound volume (effects.Volume) seems to increase it #174

M4elstr0m opened this issue Dec 1, 2024 · 1 comment

Comments

@M4elstr0m
Copy link

Hey there! I was using your module for my app normally when I found that the sound was a little too loud for users, so I decided to lower it a little. But I can't achieve to lower sound's volume, it seems I can only increase it (if I put -10.0 it is extremely loud):

func PlayNotificationSound(name string, vol float64) {
	path := path.Join("assets", "sounds", name+".mp3")

	soundFile, err := os.Open(path)
	if err != nil {
		fmt.Println("Error when reading audio file: ", err)
	}
	defer soundFile.Close()

	streamer, format, err := mp3.Decode(soundFile)
	if err != nil {
		fmt.Println("Error when decoding audio file: ", err)
	}
	defer streamer.Close()

	speaker.Init(format.SampleRate, format.SampleRate.N(time.Second/10))

	volume := &effects.Volume{Streamer: streamer, Volume: vol}
	speaker.Play(volume)

	// speaker.Play(streamer)
	time.Sleep(time.Duration(500 * time.Millisecond))
}

So here normally, I would have put vol=-10.0 to lower the volume, but when I do volume := &effects.Volume{Streamer: streamer, Volume: vol} it does the opposite (it hurts)

Can you please tell me how to lower this volume?

Thank you very much!

@MarkKremer
Copy link
Contributor

MarkKremer commented Dec 15, 2024

Hello, I'm not on my computer right now but I suspect the volume struct is missing the Base value, which causes negative volumes to result in an infinite gain.

If that doesn't work let me know. Also consider switching to the gopxl/beep fork. Faiface's repository is no longer maintained. I'll also see issues on the gopxl repo more quickly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants