/* Configuration de la partition */ int[][] notes = { /* Première ligne */ { 8, 1, 1 } , { 8, 1, 1 } , { 8, 1, 1 } , { 9, 1, 1 } , { 10, 1, 2 } , { 9, 1, 2 } , { 8, 1, 1 } , { 10, 1, 1 } , { 9, 1, 1 } , { 9, 1, 1 } , { 8, 1, 4 }, /* Deuxième ligne */ { 8, 1, 1 } , { 8, 1, 1 } , { 8, 1, 1 } , { 9, 1, 1 } , { 10, 1, 2 } , { 9, 1, 2 } , { 8, 1, 1 } , { 10, 1, 1 } , { 9, 1, 1 } , { 9, 1, 1 } , { 8, 1, 4 }, /* Troisième ligne */ { 9, 1, 1 } , { 9, 1, 1 } , { 9, 1, 1 } , { 9, 1, 1 } , { 6, 1, 2 } , { 6, 1, 2 } , { 9, 1, 1 } , { 8, 1, 1 } , { 7, 1, 1 } , { 6, 1, 1 } , { 5, 1, 4 }, /* Quatrième ligne */ { 8, 1, 1 } , { 8, 1, 1 } , { 8, 1, 1 } , { 9, 1, 1 } , { 10, 1, 2 } , { 9, 1, 2 } , { 8, 1, 1 } , { 10, 1, 1 } , { 9, 1, 1 } , { 9, 1, 1 } , { 8, 1, 4 } }; // Tableau de tableaux d'entiers pour les notes // notes[numnote][0] est la note à jouer, notes[numnote][1] est la durée de la note int bpm = 115; // tempo int timer = 0; // Initialisation du chronomètre à 0 int numnote = 0; // La première note à jouer a l'indice 0 String imagePartition = "PartitionLune.png"; /* Configuraton du synthétiseur */ int midiChannelNumber = 1; // Monotimbral, utilisation du 1er canal uniquement. int midiVelocity = 127; // Force de la note, de 0 à 127 int baseNote = 72; // Note de base à partir de laquelle les autres seront calculées. 72 : Do4 MidiChannel channel; /* Configuration de l'affichage */ float buttonRadius = 0.025; // Rayon du cercle des boutons String font = "CurlzMT-48.vlw"; // Fichier de la police int tailleTexte = 30; int[] windowSize = {1130, 650}; // Largeur et hauteur de la fenêtre float[] keyWidth = {0.070, 0.144}; // Largeur touche noire et touche blanche float[] keyHeight = {0.358, 0.538}; // Hauteur touche noire et touche blanche float[] imageSize = {0.633, 0.461}; // Largeur et hauteur de la partition float[] imageCoordinates = {0.183, 0}; // Coordonnées x et y de la partition float[] keyXCoordinates = {0.096, 0.262, 0.518, 0.678, 0.838}; // Placement horizontal des touches noires sur une octave float keyboardYCoordinate = 0.462; // Placement vertical du clavier int numOctaves = 2; // Nombre d'octave à afficher String[] nomTouchesBlanches = {"Tab", "A", "Z", "E", "R", "T", "Y", "U", "I", "O", "P", "^", "$", "Enter"}; String[] nomTouchesNoires = {"&", "é", "'", "(", "-", "_", "ç", ")", "=", "<-"}; float[] playButtonCoordinates = {0.90, 0.10}; float[] recordButtonCoordinates = {0.90, 0.20}; /* Déclaration et initialisation de diverses constantes et variables */ /* Gestion des évènements */ final int MOUSEPRESSED = 0; final int KEYPRESSED = 1; final int PLAYPRESSED = 2; final int MUSICSTARTED = 3; final int MUSICFINISHED = 4; final int RECORDINGSTARTED = 5; final int RECORDINGSTOPPED = 6; final int MUSICPLAYED = 7; boolean[] events = new boolean[8]; /* Stockages des touches cliquées */ int[][] notePressed = new int[512][2]; // Un maximum de 512 notes peuvent être enregistrées int[][] keysPressed = {new int[numOctaves*5], new int[numOctaves*7]}; // Tableau des touches cliquées. keysPressed[0] pour les touches noires et keysPressed[1] pour les blanches int[][] tmpNotes = new int[notes.length][2]; // Stockage du timestamp des notes de la partition int score = -1; PImage PartitionLune; int[] touchesNoires = new int[523]; int[] touchesBlanches = new int[523]; /* Associations des touches du clavier aux notes */ void defineKeys() { // Touches blanches touchesBlanches[9] = 1; touchesBlanches[65] = 2; touchesBlanches[90] = 3; touchesBlanches[69] = 4; touchesBlanches[82] = 5; touchesBlanches[84] = 6; touchesBlanches[89] = 7; touchesBlanches[85] = 8; touchesBlanches[73] = 9; touchesBlanches[79] = 10; touchesBlanches[80] = 11; touchesBlanches[130] = 12; touchesBlanches[514] = 12; touchesBlanches[160] = 12; touchesBlanches[515] = 13; touchesBlanches[164] = 13; touchesBlanches[10] = 14; // Touches noires touchesNoires[49] = 1; touchesNoires[50] = 2; touchesNoires[52] = 3; touchesNoires[53] = 4; touchesNoires[54] = 5; touchesNoires[56] = 6; touchesNoires[57] = 7; touchesNoires[522] = 8; touchesNoires[169] = 8; touchesNoires[61] = 9; touchesNoires[8] = 10; }