コード例 #1
0
 // -----------------------------------------------------------------
 //  Simulates a pluck by replace all the values in the queue with
 //  a value from -0.5 to 0.5
 // -----------------------------------------------------------------
 public void pluck() {
   Random rand = new Random();
   for (int i = 0; i < frequency; i++) {
     chord.dequeue();
     double randomNum = -0.5 + rand.nextDouble();
     chord.enqueue(randomNum);
   }
 }
コード例 #2
0
 // -----------------------------------------------------------------
 //  Dequeues, takes the average of it and the sample, then multiplies
 //  by .944 to create an energy decay factor
 // -----------------------------------------------------------------
 public void tic() {
   try {
     double note = chord.dequeue();
     double newnote = ((note + chord.first()) * 0.994) / 2;
     chord.enqueue(newnote);
   } catch (NullPointerException exception) {
     System.out.println("Empty array");
   }
 }