PonyTracker
Un projet de tracker de musique
 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.
1 
21 #include <stdio.h>
22 #include <stdlib.h>
23 #include <gtk/gtk.h>
24 
25 #include "motifs/motifs.h"
26 #include "melodie/melodie.h"
27 #include "lecture/lecture.h"
28 //#include <SDL2/SDL.h>
29 //#include <SDL2/SDL_mixer.h>
30 //#include <SDL2/SDL_main.h>
31 
32 #define DEF_NBR_TMP 16
33 #define MAX_PATTERNS 256
34 
35 // Fonctions de débug
36 
37 void afficherMotif(Motif* m, int nbrPortees){
38  printf("%s :\n",m->nom);
39  for (int tmp = 0; tmp < m->nbrTmp; tmp++){
40  for (int portee = 0; portee < nbrPortees; portee++){
41  printf("%d ",getNote(m,portee,tmp));
42  }
43  printf("\n");
44  }
45 }
46 
47 // Fin des fonctions de débug
48 
49 void debut(Motif* melodie[], Motif* liste, int nbrPortees){
50  ajouterMotif(&liste, DEF_NBR_TMP, nbrPortees);
51  Motif* m = liste;
52 
53  // My Little Pony.
54  definirNote(m,0,0,1);
55  definirInstrument(m,0,0,1);
56  definirInstrument(m,0,2,-1);
57  definirNote(m,0,4,1);
58  definirInstrument(m,0,4,0);
59  definirNote(m,0,5,1);
60  definirInstrument(m,0,5,1);
61  definirInstrument(m,0,6,-1);
62  definirNote(m,0,7,1);
63  definirInstrument(m,0,7,2);
64  definirInstrument(m,0,8,-1);
65  definirNote(m,0,9,1);
66  definirInstrument(m,0,9,1);
67  definirInstrument(m,0,12,-1);
68 
69  ajouterMotif(&liste, DEF_NBR_TMP, nbrPortees);
70  Motif* n = liste;
71 
72  // I used to wonder what friendship could be.
73  definirNote(n,0,1,1);
74  definirInstrument(n,0,1,3);
75  definirNote(n,0,2,1);
76  definirInstrument(n,0,2,3);
77  definirNote(n,0,3,1);
78  definirInstrument(n,0,3,3);
79  definirNote(n,0,4,1);
80  definirInstrument(n,0,4,3);
81  definirInstrument(n,0,5,-1);
82  definirNote(n,0,6,1);
83  definirInstrument(n,0,6,1);
84  definirNote(n,0,7,1);
85  definirInstrument(n,0,7,2);
86  definirInstrument(n,0,8,-1);
87  definirNote(n,0,9,1);
88  definirInstrument(n,0,9,1);
89  definirInstrument(n,0,10,-1);
90  definirNote(n,0,11,1);
91  definirInstrument(n,0,11,3);
92  definirInstrument(n,0,12,-1);
93  definirNote(n,0,13,1);
94  definirInstrument(n,0,13,2);
95  definirInstrument(n,0,14,-1);
96  definirNote(n,0,15,1);
97  definirInstrument(n,0,15,1);
98 
99  ajouterMotif(&liste, DEF_NBR_TMP, nbrPortees);
100  Motif* p = liste;
101 
102  // Until you all shared its magic with me.
103  definirNote(p,0,0,1);
104  definirInstrument(p,0,0,3);
105  definirNote(p,0,1,1);
106  definirInstrument(p,0,1,4);
107  definirInstrument(p,0,2,-1);
108  definirNote(p,0,3,1);
109  definirInstrument(p,0,3,4);
110  definirInstrument(p,0,4,-1);
111  definirNote(p,0,5,1);
112  definirInstrument(p,0,5,3);
113  definirInstrument(p,0,6,-1);
114  definirNote(p,0,7,1);
115  definirInstrument(p,0,7,2);
116  definirInstrument(p,0,8,-1);
117  definirNote(p,0,9,1);
118  definirInstrument(p,0,9,1);
119  definirNote(p,0,10,1);
120  definirInstrument(p,0,10,3);
121  definirInstrument(p,0,11,-1);
122  definirNote(p,0,12,1);
123  definirInstrument(p,0,12,2);
124  definirInstrument(p,0,14,-1);
125 
126  ajouterMotifVirtuel(melodie,0,m);
127  ajouterMotifVirtuel(melodie,1,n);
128  ajouterMotifVirtuel(melodie,2,m);
129  ajouterMotifVirtuel(melodie,3,p);
130 }
131 
132 int main( int argc, char *argv[] ){
133 
134  //lecture(nbrPortee, melodie);
135 
136  // insérer code GTK ici
137  GtkBuilder *monBuilder;
138  GtkWidget *maFenetre;
139 
140  gtk_init( &argc, &argv );
141 
142  monBuilder = gtk_builder_new();
143 
144  gtk_builder_add_from_file( monBuilder, "GUI/ponytracker.glade", NULL);
145  gtk_builder_connect_signals( monBuilder, NULL);
146 
147  maFenetre = GTK_WIDGET( gtk_builder_get_object( monBuilder, "fenetreprincipale"));
148 
149  gtk_widget_show_all (maFenetre);
150  gtk_main();
151  return EXIT_SUCCESS;
152 }
153 
154 void fenetreSample ( int argc, char *argv[] )
155 {
156  GtkBuilder *monBuilderSample;
157  GtkWidget *maFenetreSample;
158 
159  gtk_init( &argc, &argv );
160 
161  monBuilderSample = gtk_builder_new();
162 
163  gtk_builder_add_from_file( monBuilderSample, "GUI/ponytracker.glade", NULL);
164  gtk_builder_connect_signals( monBuilderSample, NULL);
165 
166  maFenetreSample = GTK_WIDGET( gtk_builder_get_object( monBuilderSample, "ajoutsample"));
167 
168  gtk_widget_show_all (maFenetreSample);
169 }
170 
171 void fenetreInstrument ( int argc, char *argv[] )
172 {
173  GtkBuilder *monBuilderInstrument;
174  GtkWidget *maFenetreInstrument;
175 
176  gtk_init( &argc, &argv );
177 
178  monBuilderInstrument = gtk_builder_new();
179 
180  gtk_builder_add_from_file( monBuilderInstrument, "GUI/ponytracker.glade", NULL);
181  gtk_builder_connect_signals( monBuilderInstrument, NULL);
182 
183  maFenetreInstrument = GTK_WIDGET( gtk_builder_get_object( monBuilderInstrument, "ajoutinstrument"));
184 
185  gtk_widget_show_all (maFenetreInstrument);
186 }
187 
188 void fenetreMotif ( int argc, char *argv[] )
189 {
190  GtkBuilder *monBuilderMotif;
191  GtkWidget *maFenetreMotif;
192 
193  gtk_init( &argc, &argv );
194 
195  monBuilderMotif = gtk_builder_new();
196 
197  gtk_builder_add_from_file( monBuilderMotif, "GUI/ponytracker.glade", NULL);
198  gtk_builder_connect_signals( monBuilderMotif, NULL);
199 
200  maFenetreMotif = GTK_WIDGET( gtk_builder_get_object( monBuilderMotif, "ajoutmotif"));
201 
202  gtk_widget_show_all (maFenetreMotif);
203 }
204 
206 {
207  Motif* melodie[MAX_PATTERNS] = {NULL};
208  Motif* liste = NULL;
209  int nbrPortees = 1;
210  courant = 0;
211  taille = 0;
212  debut(melodie, liste, nbrPortees);
213  lecture(nbrPortees,480,melodie);
214 }
215 
216 void quitter ()
217 {
218  gtk_main_quit();
219 }
int main(int argc, char *argv[])
Definition: main.c:132
void ajouterMotif(Motif **pliste, int nbrTmp, int nbrPortees)
Definition: motifs.c:22
int getNote(Motif *m, int portee, int tmp)
Definition: motifs.c:77
char nom[10]
Definition: motifs.h:32
int courant
Definition: melodie.h:8
Definition: motifs.h:31
void quitter()
Definition: main.c:216
#define MAX_PATTERNS
Definition: main.c:33
void fenetreSample(int argc, char *argv[])
Definition: main.c:154
#define DEF_NBR_TMP
Definition: main.c:32
void definirNote(Motif *m, int portee, int tmp, int note)
Definition: motifs.c:53
int nbrTmp
Definition: motifs.h:33
void fenetreInstrument(int argc, char *argv[])
Definition: main.c:171
int taille
Definition: melodie.h:10
void afficherMotif(Motif *m, int nbrPortees)
Definition: main.c:37
void debut(Motif *melodie[], Motif *liste, int nbrPortees)
Definition: main.c:49
void lecture(int nombreChaines, int tempo, Motif *melodie[])
Definition: lecture.c:45
void ajouterMotifVirtuel(Motif *melodie[], int ind, Motif *m)
Definition: melodie.c:19
void fenetreMotif(int argc, char *argv[])
Definition: main.c:188
void lancerLecture()
Definition: main.c:205
void definirInstrument(Motif *m, int portee, int tmp, int instrument)
Definition: motifs.c:61