**Set Pattern Length From Sample v1.02:** (2.7, 2.8)

1807 org.illformed.SetPatternLengthFromSample.xrnx

See this thread for more information on the origins of this tool.

**Usage** :

Select a pattern, select a sample, then launch the tool via context menu or key binding:

Pattern Editor > Pattern > Set Pattern Length From Sample

The tool has 3 functions:

**1) Set Pattern Length**:

Take the current song BPM and calculate the number of pattern lines needed to play the whole sample at that BPM. If your sample does not precisely fit into a whole number of pattern lines at the current BPM, then the timing may be off by a fraction of a pattern line. Your song BPM will not be adjusted.

**2) Set Pattern Length and BPM**:

Take the current song BPM and calculate the number of pattern lines needed to play the whole sample at that BPM. Your BPM may also be adjusted by a small amount, in order to precisely fit everything together. If your starting BPM is 120, for example, then your final BPM may be some fractional amount like 120.3 or 120.7 BPM, depending on the sample length.

**3) Set BPM**:

Take the current pattern length and calculate the BPM required to fit the sample into that whole pattern.

**Notes:**

The tool does not make any attempt to analyse the content of the sample in order to calculate its tempo or number of beats, etc. It simply takes the sample duration in seconds, and tries to calculate a pattern length and/or BPM required to fit that duration as closely as possible. Your songâs BPM and LPB is important here because it will be used as the basis for calculating the number of patterns lines required for the sample to fit into a whole pattern.

If your sample is really long, then it may exceed the maximum pattern length of 512 lines. The tool will simply clamp the values if this happens, and does not try to do anything clever like spanning multiple patterns.