//omidifon.cpp //auteur : c.hartmann //description : bibliothèque de fonctions pour le traitement midi DWORD info(char *titre,char *phr) { if(strcmp(titre,"")==0 && strcmp(phr,"")==0) return 0; return MessageBox(NULL,titre,phr,MB_ICONINFORMATION); } DWORD infochoix(char *titre,char *phr) { if(strcmp(titre,"")==0 && strcmp(phr,"")==0) return 0; return MessageBox(NULL,titre,phr,MB_YESNOCANCEL); } char mid(char *cible, char *source, int d, int l) { #include "extmidi.h" int i=0; *cible=0; if (l<=0) { return 1; } else { if(d<=0) { return 1; } else { while ( (*source != 0) && (++i0) ) *cible++=*source++; *cible=0; if (l>0) return 1; else return 0; } } } } int entrertabla(char *tablapage,int ipa,char *fichier) { #include "extmidi.h" fstream fic; char c; int i; long l; long lon; char l1[10]; strcpy(tablapage,""); fic.open(fichier,ios::in); if(!fic) { MessageBox(NULL,fichier,"impossible d'ouvrir en lecture",MB_YESNOCANCEL); return 0; } ipa--; l=notemax*ipa; lon=0L; i=0; while(c != EOF) { c=fic.get(); if(lon>=l) { i++; sprintf(l1,"%c",c); strcat(tablapage,l1); } if(i==notemax) { fic.close(); return i; } lon++; } fic.close(); return i; } int sortirtabla(char *phr,char *fic) { #include "extmidi.h" FILE *inout; if((inout=fopen(fic,"w"))==NULL) { //fprintf(stderr,"impossible d'ouvrir %s en écriture\n",fic); return 1; } fputs(phr,inout); fclose(inout); return 0; } MMRESULT erreur(MMRESULT mmresu,char * phrcommande) { #include "extmidi.h" LPSTR lptext; UINT resu; char phr[notemax]; strcpy(phr,phrcommande); MessageBox(0,"",phr,MB_ICONINFORMATION); resu=midiOutGetErrorText(mmresu,lptext,512); MessageBox(0,"",lptext,MB_ICONINFORMATION); if(mmresu==MMSYSERR_NOERROR) sprintf(phr,"%d pas d'erreur\n",mmresu); else if(mmresu==MMSYSERR_INVALHANDLE) strcpy(phr,"invalid handle"); else sprintf(phr,"%d erreur\n",mmresu); MessageBox(0,"",phr,MB_ICONINFORMATION); return mmresu; } int midiinit(void) { #include "extmidi.h" int itest; char page[notemax]; char phr[notemax]; int ndevice = midiOutGetNumDevs() ; MIDIOUTCAPS OutCaps ; int wDeviceID ; for(wDeviceID=0 ; wDeviceID4000) midilon=4000; Sleep(midilon); return midilon; } char arpeger(char basse,char *inter,DWORD *rythme) { #include "extmidi.h" int i; DWORD midin; DWORD lonnote; char note; note=basse; for(i=1;i<=inter[0]+1;i++) { midin=midinote(note); midijouer(midin); lonnote=rythme[i]; pause(lonnote); midistopper(midin); note+=inter[i]; } return 0; } char plaquer(char basse,char *inter,DWORD *rythme) { #include "extmidi.h" int i; DWORD midin[notemax]; DWORD lonnote; char note; note=basse; midin[1]=midinote(note); midijouer(midin[1]); lonnote=rythme[1]; pause(lonnote); for(i=2;i<=inter[0]+1;i++) { note+=inter[i-1]; midin[i]=midinote(note); midijouer(midin[i]); } lonnote=rythme[2]; pause(lonnote); for(i=1;i<=inter[0]+1;i++) midistopper(midin[i]); return 0; } char jouer(char tona,char *notetabla,DWORD *rythme) { #include "extmidi.h" int i; DWORD midin; DWORD lonnote; char note; for(i=1;i<=notetabla[0];i++) { if(notetabla[i]==0) { lonnote=rythme[i]; pause(lonnote); } else { note=notetabla[i]+tona; midin=midinote(note); midijouer(midin); lonnote=rythme[i]; pause(lonnote); midistopper(midin); } } return 0; } char accord(char basse,char degre,char *notegamme,char *renver,char *noteaccord) { #include "extmidi.h" int i; noteaccord[0]=renver[0]; for(i=1;i<=renver[0];i++) noteaccord[i]=basse+notegamme[degre+renver[i]-1]; return noteaccord[0]; } char alterer(char *notegamme,char *alteration,char *noteresu) { #include "extmidi.h" int i; noteresu[0]=notegamme[0]; for(i=1;i<=notegamme[0];i++) noteresu[i]=notegamme[i]+alteration[i]; return noteresu[0]; } char tablanote(char *tabla,char *notetabla,DWORD *rythme) { #include "extmidi.h" int i; int k; int lon; int octac; int imesu; DWORD lonnote; char l1[10]; char symb[10]; char indica[notemax]; char prov[notemax]; char resu[notemax]; strcpy(prov,tabla); strlwr(prov); octac=octa; suite : ; if(strlen(arma)>0) { tablaanhar(prov,resu); strcpy(prov,resu); } k=0; imesu=0; lon=strlen(prov); strcpy(symb,""); for(i=1;i<=lon;i++) { mid(l1,prov,i,1); if(strcmp(l1,"i")==0) { i++; mid(symb,prov,i,1); strcpy(indica,""); while(strcmp(l1,":") != 0 && i")==0) { if(octac<7) octac++; } else if(strcmp(l1,"<")==0) { if(octac>0) octac--; } else if(strcmp(l1,"o")==0) { mid(l1,prov,i+1,1); if(atoi(l1)>=0 && atoi(l1)<=8) octa=atoi(l1); octac=octa; i++; } else if(strcmp(l1,"t")==0) { i++; mid(l1,prov,i,3); if(atoi(l1)>30 && atoi(l1)<261) tempo=atoi(l1); if(atoi(l1)>9 && atoi(l1)<100) i++; else if(atoi(l1)>99) i+=2; } else if(atoi(l1)>0) { mid(l1,prov,i,2); dur=atoi(l1); if(dur>9 && dur<100) i++; } else if(strcmp(l1,".")==0) { mid(l1,prov,i+1,1); if(strcmp(l1,".")==0) { i++; lonnote=4*lonnote/7; rythme[k]=lonnote; } else { lonnote=2*lonnote/3; rythme[k]=lonnote; } } } rythme[0]=k; notetabla[0]=k; return imesu; } char indiquer(char *symb,char *indica,char *resu) { #include "extmidi.h" char *point; if(strcmp(symb,"a")==0) strcpy(arma,indica); else if(strcmp(symb,"c")==0) strcpy(resu,"conseil"); else if(strcmp(symb,"d")==0) strcpy(resu,"doigté"); else if(strcmp(symb,"h")==0) strcpy(resu,"harmonie"); else if(strcmp(symb,"i")==0) { instru=atoi(indica); midichanger(0x0+instru); strcpy(resu,"instrument"); } else if(strcmp(symb,"m")==0) { num=atoi(indica); if(num==0) num=4; point=strstr(indica,"/"); if(point) { point++; den=atoi(point); } else den=4; strcpy(resu,"mesure"); } else if(strcmp(symb,"n")==0) { strcpy(resu,"nuance"); if(strcmp(indica,"p")==0) strcpy(indica,"piamo"); else if(strcmp(indica,"pp")==0) strcpy(indica,"pianissimo"); else if(strcmp(indica,"f")==0) strcpy(indica,"forté"); else if(strcmp(indica,"ff")==0) strcpy(indica,"fortissimo"); else if(strcmp(indica,"<")==0) strcpy(indica,"diminuendo"); else if(strcmp(indica,">")==0) strcpy(indica,"crechendo"); } else if(strcmp(symb,"o")==0) { octa=atoi(indica); if(octa<0 || octa>8) octa=3; strcpy(resu,"octave"); } else if(strcmp(symb,"p")==0) strcpy(resu,"paroles"); else if(strcmp(symb,"r")==0) strcpy(resu,"reprise"); else if(strcmp(symb,"t")==0) { trans=atoi(indica); strcpy(resu,"transposition"); } else if(strcmp(symb,"v")==0) { if(strcmp(indica,"g")==0) { trans=0; strcpy(resu,"clef de sol"); } else if(strcmp(indica,"f")==0) { trans=-9; strcpy(resu,"clef de fa"); } else if(strcmp(indica,"u")==0) { trans=-11; strcpy(resu,"clef d'ut ligne 3"); } else if(atoi(indica)<17) { canal=0x0+atoi(indica); sprintf(resu,"voix %d",atoi(indica)); } else { if(atoi(indica)>128) vol=0x7f; else vol=0x0 + atoi(indica); sprintf(resu,"volume %d",atoi(indica)); } } else strcpy(resu,"indication non traitée"); return 0; } int tablaanhar(char *tabla,char *resu) { #include "extmidi.h" char *point; int imesu; int i; int lon; char l1[10]; char ls[10]; char armac[notemax]; char prov[notemax]; strcpy(armac,arma); strcpy(resu,""); strcat(tabla," "); strlwr(tabla); lon=strlen(tabla); imesu=0; for(i=1;i<=lon;i++) { mid(l1,tabla,i,1); if(strcmpi(l1,"i")==0) { mid(ls,tabla,i+1,1); strcpy(prov,""); while(strcmp(l1,":") != 0 && i<=lon) { i++; mid(l1,tabla,i,1); strcat(prov,l1); } if(strcmpi(ls,"a")==0) { mid(arma,prov,2,strlen(prov)-2); strcpy(armac,arma); } else { strcat(resu,"i"); strcat(resu,prov); } } else if(strcmp(l1,"|")==0 || *l1==13 || *l1==10) { strcat(resu,l1); strcpy(armac,arma); imesu++; } else if((*l1>=97 && *l1<=103) || (*l1>=65 && *l1<=71)) { mid(ls,tabla,i+1,1); if(strstr(armac,l1)==NULL) { if(strstr("+-0*á",ls)==NULL) strcat(resu,l1); else { strcat(resu,l1); strcat(resu,ls); i++; strcat(armac,l1); strcat(armac,ls); } } else { if(strstr("+-0*á",ls)==NULL) { strcat(resu,l1); point=strstr(armac,l1); point++; mid(l1,point,1,1); strcat(resu,l1); } else { i++; strcat(resu,l1); strcat(resu,ls); point=strstr(armac,l1); point++; mid(prov,armac,1,strlen(armac)-strlen(point)); strcat(prov,ls); point++; strcat(prov,point); strcpy(armac,prov); } } } else strcat(resu,l1); } return imesu; } DWORD jouerindi(char *tabla,char *symbindi,int ideb,int ifin,char *tablaresu,char *notetabla,DWORD *rythme,char *attaque,char *nuance) { #include "extmidi.h" DWORD ichoix; int i; int k; int lon; int imesu; int octac; int idebnote; int ifinnote; char iattaque; DWORD lonnote; char l1[10]; char symb[10]; char indica[notemax]; char prov[notemax]; char resu[notemax]; char tablamesu[notemax]; strcpy(prov,tabla); strlwr(prov); octac=octa; suite : ; if(strlen(arma)>0) { tablaanhar(prov,resu); strcpy(prov,resu); } k=0; lon=strlen(prov); imesu=0; idebnote=ideb; ifinnote=ifin; iattaque=0; for(i=0;i=ideb-1 && imesu=ideb-1 && imesu<=ifin) { if(ideb==1) idebnote=1; else if(imesu==ideb-1) idebnote=k+1; if(imesu==ifin) ifinnote=k; if(imesu>=ideb) { sprintf(l1,"mesure %d ",imesu); ichoix=infochoix(l1,tablamesu); } strcpy(l1,""); strcpy(tablamesu,""); } } else if(strcmp(l1,"m")==0) { i++; mid(l1,prov,i,1); if(strcmp(l1,"n")==0) iattaque=0; else if(strcmp(l1,"l")==0) iattaque=1; else if(strcmp(l1,"s")==0) iattaque=2; else if(strcmp(l1,"t")==0) iattaque=3; else nuance[k-1]=*l1; strcpy(l1,""); } else if(strstr("({[",l1) != NULL) nuance[k+1]=*l1; else if(strstr(")}]",l1) != NULL) nuance[k]=*l1; else if(strstr("cdefgabp",l1) != NULL) { if(k")==0) { if(octac<7) octac++; } else if(strcmp(l1,"<")==0) { if(octac>0) octac--; } else if(strcmp(l1,"o")==0) { mid(l1,prov,i+1,1); if(atoi(l1)>=0 && atoi(l1)<=8) octa=atoi(l1); octac=octa; i++; } else if(strcmp(l1,"t")==0) { i++; mid(l1,prov,i,3); if(atoi(l1)>30 && atoi(l1)<240) tempo=atoi(l1); if(atoi(l1)>9 && atoi(l1)<100) i++; else if(atoi(l1)>99) i+=2; sprintf(l1,"t%d ",tempo); } else if(atoi(l1)>0) { mid(l1,prov,i,2); dur=atoi(l1); if(dur>9 && dur<100) i++; sprintf(l1,"%d ",dur); } else if(strcmp(l1,".")==0) { mid(l1,prov,i+1,1); if(strcmp(l1,".")==0) { i++; lonnote=4*lonnote/7; rythme[k]=lonnote; } else { lonnote=2*lonnote/3; rythme[k]=lonnote; } } if(strstr(symbindi,"m") != NULL && imesu>=ideb-1 && imesu<=ifin) { strcat(tablamesu,l1); strcat(tablaresu,l1); } else if(strstr(symbindi,"n") != NULL && k>=ideb && k<=ifin) strcat(tablaresu,l1); } } if(strstr(symbindi,"m") != NULL) { ideb=idebnote; ifin=ifinnote; } if(ifin>k) ifin=k; if(ideb>ifin) ideb=k+1; for(i=1;i<=k;i++) { if(i>ifin) i=k; else if(i>=ideb && i<=ifin) { notetabla[i-ideb+1]=notetabla[i]; rythme[i-ideb+1]=rythme[i]; attaque[i-ideb+1]=attaque[i]; nuance[i-ideb+1]=nuance[i]; } } notetabla[0]=ifin-ideb+1; rythme[0]=ifin-ideb+1; attaque[0]=ifin-ideb+1; nuance[0]=ifin-ideb+1; mesure=imesu; if(ichoix != IDCANCEL && ichoix != IDNO) ichoix=jouernuance(0,symbindi,notetabla,rythme,attaque,nuance); return ichoix; } DWORD jouernuance(char tona,char *symbindi,char *notetabla,DWORD *rythme,char *attaque,char *nuance) { #include "extmidi.h" DWORD ichoix; int ideb; int i; int k; DWORD midin; DWORD lonnote; char note; ideb=0; for(i=1;i<=notetabla[0];i++) { if(strcmp(symbindi,"") != 0) { if(attaque[i] != 0 && attaque[i-1] != attaque[i]) ichoix=lireattaque(attaque[i]); if(ichoix==IDCANCEL || ichoix==IDNO) goto fin; if(nuance[i] != 41 && nuance[i] != 93 && nuance[i] != 125) ichoix=lirenuance(nuance[i]); if(ichoix==IDCANCEL || ichoix==IDNO) goto fin; if(notetabla[i] != 0 && rythme[i-1] != rythme[i]) ichoix=lirerythme(rythme[i]); if(ichoix==IDCANCEL || ichoix==IDNO) goto fin; ichoix=lirenote(notetabla[i],rythme[i]); } if(ideb==0 && (nuance[i]==40 || nuance[i]==91 || nuance[i]==123)) ideb=i; if(notetabla[i]==0) { lonnote=rythme[i]; pause(lonnote); } else if(attaque[i]==0 || attaque[i]==1) { note=notetabla[i]+tona; midin=midinote(note); midijouer(midin); if(ideb==0) { lonnote=rythme[i]; pause(lonnote); midistopper(midin); } } else if(attaque[i]==2) { note=notetabla[i]+tona; midin=midinote(note); midijouer(midin); if(ideb==0) { lonnote=rythme[i]; lonnote=7*lonnote/8; pause(lonnote); midistopper(midin); lonnote=rythme[i]/8; pause(lonnote); } } else if(attaque[i]==3) { ; } fin : ; if(ichoix==IDCANCEL || ichoix==IDNO || nuance[i]==41 || nuance[i]==93 || nuance[i]==125) { lonnote=rythme[ideb]; if(attaque[ideb]==2) lonnote=7*lonnote/8; pause(lonnote); for(k=ideb;k<=i;k++) { note=notetabla[k]+tona; midin=midinote(note); midistopper(midin); if(ichoix == IDCANCEL || ichoix==IDNO) return ichoix; } if(attaque[ideb]==2) pause(rythme[ideb]/8); ideb=0; } if(strcmp(symbindi,"") != 0) if(nuance[i]==41 || nuance[i]==93 || nuance[i]==125) ichoix=lirenuance(nuance[i]); } return ichoix; } DWORD lireattaque(char valattaque) { #include "extmidi.h" DWORD ichoix; char titre[notemax]; strcpy(titre,""); if(valattaque==1) strcpy(titre,"legato"); else if(valattaque==0) strcpy(titre,"normal"); else if(valattaque==2) strcpy(titre,"staccato"); else if(valattaque==3) strcpy(titre,"tenu"); if(strcmp(titre,"") != 0) ichoix=infochoix(titre,"mode"); else return 0; return ichoix; } DWORD lirenuance(char valnuance) { #include "extmidi.h" DWORD ichoix; char titre[notemax]; char phr[notemax]; strcpy(titre,""); strcpy(phr,""); if(valnuance==97) strcpy(phr,"allegro"); else if(valnuance==99) strcpy(phr,"crechendo"); else if(valnuance==100) strcpy(phr,"diminuendo"); else if(valnuance==101) strcpy(phr,"forté"); else if(valnuance==109) strcpy(phr,"modérato"); else if(valnuance==112) strcpy(phr,"piano"); else if(valnuance==114) strcpy(phr,"ralentir"); else if(valnuance==118) strcpy(phr,"vivatche"); else if(valnuance==40 || valnuance==91 || valnuance==123) strcpy(phr,"début"); else if(valnuance==41 || valnuance==93 || valnuance==125) strcpy(phr,"fin"); if(strcmp(phr,"") != 0) ichoix=infochoix(titre,phr); else return 0; return ichoix; } DWORD lirenote(char valnote,DWORD valrythme) { #include "extmidi.h" DWORD ichoix; char note; char titre[notemax]; char phr[notemax]; strcpy(titre,""); strcpy(phr,""); if(valnote==0) { if(valrythme==1000) strcpy(titre,"pause"); else if(valrythme==2000) strcpy(titre,"demi pause"); else if(valrythme==4000) strcpy(titre,"soupir"); else if(valrythme==8000) strcpy(titre,"demi soupir"); else if(valrythme==16000) strcpy(titre,"quart de soupir"); else if(valrythme==32000) strcpy(titre,"huitième de soupir"); else if(valrythme==64000) strcpy(titre,"seizième de soupir"); else if(valrythme==2000/3) strcpy(phr,"pause pointée"); else if(valrythme==4000/3) strcpy(phr,"demi pause pointée"); else if(valrythme==8000/3) strcpy(phr,"soupir pointée"); else if(valrythme==16000/3) strcpy(phr,"demi soupir pointée"); else if(valrythme==32000/3) strcpy(phr,"quart de soupir pointée"); else if(valrythme==64000/3) strcpy(phr,"huitième de soupir pointée"); else if(valrythme==128000/3) strcpy(phr,"seizième de soupir pointée"); } else { note=valnote/12; note=valnote-12*note; if(strstr(arma,"+") != NULL) { if(note==0) strcpy(titre,"do"); else if(note==1) strcpy(titre,"do dièse"); else if(note==2) strcpy(titre,"ré"); else if(note==3) strcpy(titre,"ré dièse"); else if(note==4) strcpy(titre,"mi"); else if(note==5) strcpy(titre,"fa"); else if(note==6) strcpy(titre,"fa dièse"); else if(note==7) strcpy(titre,"sol"); else if(note==8) strcpy(titre,"sol dièse"); else if(note==9) strcpy(titre,"la"); else if(note==10) strcpy(titre,"la dièse"); else if(note==11) strcpy(titre,"si"); } else { if(note==0) strcpy(titre,"do"); else if(note==1) strcpy(titre,"ré bémol"); else if(note==2) strcpy(titre,"ré"); else if(note==3) strcpy(titre,"mi bémol"); else if(note==4) strcpy(titre,"mi"); else if(note==5) strcpy(titre,"fa"); else if(note==6) strcpy(titre,"sol bémol"); else if(note==7) strcpy(titre,"sol"); else if(note==8) strcpy(titre,"la bémol"); else if(note==9) strcpy(titre,"la"); else if(note==10) strcpy(titre,"si bémol"); else if(note==11) strcpy(titre,"si"); } } if(strcmp(titre,"") != 0 || strcmp(phr,"") != 0) ichoix=infochoix(titre,phr); else return 0; return ichoix; } DWORD lirerythme(DWORD valrythme) { #include "extmidi.h" DWORD ichoix; char titre[notemax]; char phr[notemax]; strcpy(titre,""); strcpy(phr,""); if(valrythme==1000) strcpy(phr,"ronde"); else if(valrythme==2000) strcpy(phr,"blanche"); else if(valrythme==4000) strcpy(phr,"noire"); else if(valrythme==8000) strcpy(phr,"croche"); else if(valrythme==16000) strcpy(phr,"double croche"); else if(valrythme==32000) strcpy(titre,"triple croche"); else if(valrythme==64000) strcpy(phr,"quadruple croche"); else if(valrythme==3000) strcpy(titre,"triolet de blanche"); else if(valrythme==6000) strcpy(titre,"triolet de noire"); else if(valrythme==12000) strcpy(titre,"triolet de croche"); else if(valrythme==24000) strcpy(titre,"triolet de double croche"); else if(valrythme==48000) strcpy(titre,"triolet de triplecroche"); else if(valrythme==2000/3) strcpy(phr,"ronde pointée"); else if(valrythme==4000/3) strcpy(phr,"blanche pointée"); else if(valrythme==8000/3) strcpy(phr,"noire pointée"); else if(valrythme==16000/3) strcpy(phr,"croche pointée"); else if(valrythme==32000/3) strcpy(phr,"double croche pointée"); else if(valrythme==64000/3) strcpy(phr,"triple croche pointée"); else if(valrythme==128000/3) strcpy(phr,"quadruple croche pointée"); if(strcmp(phr,"") != 0) ichoix=infochoix(titre,phr); else return 0; return ichoix; } int saisirparamidi(char *page,char *phr) { #include "extmidi.h" char *point; int itest; itest=0; strcpy(phr,page); point=strstr(page,"arma="); if(point) { point+=5; strcpy(phr,point); strcpy(arma,phr); point=strstr(phr,"\n"); if(point) { mid(arma,phr,1,strlen(phr)-strlen(point)); strcpy(phr,arma); } itest=1; } point=strstr(page,"fictab="); if(point) { point+=7; strcpy(phr,point); strcpy(fictab,phr); point=strstr(phr,"\n"); if(point) { mid(fictab,phr,1,strlen(phr)-strlen(point)); strcpy(phr,fictab); } itest=4; } point=strstr(page,"indi="); if(point) { point+=5; strcpy(phr,point); strcpy(indi,phr); point=strstr(phr,"\n"); if(point) { mid(indi,phr,1,strlen(phr)-strlen(point)); strcpy(phr,indi); } itest=4; } point=strstr(page,"canal="); if(point) { point+=6; canal=(DWORD) atoi(point); canal=0x0 + canal; point++; strcpy(phr,point); itest=1; } point=strstr(page,"dur="); if(point) { point+=4; dur=(DWORD) atoi(point); point++; strcpy(phr,point); itest=1; } point=strstr(page,"octa="); if(point) { point+=5; octa=(char) atoi(point); point++; strcpy(phr,point); itest=1; } point=strstr(page,"trans="); if(point) { point+=6; trans=(char) atoi(point); point++; strcpy(phr,point); itest=1; } point=strstr(page,"tempo="); if(point) { point+=6; tempo=(DWORD) atoi(point); point+=2; strcpy(phr,point); itest=1; } point=strstr(page,"mesuredeb="); if(point) { point+=10; mesuredeb=atoi(point); point++; strcpy(phr,point); itest=1; } point=strstr(page,"mesurefin="); if(point) { point+=10; mesurefin=atoi(point); point++; strcpy(phr,point); itest=1; } point=strstr(page,"mesure="); if(point) { point+=7; mesure=(DWORD) atoi(point); point++; strcpy(phr,point); itest=1; } point=strstr(page,"vol="); if(point) { point+=4; vol=(DWORD) atoi(point); if(vol>127) vol=0x7f; else vol=0x0 + vol; point++; strcpy(phr,point); itest=1; } point=strstr(page,"instru="); if(point) { point+=7; instru=(DWORD) atoi(point); itest=3; } point=strstr(page,"num="); if(point) { point+=4; num=(DWORD) atoi(point); itest=2; } point=strstr(page,"den="); if(point) { point+=4; den=(DWORD) atoi(point); itest=3; } return itest; } int mididict(char *mot,char *motdict,char *ficdict) { #include "extmidi.h" FILE *in; char *point; char lignedict[notemax]; strcpy(motdict,""); if((in=fopen(ficdict,"r"))==NULL) { info("erreur mididict : vous devez placer ce dictionnaire dans la rubrique courante",ficdict); return 0; } while(!feof(in)) { fgets(lignedict,notemax,in); point=strstr(lignedict,mot); if(point) { point+=strlen(mot); strcpy(motdict,point); fclose(in); return strlen(motdict); } } fclose(in); return strlen(motdict); } int miditabladict(char *tabla,char *tablamot,char *tabladict,char *ficdict) { #include "extmidi.h" int i; int lon; char symb[10]; char l1[notemax]; char mot[notemax]; char motprov[notemax]; char motdict[notemax]; char prov[notemax]; lon=strlen(tabla); strcpy(mot,""); strcpy(prov,""); strcpy(tablamot,""); strcpy(tabladict,""); if(strstr(tabla,"[")==NULL && strstr(tabla,"{")==NULL) return 0; for(i=1;i<=lon;i++) { mid(l1,tabla,i,1); if(strstr("[{",l1) != 0) { strcpy(symb,l1); strcpy(mot,"["); while(strstr("]}",l1)==0 && i<=lon) { i++; mid(l1,tabla,i,1); if(strstr(" ]}",l1) != 0 && strcmp(mot,"[") != 0) { strcat(mot,"]"); mididict(mot,motdict,ficdict); if(strcmp(symb,"[")==0) strcat(tablamot,mot); else { mid(motprov,mot,2,strlen(mot)-2); sprintf(mot,"{%s}",motprov); strcat(tablamot,mot); } if(strcmp(motdict,"") != 0) { if(strcmp(symb,"[")==0) sprintf(mot,"(%s)",motdict); else strcpy(mot,motdict); strcat(tabladict,mot); } strcpy(mot,"["); } else if(strcmp(l1," ") != 0) strcat(mot,l1); } } else strcat(prov,l1); } strcpy(tabla,prov); return 0; }