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
maintest.c
Aller à la documentation de ce fichier.
1 #include <stdio.h>
2 #include <stdlib.h>
3 #include <string.h>
4 #include <gtk/gtk.h>
5 
6 #include "motifs/motifs.h"
7 #include "melodie/melodie.h"
8 #include "lecture/lecture.h"
9 
10 #define DEF_NBR_TMP 16
11 #define MAX_PATTERNS 256
12 
14 GtkBuilder *monBuilder;
15 char *Do="Do";
16 char *DoD="Do#";
17 char *Re="Re";
18 char *ReD="Re#";
19 char *Mi="Mi";
20 char *Fa="Fa";
21 char *FaD="Fa#";
22 char *Sol="Sol";
23 char *SolD="Sol#";
24 char *La="La";
25 char *LaD="La#";
26 char *Si="Si";
27 char *N1="1";
28 char *N2="2";
29 char *N3="3";
30 char *N4="4";
31 char *N5="5";
32 
33 // Fonctions de débug
34 
36  printf("%s :\n",m->nom);
37  for (int tmp = 0; tmp < m->nbrTmp; tmp++){
38  for (int portee = 0; portee < nbrPortees; portee++){
39  printf("%d ",getNote(m,portee,tmp));
40  }
41  printf("\n");
42  }
43 }
44 
45 // Fin des fonctions de débug
46 
48  ajouterMotif(&liste, DEF_NBR_TMP, nbrPortees);
49  Motif* m = liste;
50 
51  // My Little Pony.
52  definirNote(m,0,0,1);
53  definirInstrument(m,0,0,1);
54  definirInstrument(m,0,2,-1);
55  definirNote(m,0,4,1);
56  definirInstrument(m,0,4,0);
57  definirNote(m,0,5,1);
58  definirInstrument(m,0,5,1);
59  definirInstrument(m,0,6,-1);
60  definirNote(m,0,7,1);
61  definirInstrument(m,0,7,2);
62  definirInstrument(m,0,8,-1);
63  definirNote(m,0,9,1);
64  definirInstrument(m,0,9,1);
65  definirInstrument(m,0,12,-1);
66 
67  ajouterMotif(&liste, DEF_NBR_TMP, nbrPortees);
68  Motif* n = liste;
69 
70  // I used to wonder what friendship could be.
71  definirNote(n,0,1,1);
72  definirInstrument(n,0,1,3);
73  definirNote(n,0,2,1);
74  definirInstrument(n,0,2,3);
75  definirNote(n,0,3,1);
76  definirInstrument(n,0,3,3);
77  definirNote(n,0,4,1);
78  definirInstrument(n,0,4,3);
79  definirInstrument(n,0,5,-1);
80  definirNote(n,0,6,1);
81  definirInstrument(n,0,6,1);
82  definirNote(n,0,7,1);
83  definirInstrument(n,0,7,2);
84  definirInstrument(n,0,8,-1);
85  definirNote(n,0,9,1);
86  definirInstrument(n,0,9,1);
87  definirInstrument(n,0,10,-1);
88  definirNote(n,0,11,1);
89  definirInstrument(n,0,11,3);
90  definirInstrument(n,0,12,-1);
91  definirNote(n,0,13,1);
92  definirInstrument(n,0,13,2);
93  definirInstrument(n,0,14,-1);
94  definirNote(n,0,15,1);
95  definirInstrument(n,0,15,1);
96 
97  ajouterMotif(&liste, DEF_NBR_TMP, nbrPortees);
98  Motif* p = liste;
99 
100  // Until you all shared its magic with me.
101  definirNote(p,0,0,1);
102  definirInstrument(p,0,0,3);
103  definirNote(p,0,1,1);
104  definirInstrument(p,0,1,4);
105  definirInstrument(p,0,2,-1);
106  definirNote(p,0,3,1);
107  definirInstrument(p,0,3,4);
108  definirInstrument(p,0,4,-1);
109  definirNote(p,0,5,1);
110  definirInstrument(p,0,5,3);
111  definirInstrument(p,0,6,-1);
112  definirNote(p,0,7,1);
113  definirInstrument(p,0,7,2);
114  definirInstrument(p,0,8,-1);
115  definirNote(p,0,9,1);
116  definirInstrument(p,0,9,1);
117  definirNote(p,0,10,1);
118  definirInstrument(p,0,10,3);
119  definirInstrument(p,0,11,-1);
120  definirNote(p,0,12,1);
121  definirInstrument(p,0,12,2);
122  definirInstrument(p,0,14,-1);
123 
124  ajouterMotifVirtuel(melodie,0,m);
125  ajouterMotifVirtuel(melodie,1,n);
126  ajouterMotifVirtuel(melodie,2,m);
127  ajouterMotifVirtuel(melodie,3,p);
128 }
129 
130 char *str_dup(char const *s)
131 {
132  char *pc = NULL;
133 
134  if (s != NULL)
135  {
136  pc = malloc((strlen(s) + 1) * sizeof *pc);
137  if (pc != NULL)
138  {
139  strcpy(pc, s);
140  }
141  }
142 
143  return pc;
144 }
145 
146 int main( int argc, char *argv[] ){
147 
148  GtkWidget *maFenetre;
149  char *str=NULL;
150 
151  gtk_init( &argc, &argv );
152 
153  monBuilder = gtk_builder_new();
154 
155  gtk_builder_add_from_file( monBuilder, "GUI/ponytrackertest.glade", NULL);
156  gtk_builder_connect_signals( monBuilder, NULL);
157 
158  maFenetre = GTK_WIDGET( gtk_builder_get_object( monBuilder, "fenetreprincipale"));
159 
160  GtkButton *button = (GtkButton*) gtk_builder_get_object(monBuilder, "button16");
161  switch (getNote(m,0,0)) {
162  case 0 :
163  str="Do ";
164  break;
165  case 1 :
166  str="Do# ";
167  break;
168  case 2 :
169  str="Re ";
170  break;
171  case 3 :
172  str="Re# ";
173  break;
174  case 4 :
175  str="Mi ";
176  break;
177  case 5 :
178  str="Fa ";
179  break;
180  case 6 :
181  str="Fa# ";
182  break;
183  case 7 :
184  str="Sol ";
185  break;
186  case 8 :
187  str="Sol# ";
188  break;
189  case 9 :
190  str="La ";
191  break;
192  case 10 :
193  str="La# ";
194  break;
195  case 11 :
196  str="Si ";
197  break;
198  default :
199  break;
200  }
201 
202  switch (getOctave(m,0,0)) {
203  case 0 :
204  strcat(str, "1 ");
205  break;
206  case 1 :
207  strcat(str, "2 ");
208  break;
209  case 2 :
210  strcat(str, "3 ");
211  break;
212  case 3 :
213  strcat(str, "4 ");
214  break;
215  case 4 :
216  strcat(str, "5 ");
217  break;
218  default :
219  break;
220  }
221 
222  switch (getInstrument(m,0,0)) {
223  case 0 :
224  strcat(str, "1 ");
225  break;
226  case 1 :
227  strcat(str, "2 ");
228  break;
229  case 2 :
230  strcat(str, "3 ");
231  break;
232  case 3 :
233  strcat(str, "4 ");
234  break;
235  case 4 :
236  strcat(str, "5 ");
237  break;
238  default :
239  break;
240  }
241 
242  switch (getVolume(m,0,0)) {
243  case 0 :
244  strcat(str, "1 ");
245  break;
246  case 1 :
247  strcat(str, "2 ");
248  break;
249  case 2 :
250  strcat(str, "3 ");
251  break;
252  case 3 :
253  strcat(str, "4 ");
254  break;
255  case 4 :
256  strcat(str, "5 ");
257  break;
258  default :
259  break;
260  }
261 
262  switch (getEffet(m,0,0)) {
263  case 0 :
264  strcat(str, "1 ");
265  break;
266  case 1 :
267  strcat(str, "2 ");
268  break;
269  case 2 :
270  strcat(str, "3 ");
271  break;
272  case 3 :
273  strcat(str, "4 ");
274  break;
275  case 4 :
276  strcat(str, "5 ");
277  break;
278  default :
279  break;
280  }
281 
282  gtk_button_set_label(button, str);
283 
284  gtk_widget_show_all (maFenetre);
285  gtk_main();
286  return EXIT_SUCCESS;
287 }
288 
289 void fenetreSample ( int argc, char *argv[] )
290 {
291 
292  GtkWidget *maFenetreSample = GTK_WIDGET( gtk_builder_get_object( monBuilder, "ajoutsample"));
293 
294  gtk_widget_show_all (maFenetreSample);
295 }
296 
297 void fenetreInstrument ( int argc, char *argv[] )
298 {
299  GtkWidget *maFenetreInstrument = GTK_WIDGET( gtk_builder_get_object( monBuilder, "ajoutinstrument"));
300 
301  gtk_widget_show_all (maFenetreInstrument);
302 }
303 
304 void fenetreMotif ( int argc, char *argv[] )
305 {
306  GtkWidget *maFenetreMotif = GTK_WIDGET( gtk_builder_get_object( monBuilder, "ajoutmotif"));
307 
308  gtk_widget_show_all (maFenetreMotif);
309 }
310 
311 void fenetreNote ( int argc, char *argv[] )
312 {
313  GtkWidget *maFenetreNote = GTK_WIDGET( gtk_builder_get_object( monBuilder, "ajoutnote"));
314 
315  gtk_widget_show_all (maFenetreNote);
316 }
317 
318 void remplissageNote (GtkWidget *widget, gpointer *data){
319 
320  GtkEntry *entryNote = (GtkEntry*) gtk_builder_get_object(monBuilder,"combonote");
321  GtkEntry *entryOctave = (GtkEntry*) gtk_builder_get_object(monBuilder,"combooctave");
322  GtkEntry *entryInstrument = (GtkEntry*) gtk_builder_get_object(monBuilder,"comboinstrument");
323  GtkEntry *entryVolume = (GtkEntry*) gtk_builder_get_object(monBuilder,"combovolume");
324  GtkEntry *entryEffet = (GtkEntry*) gtk_builder_get_object(monBuilder,"comboeffet");
325 
326  const char *strnote = gtk_entry_get_text(GTK_ENTRY(entryNote));
327  const char *stroctave = gtk_entry_get_text(GTK_ENTRY(entryOctave));
328  const char *strinstrument = gtk_entry_get_text(GTK_ENTRY(entryInstrument));
329  const char *strvolume = gtk_entry_get_text(GTK_ENTRY(entryVolume));
330  const char *streffet = gtk_entry_get_text(GTK_ENTRY(entryEffet));
331 
332  if (strcmp(Do,strnote)==0) definirNote(m,0,0,1);
333  else
334  if (strcmp(DoD,strnote)==0) definirNote(m,0,0,2);
335  else
336  if (strcmp(Re,strnote)==0) definirNote(m,0,0,3);
337  else
338  if (strcmp(ReD,strnote)==0) definirNote(m,0,0,4);
339  else
340  if (strcmp(Mi,strnote)==0) definirNote(m,0,0,5);
341  else
342  if (strcmp(Fa,strnote)==0) definirNote(m,0,0,6);
343  else
344  if (strcmp(FaD,strnote)==0) definirNote(m,0,0,7);
345  else
346  if (strcmp(Sol,strnote)==0) definirNote(m,0,0,8);
347  else
348  if (strcmp(SolD,strnote)==0) definirNote(m,0,0,9);
349  else
350  if (strcmp(La,strnote)==0) definirNote(m,0,0,10);
351  else
352  if (strcmp(LaD,strnote)==0) definirNote(m,0,0,11);
353  else
354  if (strcmp(Si,strnote)==0) definirNote(m,0,0,12);
355 
356  if (strcmp(N1,stroctave)==0) definirOctave(m,0,0,1);
357  else
358  if (strcmp(N2,stroctave)==0) definirOctave(m,0,0,2);
359  else
360  if (strcmp(N3,stroctave)==0) definirOctave(m,0,0,3);
361  else
362  if (strcmp(N4,stroctave)==0) definirOctave(m,0,0,4);
363  else
364  if (strcmp(N5,stroctave)==0) definirOctave(m,0,0,5);
365 
366  if (strcmp(N1,strinstrument)==0) definirInstrument(m,0,0,1);
367  else
368  if (strcmp(N2,strinstrument)==0) definirInstrument(m,0,0,2);
369  else
370  if (strcmp(N3,strinstrument)==0) definirInstrument(m,0,0,3);
371  else
372  if (strcmp(N4,strinstrument)==0) definirInstrument(m,0,0,4);
373  else
374  if (strcmp(N5,strinstrument)==0) definirInstrument(m,0,0,5);
375 
376  if (strcmp(N1,strvolume)==0) definirVolume(m,0,0,1);
377  else
378  if (strcmp(N2,strvolume)==0) definirVolume(m,0,0,2);
379  else
380  if (strcmp(N3,strvolume)==0) definirVolume(m,0,0,3);
381  else
382  if (strcmp(N4,strvolume)==0) definirVolume(m,0,0,4);
383  else
384  if (strcmp(N5,strvolume)==0) definirVolume(m,0,0,5);
385 
386  if (strcmp(N1,streffet)==0) definirEffet(m,0,0,1);
387  else
388  if (strcmp(N2,streffet)==0) definirEffet(m,0,0,2);
389  else
390  if (strcmp(N3,streffet)==0) definirEffet(m,0,0,3);
391  else
392  if (strcmp(N4,streffet)==0) definirEffet(m,0,0,4);
393  else
394  if (strcmp(N5,streffet)==0) definirEffet(m,0,0,5);
395 }
396 
398 {
399  Motif* melodie[MAX_PATTERNS] = {NULL};
400  Motif* liste = NULL;
401  int nbrPortees = 1;
402  courant = 0;
403  taille = 0;
404  debut(melodie, liste, nbrPortees);
405  lecture(nbrPortees,480,melodie);
406 }
407 
408 void quitter ()
409 {
410  gtk_main_quit();
411 }
412 
413 void refresh(){}
void fenetreInstrument(int argc, char *argv[])
Definition: maintest.c:297
int getInstrument(Motif *m, int portee, int tmp)
Definition: motifs.c:85
void ajouterMotif(Motif **pliste, int nbrTmp, int nbrPortees)
Definition: motifs.c:22
#define DEF_NBR_TMP
Definition: maintest.c:10
int getNote(Motif *m, int portee, int tmp)
Definition: motifs.c:77
void fenetreSample(int argc, char *argv[])
Definition: maintest.c:289
char nom[10]
Definition: motifs.h:32
Motif * m
Definition: maintest.c:13
void afficherMotif(Motif *m, int nbrPortees)
Definition: maintest.c:35
char * SolD
Definition: maintest.c:23
int getEffet(Motif *m, int portee, int tmp)
Definition: motifs.c:93
void lancerLecture()
Definition: maintest.c:397
char * N2
Definition: maintest.c:28
char * N3
Definition: maintest.c:29
Definition: motifs.h:31
void fenetreNote(int argc, char *argv[])
Definition: maintest.c:311
void definirOctave(Motif *m, int portee, int tmp, int octave)
Definition: motifs.c:57
GtkBuilder * monBuilder
Definition: maintest.c:14
char * N4
Definition: maintest.c:30
int taille
Definition: main.c:46
void definirNote(Motif *m, int portee, int tmp, int note)
Definition: motifs.c:53
int nbrTmp
Definition: motifs.h:33
char * ReD
Definition: maintest.c:18
char * Sol
Definition: maintest.c:22
Motif * liste
Definition: main.c:42
char * Si
Definition: maintest.c:26
int main(int argc, char *argv[])
Definition: maintest.c:146
char * Mi
Definition: maintest.c:19
char * str_dup(char const *s)
Definition: maintest.c:130
int getVolume(Motif *m, int portee, int tmp)
Definition: motifs.c:89
char * N5
Definition: maintest.c:31
char * FaD
Definition: maintest.c:21
void lecture(int nombreChaines, int nombreInst, int tempo, Instrument *inst[], Motif *melodie[])
Definition: lecture.c:46
void ajouterMotifVirtuel(Motif *melodie[], int ind, Motif *m)
Definition: melodie.c:19
void quitter()
Definition: maintest.c:408
char * Re
Definition: maintest.c:17
char * La
Definition: maintest.c:24
void debut(Motif *melodie[], Motif *liste, int nbrPortees)
Definition: maintest.c:47
char * N1
Definition: maintest.c:27
char * LaD
Definition: maintest.c:25
#define MAX_PATTERNS
Definition: maintest.c:11
int nbrPortees
Definition: main.c:45
void definirEffet(Motif *m, int portee, int tmp, int effet)
Definition: motifs.c:69
void fenetreMotif(int argc, char *argv[])
Definition: maintest.c:304
FMOD_TAGTYPE char void * data
Definition: fmod_codec.h:26
Motif * melodie[MAX_PATTERNS]
Definition: main.c:41
void remplissageNote(GtkWidget *widget, gpointer *data)
Definition: maintest.c:318
void refresh()
Definition: maintest.c:413
char * Do
Definition: maintest.c:15
char * DoD
Definition: maintest.c:16
void definirInstrument(Motif *m, int portee, int tmp, int instrument)
Definition: motifs.c:61
void definirVolume(Motif *m, int portee, int tmp, int volume)
Definition: motifs.c:65
int getOctave(Motif *m, int portee, int tmp)
Definition: motifs.c:81
char * Fa
Definition: maintest.c:20