I am interested in calculating the number of possible measures. (as used in music, synonymously: bar)
Given is the number of beats per measure (e. g. 4/4 = measure length 1) and a set of possible notes and pauses (e. g. whole note = 1, half note = 1/2, quarter note = 1/4, eight note = 1/4, sixteenth note and the corresponding triplets and pauses) (note set).
We have to calculate the number of all combinations with counted permutations (partial permutations?) whose note values sum up to the measure length.
Perhaps, one can formulate a recurrence solution (measure length = note value + smaller measure length), but it seems to be complicated (due to not known recursion depth). In addition, the pauses sum up, e. g. two consecutive quarter pauses shall be indistinguishable from a half pause (not counting twice the same hearing experience).
Easily, we could use the computer, but I strive for a more elegant way.
What can we do?
Let’s do this without allowing triplets, and let’s assume that note and pause lengths can be any multiple of sixteenth notes by using ties and dots. A key observation will be that the recursion is different for measures beginning with a pause vs. a note. A pause can only be followed by a note, but notes can follow notes.
Call the number of possibilities $f(n)$, and furthermore let $f(n)=f_0(n)+f_1(n)$, where $f_0(n)$ is the number of possibilities that begin with a pause and $f_1(n)$ is the number where the measure length is $n$ sixteenth notes in length. Then the following recursion should apply.
$$f_i(n)=0 \mbox { for n<0}\\ f_i(0)=0\\ f_0(n)=\sum_{d=1}^{16}f_1(n-d)\\ f_1(n)=\sum_{d=1}^{16}f_0(n-d)+\sum_{d=1}^{16}f_1(n-d)$$.
If I got this right and programmed it into Mathematica correctly, it looks like there are $5,702,887$ different ways to fill up a $4/4$ measure with notes and rests as you describe.
If the maximum note length is as long as the measure (which makes sense if tied notes are allowed and all possible lengths can occur), the upper limit of the sum can be changed to $\infty$ and it looks like for measures of lengths $0$, $1$, $2$, and so on sixteenths, that you get the sequence here.
If you allow triplets, you’re basically allowing all multiples of “$24$th” notes and pauses, so you’d change the $16$s to $24$s, I guess.