2014-05-20 12:37:03 +02:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <gtk/gtk.h>
|
|
|
|
|
2014-05-20 23:26:25 +02:00
|
|
|
#include "motifs/motifs.h"
|
|
|
|
#include "melodie/melodie.h"
|
|
|
|
#include "lecture/lecture.h"
|
2014-05-20 12:37:03 +02:00
|
|
|
|
|
|
|
#define DEF_NBR_TMP 16
|
|
|
|
#define MAX_PATTERNS 256
|
|
|
|
|
|
|
|
Motif* m;
|
2014-05-21 20:39:42 +02:00
|
|
|
GtkBuilder *monBuilder;
|
2014-05-20 23:26:25 +02:00
|
|
|
char *Do="Do";
|
|
|
|
char *DoD="Do#";
|
|
|
|
char *Re="Re";
|
|
|
|
char *ReD="Re#";
|
|
|
|
char *Mi="Mi";
|
|
|
|
char *Fa="Fa";
|
|
|
|
char *FaD="Fa#";
|
|
|
|
char *Sol="Sol";
|
|
|
|
char *SolD="Sol#";
|
|
|
|
char *La="La";
|
|
|
|
char *LaD="La#";
|
|
|
|
char *Si="Si";
|
|
|
|
char *N1="1";
|
|
|
|
char *N2="2";
|
|
|
|
char *N3="3";
|
|
|
|
char *N4="4";
|
|
|
|
char *N5="5";
|
2014-05-20 12:37:03 +02:00
|
|
|
|
|
|
|
// Fonctions de débug
|
|
|
|
|
|
|
|
void afficherMotif(Motif* m, int nbrPortees){
|
2014-05-21 20:39:42 +02:00
|
|
|
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");
|
|
|
|
}
|
2014-05-20 12:37:03 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// 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);
|
|
|
|
}
|
|
|
|
|
2014-05-21 20:39:42 +02:00
|
|
|
char *str_dup(char const *s)
|
|
|
|
{
|
|
|
|
char *pc = NULL;
|
|
|
|
|
|
|
|
if (s != NULL)
|
|
|
|
{
|
|
|
|
pc = malloc((strlen(s) + 1) * sizeof *pc);
|
|
|
|
if (pc != NULL)
|
|
|
|
{
|
|
|
|
strcpy(pc, s);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return pc;
|
|
|
|
}
|
2014-05-20 12:37:03 +02:00
|
|
|
|
2014-05-21 20:39:42 +02:00
|
|
|
int main( int argc, char *argv[] ){
|
|
|
|
|
|
|
|
GtkWidget *maFenetre;
|
|
|
|
char *str=NULL;
|
|
|
|
|
|
|
|
gtk_init( &argc, &argv );
|
|
|
|
|
|
|
|
monBuilder = gtk_builder_new();
|
|
|
|
|
|
|
|
gtk_builder_add_from_file( monBuilder, "GUI/ponytrackertest.glade", NULL);
|
|
|
|
gtk_builder_connect_signals( monBuilder, NULL);
|
|
|
|
|
|
|
|
maFenetre = GTK_WIDGET( gtk_builder_get_object( monBuilder, "fenetreprincipale"));
|
|
|
|
|
|
|
|
GtkButton *button = (GtkButton*) gtk_builder_get_object(monBuilder, "button16");
|
2014-05-20 23:26:25 +02:00
|
|
|
switch (getNote(m,0,0)) {
|
|
|
|
case 0 :
|
|
|
|
str="Do ";
|
|
|
|
break;
|
|
|
|
case 1 :
|
|
|
|
str="Do# ";
|
|
|
|
break;
|
|
|
|
case 2 :
|
|
|
|
str="Re ";
|
|
|
|
break;
|
|
|
|
case 3 :
|
|
|
|
str="Re# ";
|
|
|
|
break;
|
|
|
|
case 4 :
|
|
|
|
str="Mi ";
|
|
|
|
break;
|
|
|
|
case 5 :
|
|
|
|
str="Fa ";
|
|
|
|
break;
|
|
|
|
case 6 :
|
|
|
|
str="Fa# ";
|
|
|
|
break;
|
|
|
|
case 7 :
|
|
|
|
str="Sol ";
|
|
|
|
break;
|
|
|
|
case 8 :
|
|
|
|
str="Sol# ";
|
|
|
|
break;
|
|
|
|
case 9 :
|
|
|
|
str="La ";
|
|
|
|
break;
|
|
|
|
case 10 :
|
|
|
|
str="La# ";
|
|
|
|
break;
|
|
|
|
case 11 :
|
|
|
|
str="Si ";
|
|
|
|
break;
|
|
|
|
default :
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
switch (getOctave(m,0,0)) {
|
|
|
|
case 0 :
|
|
|
|
strcat(str, "1 ");
|
|
|
|
break;
|
|
|
|
case 1 :
|
|
|
|
strcat(str, "2 ");
|
|
|
|
break;
|
|
|
|
case 2 :
|
|
|
|
strcat(str, "3 ");
|
|
|
|
break;
|
|
|
|
case 3 :
|
|
|
|
strcat(str, "4 ");
|
|
|
|
break;
|
|
|
|
case 4 :
|
|
|
|
strcat(str, "5 ");
|
|
|
|
break;
|
|
|
|
default :
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
switch (getInstrument(m,0,0)) {
|
|
|
|
case 0 :
|
|
|
|
strcat(str, "1 ");
|
|
|
|
break;
|
|
|
|
case 1 :
|
|
|
|
strcat(str, "2 ");
|
|
|
|
break;
|
|
|
|
case 2 :
|
|
|
|
strcat(str, "3 ");
|
|
|
|
break;
|
|
|
|
case 3 :
|
|
|
|
strcat(str, "4 ");
|
|
|
|
break;
|
|
|
|
case 4 :
|
|
|
|
strcat(str, "5 ");
|
|
|
|
break;
|
|
|
|
default :
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
switch (getVolume(m,0,0)) {
|
|
|
|
case 0 :
|
|
|
|
strcat(str, "1 ");
|
|
|
|
break;
|
|
|
|
case 1 :
|
|
|
|
strcat(str, "2 ");
|
|
|
|
break;
|
|
|
|
case 2 :
|
|
|
|
strcat(str, "3 ");
|
|
|
|
break;
|
|
|
|
case 3 :
|
|
|
|
strcat(str, "4 ");
|
|
|
|
break;
|
|
|
|
case 4 :
|
|
|
|
strcat(str, "5 ");
|
|
|
|
break;
|
|
|
|
default :
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
switch (getEffet(m,0,0)) {
|
|
|
|
case 0 :
|
|
|
|
strcat(str, "1 ");
|
|
|
|
break;
|
|
|
|
case 1 :
|
|
|
|
strcat(str, "2 ");
|
|
|
|
break;
|
|
|
|
case 2 :
|
|
|
|
strcat(str, "3 ");
|
|
|
|
break;
|
|
|
|
case 3 :
|
|
|
|
strcat(str, "4 ");
|
|
|
|
break;
|
|
|
|
case 4 :
|
|
|
|
strcat(str, "5 ");
|
|
|
|
break;
|
|
|
|
default :
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2014-05-21 20:39:42 +02:00
|
|
|
gtk_button_set_label(button, str);
|
2014-05-20 12:37:03 +02:00
|
|
|
|
|
|
|
gtk_widget_show_all (maFenetre);
|
|
|
|
gtk_main();
|
|
|
|
return EXIT_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2014-05-21 20:39:42 +02:00
|
|
|
void fenetreSample ( int argc, char *argv[] )
|
2014-05-20 23:26:25 +02:00
|
|
|
{
|
|
|
|
|
2014-05-21 20:39:42 +02:00
|
|
|
GtkWidget *maFenetreSample = GTK_WIDGET( gtk_builder_get_object( monBuilder, "ajoutsample"));
|
2014-05-20 23:26:25 +02:00
|
|
|
|
2014-05-21 20:39:42 +02:00
|
|
|
gtk_widget_show_all (maFenetreSample);
|
|
|
|
}
|
2014-05-20 23:26:25 +02:00
|
|
|
|
2014-05-21 20:39:42 +02:00
|
|
|
void fenetreInstrument ( int argc, char *argv[] )
|
|
|
|
{
|
|
|
|
GtkWidget *maFenetreInstrument = GTK_WIDGET( gtk_builder_get_object( monBuilder, "ajoutinstrument"));
|
2014-05-20 23:26:25 +02:00
|
|
|
|
2014-05-21 20:39:42 +02:00
|
|
|
gtk_widget_show_all (maFenetreInstrument);
|
|
|
|
}
|
2014-05-20 23:26:25 +02:00
|
|
|
|
2014-05-21 20:39:42 +02:00
|
|
|
void fenetreMotif ( int argc, char *argv[] )
|
|
|
|
{
|
|
|
|
GtkWidget *maFenetreMotif = GTK_WIDGET( gtk_builder_get_object( monBuilder, "ajoutmotif"));
|
2014-05-20 23:26:25 +02:00
|
|
|
|
2014-05-21 20:39:42 +02:00
|
|
|
gtk_widget_show_all (maFenetreMotif);
|
|
|
|
}
|
2014-05-20 23:26:25 +02:00
|
|
|
|
2014-05-21 20:39:42 +02:00
|
|
|
void fenetreNote ( int argc, char *argv[] )
|
|
|
|
{
|
|
|
|
GtkWidget *maFenetreNote = GTK_WIDGET( gtk_builder_get_object( monBuilder, "ajoutnote"));
|
|
|
|
|
2014-05-20 23:26:25 +02:00
|
|
|
gtk_widget_show_all (maFenetreNote);
|
|
|
|
}
|
|
|
|
|
2014-05-20 12:37:03 +02:00
|
|
|
void remplissageNote (GtkWidget *widget, gpointer *data){
|
|
|
|
|
2014-05-21 20:39:42 +02:00
|
|
|
GtkEntry *entryNote = (GtkEntry*) gtk_builder_get_object(monBuilder,"combonote");
|
|
|
|
GtkEntry *entryOctave = (GtkEntry*) gtk_builder_get_object(monBuilder,"combooctave");
|
|
|
|
GtkEntry *entryInstrument = (GtkEntry*) gtk_builder_get_object(monBuilder,"comboinstrument");
|
|
|
|
GtkEntry *entryVolume = (GtkEntry*) gtk_builder_get_object(monBuilder,"combovolume");
|
|
|
|
GtkEntry *entryEffet = (GtkEntry*) gtk_builder_get_object(monBuilder,"comboeffet");
|
2014-05-20 12:37:03 +02:00
|
|
|
|
2014-05-21 20:39:42 +02:00
|
|
|
const char *strnote = gtk_entry_get_text(GTK_ENTRY(entryNote));
|
|
|
|
const char *stroctave = gtk_entry_get_text(GTK_ENTRY(entryOctave));
|
|
|
|
const char *strinstrument = gtk_entry_get_text(GTK_ENTRY(entryInstrument));
|
|
|
|
const char *strvolume = gtk_entry_get_text(GTK_ENTRY(entryVolume));
|
|
|
|
const char *streffet = gtk_entry_get_text(GTK_ENTRY(entryEffet));
|
2014-05-20 12:37:03 +02:00
|
|
|
|
2014-05-21 20:39:42 +02:00
|
|
|
if (strcmp(Do,strnote)==0) definirNote(m,0,0,1);
|
2014-05-20 12:37:03 +02:00
|
|
|
else
|
2014-05-21 20:39:42 +02:00
|
|
|
if (strcmp(DoD,strnote)==0) definirNote(m,0,0,2);
|
2014-05-20 12:37:03 +02:00
|
|
|
else
|
2014-05-21 20:39:42 +02:00
|
|
|
if (strcmp(Re,strnote)==0) definirNote(m,0,0,3);
|
2014-05-20 23:26:25 +02:00
|
|
|
else
|
2014-05-21 20:39:42 +02:00
|
|
|
if (strcmp(ReD,strnote)==0) definirNote(m,0,0,4);
|
2014-05-20 23:26:25 +02:00
|
|
|
else
|
2014-05-21 20:39:42 +02:00
|
|
|
if (strcmp(Mi,strnote)==0) definirNote(m,0,0,5);
|
2014-05-20 23:26:25 +02:00
|
|
|
else
|
2014-05-21 20:39:42 +02:00
|
|
|
if (strcmp(Fa,strnote)==0) definirNote(m,0,0,6);
|
2014-05-20 23:26:25 +02:00
|
|
|
else
|
2014-05-21 20:39:42 +02:00
|
|
|
if (strcmp(FaD,strnote)==0) definirNote(m,0,0,7);
|
2014-05-20 23:26:25 +02:00
|
|
|
else
|
2014-05-21 20:39:42 +02:00
|
|
|
if (strcmp(Sol,strnote)==0) definirNote(m,0,0,8);
|
2014-05-20 23:26:25 +02:00
|
|
|
else
|
2014-05-21 20:39:42 +02:00
|
|
|
if (strcmp(SolD,strnote)==0) definirNote(m,0,0,9);
|
2014-05-20 23:26:25 +02:00
|
|
|
else
|
2014-05-21 20:39:42 +02:00
|
|
|
if (strcmp(La,strnote)==0) definirNote(m,0,0,10);
|
2014-05-20 23:26:25 +02:00
|
|
|
else
|
2014-05-21 20:39:42 +02:00
|
|
|
if (strcmp(LaD,strnote)==0) definirNote(m,0,0,11);
|
2014-05-20 23:26:25 +02:00
|
|
|
else
|
2014-05-21 20:39:42 +02:00
|
|
|
if (strcmp(Si,strnote)==0) definirNote(m,0,0,12);
|
2014-05-20 12:37:03 +02:00
|
|
|
|
2014-05-21 20:39:42 +02:00
|
|
|
if (strcmp(N1,stroctave)==0) definirOctave(m,0,0,1);
|
2014-05-20 12:37:03 +02:00
|
|
|
else
|
2014-05-21 20:39:42 +02:00
|
|
|
if (strcmp(N2,stroctave)==0) definirOctave(m,0,0,2);
|
2014-05-20 23:26:25 +02:00
|
|
|
else
|
2014-05-21 20:39:42 +02:00
|
|
|
if (strcmp(N3,stroctave)==0) definirOctave(m,0,0,3);
|
2014-05-20 23:26:25 +02:00
|
|
|
else
|
2014-05-21 20:39:42 +02:00
|
|
|
if (strcmp(N4,stroctave)==0) definirOctave(m,0,0,4);
|
2014-05-20 23:26:25 +02:00
|
|
|
else
|
2014-05-21 20:39:42 +02:00
|
|
|
if (strcmp(N5,stroctave)==0) definirOctave(m,0,0,5);
|
2014-05-20 12:37:03 +02:00
|
|
|
|
2014-05-21 20:39:42 +02:00
|
|
|
if (strcmp(N1,strinstrument)==0) definirInstrument(m,0,0,1);
|
2014-05-20 12:37:03 +02:00
|
|
|
else
|
2014-05-21 20:39:42 +02:00
|
|
|
if (strcmp(N2,strinstrument)==0) definirInstrument(m,0,0,2);
|
2014-05-20 23:26:25 +02:00
|
|
|
else
|
2014-05-21 20:39:42 +02:00
|
|
|
if (strcmp(N3,strinstrument)==0) definirInstrument(m,0,0,3);
|
2014-05-20 23:26:25 +02:00
|
|
|
else
|
2014-05-21 20:39:42 +02:00
|
|
|
if (strcmp(N4,strinstrument)==0) definirInstrument(m,0,0,4);
|
2014-05-20 23:26:25 +02:00
|
|
|
else
|
2014-05-21 20:39:42 +02:00
|
|
|
if (strcmp(N5,strinstrument)==0) definirInstrument(m,0,0,5);
|
2014-05-20 12:37:03 +02:00
|
|
|
|
2014-05-21 20:39:42 +02:00
|
|
|
if (strcmp(N1,strvolume)==0) definirVolume(m,0,0,1);
|
2014-05-20 12:37:03 +02:00
|
|
|
else
|
2014-05-21 20:39:42 +02:00
|
|
|
if (strcmp(N2,strvolume)==0) definirVolume(m,0,0,2);
|
2014-05-20 23:26:25 +02:00
|
|
|
else
|
2014-05-21 20:39:42 +02:00
|
|
|
if (strcmp(N3,strvolume)==0) definirVolume(m,0,0,3);
|
2014-05-20 23:26:25 +02:00
|
|
|
else
|
2014-05-21 20:39:42 +02:00
|
|
|
if (strcmp(N4,strvolume)==0) definirVolume(m,0,0,4);
|
2014-05-20 23:26:25 +02:00
|
|
|
else
|
2014-05-21 20:39:42 +02:00
|
|
|
if (strcmp(N5,strvolume)==0) definirVolume(m,0,0,5);
|
2014-05-20 12:37:03 +02:00
|
|
|
|
2014-05-21 20:39:42 +02:00
|
|
|
if (strcmp(N1,streffet)==0) definirEffet(m,0,0,1);
|
2014-05-20 12:37:03 +02:00
|
|
|
else
|
2014-05-21 20:39:42 +02:00
|
|
|
if (strcmp(N2,streffet)==0) definirEffet(m,0,0,2);
|
2014-05-20 23:26:25 +02:00
|
|
|
else
|
2014-05-21 20:39:42 +02:00
|
|
|
if (strcmp(N3,streffet)==0) definirEffet(m,0,0,3);
|
2014-05-20 23:26:25 +02:00
|
|
|
else
|
2014-05-21 20:39:42 +02:00
|
|
|
if (strcmp(N4,streffet)==0) definirEffet(m,0,0,4);
|
2014-05-20 23:26:25 +02:00
|
|
|
else
|
2014-05-21 20:39:42 +02:00
|
|
|
if (strcmp(N5,streffet)==0) definirEffet(m,0,0,5);
|
2014-05-20 12:37:03 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
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();
|
|
|
|
}
|
2014-05-21 20:39:42 +02:00
|
|
|
|
|
|
|
void refresh(){}
|