From 8f0872a9535c607db9ebd90d50fbdb2c25d09afc Mon Sep 17 00:00:00 2001 From: Jason Crawford Date: Mon, 28 Dec 2020 15:19:27 -0800 Subject: [PATCH] Updating to use MixerVolume value - using updated gomixing library --- device_directsound.go | 2 +- device_file_flac.go | 2 +- device_file_wav.go | 2 +- device_pulseaudio.go | 2 +- device_winmm.go | 2 +- go.mod | 2 +- go.sum | 4 ++-- premixdata.go | 12 ++++++++---- 8 files changed, 16 insertions(+), 12 deletions(-) diff --git a/device_directsound.go b/device_directsound.go index 768ee91..f3742bd 100644 --- a/device_directsound.go +++ b/device_directsound.go @@ -140,7 +140,7 @@ func (d *dsoundDevice) PlayWithCtx(ctx context.Context, in <-chan *PremixData) e if err != nil { continue } - d.mix.FlattenTo(segments, panmixer, row.SamplesLen, row.Data) + d.mix.FlattenTo(segments, panmixer, row.SamplesLen, row.Data, row.MixerVolume) if err := lpdsb.Unlock(segments); err != nil { continue } diff --git a/device_file_flac.go b/device_file_flac.go index 618df84..6b38a4b 100644 --- a/device_file_flac.go +++ b/device_file_flac.go @@ -100,7 +100,7 @@ func (d *fileDeviceFlac) PlayWithCtx(ctx context.Context, in <-chan *PremixData) if !ok { return nil } - mixedData := d.mix.FlattenToInts(panmixer, row.SamplesLen, row.Data) + mixedData := d.mix.FlattenToInts(panmixer, row.SamplesLen, row.Data, row.MixerVolume) subframes := make([]*frame.Subframe, d.mix.Channels) for i := range subframes { subframe := &frame.Subframe{ diff --git a/device_file_wav.go b/device_file_wav.go index 3a444f3..0f7c2f7 100644 --- a/device_file_wav.go +++ b/device_file_wav.go @@ -98,7 +98,7 @@ func (d *fileDeviceWav) PlayWithCtx(ctx context.Context, in <-chan *PremixData) if !ok { return nil } - mixedData := d.mix.Flatten(panmixer, row.SamplesLen, row.Data) + mixedData := d.mix.Flatten(panmixer, row.SamplesLen, row.Data, row.MixerVolume) d.w.Write(mixedData) d.sz += uint32(len(mixedData)) if d.onRowOutput != nil { diff --git a/device_pulseaudio.go b/device_pulseaudio.go index 406ad36..c584dad 100644 --- a/device_pulseaudio.go +++ b/device_pulseaudio.go @@ -67,7 +67,7 @@ func (d *pulseaudioDevice) PlayWithCtx(ctx context.Context, in <-chan *PremixDat if !ok { return nil } - mixedData := d.mix.Flatten(panmixer, row.SamplesLen, row.Data) + mixedData := d.mix.Flatten(panmixer, row.SamplesLen, row.Data, row.MixerVolume) d.pa.Output(mixedData) if d.onRowOutput != nil { d.onRowOutput(KindSoundCard, row) diff --git a/device_winmm.go b/device_winmm.go index ea54c98..7bfcf29 100644 --- a/device_winmm.go +++ b/device_winmm.go @@ -78,7 +78,7 @@ func (d *winmmDevice) PlayWithCtx(ctx context.Context, in <-chan *PremixData) er if !ok { return } - mixedData := d.mix.Flatten(panmixer, row.SamplesLen, row.Data) + mixedData := d.mix.Flatten(panmixer, row.SamplesLen, row.Data, row.MixerVolume) rowWave := RowWave{ Wave: d.waveout.Write(mixedData), Row: row, diff --git a/go.mod b/go.mod index a3aec28..f01d207 100644 --- a/go.mod +++ b/go.mod @@ -3,7 +3,7 @@ module github.com/gotracker/gosound go 1.15 require ( - github.com/gotracker/gomixing v1.0.5 + github.com/gotracker/gomixing v1.0.6 github.com/jfreymuth/pulse v0.1.0 github.com/mewkiz/flac v1.0.6 github.com/pkg/errors v0.9.1 diff --git a/go.sum b/go.sum index 6a303e9..0d7da3e 100644 --- a/go.sum +++ b/go.sum @@ -2,8 +2,8 @@ github.com/d4l3k/messagediff v1.2.2-0.20190829033028-7e0a312ae40b/go.mod h1:Oozb github.com/go-audio/audio v1.0.0/go.mod h1:6uAu0+H2lHkwdGsAY+j2wHPNPpPoeg5AaEFh9FlA+Zs= github.com/go-audio/riff v1.0.0/go.mod h1:l3cQwc85y79NQFCRB7TiPoNiaijp6q8Z0Uv38rVG498= github.com/go-audio/wav v1.0.0/go.mod h1:3yoReyQOsiARkvPl3ERCi8JFjihzG6WhjYpZCf5zAWE= -github.com/gotracker/gomixing v1.0.5 h1:TpeW8V692chsYq+q1TCO7cvNtQ24F4zJ3JDCh3WZRlU= -github.com/gotracker/gomixing v1.0.5/go.mod h1:orU2G///ovcRkt4bdNZMhOPvHW0vl5yebXaLKqQcHWw= +github.com/gotracker/gomixing v1.0.6 h1:RRwO+GqWUmVNzUfPsrDA+Hao2C+hJE3cBAxCUvP2rw8= +github.com/gotracker/gomixing v1.0.6/go.mod h1:orU2G///ovcRkt4bdNZMhOPvHW0vl5yebXaLKqQcHWw= github.com/icza/bitio v1.0.0 h1:squ/m1SHyFeCA6+6Gyol1AxV9nmPPlJFT8c2vKdj3U8= github.com/icza/bitio v1.0.0/go.mod h1:0jGnlLAx8MKMr9VGnn/4YrvZiprkvBelsVIbA9Jjr9A= github.com/icza/mighty v0.0.0-20180919140131-cfd07d671de6 h1:8UsGZ2rr2ksmEru6lToqnXgA8Mz1DP11X4zSJ159C3k= diff --git a/premixdata.go b/premixdata.go index 5fce14f..56b66cd 100644 --- a/premixdata.go +++ b/premixdata.go @@ -1,10 +1,14 @@ package gosound -import "github.com/gotracker/gomixing/mixing" +import ( + "github.com/gotracker/gomixing/mixing" + "github.com/gotracker/gomixing/volume" +) // PremixData is a structure containing the audio pre-mix data for a specific row or buffer type PremixData struct { - SamplesLen int - Data []mixing.ChannelData - Userdata interface{} + SamplesLen int + Data []mixing.ChannelData + MixerVolume volume.Volume + Userdata interface{} }