-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathchannelstate.go
42 lines (35 loc) · 1021 Bytes
/
channelstate.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
package playback
import (
"github.com/gotracker/playback/mixing/sampling"
"github.com/gotracker/playback/instrument"
"github.com/gotracker/playback/voice/types"
)
// ChannelState is the information needed to make an instrument play
type ChannelState[TPeriod types.Period, TVolume types.Volume, TPanning types.Panning] struct {
Instrument instrument.InstrumentIntf
Period TPeriod
vol TVolume
Pos sampling.Pos
Pan TPanning
}
// Reset sets the render state to defaults
func (s *ChannelState[TPeriod, TVolume, TPanning]) Reset() {
s.Instrument = nil
var emptyPeriod TPeriod
s.Period = emptyPeriod
s.Pos = sampling.Pos{}
var emptyPan TPanning
s.Pan = emptyPan
}
func (s *ChannelState[TPeriod, TVolume, TPanning]) GetVolume() TVolume {
return s.vol
}
func (s *ChannelState[TPeriod, TVolume, TPanning]) SetVolume(vol TVolume) {
if !vol.IsUseInstrumentVol() {
s.vol = vol
}
}
func (s *ChannelState[TPeriod, TVolume, TPanning]) NoteCut() {
var empty TPeriod
s.Period = empty
}