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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
//! Per-lane looping for the DAW layer.
//!
//! Most tracker formats (MOD / XM / IT / S3M) share a single global
//! playback timeline: every channel advances in lockstep and the song
//! wraps as a whole via [`crate::core::module::Module::song_loop_to`].
//!
//! Some replayers don't work that way. The David Whittaker `.dw` driver
//! — and most custom C64 / Amiga sound engines — give **each voice its
//! own sequence with its own loop point**. The four voices of
//! `xenon2 (title).dw`, for instance, loop at 9888 / 9888 / 9912 / 10014
//! frames and drift against each other forever; the original hardware
//! never realigns them. A single global wrap can't represent that.
//!
//! A [`ChannelLoop`] expresses one voice's loop as a half-open tick
//! region `[start_tick, end_tick)` on its lane `(song, channel)`: when
//! that lane's local playhead reaches `end_tick` it wraps back to
//! `start_tick`, independently of the other lanes. This is the same
//! abstraction modern DAWs expose as a per-track loop region (the
//! Ableton / Bitwig clip-loop brace) — distinct per-track loop lengths
//! are exactly how polymeters are built.
//!
//! The loop lives on the **lane**, not on a [`crate::core::daw::track::Track`]
//! (reusable content, shared across clips) nor on a single
//! [`crate::core::daw::clip::Clip`] (a Whittaker voice's loop spans its
//! whole sequence of segment-clips, not one clip). The player honours
//! these regions in [`crate::core::module::Module::row_at`]; when a
//! module declares no `ChannelLoop`, behaviour is byte-for-byte the
//! global-wrap path, so the tracker formats are untouched.
use ;
/// One voice's independent loop on its `(song, channel)` lane.
///
/// Ticks are in the same space as [`crate::core::daw::clip::Clip::position_tick`]
/// and [`crate::core::daw::timeline::TimelineEntry::tick`] — absolute
/// ticks from the start of the sub-song. The region is half-open:
/// playback covers `[start_tick, end_tick)` then wraps to `start_tick`.
///
/// Invariant: `start_tick < end_tick`. `start_tick` encodes the
/// driver's loop target (the position-list `loop_to`, `0` when the
/// voice loops from its very start, as every analysed `.dw` does so
/// far); `end_tick` is one tick past the voice's last rendered tick
/// (its pass length).