2014-05-15 03:44:03 +02:00
|
|
|
/**
|
|
|
|
* \mainpage CSC3502 : PonyTracker
|
|
|
|
*
|
|
|
|
* Les fonctionnalités de cette application sont les suivantes :
|
|
|
|
* <ul>
|
|
|
|
* <li> fonction 1</li>
|
|
|
|
* <li> fonction 2</li>
|
|
|
|
* <li> fonction 3</li>
|
|
|
|
* <li> fonction 4</li>
|
|
|
|
* </ul>
|
|
|
|
*
|
|
|
|
* @file main.c
|
|
|
|
*
|
|
|
|
* Programme principal du Ponytracker
|
|
|
|
*
|
|
|
|
* @version 1.1
|
|
|
|
* @author Module CSC3502 : Projet Informatique 1ère année TELECOM SudParis
|
|
|
|
* @date Mai 2014
|
|
|
|
*/
|
|
|
|
|
2014-04-03 12:16:16 +02:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
2014-04-08 18:30:56 +02:00
|
|
|
#include <gtk/gtk.h>
|
2014-04-03 12:16:16 +02:00
|
|
|
|
|
|
|
#include "motifs/motifs.h"
|
|
|
|
#include "melodie/melodie.h"
|
2014-05-21 18:08:47 +02:00
|
|
|
#include "samples/samples.h"
|
|
|
|
#include "instruments/instruments.h"
|
2014-04-08 14:23:22 +02:00
|
|
|
#include "lecture/lecture.h"
|
2014-05-14 13:29:53 +02:00
|
|
|
//#include <SDL2/SDL.h>
|
|
|
|
//#include <SDL2/SDL_mixer.h>
|
|
|
|
//#include <SDL2/SDL_main.h>
|
2014-04-03 12:16:16 +02:00
|
|
|
|
|
|
|
#define DEF_NBR_TMP 16
|
2014-04-06 20:08:43 +02:00
|
|
|
#define MAX_PATTERNS 256
|
2014-05-21 18:08:47 +02:00
|
|
|
#define NBR_INST 10
|
|
|
|
#define NBR_SMPL 5
|
2014-04-06 20:08:43 +02:00
|
|
|
|
2014-04-07 16:03:08 +02:00
|
|
|
// Fonctions de débug
|
2014-04-06 20:08:43 +02:00
|
|
|
|
|
|
|
void afficherMotif(Motif* m, int nbrPortees){
|
|
|
|
printf("%s :\n",m->nom);
|
2014-04-06 20:24:35 +02:00
|
|
|
for (int tmp = 0; tmp < m->nbrTmp; tmp++){
|
|
|
|
for (int portee = 0; portee < nbrPortees; portee++){
|
|
|
|
printf("%d ",getNote(m,portee,tmp));
|
2014-04-06 20:08:43 +02:00
|
|
|
}
|
|
|
|
printf("\n");
|
|
|
|
}
|
|
|
|
}
|
2014-04-03 12:16:16 +02:00
|
|
|
|
2014-04-07 16:03:08 +02:00
|
|
|
// Fin des fonctions de débug
|
|
|
|
|
2014-05-21 18:08:47 +02:00
|
|
|
void debut(Motif* melodie[], Instrument* inst[], Sample* smpl[], Motif* liste, int nbrPortees){
|
2014-04-07 16:03:08 +02:00
|
|
|
ajouterMotif(&liste, DEF_NBR_TMP, nbrPortees);
|
|
|
|
Motif* m = liste;
|
2014-04-10 17:44:27 +02:00
|
|
|
|
2014-05-21 18:08:47 +02:00
|
|
|
int i;
|
|
|
|
|
2014-04-10 17:44:27 +02:00
|
|
|
// My Little Pony.
|
2014-05-21 18:08:47 +02:00
|
|
|
|
|
|
|
for (i = 0; i < DEF_NBR_TMP; i++) {
|
|
|
|
definirNote(m,0,i,-1);
|
|
|
|
}
|
|
|
|
|
2014-04-10 17:44:27 +02:00
|
|
|
definirNote(m,0,0,1);
|
2014-05-21 18:08:47 +02:00
|
|
|
definirInstrument(m,0,0,0);
|
2014-04-10 17:44:27 +02:00
|
|
|
definirInstrument(m,0,2,-1);
|
2014-05-21 18:08:47 +02:00
|
|
|
definirNote(m,0,4,0);
|
2014-04-10 17:44:27 +02:00
|
|
|
definirInstrument(m,0,4,0);
|
|
|
|
definirNote(m,0,5,1);
|
2014-05-21 18:08:47 +02:00
|
|
|
definirInstrument(m,0,5,0);
|
2014-04-10 17:44:27 +02:00
|
|
|
definirInstrument(m,0,6,-1);
|
2014-05-21 18:08:47 +02:00
|
|
|
definirNote(m,0,7,3);
|
|
|
|
definirInstrument(m,0,7,0);
|
2014-04-10 17:44:27 +02:00
|
|
|
definirInstrument(m,0,8,-1);
|
|
|
|
definirNote(m,0,9,1);
|
2014-05-21 18:08:47 +02:00
|
|
|
definirInstrument(m,0,9,0);
|
2014-04-10 17:44:27 +02:00
|
|
|
definirInstrument(m,0,12,-1);
|
|
|
|
|
2014-04-07 16:03:08 +02:00
|
|
|
ajouterMotif(&liste, DEF_NBR_TMP, nbrPortees);
|
|
|
|
Motif* n = liste;
|
2014-04-10 17:44:27 +02:00
|
|
|
|
|
|
|
// I used to wonder what friendship could be.
|
2014-05-21 18:08:47 +02:00
|
|
|
|
|
|
|
for (i = 0; i < DEF_NBR_TMP; i++) {
|
|
|
|
definirNote(n,0,i,-1);
|
|
|
|
}
|
|
|
|
|
|
|
|
definirNote(n,0,1,5);
|
|
|
|
definirInstrument(n,0,1,0);
|
|
|
|
definirNote(n,0,2,5);
|
|
|
|
definirInstrument(n,0,2,0);
|
|
|
|
definirNote(n,0,3,5);
|
|
|
|
definirInstrument(n,0,3,0);
|
|
|
|
definirNote(n,0,4,5);
|
|
|
|
definirInstrument(n,0,4,0);
|
2014-04-10 17:44:27 +02:00
|
|
|
definirInstrument(n,0,5,-1);
|
|
|
|
definirNote(n,0,6,1);
|
2014-05-21 18:08:47 +02:00
|
|
|
definirInstrument(n,0,6,0);
|
|
|
|
definirNote(n,0,7,3);
|
|
|
|
definirInstrument(n,0,7,0);
|
2014-04-10 17:44:27 +02:00
|
|
|
definirInstrument(n,0,8,-1);
|
|
|
|
definirNote(n,0,9,1);
|
2014-05-21 18:08:47 +02:00
|
|
|
definirInstrument(n,0,9,0);
|
2014-04-10 17:44:27 +02:00
|
|
|
definirInstrument(n,0,10,-1);
|
2014-05-21 18:08:47 +02:00
|
|
|
definirNote(n,0,11,5);
|
|
|
|
definirInstrument(n,0,11,0);
|
2014-04-10 17:44:27 +02:00
|
|
|
definirInstrument(n,0,12,-1);
|
2014-05-21 18:08:47 +02:00
|
|
|
definirNote(n,0,13,3);
|
|
|
|
definirInstrument(n,0,13,0);
|
2014-04-10 17:44:27 +02:00
|
|
|
definirInstrument(n,0,14,-1);
|
|
|
|
definirNote(n,0,15,1);
|
2014-05-21 18:08:47 +02:00
|
|
|
definirInstrument(n,0,15,0);
|
2014-04-10 17:44:27 +02:00
|
|
|
|
|
|
|
ajouterMotif(&liste, DEF_NBR_TMP, nbrPortees);
|
|
|
|
Motif* p = liste;
|
|
|
|
|
|
|
|
// Until you all shared its magic with me.
|
2014-05-21 18:08:47 +02:00
|
|
|
|
|
|
|
for (i = 0; i < DEF_NBR_TMP; i++) {
|
|
|
|
definirNote(p,0,i,-1);
|
|
|
|
}
|
|
|
|
|
|
|
|
definirNote(p,0,0,5);
|
|
|
|
definirInstrument(p,0,0,0);
|
|
|
|
definirNote(p,0,1,8);
|
|
|
|
definirInstrument(p,0,1,0);
|
2014-04-10 17:44:27 +02:00
|
|
|
definirInstrument(p,0,2,-1);
|
2014-05-21 18:08:47 +02:00
|
|
|
definirNote(p,0,3,8);
|
|
|
|
definirInstrument(p,0,3,0);
|
2014-04-10 17:44:27 +02:00
|
|
|
definirInstrument(p,0,4,-1);
|
2014-05-21 18:08:47 +02:00
|
|
|
definirNote(p,0,5,5);
|
|
|
|
definirInstrument(p,0,5,0);
|
2014-04-10 17:44:27 +02:00
|
|
|
definirInstrument(p,0,6,-1);
|
2014-05-21 18:08:47 +02:00
|
|
|
definirNote(p,0,7,3);
|
|
|
|
definirInstrument(p,0,7,0);
|
2014-04-10 17:44:27 +02:00
|
|
|
definirInstrument(p,0,8,-1);
|
|
|
|
definirNote(p,0,9,1);
|
2014-05-21 18:08:47 +02:00
|
|
|
definirInstrument(p,0,9,0);
|
|
|
|
definirNote(p,0,10,5);
|
|
|
|
definirInstrument(p,0,10,0);
|
2014-04-10 17:44:27 +02:00
|
|
|
definirInstrument(p,0,11,-1);
|
2014-05-21 18:08:47 +02:00
|
|
|
definirNote(p,0,12,3);
|
|
|
|
definirInstrument(p,0,12,0);
|
2014-04-10 17:44:27 +02:00
|
|
|
definirInstrument(p,0,14,-1);
|
|
|
|
|
2014-04-07 16:03:08 +02:00
|
|
|
ajouterMotifVirtuel(melodie,0,m);
|
|
|
|
ajouterMotifVirtuel(melodie,1,n);
|
|
|
|
ajouterMotifVirtuel(melodie,2,m);
|
2014-04-10 17:44:27 +02:00
|
|
|
ajouterMotifVirtuel(melodie,3,p);
|
2014-05-21 18:08:47 +02:00
|
|
|
|
|
|
|
// Définir les instruments les samples
|
|
|
|
|
|
|
|
ajouterSample(smpl,0,"lecture/0.wav");
|
|
|
|
setHauteur(smpl[0],440.0);
|
|
|
|
|
|
|
|
ajouterInstrument(inst,0);
|
|
|
|
setSample(inst[0],smpl[0]);
|
2014-04-07 16:03:08 +02:00
|
|
|
}
|
|
|
|
|
2014-04-08 18:30:56 +02:00
|
|
|
int main( int argc, char *argv[] ){
|
2014-04-07 16:03:08 +02:00
|
|
|
|
2014-04-08 18:30:56 +02:00
|
|
|
//lecture(nbrPortee, melodie);
|
2014-04-07 16:03:08 +02:00
|
|
|
|
|
|
|
// insérer code GTK ici
|
2014-04-08 18:30:56 +02:00
|
|
|
GtkBuilder *monBuilder;
|
|
|
|
GtkWidget *maFenetre;
|
|
|
|
|
|
|
|
gtk_init( &argc, &argv );
|
|
|
|
|
|
|
|
monBuilder = gtk_builder_new();
|
|
|
|
|
|
|
|
gtk_builder_add_from_file( monBuilder, "GUI/ponytracker.glade", NULL);
|
|
|
|
gtk_builder_connect_signals( monBuilder, NULL);
|
2014-04-07 16:03:08 +02:00
|
|
|
|
2014-04-09 19:32:30 +02:00
|
|
|
maFenetre = GTK_WIDGET( gtk_builder_get_object( monBuilder, "fenetreprincipale"));
|
2014-04-08 18:30:56 +02:00
|
|
|
|
|
|
|
gtk_widget_show_all (maFenetre);
|
|
|
|
gtk_main();
|
2014-04-03 12:16:16 +02:00
|
|
|
return EXIT_SUCCESS;
|
|
|
|
}
|
2014-04-08 18:30:56 +02:00
|
|
|
|
|
|
|
void fenetreSample ( int argc, char *argv[] )
|
|
|
|
{
|
|
|
|
GtkBuilder *monBuilderSample;
|
|
|
|
GtkWidget *maFenetreSample;
|
|
|
|
|
|
|
|
gtk_init( &argc, &argv );
|
|
|
|
|
|
|
|
monBuilderSample = gtk_builder_new();
|
|
|
|
|
|
|
|
gtk_builder_add_from_file( monBuilderSample, "GUI/ponytracker.glade", NULL);
|
|
|
|
gtk_builder_connect_signals( monBuilderSample, NULL);
|
|
|
|
|
2014-04-09 19:32:30 +02:00
|
|
|
maFenetreSample = GTK_WIDGET( gtk_builder_get_object( monBuilderSample, "ajoutsample"));
|
2014-04-08 18:30:56 +02:00
|
|
|
|
|
|
|
gtk_widget_show_all (maFenetreSample);
|
|
|
|
}
|
|
|
|
|
|
|
|
void fenetreInstrument ( int argc, char *argv[] )
|
|
|
|
{
|
|
|
|
GtkBuilder *monBuilderInstrument;
|
|
|
|
GtkWidget *maFenetreInstrument;
|
|
|
|
|
|
|
|
gtk_init( &argc, &argv );
|
|
|
|
|
|
|
|
monBuilderInstrument = gtk_builder_new();
|
|
|
|
|
|
|
|
gtk_builder_add_from_file( monBuilderInstrument, "GUI/ponytracker.glade", NULL);
|
|
|
|
gtk_builder_connect_signals( monBuilderInstrument, NULL);
|
|
|
|
|
2014-04-09 19:32:30 +02:00
|
|
|
maFenetreInstrument = GTK_WIDGET( gtk_builder_get_object( monBuilderInstrument, "ajoutinstrument"));
|
2014-04-08 18:30:56 +02:00
|
|
|
|
|
|
|
gtk_widget_show_all (maFenetreInstrument);
|
|
|
|
}
|
|
|
|
|
|
|
|
void fenetreMotif ( int argc, char *argv[] )
|
|
|
|
{
|
|
|
|
GtkBuilder *monBuilderMotif;
|
|
|
|
GtkWidget *maFenetreMotif;
|
|
|
|
|
|
|
|
gtk_init( &argc, &argv );
|
|
|
|
|
|
|
|
monBuilderMotif = gtk_builder_new();
|
|
|
|
|
|
|
|
gtk_builder_add_from_file( monBuilderMotif, "GUI/ponytracker.glade", NULL);
|
|
|
|
gtk_builder_connect_signals( monBuilderMotif, NULL);
|
|
|
|
|
2014-04-09 19:32:30 +02:00
|
|
|
maFenetreMotif = GTK_WIDGET( gtk_builder_get_object( monBuilderMotif, "ajoutmotif"));
|
2014-04-08 18:30:56 +02:00
|
|
|
|
|
|
|
gtk_widget_show_all (maFenetreMotif);
|
|
|
|
}
|
2014-04-09 14:55:03 +02:00
|
|
|
|
|
|
|
void lancerLecture ()
|
|
|
|
{
|
|
|
|
Motif* melodie[MAX_PATTERNS] = {NULL};
|
|
|
|
Motif* liste = NULL;
|
2014-05-21 18:08:47 +02:00
|
|
|
Instrument* inst[NBR_INST] = {NULL};
|
|
|
|
Sample* smpl[NBR_SMPL] = {NULL};
|
|
|
|
|
2014-04-09 14:55:03 +02:00
|
|
|
int nbrPortees = 1;
|
2014-05-21 18:08:47 +02:00
|
|
|
//courant = 0;
|
2014-04-09 14:55:03 +02:00
|
|
|
taille = 0;
|
2014-05-21 18:08:47 +02:00
|
|
|
debut(melodie, inst, smpl, liste, nbrPortees);
|
|
|
|
lecture(nbrPortees,1,480,inst,melodie);
|
2014-04-09 14:55:03 +02:00
|
|
|
}
|
2014-04-10 14:43:10 +02:00
|
|
|
|
|
|
|
void quitter ()
|
|
|
|
{
|
|
|
|
gtk_main_quit();
|
|
|
|
}
|