-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathchannel_patternloop.go
More file actions
36 lines (28 loc) · 1.01 KB
/
channel_patternloop.go
File metadata and controls
36 lines (28 loc) · 1.01 KB
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
package machine
import "github.com/gotracker/playback/index"
func (c *channel[TPeriod, TGlobalVolume, TMixingVolume, TVolume, TPanning]) resetPatternLoop() {
c.patternLoop.Total = 0
c.patternLoop.Count = 0
}
// ContinueLoop returns the next expected row if a loop occurs
func (c *channel[TPeriod, TGlobalVolume, TMixingVolume, TVolume, TPanning]) doPatternLoop(ch index.Channel, m *machine[TPeriod, TGlobalVolume, TMixingVolume, TVolume, TPanning]) error {
if c.patternLoop.Total == 0 {
return nil
}
if m.ticker.current.Row != c.patternLoop.End {
return nil
}
newCount := c.patternLoop.Count + 1
doLoop := newCount <= c.patternLoop.Total
if !doLoop {
newCount = 0
}
traceChannelValueChangeWithComment(m, ch, "patternLoopCount", c.patternLoop.Count, newCount, "doPatternLoop")
c.patternLoop.Count = newCount
if doLoop {
return m.SetRow(c.patternLoop.Start, false)
}
traceChannelValueChangeWithComment(m, ch, "patternLoopTotal", c.patternLoop.Total, 0, "doPatternLoop")
c.patternLoop.Total = 0
return nil
}