Density Demo: Myhill Distribution

Click START, listen, and play with the sliders. A higher Mean value results in more sound events per unit time (high density).  The Ratio value controls the evenness of the rhythm (variance of the density distribution).

Each sound event is followed by a random delay which was generated by a Myhill distribution. Use the slider to slowly increase the Ratio value, and notice that the rhythm gets more and more drunkenly irregular.

The Myhill distribution can be thought of as a more flexible exponential distribution; one whose variance can be controlled. This control is reflected in a ratio whose value causes the Myhill distribution to more or less approximate
the exponential distribution. When the ratio is high (above 128), the two distributions are indistinguishable. When ratio is low, the Myhill transform generates increasingly regular, periodic patterns, as opposed to the clustering and leaps of the exponential transform.
 

The Myhill distribution is found in com.softsynth.jmsl.util.EventDistributions

Thanks to "A Catalog of Statistical Distributions" by Charles Ames. Leonardo Music Journal, Vol. 1 No. 1, 1991
 
 

You need java 

Essential code:

class DensityJob extends MusicJob {
        private double eventDensity;
        private double ratio;
 
        public double repeat(double playTime) {
                double dur = EventDistributions.genEntryDelayMyhill(eventDensity, ratio);
                double pitch = 60 + JMSLRandom.choose(12);
                double vel = JMSLRandom.choose(10, 20);
                double[] dar = { dur, pitch, vel, dur * 1.25 };
                return getInstrument().play(playTime, 1.0, dar);
        }
 
        public void setRatio(double r) {
                ratio = r;
        }
 
        public void setDensity(double d) {
                eventDensity = d;
        }
}

Complete Source

More JMSL Examples