Calculate the number of samples of the loop.
Beat (quarter note) length = 1/BPMx60 seconds
1 second = 44100 samples.
Ex : 4 bars at 120 BPM, 16 beats
1/120x60x16=8s
8x44100=352 800 samples
Beware of BPMs with decimals :
The Untold Truth About Octatrack Tempo
Not in the audio part unfortunately.
But it’s doable with midi loopback. You can get perfect loops sending the right note, qrec.
Record perfect loops with QREC, manual stop.
With QREC=PLEN, Master 1024, you get a 64 bars recording.