For a musical project, I needed a way to determine the length of a note or rest based on the outcome of a calculation.
Therefore, I have created the accompanying function that generates the code, depending on the desired length in 'tics'.
A 'tic' is defined as the length of the note or rest as determined by the code 'T', which is 1/8 of a 'beat'.
The function can be included. The test can be run by removing the /* and */.
The screenshot shows the output of the test.