package sound;
public class StochasticControl {
public static void testRandomNotes() {
randomNotes(12, 70, 100, 250);
}
public static void randomNotes(
int scale[], int numberOfNotes) {
for (int i = 0; i < numberOfNotes; i++) {
int r = getRandom(0, scale.length);
Utils.play(scale[r], 50 * getRandom(1, 4));
}
}
public static void randomNotes(int noteMin, int noteMax,
int numberOfNotes,
int duration) {
for (int i = 0; i < numberOfNotes; i++)
Utils.play(getRandom(noteMin, noteMax), duration);
}
private static void testRandom() {
for (int i = 0; i < 10; i++)
System.out.println(getRandom(1, 12));
}
public static int getRandom(int min, int max) {
return (int) ((max - min) * Math.random() + min);
}
}