Musical notes are actually just frequencies. For example vibrations at 440 Hz are an "A" note. You move up and down the musical scale by multiplying the frequency against fixed constants. For example multiplying the frequency by 2 moves your tone up one octave, dividing the frequency by 2 moves it down one octave. The difference between what we think of as "notes", i.e. semitones, is achieved by multiplying or dividing by
the 12th root of two (there are twelve semitones per octave). Multiply by the 12th root of 2 twelve times, of course, and that is equal to one octave. You have to stay within the range of about 20 hz to 20,000 hz or the human ear will no longer be able to hear your notes.
Combinations of notes, i.e. chords, that we think of as "musical" or aesthetically pleasing are generally attained by combining notes whose frequencies fit some kind of simple ratio, like 3:2 or 4:3. If you look at music theory texts they talk about constructing chords via intervals; all vocabulary about intervals is just hiding underlying statements about frequency ratios.
For example a "perfect fifth", the combination of one note and the note seven semitones up, sounds good because "seven semitones up" is really another way of saying "multiplied by (the 12th root of 2)^7", which if you type that in a calculator you'll find it is very very almost exactly equal to a frequency difference of 1.5, 3/2. To your ear, notes which are a perfect fifth apart sound like they're at a 3:2 ratio, so it sounds "good".
Note combinations that don't follow these simple ratios tend not to sound good. If you want your algorithm to sound good you're probably best off having your algorithm work by applying concepts from music theory as primitives on tones of specific frequencies. Or you can just say cat dataset.dat > /dev/audio , people will hold their ears but it will be a lot more entertaining.
Getting away from math for a moment there actually was in the 50s-70s a minor movement in avant-garde classical music toward sort of "algorithmic" music which had nothing to do with computers. Good examples here would include Terry Riley's
"In C", a piece written on sheet music but constructed in such a way that the sheet music doesn't describe so much a single piece of music but
instructions for constructing a piece of music-- the sheet music is sort of laid out like a choose-your-own-adventure book, with each individual musician getting to decide of their own free will how to move through the song. The idea is to get a bunch of musicians with various different instruments to perform the song all together; since each musician will wind up choosing to visit a different part of the song at different moments, complicated patterns emerge from the musicians' varying choices. John Cage also did a lot of work around this area, with one of the more interesting examples being his "Concerto for prepared piano". As I remember this was a piece in three movements: The first movement was composed by John Cage intentionally using normal principles of music composition; in the second movement, Cage actually performed
I Ching throws, then used the hexagrams as effectively random-number-generator inputs to drive a sort of by-hand algorithm he'd come up with for constructing a piece of music; then in the third movement the notes were determined entirely by the random results of the
I Ching. The effect was to sort of chart the composer gradually removing himself from any control over his own music over the course of the concerto...