From aca3a5af7805e8a79f09688bf394c14fcc099de8 Mon Sep 17 00:00:00 2001 From: Sander Schobers Date: Thu, 19 Aug 2021 21:37:59 +0200 Subject: [PATCH] Fixed bug where audio samples were actually louder instead of softer. --- cmd/tins2021/app.go | 4 ++-- cmd/tins2021/audio.go | 7 ++++--- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/cmd/tins2021/app.go b/cmd/tins2021/app.go index fc6c4d7..488ecc3 100644 --- a/cmd/tins2021/app.go +++ b/cmd/tins2021/app.go @@ -73,10 +73,10 @@ func (a *app) Init(ctx ui.Context) error { ); err != nil { log.Printf("failed to load samples; %v\n", err) } - if err := a.context.Audio.LoadSampleVolume(-1, "menu_interaction.mp3"); err != nil { + if err := a.context.Audio.LoadSampleVolume(-.5, "menu_interaction.mp3"); err != nil { log.Printf("failed to load samples; %v\n", err) } - if err := a.context.Audio.LoadSampleVolume(-2, + if err := a.context.Audio.LoadSampleVolume(-1, "monster_jump.mp3", "player_move.mp3", ); err != nil { diff --git a/cmd/tins2021/audio.go b/cmd/tins2021/audio.go index 062319c..9952e03 100644 --- a/cmd/tins2021/audio.go +++ b/cmd/tins2021/audio.go @@ -80,11 +80,12 @@ func (p *AudioPlayer) PlaySample(name string) error { if err != nil { return err } + volume := p.SampleVolume + sample.Volume speaker.Play(&effects.Volume{ Streamer: p.resample(sample.Stream(), sample.SampleRate), Base: 2, - Volume: p.SampleVolume - sample.Volume, - Silent: p.SampleVolume == minVolume, + Volume: volume, + Silent: volume <= minVolume, }) return nil } @@ -107,7 +108,7 @@ func (p *AudioPlayer) PlayMusic(name string, init func(*Music)) (*Music, error) Streamer: p.resample(closer, format.SampleRate), Base: 2, Volume: p.MusicVolume, - Silent: p.MusicVolume == minVolume, + Silent: p.MusicVolume <= minVolume, }, } if init != nil {