refactor level methods for strip/bus types

This commit is contained in:
onyx-and-iris 2022-12-09 00:54:40 +00:00
parent 134d016e10
commit 26765f554c
2 changed files with 18 additions and 18 deletions

14
bus.go
View File

@ -28,7 +28,7 @@ type bus struct {
iRemote
eQ *eQ
mode *busMode
levels
levels *levels
}
// Mute returns the value of the Mute parameter
@ -83,7 +83,7 @@ func (b *bus) Mode() *busMode {
// Levels returns the levels field
func (b *bus) Levels() *levels {
return &b.levels
return b.levels
}
// FadeTo sets the value of gain to target over at time interval of time_
@ -268,16 +268,16 @@ func (bm *busMode) SetRearOnly(val bool) {
}
// newBusLevels represents the levels field for a channel
func newBusLevels(i int, k *kind) levels {
func newBusLevels(i int, k *kind) *levels {
init := i * 8
return levels{iRemote{fmt.Sprintf("bus[%d]", i), i}, k, init, 8, "bus"}
return &levels{iRemote{fmt.Sprintf("bus[%d]", i), i}, k, init, 8, "bus"}
}
// All returns the level values for a bus
func (l *levels) All() []float64 {
var levels []float64
for i := l.init; i < l.init+l.offset; i++ {
levels = append(levels, convertLevel(_levelCache.busLevels[i]))
levels := make([]float64, l.offset)
for i := range levels {
levels[i] = convertLevel(_levelCache.busLevels[i+l.init])
}
return levels
}

View File

@ -598,9 +598,9 @@ func newStripLevels(i int, k *kind) *levels {
// PreFader returns the level values for this strip, PREFADER mode
func (l *levels) PreFader() []float64 {
_levelCache.stripMode = 0
var levels []float64
for i := l.init; i < l.init+l.offset; i++ {
levels = append(levels, convertLevel(_levelCache.stripLevels[i]))
levels := make([]float64, l.offset)
for i := range levels {
levels[i] = convertLevel(_levelCache.stripLevels[i+l.init])
}
return levels
}
@ -608,9 +608,9 @@ func (l *levels) PreFader() []float64 {
// PostFader returns the level values for this strip, POSTFADER mode
func (l *levels) PostFader() []float64 {
_levelCache.stripMode = 1
var levels []float64
for i := l.init; i < l.init+l.offset; i++ {
levels = append(levels, convertLevel(_levelCache.stripLevels[i]))
levels := make([]float64, l.offset)
for i := range levels {
levels[i] = convertLevel(_levelCache.stripLevels[i+l.init])
}
return levels
}
@ -618,9 +618,9 @@ func (l *levels) PostFader() []float64 {
// PostMute returns the level values for this strip, POSTMUTE mode
func (l *levels) PostMute() []float64 {
_levelCache.stripMode = 2
var levels []float64
for i := l.init; i < l.init+l.offset; i++ {
levels = append(levels, convertLevel(_levelCache.stripLevels[i]))
levels := make([]float64, l.offset)
for i := range levels {
levels[i] = convertLevel(_levelCache.stripLevels[i+l.init])
}
return levels
}