Techniques from number theory used in algorithmic compositions?  I have been experimenting with number theoretic techniques to get some algorithmic compositions. I use python (mingus) to create the midi, import it on musescore 2 and have the corresponing score.
The method is based on a few ingredients:

*

*I use C-major or C-minor and use a symmetric function $f(a,b,c,\cdots)$ and plug in numbers $a,b,c,$ from $1 \le x \le 31$ or some other intervall and compute $f(a,b,c,..) \mod 8$ or $\mod 5$ to generate the pitches.


*To generate the rhythms / bars, I use a technique to map natural numbers to binary trees (divisorTree, sumTree). This way I have some control over the rhythm fast / slow by plugging in different numbers.


*In a mixed ensemble I use binary digits to determine at which bar the instrument plays. This creates attention to the listener, so that he/she asks himself/herself, what comes next.
Which other algortihmic techniques from number theory do you know which are used for algorithmic compositions?
Thanks for your help.
The scores can be found at:
https://musescore.com/user/37663311
Edit:
I use e new technique to create a piece of 48 min with 8 instruments and 650 pages scores: (I hope you enjoy:)
https://musescore.com/user/37663311/scores/6651858
Another edit:
Voronoi diagram / Delaunay triangulation of pitch consonance similarity, as measured with the kernel $k(a,b) = \frac{\gcd(a,b)^2}{ab}$:
https://www.reddit.com/r/musictheory/comments/tcamot/an_image_of_pitches_for_pitch_consonance/
 A: This is how prime numbers sound like in C minor

here are the Fibonacci numbers

and then there's $\pi$


(the second and third of these compositions combine the number theory input in the right hand with human derived chords in the left hand; apologies for the advertisement one needs to click through in order to hear the composition)

A: The renowned Online Encyclopedia of Integer Sequences offers a “listen” link for a sequence, which converts the sequence's data to musical notes in the format of a MIDI file.  Some of them are interesting to listen to.  I suggest, for example, lending an ear to sequence A100002 (click on “listen” and use the default settings for conversion), which I submitted to the OEIS and which Neil Sloane seems to have found amusing: since many terms are computed, this gives a fairly long piece to listen to, which I think makes for somewhat decent music because of the way it rises gradually both in pitch and complexity.
A: I'm not sure how strict your interpretation of number theory is but Sofia Gubaidulina used the Evangelist and Lucas series in some of her compositions.
I don't know if this is entirely relevant to your question but I have started writing functions in C to develop themes with the techniques I have used for years with paper and pencil. Because of the ease with which it can be done on a computer I have started using random numbers to introduce a slight variation into the functions. The random numbers are produced by taking the square root of numbers such as 15 to 48- 54 decimal places and decimalising the numbers after the decimal point, using modulus 3 or 2 if only a slight variation is wanted. Sometimes I use the Euler-Mascheroni Constant and sometimes an array of random numbers of 1 and -1 if I change something up or down - e.g. when I use the mean between numbers and some are odd.
Another technique I use is convert a theme I like by another composer into numbers and use those in various ways.
What I do is not algorithmic as I copy the developed themes onto manuscript paper and then compose normally.
A: You may add this recently published paper to your reading list.

P. Špaček and P. Sobota, Musipher: Hiding information in music composition, Rad HAZU, Matematičke znanosti, Vol. 25 (2021), p. 161-179, full text online.

Abstract. In this paper, we present a new way of hiding information. We store the information directly in the process of composing music,
based on musical theory. We created an algorithm to produce music based
on binary string, where each bit is transformed into a music composition
decision. We follow simple rules to make music, which sounds good. We
conducted survey to find whether our solution works, and found promising
results of our approach.
A: Assuming that you permit a fairly loose definition of "number theory", you might find this article by Robert Schneider quite interesting:  https://arxiv.org/abs/1312.5020
He has at least one youtube video demonstrating the ideas, so you can listen to it if you want.
A: In Reddit/composer Tom Johnson was mentioned about using mathematical ideas in compositions, and who has written two books about this:
"Self-similar Melodies"
and
"Looking at Numbers"
I have not looked at Self-similar Melodies yet, but Looking at Numbers qualifies as number theory I would say.
:-)
Here his book, "Looking at Numbers" is discussed:
https://www.youtube.com/watch?v=sjO37e2H0cg
A: I would like to add one technique based on a positive definite kernel over the natural numbers:
$$k(a,b) = \frac{\gcd(a,b)^2}{ab}$$
and
$$k(a,b) = \frac{\min(a,b)}{\max(a,b)}$$
Details of this method are described here.
Music generated by this method might be found here as an example:
https://www.youtube.com/watch?v=EbrEBeDqq24
or here
https://musescore1983.bandcamp.com/track/for-us
Disclaimer: I made all this... :-)
Edit:
I have done a website to compose "parametric" music, which is based on positive definite kernels over the natural numbers. Here is an example, which I call
"Thinking and Inventing"
Parameters:
octaves = 3;4;3;5;2;3
rests = 0,1;0,1;0,1;0,1;0,1;0,1
durations: 0.125,0.25;0.25,0.125;0.25,0.5;0.5,0.25;0.125,0.5;0.5,0.125
neighbors = 5
cycles = 60
reverse = [x]
weights = 2.0,3.0,4.0,1.6;2.0,3.0,4.0,1.6;2.0,3.0,4.0,1.6;2.0,3.0,4.0,1.6;2.0,3.0,4.0,1.6;2.0,3.0,4.0,1.6
Audio:
https://drive.google.com/file/d/1dVRajNbXIxaCB6ehXbaP4uCQ4HJjUP6w/view?usp=sharing
Score:
https://drive.google.com/file/d/1S2PlKXOac0eXITD5P1H73PMp28ptx8UG/view?usp=sharing
If you want to try it out yourself: The easiest way to start is to change the number of neighbors to say 4,6,8,10,15 etc. and see the result.
