    #include "pitches.h"
    
    #define KNOB1 (0)
    #define KNOB2 (1)
    #define KNOB3 (2)
    
    #define OUT 11


    int melody[] = {
    NOTE_C4,
     
    NOTE_G5, 
    NOTE_A4, 
    NOTE_B4, 
    NOTE_B4, 
    NOTE_A5, 
    NOTE_B4,
    NOTE_A5,
    NOTE_A4,
    NOTE_G5,
    
    NOTE_G4,
    NOTE_F5,
    NOTE_G4,
    NOTE_A4,
    NOTE_G5,
    NOTE_G4,
    NOTE_G5,
    NOTE_G4,
    };

    int noteDurations[] = {
    1, 
    8, 8, 4, 4, 8, 8, 8, 8, 4,
    4, 4, 4, 4, 4, 8, 8, 8
    };

    int NOTE;
    
    int X;
    int Y;
    int Z;
  
void setup() {
    Serial.begin(9600);
    pinMode(OUT, OUTPUT);

}



void loop() {

    Z = analogRead KNOB1;
    Y = analogRead KNOB2;
    X = analogRead KNOB3;
  
    for (int NOTE = 0; NOTE<18; NOTE++) {
    int duration = 1000 / noteDurations[NOTE];
    tone (11, melody[NOTE]+X<<Z/60, noteDurations);

    int pause = Y;
    delay(pause);

    noTone(11);
    Serial.print(NOTE);
    Serial.print("\t");
    Serial.print(melody[NOTE]);
    Serial.print("\t");
    Serial.print(noteDurations[NOTE]);
    Serial.print("\n");
    
  }
}
