Merge branch 'master' of ssh://abwabwa.org:55555/home/git/ponytracker

This commit is contained in:
Raspbeguy 2014-05-21 21:13:31 +02:00
commit d29a9d075d
3 changed files with 1535 additions and 197 deletions

File diff suppressed because it is too large Load Diff

View File

@ -1,24 +1,3 @@
/**
* \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
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@ -27,14 +6,12 @@
#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
Motif* m;
GtkBuilder *monBuilder;
char *Do="Do";
char *DoD="Do#";
char *Re="Re";
@ -47,25 +24,22 @@ char *SolD="Sol#";
char *La="La";
char *LaD="La#";
char *Si="Si";
char *SiD="Si#";
char *N1="1";
char *N2="2";
char *N3="3";
char *N4="4";
char *N5="5";
void remplissageNote (GtkWidget *widget, gpointer *data);
// 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");
}
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
@ -153,25 +127,37 @@ void debut(Motif* melodie[], Motif* liste, int nbrPortees){
ajouterMotifVirtuel(melodie,3,p);
}
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;
}
int main( int argc, char *argv[] ){
//lecture(nbrPortee, melodie);
// insérer code GTK ici
GtkBuilder *monBuilder;
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"));
GtkLabel *labelNote = (GtkLabel*) gtk_builder_get_object(monBuilder,"button16");
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");
switch (getNote(m,0,0)) {
case 0 :
str="Do ";
@ -209,9 +195,6 @@ int main( int argc, char *argv[] ){
case 11 :
str="Si ";
break;
case 12 :
str="Si# ";
break;
default :
break;
}
@ -296,174 +279,127 @@ int main( int argc, char *argv[] ){
break;
}
gtk_label_set_text(labelNote, str);
gtk_button_set_label(button, str);
gtk_widget_show_all (maFenetre);
gtk_main();
return EXIT_SUCCESS;
}
void fenetreNote ( int argc, char *argv[] )
{
GtkBuilder *monBuilderNote;
GtkWidget *maFenetreNote;
gtk_init( &argc, &argv );
monBuilderNote = gtk_builder_new();
gtk_builder_add_from_file( monBuilderNote, "GUI/ponytrackertest.glade", NULL);
gtk_builder_connect_signals( monBuilderNote, NULL);
maFenetreNote = GTK_WIDGET( gtk_builder_get_object( monBuilderNote, "ajoutnote"));
GtkButton *button = (GtkButton*) gtk_builder_get_object(monBuilderNote, "buttonok");
g_signal_connect(G_OBJECT(button),"clicked",G_CALLBACK(remplissageNote),
GTK_WIDGET( gtk_builder_get_object( monBuilderNote, "ajoutnote")));
gtk_widget_show_all (maFenetreNote);
}
void remplissageNote (GtkWidget *widget, gpointer *data){
GtkBuilder *monBuilderNote;
monBuilderNote = gtk_builder_new();
gtk_builder_add_from_file( monBuilderNote, "GUI/ponytrackertest.glade", NULL);
gtk_builder_connect_signals( monBuilderNote, NULL);
GtkEntry *entryNote = (GtkEntry*) gtk_builder_get_object(monBuilderNote,"choisirnote");
GtkEntry *entryOctave = (GtkEntry*) gtk_builder_get_object(monBuilderNote,"choisiroctave");
GtkEntry *entryInstrument = (GtkEntry*) gtk_builder_get_object(monBuilderNote,"choisirinstrument");
GtkEntry *entryVolume = (GtkEntry*) gtk_builder_get_object(monBuilderNote,"entryvolume");
GtkEntry *entryEffet = (GtkEntry*) gtk_builder_get_object(monBuilderNote,"entryeffet");
if (strcmp(Do,gtk_entry_get_text(entryNote))==0) definirNote(m,0,0,1);
else
if (strcmp(DoD,gtk_entry_get_text(entryNote))==0) definirNote(m,0,0,2);
else
if (strcmp(Re,gtk_entry_get_text(entryNote))==0) definirNote(m,0,0,3);
else
if (strcmp(ReD,gtk_entry_get_text(entryNote))==0) definirNote(m,0,0,4);
else
if (strcmp(Mi,gtk_entry_get_text(entryNote))==0) definirNote(m,0,0,5);
else
if (strcmp(Fa,gtk_entry_get_text(entryNote))==0) definirNote(m,0,0,6);
else
if (strcmp(FaD,gtk_entry_get_text(entryNote))==0) definirNote(m,0,0,7);
else
if (strcmp(Sol,gtk_entry_get_text(entryNote))==0) definirNote(m,0,0,8);
else
if (strcmp(SolD,gtk_entry_get_text(entryNote))==0) definirNote(m,0,0,9);
else
if (strcmp(La,gtk_entry_get_text(entryNote))==0) definirNote(m,0,0,10);
else
if (strcmp(LaD,gtk_entry_get_text(entryNote))==0) definirNote(m,0,0,11);
else
if (strcmp(Si,gtk_entry_get_text(entryNote))==0) definirNote(m,0,0,12);
else
if (strcmp(SiD,gtk_entry_get_text(entryNote))==0) definirNote(m,0,0,13);
if (strcmp(N1,gtk_entry_get_text(entryOctave))==0) definirOctave(m,0,0,1);
else
if (strcmp(N2,gtk_entry_get_text(entryOctave))==0) definirOctave(m,0,0,2);
else
if (strcmp(N3,gtk_entry_get_text(entryOctave))==0) definirOctave(m,0,0,3);
else
if (strcmp(N4,gtk_entry_get_text(entryOctave))==0) definirOctave(m,0,0,4);
else
if (strcmp(N5,gtk_entry_get_text(entryOctave))==0) definirOctave(m,0,0,5);
if (strcmp(N1,gtk_entry_get_text(entryInstrument))==0) definirInstrument(m,0,0,1);
else
if (strcmp(N2,gtk_entry_get_text(entryInstrument))==0) definirInstrument(m,0,0,2);
else
if (strcmp(N3,gtk_entry_get_text(entryInstrument))==0) definirInstrument(m,0,0,3);
else
if (strcmp(N4,gtk_entry_get_text(entryInstrument))==0) definirInstrument(m,0,0,4);
else
if (strcmp(N5,gtk_entry_get_text(entryInstrument))==0) definirInstrument(m,0,0,5);
if (strcmp(N1,gtk_entry_get_text(entryVolume))==0) definirVolume(m,0,0,1);
else
if (strcmp(N2,gtk_entry_get_text(entryVolume))==0) definirVolume(m,0,0,2);
else
if (strcmp(N3,gtk_entry_get_text(entryVolume))==0) definirVolume(m,0,0,3);
else
if (strcmp(N4,gtk_entry_get_text(entryVolume))==0) definirVolume(m,0,0,4);
else
if (strcmp(N5,gtk_entry_get_text(entryVolume))==0) definirVolume(m,0,0,5);
if (strcmp(N1,gtk_entry_get_text(entryEffet))==0) definirEffet(m,0,0,1);
else
if (strcmp(N2,gtk_entry_get_text(entryEffet))==0) definirEffet(m,0,0,2);
else
if (strcmp(N3,gtk_entry_get_text(entryEffet))==0) definirEffet(m,0,0,3);
else
if (strcmp(N4,gtk_entry_get_text(entryEffet))==0) definirEffet(m,0,0,4);
else
if (strcmp(N5,gtk_entry_get_text(entryEffet))==0) definirEffet(m,0,0,5);
}
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/ponytrackertest.glade", NULL);
gtk_builder_connect_signals( monBuilderSample, NULL);
maFenetreSample = GTK_WIDGET( gtk_builder_get_object( monBuilderSample, "ajoutsample"));
GtkWidget *maFenetreSample = GTK_WIDGET( gtk_builder_get_object( monBuilder, "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/ponytrackertest.glade", NULL);
gtk_builder_connect_signals( monBuilderInstrument, NULL);
maFenetreInstrument = GTK_WIDGET( gtk_builder_get_object( monBuilderInstrument, "ajoutinstrument"));
GtkWidget *maFenetreInstrument = GTK_WIDGET( gtk_builder_get_object( monBuilder, "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/ponytrackertest.glade", NULL);
gtk_builder_connect_signals( monBuilderMotif, NULL);
maFenetreMotif = GTK_WIDGET( gtk_builder_get_object( monBuilderMotif, "ajoutmotif"));
GtkWidget *maFenetreMotif = GTK_WIDGET( gtk_builder_get_object( monBuilder, "ajoutmotif"));
gtk_widget_show_all (maFenetreMotif);
}
void fenetreNote ( int argc, char *argv[] )
{
GtkWidget *maFenetreNote = GTK_WIDGET( gtk_builder_get_object( monBuilder, "ajoutnote"));
gtk_widget_show_all (maFenetreNote);
}
void remplissageNote (GtkWidget *widget, gpointer *data){
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");
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));
if (strcmp(Do,strnote)==0) definirNote(m,0,0,1);
else
if (strcmp(DoD,strnote)==0) definirNote(m,0,0,2);
else
if (strcmp(Re,strnote)==0) definirNote(m,0,0,3);
else
if (strcmp(ReD,strnote)==0) definirNote(m,0,0,4);
else
if (strcmp(Mi,strnote)==0) definirNote(m,0,0,5);
else
if (strcmp(Fa,strnote)==0) definirNote(m,0,0,6);
else
if (strcmp(FaD,strnote)==0) definirNote(m,0,0,7);
else
if (strcmp(Sol,strnote)==0) definirNote(m,0,0,8);
else
if (strcmp(SolD,strnote)==0) definirNote(m,0,0,9);
else
if (strcmp(La,strnote)==0) definirNote(m,0,0,10);
else
if (strcmp(LaD,strnote)==0) definirNote(m,0,0,11);
else
if (strcmp(Si,strnote)==0) definirNote(m,0,0,12);
if (strcmp(N1,stroctave)==0) definirOctave(m,0,0,1);
else
if (strcmp(N2,stroctave)==0) definirOctave(m,0,0,2);
else
if (strcmp(N3,stroctave)==0) definirOctave(m,0,0,3);
else
if (strcmp(N4,stroctave)==0) definirOctave(m,0,0,4);
else
if (strcmp(N5,stroctave)==0) definirOctave(m,0,0,5);
if (strcmp(N1,strinstrument)==0) definirInstrument(m,0,0,1);
else
if (strcmp(N2,strinstrument)==0) definirInstrument(m,0,0,2);
else
if (strcmp(N3,strinstrument)==0) definirInstrument(m,0,0,3);
else
if (strcmp(N4,strinstrument)==0) definirInstrument(m,0,0,4);
else
if (strcmp(N5,strinstrument)==0) definirInstrument(m,0,0,5);
if (strcmp(N1,strvolume)==0) definirVolume(m,0,0,1);
else
if (strcmp(N2,strvolume)==0) definirVolume(m,0,0,2);
else
if (strcmp(N3,strvolume)==0) definirVolume(m,0,0,3);
else
if (strcmp(N4,strvolume)==0) definirVolume(m,0,0,4);
else
if (strcmp(N5,strvolume)==0) definirVolume(m,0,0,5);
if (strcmp(N1,streffet)==0) definirEffet(m,0,0,1);
else
if (strcmp(N2,streffet)==0) definirEffet(m,0,0,2);
else
if (strcmp(N3,streffet)==0) definirEffet(m,0,0,3);
else
if (strcmp(N4,streffet)==0) definirEffet(m,0,0,4);
else
if (strcmp(N5,streffet)==0) definirEffet(m,0,0,5);
}
void lancerLecture ()
{
Motif* melodie[MAX_PATTERNS] = {NULL};
Motif* liste = NULL;
int nbrPortees = 1;
int courant = 0;
courant = 0;
taille = 0;
debut(melodie, liste, nbrPortees);
lecture(nbrPortees,480,melodie);
@ -473,3 +409,5 @@ void quitter ()
{
gtk_main_quit();
}
void refresh(){}

View File

@ -954,9 +954,11 @@
<object class="GtkComboBoxText" id="choisirnote">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="has_entry">True</property>
<property name="entry_text_column">0</property>
<property name="id_column">1</property>
<items>
<item translatable="yes">Choisir une note</item>
<item translatable="yes">Do</item>
<item translatable="yes">Do#</item>
<item translatable="yes">Re</item>
@ -969,8 +971,13 @@
<item translatable="yes">La</item>
<item translatable="yes">La#</item>
<item translatable="yes">Si</item>
<item translatable="yes">Si#</item>
</items>
<child internal-child="entry">
<object class="GtkEntry" id="combonote">
<property name="can_focus">False</property>
<property name="text" translatable="yes">Choisir une note</property>
</object>
</child>
</object>
<packing>
<property name="expand">False</property>
@ -982,12 +989,19 @@
<object class="GtkComboBoxText" id="choisiroctave">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="has_entry">True</property>
<property name="entry_text_column">0</property>
<property name="id_column">1</property>
<items>
<item translatable="yes">Choisir un octave</item>
<item translatable="yes">1</item>
<item translatable="yes">2</item>
</items>
<child internal-child="entry">
<object class="GtkEntry" id="combooctave">
<property name="can_focus">False</property>
<property name="text" translatable="yes">Choisir un octave</property>
</object>
</child>
</object>
<packing>
<property name="expand">False</property>
@ -999,15 +1013,23 @@
<object class="GtkComboBoxText" id="choisirinstrument">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="has_entry">True</property>
<property name="entry_text_column">0</property>
<property name="id_column">1</property>
<items>
<item translatable="yes">Choisir un instrument</item>
<item translatable="yes">1</item>
<item translatable="yes">2</item>
<item translatable="yes">3</item>
<item translatable="yes">4</item>
<item translatable="yes">5</item>
</items>
<child internal-child="entry">
<object class="GtkEntry" id="comboinstrument">
<property name="can_focus">False</property>
<property name="text" translatable="yes">Choisir un instrument</property>
</object>
</child>
</object>
<packing>
<property name="expand">False</property>
@ -1019,15 +1041,23 @@
<object class="GtkComboBoxText" id="choisirvolume">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="has_entry">True</property>
<property name="entry_text_column">0</property>
<property name="id_column">1</property>
<items>
<item translatable="yes">Choisir un volume</item>
<item translatable="yes">1</item>
<item translatable="yes">2</item>
<item translatable="yes">3</item>
<item translatable="yes">4</item>
<item translatable="yes">5</item>
</items>
<child internal-child="entry">
<object class="GtkEntry" id="combovolume">
<property name="can_focus">False</property>
<property name="text" translatable="yes">Choisir un volume</property>
</object>
</child>
</object>
<packing>
<property name="expand">False</property>
@ -1039,15 +1069,23 @@
<object class="GtkComboBoxText" id="choisireffet">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="has_entry">True</property>
<property name="entry_text_column">0</property>
<property name="id_column">1</property>
<items>
<item translatable="yes">Choisir un effet</item>
<item translatable="yes">1</item>
<item translatable="yes">2</item>
<item translatable="yes">3</item>
<item translatable="yes">4</item>
<item translatable="yes">5</item>
</items>
<child internal-child="entry">
<object class="GtkEntry" id="comboeffet">
<property name="can_focus">False</property>
<property name="text" translatable="yes">Choisir un effet</property>
</object>
</child>
</object>
<packing>
<property name="expand">False</property>
@ -1065,6 +1103,7 @@
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<signal name="clicked" handler="remplissageNote" swapped="no"/>
</object>
<packing>
<property name="expand">False</property>
@ -1089,7 +1128,7 @@
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">5</property>
<property name="position">6</property>
</packing>
</child>
</object>
@ -2035,12 +2074,13 @@
<property name="visible">True</property>
<property name="can_focus">False</property>
<child>
<object class="GtkButton" id="Notes">
<object class="GtkButton" id="notes">
<property name="label" translatable="yes">Notes</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="yalign">0.51999998092651367</property>
<signal name="clicked" handler="refresh" swapped="no"/>
</object>
<packing>
<property name="expand">False</property>