Fixed bug where audio samples were actually louder instead of softer.

This commit is contained in:
Sander Schobers 2021-08-19 21:37:59 +02:00
parent 5935a7fea8
commit aca3a5af78
2 changed files with 6 additions and 5 deletions

View File

@ -73,10 +73,10 @@ func (a *app) Init(ctx ui.Context) error {
); err != nil { ); err != nil {
log.Printf("failed to load samples; %v\n", err) 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) 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", "monster_jump.mp3",
"player_move.mp3", "player_move.mp3",
); err != nil { ); err != nil {

View File

@ -80,11 +80,12 @@ func (p *AudioPlayer) PlaySample(name string) error {
if err != nil { if err != nil {
return err return err
} }
volume := p.SampleVolume + sample.Volume
speaker.Play(&effects.Volume{ speaker.Play(&effects.Volume{
Streamer: p.resample(sample.Stream(), sample.SampleRate), Streamer: p.resample(sample.Stream(), sample.SampleRate),
Base: 2, Base: 2,
Volume: p.SampleVolume - sample.Volume, Volume: volume,
Silent: p.SampleVolume == minVolume, Silent: volume <= minVolume,
}) })
return nil return nil
} }
@ -107,7 +108,7 @@ func (p *AudioPlayer) PlayMusic(name string, init func(*Music)) (*Music, error)
Streamer: p.resample(closer, format.SampleRate), Streamer: p.resample(closer, format.SampleRate),
Base: 2, Base: 2,
Volume: p.MusicVolume, Volume: p.MusicVolume,
Silent: p.MusicVolume == minVolume, Silent: p.MusicVolume <= minVolume,
}, },
} }
if init != nil { if init != nil {