#!/usr/bin/env python # -*- coding: utf-8 -*- # * # Application gammique évolutive # Opération = Envol système # ProgamV1epyco # from tkinter import * from tkinter.font import Font import winsound class Gammique(Tk): """ Ramification Gammique """ def __init__(self): Tk.__init__(self) "Tableau de bord" # Titre principal self.title('Entité Gammique :') # Fenêtre écran_résultat self.can=Canvas(self,bg='white', height=550,width=800) self.can.pack(side=RIGHT) # Fenêtre des utilités self.cad=Frame(self,width=300,height=300) self.cad.pack(side=LEFT) # Bouton gamme_audio tab_do=tab_re=tab_mi=tab_fa=tab_so=tab_la=tab_si=0 self.tablenotes=[tab_do,tab_re,tab_mi,tab_fa,tab_so,tab_la,tab_si] #winsound.Beep(frequency, duration) self.btrad=Button(self.cad,text ='Radio',width=15,bg='light blue', command=self.audio) self.btrad.pack() # Bouton choix chromatique self.btchr=Button(self.cad,text ='Chrome_inactif',width=15,bg='light blue') self.btchr.pack() # Bouton tableaux instruments self.bttab=Button(self.cad,text ='Tabla_inactif',width=15,bg='light blue') self.bttab.pack() # Bouton accords1357 self.bta13=Button(self.cad,text ='A1357_inactif',width=15,bg='light blue') self.bta13.pack() # Bouton quitter self.btquit=Button(self.cad, text='Quitter',bg='light grey',width=15, command=self.destroy) self.btquit.pack(side=BOTTOM) # Mémoire fantomatique self.entfan= Entry(self) self.entfan.pack() self.entfan.pack_forget() # Pantomime self.entfan.delete(0,END) self.entfan.insert(END,"IOI") # Groupe Octave RADIO self.etiqs=["Octave -1","Octave 0","Octave +1"] self.valse=["YOI","IOI","IOY"] self.variable=StringVar() self.rad=[ Radiobutton( self.cad, variable=variable, text=text, value=value, command=command, )for (variable, text, value,command) in ( (self.variable,self.etiqs[2],self.valse[2],self.yoiioiioy), (self.variable,self.etiqs[1],self.valse[1],self.yoiioiioy), (self.variable,self.etiqs[0],self.valse[0],self.yoiioiioy), ) ] for i in self.rad: i.pack() self.rad[1].select() # Les notes cursives scalpha : Graduations gérées. self.sca=[ Scale( self, length=300, orient=HORIZONTAL, label=label, troughcolor=color, sliderlength=20, showvalue=1, from_=f, to=t, tickinterval=1, command=command, ) for (label, color, f, t, command) in ( ("C", "black", 0, 5, self.scanote1), ("D", "green", -1, 4, self.scanote2), ("E", "blue", -2, 3, self.scanote3), ("F", "grey", -2, 3, self.scanote4), ("G", "red", -3, 2, self.scanote5), ("A", "orange", -4, 1, self.scanote6), ("B", "yellow", -5, 0, self.scanote7), ("CDEFGAB", "ivory", -12, 12, self.scanote8), ) ] for x in self.sca: x.pack() # Bouton gamme_naturelle self.btzer=Button(self,text ='Zéro',width=25,command=self.zero) self.btzer.pack() #self.btzer.invoke() # Bouton gamme_calculée self.btgama=Button(self,text='gamme',width=25,command=self.gama) self.btgama.pack() self.btgama.pack_forget() # Pantomime # __init__() # Premiers pixels acoustiques def audio(self): for n in range(7): frequency=self.tablenotes[n] duration=600 winsound.Beep(frequency, duration) # Les octaves du groupe RADIO def yoiioiioy(self): xradfan=self.entfan.get() xrad=self.variable.get() mqdo=self.sca[0].get() mqsi=self.sca[6].get() yo=yoc=yod=yoe=yof=yog=yoa=yob=0 fyoc=fyod=fyoe=fyof=fyog=fyoa=fyob=0 tyoc=tyod=tyoe=tyof=tyog=tyoa=tyob=0 topgam=[yoc,yod,yoe,yof,yog,yoa,yob] topform=[fyoc,fyod,fyoe,fyof,fyog,fyoa,fyob] topto=[tyoc,tyod,tyoe,tyof,tyog,tyoa,tyob] while yo < 7: yioiy=yotop=topf=topt=0 yotop=topgam[yo]=self.sca[yo].get() topf=topform[yo]=self.sca[yo].cget("from") topt=topto[yo]=self.sca[yo].cget("to") if xradfan == "IOI": if xrad == "YOI": if (mqdo>-1)and(mqsi<1): yioiy=yotop else: yioiy=yotop+12 topf=topf+12 topt=topt+12 elif xrad == "IOY": if (mqdo>-1)and(mqsi<1): yioiy= yotop else : yioiy=yotop-12 topf=topf-12 topt=topt-12 else : yioiy = yotop elif xradfan == "YOI": if xrad == "IOI": if (mqdo>-1)and(mqsi<1): yioiy= yotop else : yioiy=yotop-12 topf=topf-12 topt=topt-12 elif xrad == "IOY": if (mqdo>-1)and(mqsi<1): yioiy= yotop else : yioiy=yotop-24 topf=topf-24 topt=topt-24 else : yioiy=yotop else : if xrad == "YOI": if (mqdo>-1)and(mqsi<1): yioiy= yotop else : yioiy=yotop+24 topf=topf+24 topt=topt+24 elif xrad == "IOI": if (mqdo>-1)and(mqsi<1): yioiy= yotop else : yioiy=yotop+12 topf=topf+12 topt=topt+12 else : yioiy=yotop if yo == 0: mqdo1 = yioiy if yo == 6: mqsi1 = yioiy self.sca[yo].configure(from_ = topf, to = topt) self.sca[yo].set(yioiy) yo+=1 # while yo if xrad == "YOI": self.sca[7].configure(from_ = 0-mqdo1, to = 24-mqsi1) elif xrad == "IOI": self.sca[7].configure(from_ = -12-mqdo1, to = 12-mqsi1) elif xrad == "IOY": self.sca[7].configure(from_ = -24-mqdo1, to = 0-mqsi1) xradfan=xrad self.entfan.delete(0,END) self.entfan.insert(END,xradfan) self.btgama.invoke() # print ('*') # yoiioiioy() # Moment self.gama def momentgama(self,event): self.btgama.invoke() # Définition des curseurs def scanote1(self,xc): do=int(xc) xsi=self.sca[6].get() xre=self.sca[1].get() if doxre+1 :self.sca[1].set(do-1) # Initialise sca[7](from_) xxrad=self.variable.get() if xxrad == "YOI": self.sca[7].configure(from_ = 0-do, to = 24-xsi) elif xxrad == "IOI": self.sca[7].configure(from_ = -12-do, to = 12-xsi) elif xxrad == "IOY": self.sca[7].configure(from_ = -24-do, to = 0-xsi) self.bind('',self.momentgama) # scanote1() def scanote2(self,xd): re=int(xd) xdo=self.sca[0].get() xmi=self.sca[2].get() if rexmi+1 :self.sca[2].set(re-1) # scanote2() def scanote3(self,xe): mi=int(xe) xre=self.sca[1].get() xfa=self.sca[3].get() if mixfa:self.sca[3].set(mi) # scanote3() def scanote4(self,xf): fa=int(xf) xmi=self.sca[2].get() xsol=self.sca[4].get() if faxsol+1:self.sca[4].set(fa-1) # scanote4() def scanote5(self,xg): sol=int(xg) xfa=self.sca[3].get() xla=self.sca[5].get() if solxla+1:self.sca[5].set(sol-1) # scanote5() def scanote6(self,xa): la=int(xa) xsol=self.sca[4].get() xsi=self.sca[6].get() if laxsi+1:self.sca[6].set(la-1) # scanote6() def scanote7(self,xb): si=int(xb) xla=self.sca[5].get() xdo=self.sca[0].get() if sixdo:self.sca[0].set(si) # Initialise sca[7](from_) xxxrad=self.variable.get() if xxxrad == "YOI": self.sca[7].configure(from_ = 0-xdo, to = 24-si) elif xxxrad == "IOI": self.sca[7].configure(from_ = -12-xdo, to = 12-si) elif xxxrad == "IOY": self.sca[7].configure(from_ = -24-xdo, to = 0-si) # scanote7() def scanote8(self,xh): sch=int(xh) f_t=0 xsi=self.sca[6].get() tosi=t_si=self.sca[6].cget("to") if (xsi+sch > t_si):f_t=-1 xdo=self.sca[0].get() fromdo=f_do=self.sca[0].cget("from") todo=t_do=self.sca[0].cget("to") if (xdo+sch t_si)or(f_t==-1): fromsi = f_si+sch tosi = t_si+sch f_t=-1 self.sca[0].configure(from_ = fromdo, to = todo) self.sca[0].set(xdo+sch) self.sca[1].configure(from_ = fromre, to = tore) self.sca[1].set(xre+sch) self.sca[2].configure(from_ = frommi, to = tomi) self.sca[2].set(xmi+sch) self.sca[3].configure(from_ = fromfa, to = tofa) self.sca[3].set(xfa+sch) self.sca[4].configure(from_ = fromsol, to = tosol) self.sca[4].set(xsol+sch) self.sca[5].configure(from_ = fromla, to = tola) self.sca[5].set(xla+sch) self.sca[6].configure(from_ = fromsi, to = tosi) self.sca[6].set(xsi+sch) self.btgama.invoke() # scanote8() def zero(self): fnotes=[0,-1,-2,-2,-3,-4,-5] tnotes=[+5,+4,+3,+3,+2,+1,0] for z in range(7): self.sca[z].configure(from_ = fnotes[z], to = tnotes[z]) self.sca[z].set(0) self.sca[7].configure(from_ = -12, to = 12) self.sca[7].set(0) self.rad[1].invoke() # Remise à l'octave zéro ou "ioi" self.btgama.invoke() # zero() def gama(self): self.can.delete(ALL) # Tracé d'encadrement # Données de l'encadré : Axes(x,y)=365(x),220(y) self.can.create_line(740, 450, 740, 10, fill ='black') self.can.create_line(10, 450, 740, 450, fill ='blue') self.can.create_line(460, 450, 460, 110, fill ='green') self.can.create_line(220, 220, 740, 220, fill ='green') # De la table gammique aux tables diatoniques surnommées gammes =[[1,1,0,1,1,1,0],[0,2,0,1,1,1,0],[2,0,0,1,1,1,0],[4,0,0,0,0,1,0],[1,0,1,1,1,1,0],[0,1,1,1,1,1,0], [1,0,3,0,0,1,0],[1,2,1,0,0,1,0],[2,2,0,0,0,1,0],[0,0,1,2,1,1,0],[1,3,0,0,0,1,0],[0,0,2,1,1,1,0], [1,2,2,0,0,0,0],[0,0,4,0,0,1,0],[1,4,0,0,0,0,0],[1,0,0,2,1,1,0],[0,1,0,2,1,1,0],[1,1,3,0,0,0,0], [0,0,0,3,1,1,0],[1,1,0,0,2,1,0],[0,2,0,0,2,1,0],[0,2,0,2,0,1,0],[2,0,0,0,2,1,0],[1,0,1,0,2,1,0], [1,0,1,2,0,1,0],[1,1,1,2,0,0,0],[2,0,0,3,0,0,0],[0,0,2,0,2,1,0],[1,2,0,2,0,0,0],[1,0,0,3,0,1,0], [1,0,0,1,2,1,0],[1,1,0,3,0,0,0],[1,1,2,1,0,0,0],[0,1,0,0,3,1,0],[0,0,1,0,3,1,0],[0,0,0,1,3,1,0], [0,0,0,2,2,1,0],[1,0,0,0,3,1,0],[0,0,2,2,0,1,0],[0,0,0,0,4,1,0],[0,0,2,3,0,0,0],[1,0,0,4,0,0,0], [0,0,0,5,0,0,0],[1,1,0,1,0,2,0],[1,1,0,1,2,0,0],[0,2,0,1,0,2,0],[0,2,0,1,2,0,0],[2,0,0,1,0,2,0], [2,0,0,1,2,0,0],[1,0,1,1,0,2,0],[1,0,1,1,2,0,0],[1,1,0,0,1,2,0],[1,1,0,0,3,0,0],[1,1,0,2,1,0,0], [1,1,2,0,1,0,0],[0,2,0,0,0,3,0],[1,0,0,2,2,0,0],[1,0,0,1,0,3,0],[1,3,0,0,1,0,0],[1,0,0,0,1,3,0], [0,0,0,3,0,2,0],[0,0,2,1,2,0,0],[1,0,0,0,0,4,0],[0,0,0,3,2,0,0],[1,1,0,0,0,3,0],[3,0,0,0,0,2,0]] gamnoms =['0','-2','+2','^2','-3','-23','-34x','+34','+23x','-34','x3','°3','+34x','°34x','^3', '-4','-24','^4','°4','-5','-25','-25+','+25-','-35','-35+','+45x','+25x','°35-','+35x', '-45+','-45','x5','x45+','-25°','-35°','-45°','°45-','°5','°35+','*5','°35x','-45x', '°45x','-6','+6','-26','-26+','+26-','+26','-36','-36+','-56','-56+','+56','x46+', '-26°','-46+','-46°','x36+','-56°','°46-','°36+','*6','°46+','°6','x26-'] # Récupération des notes cursives xxx=0 xxrad0=self.variable.get() if xxrad0 == "YOI": xxx=+120 elif xxrad0 == "IOI": xxx=0 elif xxrad0 == "IOY": xxx=-120 ydo=self.sca[0].get() xcpos_=400-xxx ycpos_=220+xxx xc_=xcpos_+(ydo*10) yc_=ycpos_-(ydo*10) rc_=5 self.tablenotes[0]=xc_ self.can.create_line(xc_, 350, xc_, 40, fill ='black') self.can.create_oval(xc_-rc_,yc_-rc_,xc_+rc_,yc_+rc_,fill='black') yre=self.sca[1].get() xcpos_=420-xxx ycpos_=220+xxx xd_=xcpos_+(yre*10) yd_=ycpos_-(yre*10) rd_=5 self.tablenotes[1]=xd_ self.can.create_line(xd_, 360, xd_, 50, fill ='green') self.can.create_oval(xd_-rd_,yd_-rd_,xd_+rd_,yd_+rd_,fill='green') ymi=self.sca[2].get() xcpos_=440-xxx ycpos_=220+xxx xe_=xcpos_+(ymi*10) ye_=ycpos_-(ymi*10) re_=5 self.tablenotes[2]=xe_ self.can.create_line(xe_, 370, xe_, 60, fill ='blue') self.can.create_oval(xe_-re_,ye_-re_,xe_+re_,ye_+re_,fill='blue') yfa=self.sca[3].get() xcpos_=450-xxx ycpos_=220+xxx xf_=xcpos_+(yfa*10) yf_=ycpos_-(yfa*10) rf_=5 self.tablenotes[3]=xf_ self.can.create_line(xf_, 370, xf_, 60, fill ='grey') self.can.create_oval(xf_-rf_,yf_-rf_,xf_+rf_,yf_+rf_,fill='grey') ysol=self.sca[4].get() xcpos_=470-xxx ycpos_=220+xxx xg_=xcpos_+(ysol*10) yg_=ycpos_-(ysol*10) rg_=5 self.tablenotes[4]=xg_ self.can.create_line(xg_, 380, xg_, 70, fill ='red') self.can.create_oval(xg_-rg_,yg_-rg_,xg_+rg_,yg_+rg_,fill='red') yla=self.sca[5].get() xcpos_=490-xxx ycpos_=220+xxx xa_=xcpos_+(yla*10) ya_=ycpos_-(yla*10) ra_=5 self.tablenotes[5]=xa_ self.can.create_line(xa_, 390, xa_, 80, fill ='orange') self.can.create_oval(xa_-ra_,ya_-ra_,xa_+ra_,ya_+ra_,fill='orange') ysi=self.sca[6].get() xcpos_=510-xxx ycpos_=220+xxx xb_=xcpos_+(ysi*10) yb_=ycpos_-(ysi*10) rb_=5 self.tablenotes[6]=xb_ self.can.create_line(xb_, 400, xb_, 90, fill ='yellow') self.can.create_oval(xb_-rb_,yb_-rb_,xb_+rb_,yb_+rb_,fill='yellow') # Mesure de l'intervalle tempéré c1=(yre+1)-ydo d2=(ymi+1)-yre e3=yfa-ymi f4=(ysol+1)-yfa g5=(yla+1)-ysol a6=(ysi+1)-yla b7=i=cum_diat=ok=x=0 diata=[c1,d2,e3,f4,g5,a6,b7] while i < 6: cum_diat += diata[i] i+=1 # while i diata[i]=5-cum_diat # Recherche diatonique par l'itération cc1=dd2=ee3=ff4=gg5=aa6=bb7=0 diata2=[cc1,dd2,ee3,ff4,gg5,aa6,bb7] while x < 7: m=x y=0 while y < 7: diata2[y]=diata[m] y+=1 m+=1 if m > 6: m=0 # while myx=myx2=0 for my in gammes: if diata2 == my: degre=x myx2=myx x=7 # if diata2 myx+=1 # for my x+=1 # while x # Ici : diata(original cursif).degre(tonique).my(gamme) # Définition diatonique # GMAJ= gammes[0] gmaj = [1,1,0,1,1,1,0] # Forme majeure simplifiée # GNAT= Ordre cursif comme diata[] gnat = ['C','D','E','F','G','A','B'] # Forme alphabétique cnat = ['','','','','','',''] # Niveaux d'altérations nordiese = ['','+','x','^','+^','x^','^^','+^^','x^^','^^^','+^^^','x^^^','^^^^','13(#)','14(#)','15(#)', '16(#)','17(#)','18(#)','19(#)','20(#)','21(#)','22(#)','23(#)','24(#)', '25(#)','26(#)','27(#)','28(#)','29(#)','30(#)','31(#)','32(#)'] subemol = ['','32(b)','31(b)','30(b)','29(b)','28(b)','27(b)','26(b)','25(b)','24(b)','23(b)','22(b)', '21(b)','20(b)','19(b)','18(b)','17(b)','16(b)','15(b)','14(b)','13(b)', '****','°***','-***','***','°**','-**','**','°*','-*','*','°','-'] # Configuration modale gdeg = ['I','II','III','IV','V','VI','VII'] # Définition de l'écriture font = Font(family='Liberation Serif', size=9) # Définition des notes cursives cursifs=[ydo,yre,ymi,yfa,ysol,yla,ysi] ynat=ymod=0 for ycurs in cursifs: if ycurs > 0 : ymod=nordiese[ycurs] if ycurs < 0 : ymod=subemol[ycurs] if ycurs == 0 : ymod=subemol[ycurs] cnat[ynat]=ymod ynat+=1 # for ycurs # Une tournée produit une tonalité modale de 7 notes nat2=degre deg = nom = 0 ynote = xgdeg = 30 ytone = 50 while deg < 7 : nat = deg # Degré tonal en question cri = gimj = gmod = maj = 0 xdeg = 60 text0 = gdeg[deg] self.can.create_text(xgdeg,ynote+10,text=text0, font='bold',fill='black') while maj < 7 : # Tonalité modale du degré gmj = gmaj[maj] # Forme majeure (1101110) imaj = diata2[nat] # Forme modale (DIATA[DEGRE]) ynt = cnat[nat2] # Forme altérative des notes gnt = gnat[nat2] # Forme tonale (CDEFGAB) ideg = gdeg[deg] cri = cri + gimj # Tonalité cumulée gimj = imaj - gmj # Calcul tonal PAS/PAS cmod = gmod = cri if gmod > 0 : # Forme altérative des tonalités imod = nordiese[cmod] if gmod < 0 : imod = subemol[cmod] if gmod == 0 : imod = subemol[cmod] gmod = gmod + cri # Transition tonale # Construction du nom de la gamme if nom == 0 : ynom = ynt gnom = gnt tnom=gnom,gamnoms[myx2] self.can.create_text(xdeg+240,ynote-12,text=ynom,font=font,fill='red') self.can.create_text(xdeg+250,ynote+2,text=tnom, font='bold',fill='black') # if nom nat+=1 nat2+=1 if nat > 6 : nat = 0 if nat2 > 6 : nat2 = 0 maj = maj + 1 text1=[gnt] text2=[imod,maj] self.can.create_text(xdeg,ynote-12,text=ynt,font=font,fill='red') self.can.create_text(xdeg,ynote,text=text1) self.can.create_text(xdeg,ytone,text=text2,fill='blue') xdeg+=30 nom=1 # while maj ynote+=60 ytone+=60 nat2+=1 if nat2 > 6 : nat2 = 0 deg = deg + 1 # while deg # gamma() # class Gammique Gammique().mainloop()