loop package:tidal

loops the sample (from begin to end) the specified number of times.
loopAt makes a sample fit the given number of cycles. Internally, it works by setting the unit parameter to "c", changing the playback speed of the sample with the speed parameter, and setting setting the density of the pattern to match.
d1 $ loopAt 4 $ sound "breaks125"
It’s a good idea to use this in conjuction with chop, so the break is chopped into pieces and you don’t have to wait for the whole sample to start/stop.
d1 $ loopAt 4 $ chop 32 $ sound "breaks125"
Like all Tidal functions, you can mess about with this considerably. The below example shows how you can supply a pattern of cycle counts to loopAt:
d1 $ juxBy 0.6 (|* speed "2")
$ slowspread (loopAt) [4,6,2,3]
$ chop 12
$ sound "fm:14"
Takes a pattern and loops only the first cycle of the pattern. For example, the following code will only play the bass drum sample:
d1 $ loopFirst $ s "<<bd*4 ht*8> cp*4>"
This function combines with sometimes to insert events from the first cycle randomly into subsequent cycles of the pattern:
d1 $ sometimes loopFirst $ s "<<bd*4 ht*8> cp*4>"
seqPLoop will keep looping the sequence when it gets to the end:
d1 $ qtrigger $ seqPLoop
[ (0, 12, sound "bd bd*2")
, (4, 12, sound "hh*2 [sn cp] cp future*4")
, (8, 12, sound (samples "arpy*8" (run 16)))
]