# PonyTracker: Fichier source de sources/main.c

Tout Structures de données Espaces de nommage Fichiers Fonctions Variables Définitions de type Énumérations Valeurs énumérées Macros Pages
main.c
Aller à la documentation de ce fichier.
#include <stdio.h>
#include <stdlib.h>
#include <gtk/gtk.h>
#include "motifs/motifs.h"
#include "melodie/melodie.h"
#include "lecture/lecture.h"
//#include <SDL2/SDL.h>
//#include <SDL2/SDL_mixer.h>
//#include <SDL2/SDL_main.h>
#define DEF_NBR_TMP 16
#define MAX_PATTERNS 256
// Fonctions de débug
void afficherMotif(Motif* m, int nbrPortees){
printf("%s :\n",m->nom);
for (int tmp = 0; tmp < m->nbrTmp; tmp++){
for (int portee = 0; portee < nbrPortees; portee++){
printf("%d ",getNote(m,portee,tmp));
}
printf("\n");
}
}
// Fin des fonctions de débug
void debut(Motif* melodie[], Motif* liste, int nbrPortees){
ajouterMotif(&liste, DEF_NBR_TMP, nbrPortees);
Motif* m = liste;
// My Little Pony.
definirNote(m,0,0,1);
definirInstrument(m,0,0,1);
definirInstrument(m,0,2,-1);
definirNote(m,0,4,1);
definirInstrument(m,0,4,0);
definirNote(m,0,5,1);
definirInstrument(m,0,5,1);
definirInstrument(m,0,6,-1);
definirNote(m,0,7,1);
definirInstrument(m,0,7,2);
definirInstrument(m,0,8,-1);
definirNote(m,0,9,1);
definirInstrument(m,0,9,1);
definirInstrument(m,0,12,-1);
ajouterMotif(&liste, DEF_NBR_TMP, nbrPortees);
Motif* n = liste;
// I used to wonder what friendship could be.
definirNote(n,0,1,1);
definirInstrument(n,0,1,3);
definirNote(n,0,2,1);
definirInstrument(n,0,2,3);
definirNote(n,0,3,1);
definirInstrument(n,0,3,3);
definirNote(n,0,4,1);
definirInstrument(n,0,4,3);
definirInstrument(n,0,5,-1);
definirNote(n,0,6,1);
definirInstrument(n,0,6,1);
definirNote(n,0,7,1);
definirInstrument(n,0,7,2);
definirInstrument(n,0,8,-1);
definirNote(n,0,9,1);
definirInstrument(n,0,9,1);
definirInstrument(n,0,10,-1);
definirNote(n,0,11,1);
definirInstrument(n,0,11,3);
definirInstrument(n,0,12,-1);
definirNote(n,0,13,1);
definirInstrument(n,0,13,2);
definirInstrument(n,0,14,-1);
definirNote(n,0,15,1);
definirInstrument(n,0,15,1);
ajouterMotif(&liste, DEF_NBR_TMP, nbrPortees);
Motif* p = liste;
// Until you all shared its magic with me.
definirNote(p,0,0,1);
definirInstrument(p,0,0,3);
definirNote(p,0,1,1);
definirInstrument(p,0,1,4);
definirInstrument(p,0,2,-1);
definirNote(p,0,3,1);
definirInstrument(p,0,3,4);
definirInstrument(p,0,4,-1);
definirNote(p,0,5,1);
definirInstrument(p,0,5,3);
definirInstrument(p,0,6,-1);
definirNote(p,0,7,1);
definirInstrument(p,0,7,2);
definirInstrument(p,0,8,-1);
definirNote(p,0,9,1);
definirInstrument(p,0,9,1);
definirNote(p,0,10,1);
definirInstrument(p,0,10,3);
definirInstrument(p,0,11,-1);
definirNote(p,0,12,1);
definirInstrument(p,0,12,2);
definirInstrument(p,0,14,-1);
ajouterMotifVirtuel(melodie,0,m);
ajouterMotifVirtuel(melodie,1,n);
ajouterMotifVirtuel(melodie,2,m);
ajouterMotifVirtuel(melodie,3,p);
}
int main( int argc, char *argv[] ){
//lecture(nbrPortee, melodie);
// insérer code GTK ici
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);
maFenetre = GTK_WIDGET( gtk_builder_get_object( monBuilder, "fenetreprincipale"));
gtk_widget_show_all (maFenetre);
gtk_main();
return EXIT_SUCCESS;
}
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);
maFenetreSample = GTK_WIDGET( gtk_builder_get_object( monBuilderSample, "ajoutsample"));
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);
maFenetreInstrument = GTK_WIDGET( gtk_builder_get_object( monBuilderInstrument, "ajoutinstrument"));
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);
maFenetreMotif = GTK_WIDGET( gtk_builder_get_object( monBuilderMotif, "ajoutmotif"));
gtk_widget_show_all (maFenetreMotif);
}
void lancerLecture ()
{
Motif* melodie[MAX_PATTERNS] = {NULL};
Motif* liste = NULL;
int nbrPortees = 1;
courant = 0;
taille = 0;
debut(melodie, liste, nbrPortees);
lecture(nbrPortees,480,melodie);
}
void quitter ()
{
gtk_main_quit();
}
main
int main(int argc, char *argv[])
Definition: main.c:132
ajouterMotif
void ajouterMotif(Motif **pliste, int nbrTmp, int nbrPortees)
Definition: motifs.c:22
getNote
int getNote(Motif *m, int portee, int tmp)
Definition: motifs.c:77
_motif::nom
char nom[10]
Definition: motifs.h:32
courant
int courant
Definition: melodie.h:8
_motif
Definition: motifs.h:31
quitter
void quitter()
Definition: main.c:216
MAX_PATTERNS
#define MAX_PATTERNS
Definition: main.c:33
melodie.h
fenetreSample
void fenetreSample(int argc, char *argv[])
Definition: main.c:154
DEF_NBR_TMP
#define DEF_NBR_TMP
Definition: main.c:32
definirNote
void definirNote(Motif *m, int portee, int tmp, int note)
Definition: motifs.c:53
_motif::nbrTmp
int nbrTmp
Definition: motifs.h:33
fenetreInstrument
void fenetreInstrument(int argc, char *argv[])
Definition: main.c:171
taille
int taille
Definition: melodie.h:10
afficherMotif
void afficherMotif(Motif *m, int nbrPortees)
Definition: main.c:37
debut
void debut(Motif *melodie[], Motif *liste, int nbrPortees)
Definition: main.c:49
lecture
void lecture(int nombreChaines, int tempo, Motif *melodie[])
Definition: lecture.c:45
ajouterMotifVirtuel
void ajouterMotifVirtuel(Motif *melodie[], int ind, Motif *m)
Definition: melodie.c:19
fenetreMotif
void fenetreMotif(int argc, char *argv[])
Definition: main.c:188
lecture.h
motifs.h
lancerLecture
void lancerLecture()
Definition: main.c:205
definirInstrument
void definirInstrument(Motif *m, int portee, int tmp, int instrument)
Definition: motifs.c:61