progamv6encore.py
1    # !/usr/bin/env python 3.5 
2    # -*- coding: utf-8 -*- 
3    # * Vendredi 5 octobre 2016 à 12h57mn 
4    # Application gammique évolutive 
5    # Operate Envol sysTM 
6    # ProgamV6encore 
7    # Approche commatique (Empreinte chromatique) 
8     
9    from tkinter import * 
10   from tkinter.font import Font 
11   from wave import struct, open 
12   from pyaudio import PyAudio 
13   from math import sin, pi 
14    
15    
16   class Gammique(Tk): 
17       """ Ramification Gammique """ 
18    
19       def __init__(self): 
20           Tk.__init__(self) 
21           "Tableau de bord" 
22           # Titre principal 
23           self.title('Entité Gammique :') 
24           self.geometry('1200x700+77+7') 
25    
26           # Fenêtre écran_résultat 
27           self.can = Canvas(self, bg='white', height=550, width=700) 
28           self.can.pack(side=RIGHT) 
29           # Fenêtre des utilités 
30           self.cad = Frame(self, width=30, height=80) 
31           self.cad.pack(side=LEFT) 
32    
33           # Bouton gamme_radio 
34           tab_do = tab_re = tab_mi = tab_fa = tab_so = tab_la = tab_si = 0 
35           # self.tablenotes = les positions du cours self.gama 
36           self.tablenotes = [tab_do, tab_re, tab_mi, tab_fa, tab_so, tab_la, tab_si] 
37           self.tbdegre = [0]  # Contient le mode tonique en cours 
38           self.btrad = Button(self.cad, text='Radio', width=15, bg='light blue', command=self.radio) 
39           self.btrad.pack() 
40    
41           # Bouton gamme_audio avec écriture sur le disque dur 
42           # self.fichnom = les noms des fichiers audio_notes (communs) 
43           self.presaudio = 0  # Utile au bouton accord/sans le résultat audio 
44           self.gamula = ['C', 'D', 'E', 'F', 'G', 'A', 'B'] 
45           self.framno = ['', '', '', '', '', '', ''] 
46           # self.fichnom : Ces fichiers vont être écrits sur votre disque dur 
47           self.fichnom = ['a1.wav', 'a2.wav', 'a3.wav', 'a4.wav', 'a5.wav', 'a6.wav', 'a7.wav'] 
48           self.btaud = Button(self.cad, text='Audio', width=15, bg='light blue', command=lambda: self.actuac(1)) 
49           self.btaud.pack() 
50           self.btaud2 = Button(self.cad, command=self.audio) 
51           self.btaud2.pack_forget()  # Pantomime 
52    
53           # Bouton choix chromatique 
54           self.chm = None 
55           hau_do = hau_re = hau_mi = hau_fa = hau_so = hau_la = hau_si = 0 
56           # self.tablehaute = les hauteurs (y) des notes graphiques 
57           self.tablehaute = [hau_do, hau_re, hau_mi, hau_fa, hau_so, hau_la, hau_si] 
58           self.chrmaj = [0, 20, 40, 50, 70, 90, 110]  # Forme graphique majeure 
59           self.chrgen = {}  # Tableau chromatique généré 
60           ntchtxt = 'Chrome naturel' 
61           self.btchr = Button(self.cad, text=ntchtxt, width=15, bg='light blue', command=self.chrome) 
62           self.btchr.pack() 
63    
64           # Bouton tableaux instruments 
65           # self.piano_wav : Ces fichiers vont être écrits sur votre disque dur 
66           self.tur = None 
67           self.sel_nbr = -1 
68           self.sel_stp = 0 
69           self.tbltr_nom = ['Tonice', 'Tonale', 'Mélodie', 'Médiane', 'Domine', 'Harmonie'] 
70           self.piano_wav = ['p_w1.wav', 'p_w2.wav'] 
71           self.seldiaton = [] 
72           self.bttab = Button(self.cad, text='Tablature', width=15, bg='light blue', command=lambda: self.actuac(9)) 
73           self.bttab.pack() 
74           self.bttab_2 = Button(self.cad, text='Tablature', width=15, bg='light blue', command=self.tabla) 
75           self.bttab_2.pack_forget()  # Pantomime 
76    
77           # Bouton accords avec écriture sur le disque dur 
78           # self.fichacc = les noms des fichiers audio_accords (communs) 
79           self.acc = None 
80           self.accdiese = ['', '+', 'x', '^', '+^', 'x^', '^^']  # Tableaux des accords - altérations 
81           self.accbemol = ['', '**', '°*', '-*', '*', '°', '-']  # Tableaux des accords - altérations 
82           # self.fichacc : Ces fichiers vont être écrits sur votre disque dur 
83           self.fichacc = ['acc1.wav', 'acc2.wav', 'acc3.wav', 'acc4.wav', 'acc5.wav', 'acc6.wav', 'acc7.wav'] 
84           self.btacc = Button(self.cad, text='Accords', width=15, bg='light blue', command=self.accord) 
85           self.btacc.pack() 
86    
87           # Bouton tables tétracordiques 
88           self.ttt = None 
89           # self.tet_maj = {} 
90           self.pretetutil = 0 
91           self.bttet = Button(self.cad, text='Tétracorde', width=15, bg='ivory', command=self.tetra) 
92           self.bttet.pack() 
93    
94           # Bouton tables commatiques 
95           self.ccc = None 
96           self.btcom = Button(self.cad, text='Commatisme', width=15, bg='ivory', command=self.comma) 
97           self.btcom.pack() 
98           self.comchr = [] 
99           self.comgen = [] 
100          self.co_tbgen = [], [], [], [], [], [], [], [], [], [], [], []  # Table des notes altérées 
101          self.co_tbval = [], [], [], [], [], [], [], [], [], [], [], []  # Table des valeurs tonales 
102          self.comfdb = [0]  # Ligne diatone, forme: dia ou/et com 
103          self.comfcb = [0]  # Ligne chrome, forme: com ou/et dia 
104          self.comfct = [0]  # -1: formulé chromatique total 
105          self.compy_ = [0]  # Les 2 niveaux chromatiques 
106          self.prescomma = 0 
107          self.btcom3color = self.btcom4color = 'light grey' 
108          self.com2 = Commatique() 
109   
110          # Bouton quitter 
111          self.btquit = Button(self.cad, text='Quitter', bg='light grey', width=15, command=self.destroy) 
112          self.btquit.pack(side=BOTTOM) 
113   
114          # Mémoire fantomatique 
115          self.entfan = Entry(self) 
116          # self.entfan.pack() 
117          self.entfan.pack_forget()  # Pantomime 
118          self.entfan.delete(0, END) 
119          self.entfan.insert(END, "IOI") 
120   
121          # Groupe Octave RADIO 
122          etiqs = ["Octave -1", "Octave  0", "Octave +1"] 
123          valse = ["YOI", "IOI", "IOY"] 
124          self.variable = StringVar() 
125          self.rad = [] 
126          for (variable, text, value, command) in ( 
127                  (self.variable, etiqs[2], valse[2], self.yoiioiioy), 
128                  (self.variable, etiqs[1], valse[1], self.yoiioiioy), 
129                  (self.variable, etiqs[0], valse[0], self.yoiioiioy), 
130          ): 
131              self.rad.append(Radiobutton( 
132                  self.cad, 
133                  variable=self.variable, 
134                  text=text, 
135                  value=value, 
136                  command=command, 
137              )) 
138          for i in self.rad: i.pack() 
139          self.rad[1].select() 
140   
141          # Bouton sélection diatonique 
142          self.preselect = [0] 
143          self.sel_bon = [] 
144          self.select = [0] 
145          self.sel_yes = 0 
146          self.sel_myx = [0] 
147          # Tables gen*: Contient les indices des fréquences "tab_freqs" 
148          self.gen_b = [3, 5, 7, 8, 10, 12, 14, 15, 17, 19, 20, 22, 24, 26, 27, 29, 31, 32, 34, 36, 38] 
149          self.gen_n = [4, 6, -1, 9, 11, 13, -1, 16, 18, -1, 21, 23, 25, -1, 28, 30, -1, 33, 35, 37] 
150          # Tables gen**: Contient les indices des touches 
151          self.gen_bz = [0, 2, 4, 5, 7, 9, 11, 12, 14, 16, 17, 19, 21, 23, 24, 26, 28, 29, 31, 33, 35, 36, 38] 
152          self.gen_nz = [1, 3, -1, 6, 8, 10, -1, 13, 15, -1, 18, 20, 22, -1, 25, 27, -1, 30, 32, 34, -1, 37] 
153          self.sel_gam = [12, 14, 16, 17, 19, 21, 23]  # Positions relatives majeures 
154          self.btsel = Button(self.cad, text='Sélectif', width=15, bg='orange', command=lambda: self.actuac(8)) 
155          self.btsel.pack() 
156   
157          # Les notes cursives scalpha : Graduations gérées. 
158          self.sca = [] 
159          for (label, color, f, t, command) in ( 
160                  ("C", "black", 0, 5, self.scanote1), 
161                  ("D", "green", -1, 4, self.scanote2), 
162                  ("E", "blue", -2, 3, self.scanote3), 
163                  ("F", "grey", -2, 3, self.scanote4), 
164                  ("G", "red", -3, 2, self.scanote5), 
165                  ("A", "orange", -4, 1, self.scanote6), 
166                  ("B", "yellow", -5, 0, self.scanote7), 
167                  ("CDEFGAB", "ivory", -12, 12, self.scanote8), 
168          ): 
169              self.sca.append(Scale( 
170                  self, 
171                  length=300, 
172                  orient=HORIZONTAL, 
173                  label=label, 
174                  troughcolor=color, 
175                  sliderlength=20, 
176                  showvalue=1, 
177                  from_=f, 
178                  to=t, 
179                  tickinterval=1, 
180                  command=command, 
181              )) 
182          for x in self.sca: x.pack() 
183   
184          # Case à cocher de conversion scanote8(CDEFGAB) vers l'octave majeure 
185          # Car, la gamme de bCmaj(scanote8) = Bmaj à l'octave principale 
186          # Exemple : bC,bD,bE,bF,bG,bA,bB = B,#C,#D,E,#F,#G,#A 
187          self.fr_8 = [0, 0, 0, 0, 0, 0, 0]  # Les tableaux self.(fr/to/sc/_8) 
188          self.to_8 = [0, 0, 0, 0, 0, 0, 0]  # Sont utilisés à def self.scanote8(_8) 
189          self.sc_8 = [0, 0, 0, 0, 0, 0, 0]  # from_(fr), to(to), .set(sc) 
190          self.cb_chk = IntVar() 
191          self.cbchk8 = Checkbutton(self, text='Conversion Octave Majeure', 
192                                    variable=self.cb_chk, fg='black', command=self.convers) 
193          self.cbchk8.pack() 
194          self.cbchk8.deselect() 
195   
196          # Bouton gamme_naturelle 
197          self.scolors = ['black', 'green', 'blue', 'grey', 'red', 'orange', 'yellow'] 
198          self.fnotes = [0, -1, -2, -2, -3, -4, -5]  # Les from_'s majeurs 
199          self.tnotes = [+5, +4, +3, +3, +2, +1, 0]  # Les to's majeurs 
200          self.btzer = Button(self, text='Zéro', width=25, command=self.zero) 
201          self.btzer.pack() 
202   
203          # Bouton gamme_calculée 
204          self.nordiese = [] 
205          self.subemol = [] 
206          self.cursifs = [] 
207          self.gammescopie = [] 
208          self.gamnomscopie = [] 
209          self.decore = {}  # Base du zéro tonique des accords 
210          self.declare = {}  # Base (degrés - notes - altérations) 
211          self.dechire = {}  # Base avec l'indice adapté aux tableaux(b/#) 
212          self.btgama = Button(self, text='gamme', width=25, command=self.gama) 
213          self.btgama.pack_forget()  # Pantomime 
214   
215      # Section com 
216
def comma(self): 217 if self.ccc is not None: 218 self.ccc.destroy() 219 self.ccc = Toplevel(self) 220 self.ccc.title('Entité Gammique : Chromatisme') 221 self.ccc.geometry('600x666+300+30') 222 frcom_up = Frame(self.ccc, width=30, height=3) # Partie haute 223 frcom_up.pack() 224 c_oo = [] 225 c_pp = [] 226 c_ii = [] 227 # Traitement d'accrochage de la gamme (nom et type) 228 # self.tbdegre : Première note du mode tonique en cours 229 # self.gamula = ['C','D','E','F','G','A','B'] 230 # self.sel_myx[0] : Est l'indice [i] en cours, dans self.gamnomscopie[i] 231 c_gam = self.gamnomscopie[self.sel_myx[0]] # c_gam = Rapport du Type 232 if c_gam == '0': 233 c_gam = "Majeur" 234 c_deg = self.tbdegre[0] # c_deg = Rapport du Degré 235 c_not = self.gamula[c_deg] # c_not = Rapport du Nom 236 c_ide = c_not, c_gam 237 c_ii.append(c_ide) 238 btcom_id = Button(frcom_up, text=c_ide, height=1, width=15, bg='light green') 239 btcom_id.pack(side=RIGHT) 240 btcom_up = Button(frcom_up, text='Commane', height=1, width=15, bg='pink', 241 command=lambda: self.com2.brnch_1(c_oo, c_pp, c_ii)) 242 btcom_up.pack(side=LEFT) 243 frcom_gaup = Frame(self.ccc, width=30, height=3) # Partie gauche 244 frcom_gaup.place(x=20, y=10, anchor='nw') 245 btcom_ga0up = Button(frcom_gaup, text='Console', height=1, width=15, bg='yellow') 246 btcom_ga0up.pack() 247 frcom_ga = Frame(self.ccc, width=30, height=3) # Partie gauche 248 frcom_ga.pack(side=LEFT) 249 btcom_ga0 = Button(frcom_ga, text='Forme totale', height=1, width=15, bg='white', 250 command=lambda: compyac(0)) 251 btcom_ga0.pack() 252 btcom_ga01 = Button(frcom_ga, text='Forme augmentée', height=1, width=18, bg='orange', 253 command=lambda: compyac(1)) 254 btcom_ga01.pack() 255 btcom_ga02 = Button(frcom_ga, text='Forme diminuée', height=1, width=18, bg='light blue', 256 command=lambda: compyac(2)) 257 btcom_ga02.pack() 258 btcom_ga03 = Button(frcom_ga, text='Chrome naturel', height=1, width=15, bg=self.btcom3color, 259 command=lambda: compyac(3)) 260 btcom_ga03.pack() 261 btcom_ga04 = Button(frcom_ga, text='Chrome atonal', height=1, width=15, bg=self.btcom4color, 262 command=lambda: compyac(4)) 263 btcom_ga04.pack() 264 265 def compyac(y): 266 if y == 0: 267 self.compy_[0] = 0 # Intègres 268 elif y == 1: 269 self.compy_[0] = 1 # Augmentations 270 elif y == 2: 271 self.compy_[0] = 2 # Diminutions 272 elif y == 3: 273 self.btchr.configure(text='Chrome naturel') 274 self.btcom3color = 'ivory' 275 self.btcom4color = 'light grey' 276 elif y == 4: 277 self.btchr.configure(text='Chrome atonal') 278 self.btcom3color = 'light grey' 279 self.btcom4color = 'ivory' 280 self.ccc.destroy() 281 self.btcom.invoke() 282 283 frcom_drup2 = Frame(self.ccc, width=20, height=3) # Partie droite 284 frcom_drup2.place(x=468, y=10, anchor='nw') 285 btcom_dr0up = Button(frcom_drup2, text='Scalaire', height=1, width=15, bg='yellow') 286 btcom_dr0up.pack() 287 frcom_dr = Frame(self.ccc, width=30, height=3) # Partie droite 288 frcom_dr.pack(side=RIGHT) 289 btcom_dr0 = Button(frcom_dr, text='Toutes les lignes', height=1, width=15, bg='white', 290 command=lambda: commuac(-1)) 291 btcom_dr0.pack() 292 btcom_dr01 = Button(frcom_dr, text='Ligne diatone.diatone', height=1, width=18, bg='light grey', 293 command=lambda: commuac(1)) 294 btcom_dr01.pack() 295 btcom_dr02 = Button(frcom_dr, text='Ligne diatone.chrome', height=1, width=18, bg='light grey', 296 command=lambda: commuac(2)) 297 btcom_dr02.pack() 298 btcom_dr03 = Button(frcom_dr, text='Ligne chrome.chrome', height=1, width=18, bg='light grey', 299 command=lambda: commuac(3)) 300 btcom_dr03.pack() 301 btcom_dr04 = Button(frcom_dr, text='Ligne chrome.diatone', height=1, width=18, bg='light grey', 302 command=lambda: commuac(4)) 303 btcom_dr04.pack() 304 btcom_dr05 = Button(frcom_dr, text='Lignes diatones', height=1, width=15, bg='pink', 305 command=lambda: commuac(5)) 306 btcom_dr05.pack() 307 btcom_dr06 = Button(frcom_dr, text='Lignes chromes', height=1, width=15, bg='light green', 308 command=lambda: commuac(6)) 309 btcom_dr06.pack() 310
311
def commuac(c): 312 self.comfct[0] = 0 # Toute.Ligne 313 self.comfdb[0] = 0 # Ligne dia.dia et/ou com 314 self.comfcb[0] = 0 # Ligne com.com et/ou dia 315 if c == -1: 316 self.comfct[0] = -1 # Toute.Ligne 317 elif c == 0: 318 pass 319 elif c == 1: 320 self.comfdb[0] = 1 # Ligne dia.dia 321 elif c == 2: 322 self.comfdb[0] = 2 # Ligne dia.com 323 elif c == 3: 324 self.comfcb[0] = 3 # Ligne com.com 325 elif c == 4: 326 self.comfcb[0] = 4 # Ligne com.dia 327 elif c == 5: 328 self.comfdb[0] = 5 # Ligne dia.dia/com 329 elif c == 6: 330 self.comfcb[0] = 6 # Ligne com.com/dia 331 self.ccc.destroy() 332 self.btcom.invoke() 333 334 # (self.comfct[0],self.comfdb[0],self.comfcb[0]) 335 comcan_1 = Canvas(self.ccc, bg='ivory', height=600, width=300) 336 comcan_1.place(x=150, y=30, anchor='nw') 337 comcan_1.delete(ALL) 338 frcom_bo = Frame(self.ccc, width=30, height=3) # Partie basse 339 frcom_bo.pack(side=BOTTOM) 340 btcom_bo = Button(frcom_bo, text='Changer', height=1, width=15, bg='light grey', 341 command=self.ccc.destroy) 342 btcom_bo.pack() 343 fontval = Font(family='Liberation Serif', size=8) 344 fontchr = Font(family='Liberation Serif', size=7) 345 fontcom = Font(family='Liberation Serif', size=9) 346 # self.scolors = ['black','green','blue','grey','red','orange','yellow']# Couleurs usuelles 347 # self.chrgen : Dictionnaire du premier mode chromatique en cours 348 # self.comchr : Premier mode chromatique indexé 349 commaj_gam = [0, 2, 4, 5, 7, 9, 11] # Forme majeure 350 # self.commaj_com = [1, 3, 6, 8, 10] # Forme de l'indice chrome 351 self.prescomma = 1 352 self.btchr.invoke() 353 self.comchr = [], [] 354 self.comgen = [], [], [], [], [], [], [], [], [], [], [], [] 355 compro = [0] 356 # Prélèvement des primitives chromatiques 357 for ci in self.chrgen: 358 change = self.chrgen[ci][7] 359 if change[0] == 'n': 360 cochr = 'gam', self.chrgen[ci][2], self.chrgen[ci][3] 361 self.comchr[0].append(cochr) 362 else: 363 cochr = 'com', self.chrgen[ci][2], self.chrgen[ci][3], self.chrgen[ci][5], \ 364 self.chrgen[ci][6] 365 self.comchr[0].append(cochr) 366 # print('comchr', self.comchr[0]) 367 compro[0] = self.comchr[0] 368 # ('compro',compro[0]) # Forme d'écriture et de lecture 369 # Composition du modèle chrome diatonique 370 for ci in range(12): 371 count = ci 372 for co in range(12): 373 self.comgen[ci].append(compro[0][count]) 374 count += 1 375 if count > 11: 376 count = 0 377 # ('comgen', ci, self.comgen[ci]) 378 # écriture du modèle chrome diatonique 379 # self.dechire[(deg,maj)] # Tableau des tonalités diatoniques 380 # c_deg = indice de tonalité 381 co_d1 = -1 382 co_tbnat = [1, 2, 3, 4, 5, 6, 7] 383 self.co_tbgen = [], [], [], [], [], [], [], [], [], [], [], [] # Table des notes altérées 384 self.co_tbval = [], [], [], [], [], [], [], [], [], [], [], [] # Table des valeurs tonales 385 for ci in range(12): 386 co_d2i = co_d2 = co_d3 = 0 387 c_zer = [0] 388 c_zof = 0 389 co_tbmod = [], [], [], [], [], [], [], [], [], [], [], [] # Passe les notes altérées 390 co_tbdif = [], [], [], [], [], [], [], [], [], [], [], [] # Passe les valeurs tonales 391 for co in range(12): 392 compris = self.comgen[ci][co][0] 393 if co == 0 and compris == 'gam': 394 co_c1 = 0 395 co_c0 = self.comgen[ci][co][2] 396 for c_ in self.gamula: 397 if c_ == co_c0[0][0]: 398 c_deg0 = co_c1 399 break 400 co_c1 += 1 401 co_d1 += 1 402 c_zer[0] = 'on' 403 elif co == 0 and compris == 'com': 404 co_c1 = 0 405 co_c0 = self.comgen[ci][co][2] 406 for c_ in self.gamula: 407 if c_ == co_c0[0][0]: 408 c_deg0 = co_c1 409 break 410 co_c1 += 1 411 c_zof = 1 412 c_zer[0] = 'of' 413 # ('compris', compris) 414 if compris == 'gam': 415 co_sign0 = self.comgen[ci][co][1] 416 comcan_1.create_text(12 + co * 25, (30 + ci * 49) - 10, font=fontchr, 417 text=co_sign0[0], fill='black') 418 co_note0 = self.comgen[ci][co][2] 419 comcan_1.create_text(12 + co * 25, 30 + ci * 49, font=fontcom, 420 text=co_note0[0], fill='black') 421 # méthode 7 notes ("déchire") 422 if co_d2 < 7 and c_zer[0] == 'on': # Ligne diatonique : dia 423 co_d2 += 1 # co_d2 = degré 424 co_d0 = self.dechire[(co_d1, co_d2)] # co_d0 = signe (+/-) 425 if co_d0 >= 0: 426 co_d01 = self.nordiese[co_d0], co_d2 427 else: 428 co_d01 = self.subemol[co_d0], co_d2 429 # Selon l'activité demandée 430 if self.comfdb[0] == 2 or self.comfcb[0] != 0: 431 pass 432 else: 433 comcan_1.create_text(12 + co * 25, (30 + ci * 49) + 20, 434 font=fontval, text=co_d01, fill='magenta') 435 co_d012 = 'g', co, co_d01 436 co_tbdif[co].append(co_d012) 437 elif co_d2i < 7 and c_zer[0] == 'of': # Ligne chromatique : dia 438 co_d2i += 1 # co_d2i = degré 439 co_n0 = 0 440 for c_ in self.gamula: # obtenir tonique 441 if c_ == co_note0[0][0]: 442 if c_deg0 == 0: 443 c_dif = co_n0 + c_deg0 444 else: 445 c_dif = co_n0 - c_deg0 446 c_ree = int(commaj_gam[co_tbnat[c_dif] - 1]) 447 co_s2 = co - c_ree # (+1/-1) 448 # ('ci',ci,'co',co,'co_s2',co_s2) # (+1/-1) 449 if co_s2 >= 0: 450 co_res = self.nordiese[co_s2] 451 else: 452 co_res = self.subemol[co_s2] 453 co_s1 = co_res, co_tbnat[c_dif] 454 # Selon l'activité demandée 455 if self.comfdb[0] != 0 or self.comfcb[0] == 3: 456 pass 457 else: 458 comcan_1.create_text(12 + co * 25, (30 + ci * 49) + 22, 459 font=fontchr, text=co_s1, fill='magenta') 460 co_s12 = 'c', co, co_s1 461 co_tbdif[co].append(co_s12) 462 co_n0 += 1 463 co_tbgam = co_sign0[0], co_note0[0][0] 464 co_tbmod[co].append(co_tbgam) 465 if compris == 'com': 466 co_sign1 = self.comgen[ci][co][1] # augmentation chromatique (signe) 467 co_note1 = self.comgen[ci][co][2] # augmentation chromatique (note) 468 co_sign2 = self.comgen[ci][co][3:4] # diminution chromatique (signe) 469 co_note2 = self.comgen[ci][co][4:] # diminution chromatique (note) 470 if self.compy_[0] == 0 or self.compy_[0] == 1: 471 comcan_1.create_text(12 + co * 25, (30 + ci * 49) + 12, font=fontval, 472 text=co_sign1[0], fill='red') 473 comcan_1.create_text(12 + co * 25, (30 + ci * 49) + 4, font=fontchr, 474 text=co_note1[0][0], fill='red') 475 if self.compy_[0] == 0 or self.compy_[0] == 2: 476 comcan_1.create_text(12 + co * 25, (30 + ci * 49) - 15, font=fontval, 477 text=co_sign2[0][0], fill='blue') 478 comcan_1.create_text(12 + co * 25, (30 + ci * 49) - 5, font=fontchr, 479 text=co_note2[0][0][0], fill='blue') 480 if co_d3 < 5 and c_zer[0] == 'on' or c_zof == 1: # degré chromatique diatonique 481 # commaj_gam = forme majeure 482 co_d3 += 1 483 co_n0 = c_sauf = 0 484 for c_ in self.gamula: # obtenir tonique 485 if c_ == co_note1[0][0]: 486 if c_deg0 == 0: 487 c_dif = co_n0 + c_deg0 488 else: 489 c_dif = co_n0 - c_deg0 490 c_ree = int(commaj_gam[co_tbnat[c_dif] - 1]) 491 co_s2 = co - c_ree # (+1/-1) 492 # ('ci',ci,'co',co,'co_s2',co_s2) # (+1/-1) 493 if co_s2 >= 0: 494 co_res = self.nordiese[co_s2] 495 else: 496 co_res = self.subemol[co_s2] 497 co_s1 = co_res, co_tbnat[c_dif] 498 # Selon l'activité demandée 499 if c_zer[0] == 'on' and self.comfct[0] == 0: 500 if self.comfdb[0] == 1 or self.comfcb[0] != 0: 501 c_sauf = -1 502 elif c_zof == 1 and self.comfct[0] == 0: 503 if self.comfdb[0] != 0 or self.comfcb[0] == 4: 504 c_sauf = -1 505 if c_sauf == 0: 506 comcan_1.create_text(12 + co * 25, (30 + ci * 49) + 22, 507 font=fontchr, text=co_s1, fill='green') 508 co_s12 = '', co, co_s1 509 co_tbdif[co].append(co_s12) 510 co_n0 += 1 511 co_tbplus = co_sign1[0], co_note1[0][0] 512 co_tbmoins = co_sign2[0][0], co_note2[0][0][0] 513 co_tbplns = co_tbplus, co_tbmoins 514 co_tbmod[co].append(co_tbplns) 515 self.co_tbgen[ci].append(co_tbmod) 516 self.co_tbval[ci].append(co_tbdif) 517 # print('iii', ci, self.co_tbgen[ci]) 518 # print('iii', ci, self.co_tbval[ci]) 519 c_oo.append(self.co_tbgen) 520 c_pp.append(self.co_tbval) 521 # cob2 = self.co_tbval 522 # Self.co_tbgen, self.co_tbval: Utilisation au rapport commatique 523 # (ci,co,self.co_tbgen[ci][co]) # Remplacer "#" par "print" pour la forme 524 # (ci,co,self.co_tbval[ci][co]) 525 526 # Panoplie tétracordique
527
def tetra(self): 528 if self.ttt is not None: 529 self.ttt.destroy() 530 self.ttt = Toplevel(self) 531 self.ttt.title('Entité Gammique : Tétracorde') 532 self.ttt.geometry('600x666+300+50') 533 fonttt = Font(size=7) 534 frtet = Frame(self.ttt, width=30, height=3, bg='green') 535 frtet.pack(side=RIGHT) 536 bttet1 = Button(frtet, text='Tétras', height=1, width=10, bg='orange', command=lambda: ttractuac(1)) 537 bttet1.pack() 538 bttet2 = Button(frtet, text='Utiles', height=1, width=10, bg='orange', command=lambda: ttractuac(2)) 539 bttet2.pack() 540 bttet3 = Button(frtet, text='Clones', height=1, width=10, bg='orange', command=lambda: ttractuac(3)) 541 bttet3.pack() 542 frtet_ = Frame(self.ttt, width=30, height=1) 543 frtet_.pack(side=BOTTOM) 544 bttet_ = Button(frtet_, text='Quitter', height=1, width=15, bg='lightgrey', command=self.ttt.destroy) 545 bttet_.pack() 546 tetcan = Canvas(self.ttt, bg='ivory', height=500, width=300) 547 tetcan.place(x=30, y=30, anchor='nw') 548 tetcan_ = Canvas(self.ttt, bg='pink', height=500, width=150) 549 tetcan_.place(x=350, y=30, anchor='nw') 550 tetcan.create_line(50, 30, 250, 30, fill='blue') 551 txlgh = 50 552 txldh = 250 553 tylgh = tyldh = 60 # Axe horizontal 554 tylgv = 50 555 tyldv = 460 556 txlgv = txldv = 30 # Axe vertical 557 for i in range(66): 558 tetcan.create_line(txlgh, tylgh + i * 6, txldh, tyldh + i * 6, fill='lightgrey') 559 for i in range(13): 560 tetcan.create_line(txlgv + i * 20, tylgv, txldv + i * 20, tyldv, fill='lightgrey') 561 # Le pas : (horizontal = *20)(vertical = *6) 562 r1 = 3 563 x1 = 150 564 y1 = 15 565 tetcan.create_oval(x1 - r1, y1 - r1, x1 + r1, y1 + r1, fill='white') 566 r2 = 2 567 x2 = 150 568 y2 = 24 569 tetcan.create_oval(x2 - r2, y2 - r2, x2 + r2, y2 + r2, fill='white') 570 # Label(self.ttt, text="Tétra's", font='bold', fg='blue') 571 tetcan.create_text(66, 15, text='Système tétracordique', fill='black') 572 self.pretetutil = 0 573 574 def ttractuac(t1): 575 tetcan.delete(ALL) 576 tetcan.create_line(50, 30, 250, 30, fill='blue') 577 for i1 in range(66): 578 tetcan.create_line(txlgh, tylgh + i1 * 6, txldh, tyldh + i1 * 6, fill='lightgrey') 579 for i2 in range(13): 580 tetcan.create_line(txlgv + i2 * 20, tylgv, txldv + i2 * 20, tyldv, fill='lightgrey') 581 if self.pretetutil == 1: 582 self.fr_sup.destroy() 583 self.fr_inf.destroy() 584 self.btpont.destroy() 585 xh = 30 586 yh = 60 # Départ Axe horizontal 587 if t1 == 0: 588 pass 589 elif t1 == 1: # Bouton tétras (tgam_tet = []) 590 # xh= 30; yh= 60 # Départ Axe horizontal(x)/vertical(y) 591 tetcan.create_text(150, 15, text='Système tétracordique ordonné', fill='grey') 592 tv = 0 593 for tt in tgam_tet: 594 th = 0 595 tt_inf = tt[0] 596 tt_sup = tt[1] 597 td = 13 - len(tt_inf + tt_sup) 598 for tti in tt_inf: 599 if tti == 1: 600 tetcan.create_oval(xh + th * 20 - r1, yh + tv * 6 - r1, 601 xh + th * 20 + r1, yh + tv * 6 + r1, 602 fill='red') 603 th += 1 604 else: 605 tetcan.create_oval(xh + th * 20 - r2, yh + tv * 6 - r2, 606 xh + th * 20 + r2, yh + tv * 6 + r2, 607 fill='yellow') 608 th += 1 609 if td > 0: 610 th1 = th 611 for td_ in range(td): 612 tetcan.create_oval(xh + th1 * 20 - r1, yh + tv * 6 - r1, 613 xh + th1 * 20 + r1, yh + tv * 6 + r1, 614 fill='white') 615 th1 += 1 616 th = th1 617 for tts in tt_sup: 618 if tts == 1: 619 tetcan.create_oval(xh + th * 20 - r1, yh + tv * 6 - r1, 620 xh + th * 20 + r1, yh + tv * 6 + r1, 621 fill='blue') 622 th += 1 623 else: 624 tetcan.create_oval(xh + th * 20 - r2, yh + tv * 6 - r2, 625 xh + th * 20 + r2, yh + tv * 6 + r2, 626 fill='yellow') 627 th += 1 628 tv += 1 629 elif t1 == 2: # Bouton utiles (tet_is:inf/sup/nom,tet_tt:ordre,tgam_util:clone) 630 # xh= 30; yh= 60 # Départ Axe horizontal(x)/vertical(y) 631 tetcan.create_text(150, 15, text='Système tétracordique utilisé', fill='grey') 632 if self.pretetutil == 1: 633 self.fr_sup.destroy() 634 self.fr_inf.destroy() 635 self.btpont.destroy() 636 self.btpont = Button(self.ttt, text='Pont', height=1, width=5, bg='ivory') 637 self.btpont.pack(side=RIGHT) 638 self.fr_sup = Frame(self.ttt, width=3, height=1, ) 639 self.fr_sup.pack(side=RIGHT) 640 self.fr_inf = Frame(self.ttt, width=3, height=1) 641 self.fr_inf.pack(side=RIGHT) 642 tu = x_01i = x_01s = 0 # x_01:Jeux de marges du texte 643 for tt in tgam_util: # tt:clone(tt)=[1, 1, 1, 1] 644 t_is = tet_is[tu] # t_is:"inf/sup"/nom(tu):"L'horizontale(x)":=('Inf', '0') 645 t_tt = tet_tt[tu] # t_tt:ordre(tu):La verticale(y):=zéro à 66 646 t_ut = tt 647 th = 0 648 tis0i = tis0s = 0 # Compteurs des tétras(inf/sup) 649 if t_is[0] == 'Inf': 650 tis0i += 1 651 if x_01i == 1: 652 x10 = 7 # Marges de principe(x) 653 x_01i = 0 654 else: 655 x10 = 17 # Marges de principe(x) 656 x_01i = 1 657 for t2 in t_ut: 658 if t2 == 1: 659 tetcan.create_oval(xh + th * 20 - r1, 660 yh + t_tt * 6 - r1, 661 xh + th * 20 + r1, 662 yh + t_tt * 6 + r1, fill='red') 663 else: 664 tetcan.create_oval(xh + th * 20 - r2, 665 yh + t_tt * 6 - r2, 666 xh + th * 20 + r2, 667 yh + t_tt * 6 + r2, fill='yellow') 668 th += 1 669 tetcan.create_text(x10, yh + t_tt * 6, text=t_is[1], font=fonttt, fill='red') 670 Button(self.fr_inf, text=t_is[1], height=1, width=5, bg='lightblue').pack() 671 elif t_is[0] == 'Sup': 672 tis0s += 1 673 if x_01s == 1: 674 x290 = 284 # Marges de principe(x) 675 x_01s = 0 676 else: 677 x290 = 292 # Marges de principe(x) 678 x_01s = 1 679 t_len = 13 - len(tt) 680 th += t_len 681 for t3 in t_ut: 682 if t3 == 1: 683 tetcan.create_oval(xh + th * 20 - r1, 684 yh + t_tt * 6 - r1, 685 xh + th * 20 + r1, 686 yh + t_tt * 6 + r1, fill='blue') 687 else: 688 tetcan.create_oval(xh + th * 20 - r2, 689 yh + t_tt * 6 - r2, 690 xh + th * 20 + r2, 691 yh + t_tt * 6 + r2, fill='yellow') 692 th += 1 693 tetcan.create_text(x290, yh + t_tt * 6, text=t_is[1], font=fonttt, fill='blue') 694 Button(self.fr_sup, text=t_is[1], height=1, width=5, bg='pink').pack() 695 tu += 1 696 self.pretetutil = 1 697 elif t1 == 3: # Bouton clones (ts_simil = []) 698 # ts_simil[0] = [('Inf', 'Inf', 0, '0'),] 699 # tg_tra[0] = [([1, 0, 1, 0, 1, 1], [1, 0, 1, 0, 1, 1])] gamme en cours 700 # self.sel_myx[0] : Est l'indice [i] en cours, dans self.gamnomscopie[i] 701 # xh= 30; yh= 60 # Départ Axe horizontal(x)/vertical(y) 702 tetcan.create_text(150, 15, text='Système tétracordique cloné', fill='grey') 703 if self.pretetutil == 1: 704 self.fr_sup.destroy() 705 self.fr_inf.destroy() 706 self.btpont.destroy() 707 teg = 0 708 te = -1 709 te_pos = self.sel_myx[0] 710 tetcan.create_line(30, tylgh + te_pos * 6, 270, tyldh + te_pos * 6, fill='grey') 711 x_01i = x_01s = 0 712 te_ego = self.gamnomscopie[self.sel_myx[0]] # Nom en cours 713 tetcan.create_text(50, 44, text=te_ego, font='bold', fill='black') 714 tg_in = tgam_tet[te_pos][0] 715 tg_su = tgam_tet[te_pos][1] 716 t_colinf = [0] 717 t_colsup = [0] 718 for te_ in tgam_tet: 719 te += 1 720 th = te_one = 0 721 teg_in = [] 722 teg_su = [] 723 te_fix = 0 724 teg_inf = '' 725 teg_sup = '' 726 te_in = te_[0] 727 te_su = te_[1] 728 t_tt = te 729 if tg_in == te_in: 730 teg += 1 # Compteur teg inutilisé 731 te_one += 1 # Recherche diatonique 732 teg_in = te_in # L'égalité rentrante(te_in) 733 teg_inf = 'inf' # Le côté sortant (position) 734 t_colinf[0] = 'red' 735 if tg_in == te_su: 736 teg += 1 737 te_one += 1 738 teg_su = te_su 739 teg_sup = 'sup' # Le côté sortant 740 t_colsup[0] = 'red' 741 if tg_su == te_in: 742 teg += 1 743 te_one += 1 744 teg_in = te_in 745 teg_inf = 'inf' # Le côté sortant 746 t_colinf[0] = 'blue' 747 if tg_su == te_su: 748 teg += 1 749 te_one += 1 750 teg_su = te_su 751 teg_sup = 'sup' # Le côté sortant 752 t_colsup[0] = 'blue' 753 if 0 < te_one: 754 te_ts = self.gamnomscopie[te] 755 te_ninf = len(teg_in) 756 te_nsup = len(teg_su) 757 te_fix = te_ninf + te_nsup 758 if teg_inf == 'inf': 759 if x_01i == 1: 760 x10 = 7 # Marges de principe(x) 761 x_01i = 0 762 else: 763 x10 = 17 # Marges de principe(x) 764 x_01i = 1 765 for t4 in teg_in: 766 if t4 == 1: 767 tetcan.create_oval(xh + th * 20 - r1, 768 yh + t_tt * 6 - r1, 769 xh + th * 20 + r1, 770 yh + t_tt * 6 + r1, fill=t_colinf[0]) 771 else: 772 tetcan.create_oval(xh + th * 20 - r2, 773 yh + t_tt * 6 - r2, 774 xh + th * 20 + r2, 775 yh + t_tt * 6 + r2, fill='yellow') 776 th += 1 777 tetcan.create_text(x10, yh + t_tt * 6, text=te_ts, font=fonttt, fill='red') 778 if teg_sup == 'sup': 779 # nel = 0 780 nel = 13 - te_fix 781 th += nel 782 if x_01s == 1: 783 x290 = 284 # Marges de principe(x) 784 x_01s = 0 785 else: 786 x290 = 292 # Marges de principe(x) 787 x_01s = 1 788 for t5 in teg_su: 789 if t5 == 1: 790 tetcan.create_oval(xh + th * 20 - r1, 791 yh + t_tt * 6 - r1, 792 xh + th * 20 + r1, 793 yh + t_tt * 6 + r1, fill=t_colsup[0]) 794 else: 795 tetcan.create_oval(xh + th * 20 - r2, 796 yh + t_tt * 6 - r2, 797 xh + th * 20 + r2, 798 yh + t_tt * 6 + r2, fill='yellow') 799 th += 1 800 tetcan.create_text(x290, yh + t_tt * 6, text=te_ts, font=fonttt, 801 fill='blue') 802 803 # La gamme en cours comme élément - système de définition tétracordique 804 # Développé tétra similaire diatonique: TETRA/CLONE/DIATONE 805 # self.gamnomscopie[]:(noms[+2])gammes - signatures(int) 806 # self.gammescopie[] :(valeurs[1,1,0,,,])gammes - intervalles(int) 807 # self.accdiese[(de 0 à +6)]: Table des altérations/str(+) 808 # self.accbemol[(de -1 à -6)]: Table des altérations/str(-) 809 # self.sel_myx[0] : Est l'indice [i] en cours, dans self.gamnomscopie[i] 810 # La transition modifie [1,1,0,1,1,1,0] en ([1,0,1,0,1,1],[1,0,1,0,1,1]) 811 tginf_tra = [] 812 tgsup_tra = [] # Tables transitives (inf/sup) 813 tgam_tet = [] # tgam_tet : Table tétra's complète 814 tg_tra = [0] # tg_tra[0]: Table tétra en cours 815 ts_simil = [] # Table des similaires 816 tgam_util = [] # Tables des utilités 817 tginf_nbr = tgsup_nbr = 0 818 t_gam = self.gammescopie[self.sel_myx[0]] 819 tgam_inf = t_gam[:4] 820 tgam_sup = t_gam[4:] 821 for tg_i in tgam_inf: 822 if tg_i > 0: 823 for tg_ii in range(tg_i + 1): 824 if tg_ii == 0: 825 tginf_tra.append(1) 826 tginf_nbr += 1 827 elif tginf_nbr < 4: 828 tginf_tra.append(0) 829 else: 830 tginf_tra.append(1) 831 tginf_nbr += 1 832 for tg_s in tgam_sup: 833 if tg_s > 0: 834 for tg_ss in range(tg_s + 1): 835 if tg_ss == 0: 836 tgsup_tra.append(1) 837 tgsup_nbr += 1 838 elif tgsup_nbr < 4: 839 tgsup_tra.append(0) 840 if tgsup_nbr == 4: 841 tgsup_tra.append(1) 842 tgsup_nbr += 1 843 if tg_s == 0: 844 tgsup_tra.append(1) 845 tgsup_nbr += 1 846 tgsup_tra.append(1) 847 tgsup_nbr += 1 848 tg_tra[0] = tginf_tra, tgsup_tra 849 # (tg_tra) # Remplacer "#" par "print" pour la forme 850 # Bouton tétras : L'ensemble tétracordique 851 t = 0 852 for t_ in self.gammescopie: 853 tinf_tra = [] 854 tsup_tra = [] 855 tinf_nbr = tsup_nbr = 0 856 t_tra = [0] 857 t += 1 858 t_inf = t_[:4] 859 t_sup = t_[4:] 860 for t_i in t_inf: 861 if t_i > 0: 862 for t_ii in range(t_i + 1): 863 if t_ii == 0: 864 tinf_tra.append(1) 865 tinf_nbr += 1 866 elif tinf_nbr < 4: 867 tinf_tra.append(0) 868 else: 869 tinf_tra.append(1) 870 tinf_nbr += 1 871 for t_s in t_sup: 872 if t_s > 0: 873 for t_ss in range(t_s + 1): 874 if t_ss == 0: 875 tsup_tra.append(1) 876 tsup_nbr += 1 877 elif tsup_nbr < 4: 878 tsup_tra.append(0) 879 if tsup_nbr == 4: 880 tsup_tra.append(1) 881 tsup_nbr += 1 882 if t_s == 0: 883 tsup_tra.append(1) 884 tsup_nbr += 1 885 tsup_tra.append(1) 886 tsup_nbr += 1 887 t_tra[0] = tinf_tra, tsup_tra 888 tgam_tet.append(t_tra[0]) # tgam_tet : Table tétra's complète 889 # (t, tgam_tet) # Remplacer "#" par "print" pour la forme 890 # Bouton clones : Les clones dans le système 891 tin_f = tg_tra[0][0] 892 tsu_p = tg_tra[0][1] 893 ts = ts_t = 0 # ts = Quantité de similitudes 894 for t_ in tgam_tet: 895 ts_eti = t_[0] 896 ts_ets = t_[1] 897 if tin_f == ts_eti: 898 tin_nom = 'Inf', 'Inf', ts_t, self.gamnomscopie[ts_t] 899 ts_simil.append(tin_nom) 900 ts += 1 901 if tin_f == ts_ets: 902 tin_nom = 'Inf', 'Sup', ts_t, self.gamnomscopie[ts_t] 903 ts_simil.append(tin_nom) 904 ts += 1 905 if tsu_p == ts_ets: 906 tin_nom = 'Sup', 'Sup', ts_t, self.gamnomscopie[ts_t] 907 ts_simil.append(tin_nom) 908 ts += 1 909 if tsu_p == ts_eti: 910 tin_nom = 'Sup', 'Inf', ts_t, self.gamnomscopie[ts_t] 911 ts_simil.append(tin_nom) 912 ts += 1 913 ts_t += 1 914 # (ts,ts_simil) # Remplacer "#" par "print" pour la forme 915 # Bouton utiles : Sans les clones de l'ensemble tétracordique 916 tet_is = [] 917 tet_tt = [] 918 t = t_t = 0 # t = compteur pouvant être utilisé 919 for t_ in tgam_tet: 920 ti_egal = ts_egal = 0 921 if t == 0: 922 ti_nom = 'Inf', self.gamnomscopie[t_t] 923 tet_is.append(ti_nom) 924 tet_tt.append(t_t) 925 tet_i = t_[0] 926 tgam_util.append(tet_i) 927 t += 1 928 tet_s = t_[1] 929 if tet_i != tet_s: 930 ts_nom = 'Sup', self.gamnomscopie[t_t] 931 tet_is.append(ts_nom) 932 tet_tt.append(t_t) 933 tgam_util.append(tet_s) 934 t += 1 935 else: 936 tet_i = t_[0] 937 tet_s = t_[1] 938 for t_u in tgam_util: 939 if t_u == tet_i: 940 ti_egal = 1 941 if t_u == tet_s: 942 ts_egal = 1 943 if ti_egal == 0: 944 ti_nom = 'Inf', self.gamnomscopie[t_t] 945 tet_is.append(ti_nom) 946 tet_tt.append(t_t) 947 tgam_util.append(tet_i) 948 t += 1 949 if ts_egal == 0: 950 ts_nom = 'Sup', self.gamnomscopie[t_t] 951 tet_is.append(ts_nom) 952 tet_tt.append(t_t) 953 tgam_util.append(tet_s) 954 t += 1 955 t_t += 1 956 # (t,tet_is,tet_tt,tgam_util) # Remplacer "#" par "print" pour la forme 957 958 # Version con
959
def convers(self): 960 con_chk = self.cb_chk.get() 961 if con_chk == 1: 962 # self.tablenotes : Conteneur diatonique | Calcul graphique horizontal 963 del (self.sel_bon[:]) 964 for y in range(7): 965 con_m = (self.tablenotes[y] // 10) - 28 966 con_ = con_m 967 if con_m < 12: 968 con_ += 12 969 if con_m > 23: 970 con_ -= 12 971 self.sel_bon.append(con_) 972 self.sel_bon.sort() 973 self.select[0] = self.sel_bon 974 for z in range(7): 975 sel_z = self.select[0][z] - self.sel_gam[z] 976 # (z,sel_z) # Remplacer "#" par "print" pour la forme 977 self.sca[z].configure(from_=self.fnotes[z], to=self.tnotes[z]) 978 self.sca[z].set(sel_z) 979 self.sca[7].configure(from_=-12, to=12) 980 self.sca[7].set(0) 981 else: 982 pass 983 self.rad[1].invoke() # Remise à l'octave zéro ou "ioi" 984 985 # Sel de fonction
986
def selection(self): 987 # ('yes',self.select[0]) # Remplacer "#" par "print" pour la forme 988 for z in range(7): 989 sel_z = self.select[0][z] - self.sel_gam[z] 990 self.sca[z].configure(from_=self.fnotes[z], to=self.tnotes[z]) 991 self.sca[z].set(sel_z) 992 self.sca[7].configure(from_=-12, to=12) 993 self.sca[7].set(0) 994 self.tur.destroy() 995 self.rad[1].invoke() # Remise à l'octave zéro ou "ioi" 996 self.btgama.invoke() 997 self.preselect[0] = 0 # def selec/Bouton sélection désactivé 998 self.bttab.invoke() 999 1000 # Piano ou clavier visuel
1001
def tabla(self): 1002 if self.tur is not None: 1003 self.tur.destroy() 1004 del (self.sel_bon[:]) # Remise à zéro sélection 1005 # (min:max) ; Tonice(0). Tonale(1:3). Mélode(4:14). Médiane(15:18). Domine(19:42). Harmone(43:65) 1006 # self.gamnomscopie : exemple(self.gamnomscopie[tbltr] == (noms)gammes concernées par ce type) 1007 # self.gammescopie : exemple(self.gammescopie[tbltr] == (valeurs)gammes concernées par ce type) 1008 # self.sel_myx[0] : Contient l'indice de la table gammenoms[myx2] (gamme en cours) 1009 self.tur = Toplevel(self) 1010 self.tur.title('Entité Gammique : Tablature') 1011 self.tur.geometry('700x300+300+50') 1012 Label(self.tur, text=self.sel_yes, font='bold', fg='black').pack() 1013 # Cadre de visualisation : Tablatures 1014 frtur = Frame(self.tur, width=30, height=1) 1015 frtur.pack(side=BOTTOM) 1016 bttur_p = Button(frtur, text='Sélectif', height=1, width=30, bg='orange', 1017 command=lambda: self.actuac(6)) 1018 bttur_p.pack(side=LEFT) 1019 bttur_g = Button(frtur, text='Quitter', height=1, width=30, bg='light grey', 1020 command=lambda: self.actuac(7)) 1021 bttur_g.pack(side=RIGHT) 1022 btsel_ = Button(frtur, text='Invisible', command=self.selection) 1023 btsel_.pack_forget() 1024 fontsel = Font(family='Liberation Serif', size=8) 1025 f0 = 110 1026 tab_freqs = [] 1027 for ai in range(39): # Construction tableau TM 1028 freq = f0 * 2 ** (ai / 12) 1029 tab_freqs.append(freq) # Tableau en écriture TM 1030 # (tab_freqs) # Remplacer "#" par "print" pour la forme 1031 if self.preselect[0] == 1: 1032 Label(self.tur, text='Sélectionner 7 notes, puis une dernière pour rechercher la gamme', 1033 font=fontsel, fg='red').place(x=30, y=250, anchor='nw') 1034 # Encadrement littéral de la gamme 1035 ind_ = '' 1036 sel_ind = self.sel_myx[0] 1037 if sel_ind == 0: 1038 ind_ = self.tbltr_nom[0] 1039 elif 0 < sel_ind < 4: 1040 ind_ = self.tbltr_nom[1] 1041 elif 3 < sel_ind < 15: 1042 ind_ = self.tbltr_nom[2] 1043 elif 14 < sel_ind < 19: 1044 ind_ = self.tbltr_nom[3] 1045 elif 18 < sel_ind < 43: 1046 ind_ = self.tbltr_nom[4] 1047 elif 42 < sel_ind < 66: 1048 ind_ = self.tbltr_nom[5] 1049 Label(self.tur, text=ind_, font='bold', fg='blue').place(x=30, y=3, anchor='nw') 1050 self.sel_nbr = -1 1051 self.sel_stp = 0 1052 1053 def piano_b(m): 1054 i_ = 0 1055 self.sel_nbr += 1 1056 freqhtz = int(tab_freqs[self.gen_b[m]]) 1057 nboctet = nbcanal = 1 1058 fech = 64000 1059 niveau = float(1 / 2) 1060 duree = float(1 / 6) 1061 nbech = int(duree * fech) 1062 manote = open(self.piano_wav[0], 'wb') 1063 param = (nbcanal, nboctet, fech, nbech, 'NONE', 'not compressed') 1064 manote.setparams(param) 1065 amp = 127.5 * niveau 1066 for i in range(0, nbech): 1067 val = struct.pack('B', int(128.0 + amp * sin(2.0 * pi * freqhtz * i / fech))) 1068 manote.writeframes(val) 1069 manote.close() 1070 p = PyAudio() 1071 chunk = 2048 1072 wf = open(self.piano_wav[0], 'rb') 1073 stream = p.open(format=p.get_format_from_width(wf.getsampwidth()), 1074 channels=wf.getnchannels(), 1075 rate=wf.getframerate(), 1076 output=True) 1077 data = wf.readframes(chunk) 1078 while len(data) > 0: 1079 stream.write(data) 1080 data = wf.readframes(chunk) 1081 stream.stop_stream() 1082 stream.close() 1083 p.terminate() 1084 if self.preselect[0] == 1 and self.sel_stp == 0: 1085 if self.sel_nbr < 7: 1086 mb = m 1087 sg_b = self.gen_bz[m] 1088 if sg_b < 12: 1089 sg_b += 12 1090 mb = m + 7 1091 if sg_b > 23: 1092 sg_b -= 12 1093 mb = m - 7 1094 self.sel_bon.sort() 1095 if self.sel_nbr == 0: 1096 pb = 0 1097 else: 1098 pb = len(self.sel_bon) 1099 for i in range(pb): 1100 if self.sel_bon[i] == self.gen_bz[mb]: 1101 self.sel_nbr -= 1 1102 i_ = 1 1103 if i_ == 0: 1104 self.sel_bon.append(sg_b) 1105 bts[m].configure(bg="orange") 1106 bts[mb].configure(bg="yellow") 1107 # ('m',self.gen_bz[m]) # Blanches() 1108 else: 1109 self.sel_stp = 1 1110 self.sel_bon.sort() 1111 self.select[0] = self.sel_bon 1112 btsel_.invoke() 1113 # del(self.sel_bon[:]) # Remise à zéro sélection 1114
1115
def piano_n(m): 1116 i_ = 0 1117 self.sel_nbr += 1 1118 freqhtz = int(tab_freqs[self.gen_n[m]]) 1119 nboctet = nbcanal = 1 1120 fech = 64000 1121 niveau = float(1 / 2) 1122 duree = float(1 / 6) 1123 nbech = int(duree * fech) 1124 manote = open(self.piano_wav[1], 'wb') 1125 param = (nbcanal, nboctet, fech, nbech, 'NONE', 'not compressed') 1126 manote.setparams(param) 1127 amp = 127.5 * niveau 1128 for i in range(0, nbech): 1129 val = struct.pack('B', int(128.0 + amp * sin(2.0 * pi * freqhtz * i / fech))) 1130 manote.writeframes(val) 1131 manote.close() 1132 p = PyAudio() 1133 chunk = 2048 1134 wf = open(self.piano_wav[1], 'rb') 1135 stream = p.open(format=p.get_format_from_width(wf.getsampwidth()), 1136 channels=wf.getnchannels(), 1137 rate=wf.getframerate(), 1138 output=True) 1139 data = wf.readframes(chunk) 1140 while len(data) > 0: 1141 stream.write(data) 1142 data = wf.readframes(chunk) 1143 stream.stop_stream() 1144 stream.close() 1145 p.terminate() 1146 if self.preselect[0] == 1 and self.sel_stp == 0: 1147 if self.sel_nbr < 7: 1148 mn = m 1149 sg_n = self.gen_nz[m] 1150 # ('sgn',sg_n) 1151 if sg_n < 12: 1152 sg_n += 12 1153 mn = m + 7 1154 elif sg_n > 23: 1155 sg_n -= 12 1156 mn = m - 7 1157 self.sel_bon.sort() 1158 if self.sel_nbr == 0: 1159 pb = 0 1160 else: 1161 pb = len(self.sel_bon) 1162 for i in range(pb): 1163 if self.sel_bon[i] == self.gen_nz[mn]: 1164 self.sel_nbr -= 1 1165 i_ = 1 1166 if i_ == 0: 1167 self.sel_bon.append(sg_n) 1168 btns[m].configure(bg="orange") 1169 btns[mn].configure(bg="yellow") 1170 # ('m',self.gen_nz[m]) # Noires() 1171 else: 1172 self.sel_stp = 1 1173 self.sel_bon.sort() 1174 self.select[0] = self.sel_bon 1175 btsel_.invoke() 1176 # del(self.sel_bon[:]) # Remise à zéro sélection 1177 1178 # Les touches blanches définition 1179 bts = [] 1180 lbab_bs = [] 1181 for x in range(21): 1182 bt = Button(self.tur, text='', height=10, width=3, bg='ivory', 1183 command=lambda m=x: piano_b(m), relief="groove") 1184 bt.place(x=30 * x + 30, y=30, anchor='nw') 1185 bts.append(bt) 1186 lbab_b = Label(self.tur, text='', font=fontsel, fg='black') 1187 lbab_b.place(x=30 * x + 30, y=225, anchor='nw') 1188 lbab_bs.append(lbab_b) 1189 # Les touches noires: Attention aux absences indicées ! (les -1) 1190 btns = [] 1191 lbab_ns = [] 1192 o = btn = 0 1193 for x in range(21): 1194 if o == 2 or o == 6: 1195 pass 1196 else: 1197 btn = Button(self.tur, text='', height=5, width=2, bg='black', 1198 command=lambda m=x: piano_n(m), relief="groove") 1199 btn.place(x=30 * x + 45, y=30, anchor='nw') 1200 o += 1 1201 if o > 6: 1202 o = 0 1203 btns.append(btn) 1204 lbab_n = Label(self.tur, text='', font=fontsel, fg='black') 1205 lbab_n.place(x=30 * x + 45, y=200, anchor='nw') 1206 lbab_ns.append(lbab_n) 1207 # self.tablenotes : Conteneur diatonique (x) 1208 s_deg = self.tbdegre[0] 1209 s_deg = 7 - s_deg 1210 for x in range(7): 1211 bon_ok = bob = bon = 0 1212 z = (self.tablenotes[x] // 10) - 28 1213 if s_deg > 6: s_deg = 0 1214 for bz in self.gen_bz: 1215 if z == bz and bon_ok == 0: 1216 bts[bob].configure(bg="lightblue") 1217 s_bob = self.decore[s_deg] 1218 lbab_bs[bob].configure(text=s_bob) 1219 bon_ok = 1 1220 break 1221 else: 1222 bob += 1 1223 for nz in self.gen_nz: 1224 if z == nz and bon_ok == 0: 1225 btns[bon].configure(bg="lightblue") 1226 s_bon = self.decore[s_deg] 1227 lbab_ns[bon].configure(text=s_bon) 1228 # bon_ok = 1 1229 break 1230 else: 1231 bon += 1 1232 s_deg += 1 1233 1234 # Actualité " actuac "
1235
def actuac(self, a): 1236 if a == 5: # def accord/Bouton fermer 1237 self.acc.destroy() 1238 elif a == 3: # def accord/Bouton actualiser 1239 self.acc.destroy() 1240 self.presaudio = 1 1241 self.btaud2.invoke() 1242 self.btacc.invoke() 1243 elif a == 1: # def audio/Bouton audio 1244 self.presaudio = 0 1245 self.btaud2.invoke() 1246 elif a == 2: # def chrome/Bouton C_n 1247 self.btchr.configure(text='Chrome naturel') 1248 self.chm.destroy() 1249 self.btchr.invoke() 1250 elif a == 4: # def chrome/Bouton C_a 1251 self.btchr.configure(text='Chrome atonal') 1252 self.chm.destroy() 1253 self.btchr.invoke() 1254 elif a == 6: # def tabla/Bouton sélection activé 1255 self.preselect[0] = 1 1256 self.bttab_2.invoke() 1257 elif a == 7: # def tabla/Bouton quitter 1258 self.tur.destroy() 1259 elif a == 8: # def select/Bouton sélection activé 1260 self.preselect[0] = 1 1261 self.bttab_2.invoke() 1262 elif a == 9: # def init/Bouton Tablature activé 1263 self.preselect[0] = 0 1264 self.bttab_2.invoke() 1265 1266 # Prémices chromatiques
1267
def chrome(self): 1268 if self.chm is not None: 1269 self.chm.destroy() 1270 self.chm = Toplevel(self) 1271 self.chm.title('Entité Gammique : Chromatisme') 1272 self.chm.geometry('700x600+300+50') 1273 # Sélection du mode chromatique (naturel) ou (atonal) 1274 frchm = Frame(self.chm, width=200, height=10) 1275 frchm.pack(side=BOTTOM) 1276 btchn = Button(frchm, text='Chrome naturel', width=30, bg='ivory', 1277 command=lambda: self.actuac(2)) 1278 btchn.pack(side=LEFT) 1279 btcha = Button(frchm, text='Chrome atonal', width=30, bg='ivory', 1280 command=lambda: self.actuac(4)) 1281 btcha.pack(side=RIGHT) 1282 frchm_ = Frame(self.chm, width=200, height=10) 1283 frchm_.pack(side=TOP) 1284 # Fenêtre écran_résultat 1285 chrcan = Canvas(self.chm, bg='white', height=456, width=666) 1286 chrcan.pack() 1287 Label(frchm_, text="Chromatismes", fg='red').pack() 1288 fontchr = Font(family='Liberation Serif', size=10) 1289 # Le pas graphique entre 2 notes = 10, en cotation horizontale 1290 # self.tablenotes : Conteneur diatonique | Calcul graphique horizontal 1291 # self.tablehaute : Conteneur diatonique | Calcul graphique vertical 1292 # self.tbdegre : Première note du mode tonique en cours 1293 # self.chrgen : Tableau graphique chromatique( note , signe ,,, ) 1294 # self.dechire : Tableau des positions altérées 1295 chnat_aug = [1, 2, 4, 5, 6] 1296 chnat_min = [2, 3, 5, 6, 7] 1297 chr_trans = [] 1298 chr_curs = [] 1299 chr_lepas = 10 1300 chrselect = self.btchr.cget('text') 1301 # self.tablenotes : Conteneur diatonique | Calcul graphique horizontal 1302 cy_zer = self.tbdegre[0] # Premier degré de la gamme 1303 for cy_ in range(7): 1304 if cy_ == 0: 1305 cy_inter = self.tablenotes[cy_zer] - 0 1306 if self.tablenotes[cy_zer] < cy_inter: 1307 cy_trans = self.tablenotes[cy_zer] - cy_inter + 120 1308 else: 1309 cy_trans = self.tablenotes[cy_zer] - cy_inter 1310 chr_trans.append(cy_trans) # Transformé élémentaire 1311 chr_curs.append(self.cursifs[cy_zer]) 1312 cy_zer += 1 1313 if cy_zer > 6: cy_zer = 0 1314 # print('chr_trans', chr_trans) # Contenu graphique diatonique 1315 # Génération élémentaire du tableau chromatique 1316 # Formation chromatique 1317 chr_chrom = [] 1318 chr_bem = [] 1319 chr_dies = [] 1320 tra0 = 6 1321 maj1 = 1 1322 maj0 = 0 1323 coltyp1 = [0] 1324 coltyp2 = [0] 1325 for c in range(0, 120, 10): 1326 c0 = c 1327 if c == chr_trans[maj0]: 1328 c_tr1 = chr_trans[tra0] 1329 while c_tr1 == 110: 1330 c_tr1 = -10 1331 if c0 - 10 is not c_tr1 and c_tr1 > -1: 1332 for di in chnat_aug: 1333 if di == maj0: 1334 rg_dies = c0 - 10 1335 rg_diesdeg = rg_dies, maj0 1336 chr_dies.append(rg_diesdeg) 1337 maj1 += 1 1338 if maj1 > 7: 1339 maj1 = 1 1340 maj0 = maj1 - 1 1341 tra0 += 1 1342 if tra0 > 6: 1343 tra0 = 0 1344 else: 1345 c_tr1 = chr_trans[tra0] 1346 chr_chrom.append(c - (c * 2)) 1347 if c0 - 10 == c_tr1: 1348 for be in chnat_min: 1349 if be == maj1: 1350 rg_bemdeg = c, maj1 1351 chr_bem.append(rg_bemdeg) 1352 1353 def c_sign(c_dbs): 1354 cdb_ = c_dbs 1355 if c_dbs > -1: 1356 c_sdb[0] = self.nordiese[cdb_] 1357 coltyp1[0] = 'plum' 1358 else: 1359 c_sdb[0] = self.subemol[cdb_] 1360 coltyp2[0] = 'pink' 1361
1362
def c_form(c_noes): 1363 cf_ = c_noes 1364 c_ie = len(self.nordiese) 1365 for cie in range(c_ie): 1366 eic = cie - (cie * 2) 1367 ce_aug = self.nordiese[cie] 1368 ce_min = self.subemol[eic] 1369 if ce_aug == cf_: 1370 c_dbn[0] = cie 1371 if ce_min == cf_: 1372 c_dbn[0] = eic 1373 1374 # Définitions données 1375 ch_chrdies = ['0', '0', '0', '0', '0'] 1376 ch_chrbem = ['0', '0', '0', '0', '0'] 1377 c_sdb = [0] 1378 c_dbn = [0] 1379 # c1_,c7_ = 'n',0 1380 for ch in chr_chrom: 1381 ch_o = ch - (ch * 2) 1382 # cz_ = ch_o 1383 for ch_d in chr_dies: 1384 ch_wd = ch_d[0] 1385 if ch_wd == ch_o: 1386 ch_dx = ch_d[1] 1387 for cb in range(5): 1388 cb_o = chr_chrom[cb] 1389 cbo = cb_o - (cb_o * 2) 1390 if ch_wd == cbo: 1391 c_ = cb 1392 c_noe0 = self.decore[ch_dx - 1] 1393 c_noe1 = c_noe0[1] 1394 c_noe2 = c_noe0[0] 1395 c_form(c_noe2) 1396 ch_wdx2 = (ch_wd - chr_trans[ch_dx - 1]) // 10 1397 ch_wdx = ch_wdx2 + c_dbn[0] 1398 c_db = ch_wdx 1399 c_sign(c_db) 1400 c2_0 = c_sdb[0] 1401 c3_0 = c_noe1 1402 # c4_0 = c2_0 1403 ch_chrdies[c_] = ch_o, ch_dx, c2_0, c3_0, 'plum', ch_wdx 1404 for ch_b in chr_bem: 1405 ch_yb = ch_b[0] 1406 if ch_yb == ch_o: 1407 ch_bz = ch_b[1] 1408 for cb in range(5): 1409 cb_o = chr_chrom[cb] 1410 cbo = cb_o - (cb_o * 2) 1411 if ch_yb == cbo: 1412 c_ = cb 1413 c_noe0 = self.decore[ch_bz - 1] 1414 c_noe2 = c_noe0[0] 1415 c_noe1 = c_noe0[1] 1416 c_form(c_noe2) 1417 ch_ybz2 = (ch_yb - chr_trans[ch_bz - 1]) // 10 1418 ch_ybz = ch_ybz2 + c_dbn[0] 1419 c_db = ch_ybz 1420 c_sign(c_db) 1421 c5_0 = c_sdb[0] 1422 c6_0 = c_noe1 1423 ch_chrbem[c_] = ch_o, ch_bz, c5_0, c6_0, 'pink', ch_ybz 1424 # print('ch_chrdies0', ch_chrdies) 1425 # print('ch_chrbem0', ch_chrbem) 1426 c_aug = [] 1427 for ci_ in ch_chrdies: 1428 if ci_ != '0': 1429 c_aug.append(ci_[1]) 1430 c_aug.sort() 1431 c_min = [] 1432 for ci_ in ch_chrbem: 1433 if ci_ != '0': 1434 c_min.append(ci_[1]) 1435 c_min.sort() 1436 c2_aug = [] 1437 c2_min = [] 1438 # Définitions ajoutées 1439 for c in range(5): 1440 ch_c = chr_chrom[c] 1441 c_ch = ch_c - (ch_c * 2) 1442 if ch_chrdies[c] is '0': 1443 c20 = c2_o = -1 1444 for c_a2 in chnat_aug: 1445 if c20 < 0: 1446 c20 = 0 1447 c2_o += 1 1448 for c_a3 in c_aug: 1449 if c_a2 == c_a3: 1450 c20 = -1 1451 break 1452 for c_a4 in c2_aug: 1453 if c_a2 == c_a4: 1454 c20 = -1 1455 break 1456 if c20 == 0: 1457 c2_aug.append(c_a2) 1458 break 1459 c2 = c2_o 1460 c_a = chnat_aug[c2] 1461 c_a0 = c_a - 1 1462 c_noe0 = self.decore[c_a0] 1463 c_noe1 = c_noe0[1] 1464 c_noe2 = c_noe0[0] 1465 c_form(c_noe2) 1466 c_mj2 = (c_ch - chr_trans[c_a0]) // 10 1467 c_mj = c_mj2 + c_dbn[0] 1468 c_db = c_mj 1469 c_sign(c_db) 1470 c2_0 = c_sdb[0] 1471 c3_0 = c_noe1 1472 # c4_0 = c_mj 1473 ch_chrdies[c] = c_ch, c_a, c2_0, c3_0, 'plum', c_mj 1474 if ch_chrbem[c] is '0': 1475 c20 = c2_o = -1 1476 for c_a2 in chnat_min: 1477 if c20 < 0: 1478 c20 = 0 1479 c2_o += 1 1480 for c_a3 in c_min: 1481 if c_a2 == c_a3: 1482 c20 = -1 1483 break 1484 for c_a4 in c2_min: 1485 if c_a2 == c_a4: 1486 c20 = -1 1487 break 1488 if c20 == 0: 1489 c2_min.append(c_a2) 1490 break 1491 c2 = c2_o 1492 c_a = chnat_min[c2] 1493 c_a0 = c_a - 1 1494 c_noe0 = self.decore[c_a0] 1495 c_noe1 = c_noe0[1] 1496 c_noe2 = c_noe0[0] 1497 c_form(c_noe2) 1498 c_mj2 = (c_ch - chr_trans[c_a0]) // 10 1499 c_mj = c_mj2 + c_dbn[0] 1500 c_db = c_mj 1501 c_sign(c_db) 1502 c2_0 = c_sdb[0] 1503 c3_0 = c_noe1 1504 # c4_0 = c2_0 1505 ch_chrbem[c] = c_ch, c_a, c2_0, c3_0, 'pink', c_mj 1506 # print('ch_chrdies1', ch_chrdies) 1507 # print('ch_chrbem1', ch_chrbem) 1508 c_chaug = [0] 1509 c_chmin = [0] 1510 c_doube = [0] 1511 cz_ = cx_tr = cn_ = 0 1512 cx_uu = 1 1513 chtop6 = chr_trans[6] // 10 1514 xcpos_ = 180 1515 ycpos_ = 234 1516 chposx = 0 1517 rb_ = 15 1518 chrcan.create_line(15, 234, 585, 234, fill='blue') 1519 for cx_ in range(12): 1520 c1_ = c2_ = c3_ = c4_ = c5_ = c6_ = c7_ = 'n' # -1 = Emplacement chromatique 1521 c2_a1 = c2_m1 = c3_a = c3_m = c4_a = c4_a1 = c4_m = c4_m1 = comp = 0 1522 coltyp = 'light grey' 1523 if cx_ == 0: 1524 c1_ = chr_trans[cx_tr] # Incrustation diatonique 1525 c2_ = chr_curs[cx_tr] # Hauteur tonale 1526 c3_ = self.decore[cx_tr][1:] # Note naturelle 1527 c4_ = self.dechire[(0, cx_uu)] # Valeur tonale 1528 cx_tr += 1 1529 cx_uu += 1 1530 chposx += 1 1531 chposyn = c4_ 1532 xb_ = xcpos_ + (chposx * 30) 1533 ybn_ = ycpos_ - (chposyn * 30) 1534 chvow_n = c2_, c3_ 1535 chrcan.create_oval(xb_ - rb_, ybn_ - rb_, xb_ + rb_, ybn_ + rb_, fill=coltyp) 1536 chrcan.create_text(xb_, ybn_, text=chvow_n, font=fontchr, fill='black') 1537 else: 1538 if chr_trans[cx_tr] == cx_ * 10: 1539 c1_ = chr_trans[cx_tr] 1540 c2_ = chr_curs[cx_tr] 1541 c3_ = self.decore[cx_tr][1:] 1542 c4_ = self.dechire[(0, cx_uu)] 1543 cx_tr += 1 1544 cx_uu += 1 1545 chposx += 1 1546 chposyn = c4_ 1547 xb_ = xcpos_ + (chposx * 30) 1548 ybn_ = ycpos_ - (chposyn * 30) 1549 chvow_n = c2_, c3_ 1550 chrcan.create_oval(xb_ - rb_, ybn_ - rb_, xb_ + rb_, ybn_ + rb_, fill=coltyp) 1551 chrcan.create_text(xb_, ybn_, text=chvow_n, font=fontchr, fill='black') 1552 else: 1553 comp = -1 1554 # Zone des futurs 1555 if comp == -1 and cn_ < 5: 1556 if chrselect == 'Chrome atonal': 1557 if chtop6 < cx_: 1558 chpre = chr_trans[6] // 10 1559 chsui = chr_trans[0] // 10 1560 c2_pre = chr_curs[6] 1561 c2_sui = chr_curs[0] 1562 c3_pre = self.decore[6][1:] 1563 c3_sui = self.decore[0][1:] 1564 c4_pre = self.dechire[(0, 7)] 1565 c4_sui = self.dechire[(0, 1)] 1566 else: 1567 chpre = chr_trans[cx_tr - 1] // 10 1568 chsui = chr_trans[cx_tr] // 10 1569 c2_pre = chr_curs[cx_tr - 1] 1570 c2_sui = chr_curs[cx_tr] 1571 c3_pre = self.decore[cx_tr - 1][1:] 1572 c3_sui = self.decore[cx_tr][1:] 1573 c4_pre = self.dechire[(0, cx_tr)] 1574 c4_sui = self.dechire[(0, cx_tr + 1)] 1575 tg_pre = cx_ - chpre 1576 tg_sui = cx_ - chsui 1577 c2_ax = tg_pre + c2_pre 1578 c_db = c2_ax 1579 c_sign(c_db) 1580 c2_a1 = c_sdb[0] 1581 c2_mx = tg_sui + c2_sui 1582 c_db = c2_mx 1583 c_sign(c_db) 1584 c2_m1 = c_sdb[0] 1585 c3_a = c3_pre 1586 c3_m = c3_sui 1587 c4_a = c4_pre + tg_pre 1588 c_db = c4_a 1589 c_sign(c_db) 1590 c4_a1 = c_sdb[0] 1591 c4_m = c4_sui + tg_sui 1592 c_db = c4_m 1593 c_sign(c_db) 1594 c4_m1 = c_sdb[0] 1595 if chrselect == 'Chrome naturel': 1596 c_chaug[0] = ch_chrdies[cn_] 1597 c2_a1 = c_chaug[0][2] 1598 c3_a = c_chaug[0][3] 1599 c4_a1 = c2_a1 1600 coltyp1[0] = c_chaug[0][4] 1601 c4_a = c_chaug[0][5] 1602 c_chmin[0] = ch_chrbem[cn_] 1603 c2_m1 = c_chmin[0][2] 1604 c3_m = c_chmin[0][3] 1605 c4_m1 = c2_m1 1606 coltyp2[0] = c_chmin[0][4] 1607 c4_m = c_chmin[0][5] 1608 c_doube[0] = 0 1609 if c3_a == c3_m: 1610 c_doube[0] = 2 1611 cn_ += 1 1612 chposx += 1 1613 c2_ = c2_a1 1614 c3_ = c3_a 1615 c4_ = c4_a1 1616 c5_ = c2_m1 1617 c6_ = c3_m 1618 c7_ = c4_m1 1619 chposya = c4_a 1620 chposym = c4_m 1621 xb_ = xcpos_ + (chposx * 30) 1622 yb1_ = ycpos_ - (chposya * 30) 1623 chvow_a = c3_, c2_ 1624 if c_doube[0] == 2: 1625 coltyp1[0] = 'tan' 1626 coltyp2[0] = 'tan' 1627 chrcan.create_oval(xb_ - rb_, yb1_ - rb_, xb_ + rb_, yb1_ + rb_, fill=coltyp1[0]) 1628 chrcan.create_text(xb_, yb1_, text=chvow_a, font=fontchr, fill='black') 1629 yb2_ = ycpos_ - (chposym * 30) 1630 chvow_m = c6_, c5_ 1631 chrcan.create_oval(xb_ - rb_, yb2_ - rb_, xb_ + rb_, yb2_ + rb_, fill=coltyp2[0]) 1632 chrcan.create_text(xb_, yb2_, text=chvow_m, font=fontchr, fill='black') 1633 self.chrgen[cx_] = [cz_], [c1_], [c2_], [c3_], [c4_], [c5_], [c6_], [c7_] 1634 cz_ += chr_lepas 1635 # Génération analogique du tableau chromatique 1636 # chrcan = Canvas(height=300,width=600) 1637 chvow = 'Gamme chromatique :', chrselect 1638 chrcan.create_line(5, 15, 5, 5, fill='black') 1639 chrcan.create_text(120, 10, text=chvow, fill='red') 1640 # print('chrgen', cx_, self.chrgen[cx_]) # Tableau chromatique sélectionné (nature/atone) 1641 if self.prescomma == 1: 1642 self.chm.destroy() 1643 self.prescomma = 0 1644 1645 # Les accords acoustiques
1646
def wavacc(self, w): 1647 nboctet = nbcanal = 1 1648 fech = 64000 1649 niveau = float(1) 1650 duree = float(1 / 2) 1651 nbech = int(duree * fech) 1652 waplo = self.fichacc[w] 1653 monac = open(waplo, 'wb') 1654 param = (nbcanal, nboctet, fech, nbech, 'NONE', 'not compressed') 1655 monac.setparams(param) 1656 amp = 127.5 * niveau 1657 vacc = [0, 0, 0, 0] 1658 vacc_oct = 0 1659 ww = w 1660 for vv in range(4): 1661 if ww == 7: 1662 ww = 0 1663 vacc[vv] = self.framno[ww] * 2 1664 vacc_oct = 1 1665 elif ww == 8: 1666 ww = 1 1667 vacc[vv] = self.framno[ww] * 2 1668 vacc_oct = 1 1669 if vacc_oct == 0: 1670 vacc[vv] = self.framno[ww] 1671 else: 1672 vacc[vv] = self.framno[ww] * 2 1673 ww += 2 1674 freq1 = vacc[0] * 2 1675 freq2 = vacc[1] * 2 1676 freq3 = vacc[2] * 2 1677 freq4 = vacc[3] * 2 1678 for i in range(0, nbech): 1679 val1 = struct.pack('B', int(128.0 + amp * sin(2.0 * pi * freq1 * i / fech))) 1680 val2 = struct.pack('B', int(128.0 + amp * sin(2.0 * pi * freq2 * i / fech))) 1681 val3 = struct.pack('B', int(128.0 + amp * sin(2.0 * pi * freq3 * i / fech))) 1682 val4 = struct.pack('B', int(128.0 + amp * sin(2.0 * pi * freq4 * i / fech))) 1683 monac.writeframes(val1 + val2 + val3 + val4) 1684 monac.close() 1685 p = PyAudio() 1686 chunk = 2048 1687 wf = open(self.fichacc[w], 'rb') 1688 stream = p.open(format=p.get_format_from_width(wf.getsampwidth()), 1689 channels=wf.getnchannels(), 1690 rate=wf.getframerate(), 1691 output=True) 1692 data = wf.readframes(chunk) 1693 while len(data) > 0: 1694 stream.write(data) 1695 data = wf.readframes(chunk) 1696 stream.stop_stream() 1697 stream.close() 1698 p.terminate() 1699 1700 # L'harmonie des accords
1701
def accord(self): 1702 if self.acc is not None: 1703 self.acc.destroy() 1704 self.btaud2.invoke() 1705 self.acc = Toplevel(self) 1706 self.acc.title('Entité Gammique : Harmonie') 1707 self.acc.geometry('700x300+300+50') 1708 if self.presaudio == 0: 1709 self.presaudio = 1 1710 self.btaud2.invoke() 1711 # Définition du style d'écriture 1712 fotyp = Font(family='Liberation Serif', size=12) 1713 fofin = Font(family='Liberation Serif', size=8) 1714 fonot = Font(family='Liberation Serif', size=14) 1715 # Fenêtrage des widgets 1716 fra = Frame(self.acc, width=100, height=50) 1717 fra.pack(side=BOTTOM) 1718 fraleft = Frame(self.acc, width=30, height=30) 1719 fraleft.pack(side=LEFT) 1720 fraright = Frame(self.acc, width=30, height=30) 1721 fraright.pack(side=RIGHT) 1722 # Les accords 1357 de la gamme en cours (partie gauche(left)) 1723 Button(fra, text='Actualiser', width=20, command=lambda: self.actuac(3)).pack(side=LEFT) 1724 Label(fraleft, text='Accords 1357', fg='red').pack() 1725 btaccleft = [] 1726 for i in range(7): 1727 btaccleft.append(Button(fraleft, text='', bg='light blue', width=10, 1728 command=lambda w=i: self.wavacc(w))) 1729 btaccleft[i].pack() 1730 # Les autres accords de la gamme en cours (partie droite(right)) 1731 btferm = Button(fra, text='Fermer', width=20, bg='light grey', command=lambda: self.actuac(5)) 1732 btferm.pack(side=RIGHT) 1733 Label(fraright, text='Autre accord', fg='blue').pack() 1734 Button(fraright, text='inactif', bg='light blue', width=10).pack() 1735 # L'espace blanc central pour écrire l'accord 1736 caaacc = Canvas(self.acc, bg='white', height=300, width=300) 1737 caaacc.pack() 1738 caaacc.delete(ALL) 1739 # Types d'accords 1357 : chr(248) = ( ø ) 1740 # Majeur_7ème(maj7). Mineur_7ème(7). Demi-diminué_7ème(ø7). Diminué_7ème(°7) 1741 accmaj7 = [0, 0, 0, 0] 1742 acc7 = [0, 0, 0, -1] 1743 accdd7 = [0, -1, -1, -1] 1744 accd7 = [0, -1, -1, -2] 1745 tbtxgd = ['1', '3', '5', '7'] 1746 tbacc7 = [] # Tableau de l'accord forme(str) 1747 tbsign = [] # Tableau de l'accord forme(int) 1748 tbfine = [] # Tableau des accords forme fine 1749 tbgene = [] # Tableau des accords forme écriture 1750 tblect = [] # Tableau des accords forme lecture 1751 # self.decore[] = altération et note tonique de l'accord 1752 xcc, ycc = 120, 80 1753 xtt = 20 1754 ypos = 26 1755 for decdegre in range(7): 1756 accnote = self.decore[decdegre][1:] 1757 accsign = self.decore[decdegre][:1] 1758 # self.declare[] = altérations "3.5.7" en rang 1759 decnote = 1 1760 txga = txdr = '' 1761 ydd = ycc + (ypos * decdegre) 1762 xdd = xcc + 30 1763 xgg = xcc - 30 1764 while decnote < 8: # Définition de l'accord modal(str) 1765 decalt = self.declare[(decdegre, decnote)] 1766 tbacc7.append(decalt) 1767 decnote += 2 1768 # Transcodage de l'accord de type original(str) 1769 for a_ in range(4): 1770 z_ = -1 1771 a_acc = tbacc7[a_] 1772 for b_ in range(7): # Lecture et transformation 1773 if a_acc == '': 1774 b_alt = 0 1775 tbsign.append(b_alt) 1776 break 1777 if a_acc == self.accdiese[b_]: 1778 b_alt = b_ 1779 tbsign.append(b_alt) 1780 break 1781 if a_acc == self.accbemol[z_]: 1782 b_alt = z_ 1783 tbsign.append(b_alt) 1784 break 1785 z_ += -1 1786 # Définition des accords de 7ème 1787 if tbsign[3] == 0: 1788 # L'accord est majeur 7(maj7) 1789 for t_ in range(4): 1790 txsg = '' 1791 zone = 0 1792 if accmaj7[t_] == tbsign[t_]: 1793 t_fin = 0 1794 else: 1795 t_fin = tbsign[t_] - accmaj7[t_] 1796 if t_ == 1 and t_fin != 0: 1797 if t_fin < -1: # Zone de droite 1798 txsg = self.accbemol[t_fin] + tbtxgd[t_] 1799 zone = 1 1800 elif t_fin > -1: # Zone de droite 1801 txsg = self.accdiese[t_fin] + tbtxgd[t_] 1802 zone = 1 1803 else: # Zone de gauche 1804 txsg = self.accbemol[t_fin] 1805 zone = -1 1806 if t_ == 2 and t_fin != 0: 1807 if t_fin < 0: # Zone de droite 1808 txsg = self.accbemol[t_fin] + tbtxgd[t_] 1809 zone = 1 1810 elif t_fin > 2: # Zone de droite 1811 txsg = self.accdiese[t_fin] + tbtxgd[t_] 1812 zone = 1 1813 else: # Zone de gauche 1814 txsg = self.accdiese[t_fin] 1815 zone = -1 1816 if t_ == 3 and t_fin != 0: # Zone de droite 1817 txsg = self.accbemol[t_fin] + tbtxgd[t_] 1818 zone = 1 1819 if zone == 1: # Zone de droite 1820 txdr += txsg 1821 caaacc.create_text(xdd, ydd, text=txsg, font=fofin, fill='blue') 1822 xdd += 20 1823 if zone == -1: # Zone de gauche 1824 txga += txsg 1825 caaacc.create_text(xgg, ydd, text=txsg, font=fofin, fill='blue') 1826 xgg -= 20 1827 tbfine.append(t_fin) 1828 txbadr = txga + 'maj7' + txdr 1829 btaccleft[decdegre].configure(text=txbadr) 1830 caaacc.create_text(xcc, ydd, text='maj7', font=fotyp, fill='black') 1831 caaacc.create_text(xtt, ydd, text=accsign, font=fofin, fill='blue') 1832 caaacc.create_text(xtt + 20, ydd, text=accnote, font=fonot, fill='black') 1833 if tbsign[3] == -1: 1834 if (tbsign[1] or tbsign[2] >= 0) or ((tbsign[1] or tbsign[2]) < 0): 1835 if tbsign[1] and tbsign[2] < 0: 1836 pass 1837 else: 1838 # L'accord est 7 mineure (7) 1839 for t_ in range(4): 1840 txsg = '' 1841 zone = 0 1842 if acc7[t_] == tbsign[t_]: 1843 t_fin = 0 1844 else: 1845 t_fin = tbsign[t_] - acc7[t_] 1846 if t_ == 1 and t_fin != 0: 1847 if t_fin < -1: # Zone de droite 1848 txsg = self.accbemol[t_fin] + tbtxgd[t_] 1849 zone = 1 1850 elif t_fin > -1: # Zone de droite 1851 txsg = self.accdiese[t_fin] + tbtxgd[t_] 1852 zone = 1 1853 else: # Zone de gauche 1854 txsg = self.accbemol[t_fin] 1855 zone = -1 1856 if t_ == 2 and t_fin != 0: 1857 if t_fin < 0: # Zone de droite 1858 txsg = self.accbemol[t_fin] + tbtxgd[t_] 1859 zone = 1 1860 elif t_fin > 2: # Zone de droite 1861 txsg = self.accdiese[t_fin] + tbtxgd[t_] 1862 zone = 1 1863 else: # Zone de gauche 1864 txsg = self.accdiese[t_fin] 1865 zone = -1 1866 if t_ == 3 and t_fin != 0: # Zone de droite 1867 txsg = self.accbemol[t_fin] + tbtxgd[t_] 1868 zone = 1 1869 if zone == 1: # Zone de droite 1870 txdr += txsg 1871 caaacc.create_text(xdd, ydd, text=txsg, font=fofin, fill='blue') 1872 xdd += 20 1873 if zone == -1: # Zone de gauche 1874 txga += txsg 1875 caaacc.create_text(xgg, ydd, text=txsg, font=fofin, fill='blue') 1876 xgg -= 20 1877 tbfine.append(t_fin) 1878 txbadr = txga + '7' + txdr 1879 btaccleft[decdegre].configure(text=txbadr) 1880 caaacc.create_text(xcc, ydd, text='7', font=fotyp, fill='black') 1881 caaacc.create_text(xtt, ydd, text=accsign, font=fofin, fill='blue') 1882 caaacc.create_text(xtt + 20, ydd, text=accnote, font=fonot, fill='black') 1883 if (tbsign[3] == -1) and (tbsign[1] and tbsign[2] < 0): 1884 # L'accord est demi-diminué 7(ø7) 1885 for t_ in range(4): 1886 txsg = '' 1887 zone = 0 1888 if accdd7[t_] == tbsign[t_]: 1889 t_fin = 0 1890 else: 1891 t_fin = tbsign[t_] - accdd7[t_] 1892 if t_ == 1 and t_fin != 0: 1893 if t_fin < -1: # Zone de droite 1894 txsg = self.accbemol[t_fin] + tbtxgd[t_] 1895 zone = 1 1896 elif t_fin > -1: # Zone de droite 1897 txsg = self.accdiese[t_fin] + tbtxgd[t_] 1898 zone = 1 1899 else: # Zone de gauche 1900 txsg = self.accbemol[t_fin] 1901 zone = -1 1902 if t_ == 2 and t_fin != 0: 1903 if t_fin < 0: # Zone de droite 1904 txsg = self.accbemol[t_fin] + tbtxgd[t_] 1905 zone = 1 1906 elif t_fin > 2: # Zone de droite 1907 txsg = self.accdiese[t_fin] + tbtxgd[t_] 1908 zone = 1 1909 else: # Zone de gauche 1910 txsg = self.accdiese[t_fin] 1911 zone = -1 1912 if t_ == 3 and t_fin != 0: # Zone de droite 1913 txsg = self.accbemol[t_fin] + tbtxgd[t_] 1914 zone = 1 1915 if zone == 1: # Zone de droite 1916 txdr += txsg 1917 caaacc.create_text(xdd, ydd, text=txsg, font=fofin, fill='blue') 1918 xdd += 20 1919 if zone == -1: # Zone de gauche 1920 txga += txsg 1921 caaacc.create_text(xgg, ydd, text=txsg, font=fofin, fill='blue') 1922 xgg -= 20 1923 tbfine.append(t_fin) 1924 txbadr = txga + 'ø7' + txdr 1925 btaccleft[decdegre].configure(text=txbadr) 1926 caaacc.create_text(xcc, ydd, text='ø7', font=fotyp, fill='black') 1927 caaacc.create_text(xtt, ydd, text=accsign, font=fofin, fill='blue') 1928 caaacc.create_text(xtt + 20, ydd, text=accnote, font=fonot, 1929 fill='black') 1930 if tbsign[3] < -1: 1931 # L'accord est diminué 7(°7) 1932 for t_ in range(4): 1933 txsg = '' 1934 zone = 0 1935 if accd7[t_] == tbsign[t_]: 1936 t_fin = 0 1937 else: 1938 t_fin = tbsign[t_] - accd7[t_] 1939 if t_ == 1 and t_fin != 0: 1940 if t_fin < -1: # Zone de droite 1941 txsg = self.accbemol[t_fin] + tbtxgd[t_] 1942 zone = 1 1943 elif t_fin > -1: # Zone de droite 1944 txsg = self.accdiese[t_fin] + tbtxgd[t_] 1945 zone = 1 1946 else: # Zone de gauche 1947 txsg = self.accbemol[t_fin] 1948 zone = -1 1949 if t_ == 2 and t_fin != 0: 1950 if t_fin < 0: # Zone de droite 1951 txsg = self.accbemol[t_fin] + tbtxgd[t_] 1952 zone = 1 1953 elif t_fin > 2: # Zone de droite 1954 txsg = self.accdiese[t_fin] + tbtxgd[t_] 1955 zone = 1 1956 else: # Zone de gauche 1957 txsg = self.accdiese[t_fin] 1958 zone = -1 1959 if t_ == 3 and t_fin != 0: # Zone de droite 1960 txsg = self.accbemol[t_fin] + tbtxgd[t_] 1961 zone = 1 1962 xdd += 20 1963 if zone == 1: # Zone de droite 1964 txdr += txsg 1965 caaacc.create_text(xdd, ydd, text=txsg, font=fofin, fill='blue') 1966 xdd += 20 1967 if zone == -1: # Zone de gauche 1968 txga += txsg 1969 caaacc.create_text(xgg, ydd, text=txsg, font=fofin, fill='blue') 1970 xgg -= 20 1971 tbfine.append(t_fin) 1972 txbadr = txga + '°7' + txdr 1973 btaccleft[decdegre].configure(text=txbadr) 1974 caaacc.create_text(xcc, ydd, text='°7', font=fotyp, fill='black') 1975 caaacc.create_text(xtt, ydd, text=accsign, font=fofin, fill='blue') 1976 caaacc.create_text(xtt + 20, ydd, text=accnote, font=fonot, fill='black') 1977 tblect.append(tbsign[:4]) 1978 tbgene.append(tbfine[:4]) 1979 del (tbsign[:]) # Remise à zéro de l'accord(int) 1980 del (tbacc7[:]) # Remise à zéro de l'accord(str) 1981 del (tbfine[:]) # Remise à zéro de l'accord écriture 1982 del (tblect[:]) # Remise à zéro forme lecture 1983 del (tbgene[:]) # Remise à zéro forme écriture 1984 1985 # Premiers pixels acoustiques
1986
def radio(self): 1987 ay = '0' 1988 ayay = self.tbdegre[0] 1989 for n in range(7): 1990 freqhtz = self.tablenotes[ayay] 1991 if ay == '0': 1992 pass 1993 else: 1994 freqhtz += 120 1995 ayay += 1 1996 if ayay > 6: 1997 ayay = 0 1998 ay = '1' 1999 nboctet = nbcanal = 1 2000 fech = 64000 2001 niveau = float(1 / 2) 2002 duree = float(1 / 6) 2003 nbech = int(duree * fech) 2004 manote = open(self.fichnom[n], 'wb') 2005 param = (nbcanal, nboctet, fech, nbech, 'NONE', 'not compressed') 2006 manote.setparams(param) 2007 amp = 127.5 * niveau 2008 for i in range(0, nbech): 2009 val = struct.pack('B', int(128.0 + amp * sin(2.0 * pi * freqhtz * i / fech))) 2010 manote.writeframes(val) 2011 manote.close() 2012 p = PyAudio() 2013 chunk = 2048 2014 wf = open(self.fichnom[n], 'rb') 2015 stream = p.open(format=p.get_format_from_width(wf.getsampwidth()), 2016 channels=wf.getnchannels(), 2017 rate=wf.getframerate(), 2018 output=True) 2019 data = wf.readframes(chunk) 2020 while len(data) > 0: 2021 stream.write(data) 2022 data = wf.readframes(chunk) 2023 stream.stop_stream() 2024 stream.close() 2025 p.terminate() 2026 2027 # Premières notes acoustiques
2028
def audio(self): 2029 la440 = 440 2030 la2 = la440 / 2 2031 fabula = ['A', '_', 'B', 'C', '_', 'D', '_', 'E', 'F', '_', 'G', '_', 'A'] 2032 # FC # Fréquences cursives (pixels) 2033 notula = [] 2034 modula = [] 2035 for az in range(7): # Construction tableau FC 2036 notula.append(self.tablenotes[az]) 2037 mula = notula[az] / 10 - 25 # Transition vers l'indice 2038 modula.append(mula) # Indice du tableau "sequla[]" 2039 # TM # Tableau majeur 2040 tabula = [] 2041 for ai in range(13): # Construction tableau TM 2042 paula = la2 * 2 ** (ai / 12) # Calcul fréquence 2043 tabula.append(paula) # Tableau en écriture TM 2044 # TF # Table des fréquences (1/12) 2045 sequla = [] 2046 nomula = [] 2047 yula = nula = 0 2048 for ay in range(40): # Construction tableau TF 2049 if ay < 12: # Niveau -1: Octave basse 2050 yula = tabula[ay] / 2 # yula: TM/2 2051 nula = fabula[ay] # nula: Notes naturelles 2052 elif 11 < ay < 24: # Niveau 0: Octave naturelle 2053 yula = tabula[ay - 12] # yula: Déviation de l'indice(ay) 2054 nula = fabula[ay - 12] 2055 elif 23 < ay < 37: # Niveau 1: Octave haute 2056 yula = tabula[ay - 24] * 2 # yula: Déviation de l'indice(ay)+TM*2 2057 nula = fabula[ay - 24] 2058 elif 36 < ay < 41: # Niveau 2: Octave relative 2059 yula = tabula[ay - 36] * 4 # yula: Déviation de l'indice(ay)+TM*4 2060 nula = fabula[ay - 36] 2061 sequla.append(yula) # Tableau en écriture TF 2062 nomula.append(nula) # Tableau en écriture TF 2063 # TR # Tableau des résultats (fréquences cursives) 2064 freula = [] 2065 for ax in range(7): # Construction tableau TR 2066 xula = int(modula[ax]) # xula: Lecture indice-entier FC 2067 qula = sequla[xula] # qula: Lecture de fréquence TF 2068 freula.append(qula) # Tableau en écriture TR 2069 aw2 = self.tbdegre[0] 2070 diato = [] 2071 opoto = [] 2072 ax = '0' 2073 for aw in range(7): # Construction tableau TR-tonique 2074 freqhtz = freula[aw2] 2075 if ax == '0': 2076 diato.append(freqhtz) 2077 else: 2078 diato.append(freqhtz * 2) 2079 opoto.append(self.gamula[aw2]) 2080 aw2 += 1 2081 if aw2 > 6: 2082 aw2 = 0 2083 ax = '1' 2084 # Partie échantillonnage 2085 nboctet = nbcanal = 1 2086 fech = 64000 2087 niveau = float(1 / 2) 2088 duree = float(1 / 6) 2089 nbech = int(duree * fech) 2090 for fy in range(7): 2091 manote = open(self.fichnom[fy], 'wb') 2092 param = (nbcanal, nboctet, fech, nbech, 'NONE', 'not compressed') 2093 manote.setparams(param) 2094 freq = diato[fy] 2095 self.framno[fy] = freq 2096 amp = 127.5 * niveau 2097 for i in range(0, nbech): 2098 val = struct.pack('B', int(128.0 + amp * sin(2.0 * pi * freq * i / fech))) 2099 manote.writeframes(val) 2100 manote.close() 2101 if self.presaudio == 0: 2102 p = PyAudio() 2103 chunk = 2048 2104 wf = open(self.fichnom[fy], 'rb') 2105 stream = p.open(format=p.get_format_from_width(wf.getsampwidth()), 2106 channels=wf.getnchannels(), 2107 rate=wf.getframerate(), 2108 output=True) 2109 data = wf.readframes(chunk) 2110 while len(data) > 0: 2111 stream.write(data) 2112 data = wf.readframes(chunk) 2113 stream.stop_stream() 2114 stream.close() 2115 p.terminate() 2116 del (modula[:]) 2117 del (tabula[:]) 2118 del (sequla[:]) 2119 del (nomula[:]) 2120 del (freula[:]) 2121 del (diato[:]) 2122 2123 # Les octaves du groupe RADIO
2124
def yoiioiioy(self): 2125 xradfan = self.entfan.get() 2126 xrad = self.variable.get() 2127 mqdo = self.sca[0].get() 2128 mqsi = self.sca[6].get() 2129 yo = yoc = yod = yoe = yof = yog = yoa = yob = 0 2130 fyoc = fyod = fyoe = fyof = fyog = fyoa = fyob = 0 2131 tyoc = tyod = tyoe = tyof = tyog = tyoa = tyob = 0 2132 topgam = [yoc, yod, yoe, yof, yog, yoa, yob] 2133 topform = [fyoc, fyod, fyoe, fyof, fyog, fyoa, fyob] 2134 topto = [tyoc, tyod, tyoe, tyof, tyog, tyoa, tyob] 2135 mqdo1 = mqsi1 = 0 2136 while yo < 7: 2137 yotop = topgam[yo] = self.sca[yo].get() 2138 topf = topform[yo] = self.sca[yo].cget("from") 2139 topt = topto[yo] = self.sca[yo].cget("to") 2140 if xradfan == "IOI": 2141 if xrad == "YOI": 2142 if (mqdo > -1) and (mqsi < 1): 2143 yioiy = yotop 2144 else: 2145 yioiy = yotop + 12 2146 topf += 12 2147 topt += 12 2148 elif xrad == "IOY": 2149 if (mqdo > -1) and (mqsi < 1): 2150 yioiy = yotop 2151 else: 2152 yioiy = yotop - 12 2153 topf -= 12 2154 topt -= 12 2155 else: 2156 yioiy = yotop 2157 elif xradfan == "YOI": 2158 if xrad == "IOI": 2159 if (mqdo > -1) and (mqsi < 1): 2160 yioiy = yotop 2161 else: 2162 yioiy = yotop - 12 2163 topf -= 12 2164 topt -= 12 2165 elif xrad == "IOY": 2166 if (mqdo > -1) and (mqsi < 1): 2167 yioiy = yotop 2168 else: 2169 yioiy = yotop - 24 2170 topf -= 24 2171 topt -= 24 2172 else: 2173 yioiy = yotop 2174 else: 2175 if xrad == "YOI": 2176 if (mqdo > -1) and (mqsi < 1): 2177 yioiy = yotop 2178 else: 2179 yioiy = yotop + 24 2180 topf += 24 2181 topt += 24 2182 elif xrad == "IOI": 2183 if (mqdo > -1) and (mqsi < 1): 2184 yioiy = yotop 2185 else: 2186 yioiy = yotop + 12 2187 topf += 12 2188 topt += 12 2189 else: 2190 yioiy = yotop 2191 if yo == 0: mqdo1 = yioiy 2192 if yo == 6: mqsi1 = yioiy 2193 self.sca[yo].configure(from_=topf, to=topt) 2194 self.sca[yo].set(yioiy) 2195 yo += 1 2196 if xrad == "YOI": 2197 self.sca[7].configure(from_=0 - mqdo1, to=24 - mqsi1) 2198 elif xrad == "IOI": 2199 self.sca[7].configure(from_=-12 - mqdo1, to=12 - mqsi1) 2200 elif xrad == "IOY": 2201 self.sca[7].configure(from_=-24 - mqdo1, to=0 - mqsi1) 2202 xradfan = xrad 2203 self.entfan.delete(0, END) 2204 self.entfan.insert(END, xradfan) 2205 self.btgama.invoke() 2206 2207 # Moment self.gama
2208
def momentgama(self, event): 2209 if event != '': 2210 self.btgama.invoke() 2211 2212 # Définition des curseurs
2213
def scanote1(self, xc): 2214 do = int(xc) 2215 xsi = self.sca[6].get() 2216 xre = self.sca[1].get() 2217 if do < xsi: self.sca[6].set(do) 2218 if do > xre + 1: self.sca[1].set(do - 1) 2219 # Initialise sca[7](from_) 2220 xxrad = self.variable.get() 2221 if xxrad == "YOI": 2222 self.sca[7].configure(from_=0 - do, to=24 - xsi) 2223 elif xxrad == "IOI": 2224 self.sca[7].configure(from_=-12 - do, to=12 - xsi) 2225 elif xxrad == "IOY": 2226 self.sca[7].configure(from_=-24 - do, to=0 - xsi) 2227 self.bind('<ButtonRelease-1>', self.momentgama) 2228
2229
def scanote2(self, xd): 2230 ren = int(xd) 2231 xdo = self.sca[0].get() 2232 xmi = self.sca[2].get() 2233 if ren < xdo - 1: self.sca[0].set(ren + 1) 2234 if ren > xmi + 1: self.sca[2].set(ren - 1) 2235
2236
def scanote3(self, xe): 2237 mi = int(xe) 2238 xre = self.sca[1].get() 2239 xfa = self.sca[3].get() 2240 if mi < xre - 1: self.sca[1].set(mi + 1) 2241 if mi > xfa: self.sca[3].set(mi) 2242
2243
def scanote4(self, xf): 2244 fa = int(xf) 2245 xmi = self.sca[2].get() 2246 xsol = self.sca[4].get() 2247 if fa < xmi: self.sca[2].set(fa) 2248 if fa > xsol + 1: self.sca[4].set(fa - 1) 2249
2250
def scanote5(self, xg): 2251 sol = int(xg) 2252 xfa = self.sca[3].get() 2253 xla = self.sca[5].get() 2254 if sol < xfa - 1: self.sca[3].set(sol + 1) 2255 if sol > xla + 1: self.sca[5].set(sol - 1) 2256
2257
def scanote6(self, xa): 2258 la = int(xa) 2259 xsol = self.sca[4].get() 2260 xsi = self.sca[6].get() 2261 if la < xsol - 1: self.sca[4].set(la + 1) 2262 if la > xsi + 1: self.sca[6].set(la - 1) 2263
2264
def scanote7(self, xb): 2265 si = int(xb) 2266 xla = self.sca[5].get() 2267 xdo = self.sca[0].get() 2268 if si < xla - 1: self.sca[5].set(si + 1) 2269 if si > xdo: self.sca[0].set(si) 2270 # Initialise sca[7](from_) 2271 xxxrad = self.variable.get() 2272 if xxxrad == "YOI": 2273 self.sca[7].configure(from_=0 - xdo, to=24 - si) 2274 elif xxxrad == "IOI": 2275 self.sca[7].configure(from_=-12 - xdo, to=12 - si) 2276 elif xxxrad == "IOY": 2277 self.sca[7].configure(from_=-24 - xdo, to=0 - si) 2278
2279
def scanote8(self, xh): 2280 sch = int(xh) 2281 f_t = 0 2282 xsi = self.sca[6].get() 2283 t_si = self.sca[6].cget("to") 2284 if xsi + sch > t_si: f_t = -1 2285 xdo = self.sca[0].get() 2286 fromdo = f_do = self.sca[0].cget("from") 2287 todo = t_do = self.sca[0].cget("to") 2288 if (xdo + sch < f_do) or (f_t == -1): 2289 fromdo = f_do + sch 2290 todo = t_do + sch 2291 f_t = -1 2292 xre = self.sca[1].get() 2293 fromre = f_re = self.sca[1].cget("from") 2294 tore = t_re = self.sca[1].cget("to") 2295 if f_t == -1: 2296 fromre = f_re + sch 2297 tore = t_re + sch 2298 xmi = self.sca[2].get() 2299 frommi = f_mi = self.sca[2].cget("from") 2300 tomi = t_mi = self.sca[2].cget("to") 2301 if f_t == -1: 2302 frommi = f_mi + sch 2303 tomi = t_mi + sch 2304 xfa = self.sca[3].get() 2305 fromfa = f_fa = self.sca[3].cget("from") 2306 tofa = t_fa = self.sca[3].cget("to") 2307 if f_t == -1: 2308 fromfa = f_fa + sch 2309 tofa = t_fa + sch 2310 xsol = self.sca[4].get() 2311 fromsol = f_sol = self.sca[4].cget("from") 2312 tosol = t_sol = self.sca[4].cget("to") 2313 if f_t == -1: 2314 fromsol = f_sol + sch 2315 tosol = t_sol + sch 2316 xla = self.sca[5].get() 2317 fromla = f_la = self.sca[5].cget("from") 2318 tola = t_la = self.sca[5].cget("to") 2319 if f_t == -1: 2320 fromla = f_la + sch 2321 tola = t_la + sch 2322 xsi = self.sca[6].get() 2323 fromsi = f_si = self.sca[6].cget("from") 2324 tosi = t_si = self.sca[6].cget("to") 2325 if (xsi + sch > t_si) or (f_t == -1): 2326 fromsi = f_si + sch 2327 tosi = t_si + sch 2328 # Formation des données scanote8 2329 self.sc_8[0] = xdo 2330 self.sc_8[1] = xre 2331 self.sc_8[2] = xmi 2332 self.sc_8[3] = xfa 2333 self.sc_8[4] = xsol 2334 self.sc_8[5] = xla 2335 self.sc_8[6] = xsi 2336 self.fr_8[0] = fromdo 2337 self.fr_8[1] = fromre 2338 self.fr_8[2] = frommi 2339 self.fr_8[3] = fromfa 2340 self.fr_8[4] = fromsol 2341 self.fr_8[5] = fromla 2342 self.fr_8[6] = fromsi 2343 self.to_8[0] = todo 2344 self.to_8[1] = tore 2345 self.to_8[2] = tomi 2346 self.to_8[3] = tofa 2347 self.to_8[4] = tosol 2348 self.to_8[5] = tola 2349 self.to_8[6] = tosi 2350 for i in range(7): 2351 self.sca[i].configure(from_=self.fr_8[i], to=self.to_8[i]) 2352 self.sca[i].set(self.sc_8[i] + sch) 2353 cb_ = self.cb_chk.get() 2354 if cb_ == 1: 2355 self.cbchk8.invoke() 2356 self.btgama.invoke() # Retirer cette ligne ; affiche une page blanche d'accueil 2357 2358 # La gamme naturelle
2359
def zero(self): 2360 for z in range(7): 2361 self.sca[z].configure(from_=self.fnotes[z], to=self.tnotes[z]) 2362 self.sca[z].set(0) 2363 self.sca[7].configure(from_=-12, to=12) 2364 self.sca[7].set(0) 2365 self.cbchk8.deselect() 2366 self.rad[1].invoke() # Remise à l'octave zéro ou "ioi" 2367 self.btgama.invoke() 2368 2369 # Motorisation Gammique
2370
def gama(self): 2371 self.decore.clear() # Remise au zéro tonique des accords 2372 self.can.delete(ALL) 2373 # Tracé d'encadrement 2374 # Données de l'encadré : Axes(x,y)=365(x),220(y) 2375 self.can.create_line(10, 450, 740, 450, fill='blue') 2376 self.can.create_line(390, 220, 520, 220, fill='green') 2377 self.can.create_line(270, 340, 400, 340, fill='red') 2378 self.can.create_line(510, 100, 640, 100, fill='blue') 2379 # Nombres d'intervalles des gammes et les diatoniques surnommées 2380 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], 2381 [1, 0, 1, 1, 1, 1, 0], [0, 1, 1, 1, 1, 1, 0], 2382 [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], 2383 [1, 3, 0, 0, 0, 1, 0], [0, 0, 2, 1, 1, 1, 0], 2384 [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], 2385 [0, 1, 0, 2, 1, 1, 0], [1, 1, 3, 0, 0, 0, 0], 2386 [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], 2387 [2, 0, 0, 0, 2, 1, 0], [1, 0, 1, 0, 2, 1, 0], 2388 [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], 2389 [1, 2, 0, 2, 0, 0, 0], [1, 0, 0, 3, 0, 1, 0], 2390 [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], 2391 [0, 0, 1, 0, 3, 1, 0], [0, 0, 0, 1, 3, 1, 0], 2392 [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], 2393 [0, 0, 2, 3, 0, 0, 0], [1, 0, 0, 4, 0, 0, 0], 2394 [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], 2395 [0, 2, 0, 1, 2, 0, 0], [2, 0, 0, 1, 0, 2, 0], 2396 [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], 2397 [1, 1, 0, 0, 3, 0, 0], [1, 1, 0, 2, 1, 0, 0], 2398 [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], 2399 [1, 3, 0, 0, 1, 0, 0], [1, 0, 0, 0, 1, 3, 0], 2400 [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], 2401 [1, 1, 0, 0, 0, 3, 0], [3, 0, 0, 0, 0, 2, 0]] 2402 self.gammescopie = gammes 2403 # Tonice(0). Tonale(1:3). Mélode(4:14). Médiane(15:18). Domine(19:42). Harmone(43:65) 2404 gamnoms = ['0', '-2', '+2', '^2', '-3', '-23', '-34x', '+34', '+23x', '-34', 'x3', '°3', '+34x', '°34x', 2405 '^3', 2406 '-4', '-24', '^4', '°4', '-5', '-25', '-25+', '+25-', '-35', '-35+', '+45x', '+25x', '°35-', 2407 '+35x', 2408 '-45+', '-45', 'x5', 'x45+', '-25°', '-35°', '-45°', '°45-', '°5', '°35+', '*5', '°35x', 2409 '-45x', 2410 '°45x', '-6', '+6', '-26', '-26+', '+26-', '+26', '-36', '-36+', '-56', '-56+', '+56', 2411 'x46+', 2412 '-26°', '-46+', '-46°', 'x36+', '-56°', '°46-', '°36+', '*6', '°46+', '°6', 'x26-'] 2413 self.gamnomscopie = gamnoms 2414 2415 # Récupération des notes cursives 2416 xxx = 0 2417 xxrad0 = self.variable.get() 2418 if xxrad0 == "YOI": 2419 xxx = +120 2420 elif xxrad0 == "IOI": 2421 xxx = 0 2422 elif xxrad0 == "IOY": 2423 xxx = -120 2424 2425 ydo = self.sca[0].get() 2426 xcpos_ = 400 - xxx 2427 ycpos_ = 220 + xxx 2428 xc_ = xcpos_ + (ydo * 10) 2429 yc_ = ycpos_ - (ydo * 10) 2430 rc_ = 5 2431 self.tablenotes[0] = xc_ 2432 self.tablehaute[0] = yc_ 2433 self.can.create_line(xc_, 350, xc_, 40, fill='black') 2434 self.can.create_oval(xc_ - rc_, yc_ - rc_, xc_ + rc_, yc_ + rc_, fill='black') 2435 yre = self.sca[1].get() 2436 xcpos_ = 420 - xxx 2437 ycpos_ = 220 + xxx 2438 xd_ = xcpos_ + (yre * 10) 2439 yd_ = ycpos_ - (yre * 10) 2440 rd_ = 5 2441 self.tablenotes[1] = xd_ 2442 self.tablehaute[1] = yd_ 2443 self.can.create_line(xd_, 360, xd_, 50, fill='green') 2444 self.can.create_oval(xd_ - rd_, yd_ - rd_, xd_ + rd_, yd_ + rd_, fill='green') 2445 ymi = self.sca[2].get() 2446 xcpos_ = 440 - xxx 2447 ycpos_ = 220 + xxx 2448 xe_ = xcpos_ + (ymi * 10) 2449 ye_ = ycpos_ - (ymi * 10) 2450 re_ = 5 2451 self.tablenotes[2] = xe_ 2452 self.tablehaute[2] = ye_ 2453 self.can.create_line(xe_, 370, xe_, 60, fill='blue') 2454 self.can.create_oval(xe_ - re_, ye_ - re_, xe_ + re_, ye_ + re_, fill='blue') 2455 yfa = self.sca[3].get() 2456 xcpos_ = 450 - xxx 2457 ycpos_ = 220 + xxx 2458 xf_ = xcpos_ + (yfa * 10) 2459 yf_ = ycpos_ - (yfa * 10) 2460 rf_ = 5 2461 self.tablenotes[3] = xf_ 2462 self.tablehaute[3] = yf_ 2463 self.can.create_line(xf_, 370, xf_, 60, fill='grey') 2464 self.can.create_oval(xf_ - rf_, yf_ - rf_, xf_ + rf_, yf_ + rf_, fill='grey') 2465 ysol = self.sca[4].get() 2466 xcpos_ = 470 - xxx 2467 ycpos_ = 220 + xxx 2468 xg_ = xcpos_ + (ysol * 10) 2469 yg_ = ycpos_ - (ysol * 10) 2470 rg_ = 5 2471 self.tablenotes[4] = xg_ 2472 self.tablehaute[4] = yg_ 2473 self.can.create_line(xg_, 380, xg_, 70, fill='red') 2474 self.can.create_oval(xg_ - rg_, yg_ - rg_, xg_ + rg_, yg_ + rg_, fill='red') 2475 yla = self.sca[5].get() 2476 xcpos_ = 490 - xxx 2477 ycpos_ = 220 + xxx 2478 xa_ = xcpos_ + (yla * 10) 2479 ya_ = ycpos_ - (yla * 10) 2480 ra_ = 5 2481 self.tablenotes[5] = xa_ 2482 self.tablehaute[5] = ya_ 2483 self.can.create_line(xa_, 390, xa_, 80, fill='orange') 2484 self.can.create_oval(xa_ - ra_, ya_ - ra_, xa_ + ra_, ya_ + ra_, fill='orange') 2485 ysi = self.sca[6].get() 2486 xcpos_ = 510 - xxx 2487 ycpos_ = 220 + xxx 2488 xb_ = xcpos_ + (ysi * 10) 2489 yb_ = ycpos_ - (ysi * 10) 2490 rb_ = 5 2491 self.tablenotes[6] = xb_ 2492 self.tablehaute[6] = yb_ 2493 self.can.create_line(xb_, 400, xb_, 90, fill='yellow') 2494 self.can.create_oval(xb_ - rb_, yb_ - rb_, xb_ + rb_, yb_ + rb_, fill='yellow') 2495 2496 # Mesure de l'intervalle tempéré 2497 c1 = (yre + 1) - ydo 2498 d2 = (ymi + 1) - yre 2499 e3 = yfa - ymi 2500 f4 = (ysol + 1) - yfa 2501 g5 = (yla + 1) - ysol 2502 a6 = (ysi + 1) - yla 2503 b7 = i = cum_diat = x = 0 2504 diata = [c1, d2, e3, f4, g5, a6, b7] 2505 while i < 6: 2506 cum_diat += diata[i] 2507 i += 1 2508 diata[i] = 5 - cum_diat 2509 2510 # Recherche diatonique par l'itération 2511 cc1 = dd2 = ee3 = ff4 = gg5 = aa6 = bb7 = degre = 0 2512 diata2 = [cc1, dd2, ee3, ff4, gg5, aa6, bb7] 2513 while x < 7: 2514 m = x 2515 y = 0 2516 while y < 7: # Une tonalité modale / tour 2517 diata2[y] = diata[m] 2518 y += 1 2519 m += 1 2520 if m > 6: m = 0 2521 myx = myx2 = 0 2522 for my in gammes: # Comparaison tonale / table gammes 2523 if diata2 == my: 2524 degre = x 2525 myx2 = myx 2526 x = 7 2527 myx += 1 2528 x += 1 2529 # Ici : diata(original cursif).degre(tonique).my(gamme) 2530 2531 # Définition diatonique 2532 # GMAJ= gammes[0] 2533 gmaj = [1, 1, 0, 1, 1, 1, 0] # Forme majeure simplifiée 2534 # GNAT= Ordre cursif comme diata[] 2535 gnat = ['C', 'D', 'E', 'F', 'G', 'A', 'B'] # Forme alphabétique 2536 cnat = ['', '', '', '', '', '', ''] 2537 # Niveaux d'altérations 2538 self.nordiese = ['', '+', 'x', '^', '+^', 'x^', '^^', '+^^', 'x^^', '^^^', '+^^^', 'x^^^', '^^^^', 2539 '13(#)', '14(#)', '15(#)', 2540 '16(#)', '17(#)', '18(#)', '19(#)', '20(#)', '21(#)', '22(#)', '23(#)', '24(#)', 2541 '25(#)', '26(#)', '27(#)', '28(#)', '29(#)', '30(#)', '31(#)', '32(#)'] 2542 self.subemol = ['', '32(b)', '31(b)', '30(b)', '29(b)', '28(b)', '27(b)', '26(b)', '25(b)', '24(b)', 2543 '23(b)', '22(b)', 2544 '21(b)', '20(b)', '19(b)', '18(b)', '17(b)', '16(b)', '15(b)', '14(b)', '13(b)', 2545 '****', '°***', '-***', '***', '°**', '-**', '**', '°*', '-*', '*', '°', '-'] 2546 # Configuration modale 2547 gdeg = ['I', 'II', 'III', 'IV', 'V', 'VI', 'VII'] 2548 # Définition du style d'écriture 2549 font = Font(family='Liberation Serif', size=9) 2550 font2 = Font(family='Liberation Serif', size=12) 2551 # Définition des notes cursives 2552 self.cursifs = [ydo, yre, ymi, yfa, ysol, yla, ysi] 2553 ynat = ymod = 0 2554 for ycurs in self.cursifs: 2555 if ycurs > 0: 2556 ymod = self.nordiese[ycurs] 2557 if ycurs < 0: 2558 ymod = self.subemol[ycurs] 2559 if ycurs == 0: 2560 ymod = self.subemol[ycurs] 2561 cnat[ynat] = ymod 2562 ynat += 1 2563 2564 # Une tournée produit une tonalité modale de 7 notes 2565 nat2 = degre 2566 deg = nom = 0 2567 ynote = xgdeg = 30 2568 ytone = 50 2569 while deg < 7: 2570 nat = deg # Degré tonal en question 2571 cri = gimj = maj = 0 2572 xdeg = 80 2573 text0 = gdeg[deg] 2574 self.can.create_text(xgdeg + 25, ynote + 10, text=text0, font='bold', fill='black') 2575 while maj < 7: # Tonalité modale du degré 2576 gmj = gmaj[maj] # Forme majeure (1101110) 2577 imaj = diata2[nat] # Forme modale (DIATA[DEGRE]) 2578 ynt = cnat[nat2] # Forme altérative des notes 2579 gnt = gnat[nat2] # Forme tonale (CDEFGAB) 2580 cri += gimj # Tonalité cumulée 2581 gimj = imaj - gmj # Calcul tonal PAS/PAS 2582 cmod = gmod = cri 2583 if maj == 0: 2584 yntgnt = ynt, gnt 2585 self.decore[deg] = yntgnt 2586 # print('decore', deg, self.decore[deg]) 2587 if gmod > 0: # Forme altérative des tonalités 2588 imod = self.nordiese[cmod] 2589 if gmod < 0: 2590 imod = self.subemol[cmod] 2591 if gmod == 0: 2592 imod = self.subemol[cmod] 2593 gmod += cri # Transition tonale 2594 # Construction du nom de la gamme 2595 if nom == 0: 2596 ynom = ynt 2597 gnom = gnt 2598 tnom = gnom, gamnoms[myx2] 2599 self.sel_yes = ynom, tnom # Report nom vers sélection 2600 self.sel_myx[0] = myx2 # Report type vers sélection 2601 self.can.create_text(28, 10, text=ynom, font=font, fill='red') 2602 self.can.create_text(28, 25, text=tnom, font=font2, fill='black') 2603 nat += 1 2604 nat2 += 1 2605 if nat > 6: 2606 nat = 0 2607 if nat2 > 6: 2608 nat2 = 0 2609 maj += 1 2610 text1 = gnt 2611 text2 = [imod, maj] 2612 self.can.create_text(xdeg, ynote - 12, text=ynt, font=font, fill='red') 2613 self.can.create_text(xdeg, ynote, text=text1) 2614 self.can.create_text(xdeg, ytone, text=text2, fill='blue') 2615 xdeg += 30 2616 nom = 1 2617 self.declare[(deg, maj)] = imod 2618 self.dechire[(deg, maj)] = cmod # Utilisation chromatique 2619 # print('dechire', deg, maj, self.dechire[(deg, maj)]) 2620 ynote += 60 2621 ytone += 60 2622 nat2 += 1 2623 if nat2 > 6: 2624 nat2 = 0 2625 deg += 1 2626 self.tbdegre[0] = degre 2627 2628
2629
class Commatique(Frame): 2630 """Branchement Commique""" 2631 def __init__(self): 2632 Frame.__init__(self) 2633 self.c_bb = [] 2634 self.c_cc = [] 2635 self.coo_valone = self.coo_valpos = self.coo_valneg = None 2636 self.coo_gym = ['', '', '', '', '', '', ''] 2637 self.coo_gam = ['C', 'D', 'E', 'F', 'G', 'A', 'B'] 2638 self.ctpier = self.ccnbase = None 2639 self.ctb_form = None # Table originale 2640 self.ctb_finv = None # Originale inversée 2641 self.f_bs = Font(family='Arial', size=8) 2642 self.f_bt = Font(family='Arial', size=7) 2643 self.f_bu = Font(family='Arial', size=6) 2644 self.f_bv = Font(family='Arial', size=6) 2645
2646
def brnch_1(self, c_oo, c_pp, c_ii): 2647 # c_oo c_pp c_cc de class Gammique.comma.co_tbval().. 2648 if self.ctpier is not None: 2649 self.ctpier.destroy() 2650 self.ctpier = Toplevel(self) 2651 self.ctpier.title('Entité Chromatique : Commatisme en %s' % c_ii) 2652 self.ctpier.geometry('777x567+234+100') 2653 self.c_bb = [] 2654 self.c_cc = [] 2655 self.ctb_form = [], [], [], [], [], [], [], [], [], [], [], [] 2656 self.ctb_finv = [], [], [], [], [], [], [], [], [], [], [], [] 2657 for i in range(12): 2658 self.c_bb.append(c_oo[0][i][0][:12]) 2659 self.c_cc.append(c_pp[0][i][0][:12]) 2660 if i == 0: 2661 self.coo_valone = self.c_bb[i] # c_vo ([(0, 'C')], [(('+', 'C'), ('-', 'D'))], 2662 self.coo_valpos = self.c_cc[i] # c_vp ([('g', 0, ('', 1))], [('', 1, ('+', 1))], 2663 if i == 11: 2664 self.coo_valneg = self.c_cc[i] # c_vn ([('g', 0, ('', 1))], [('g', 1, ('-', 2))], 2665 # Première écriture chromatique de la gamme en cours 2666 self.ccnbase = Canvas(self.ctpier, bg='Ivory', height=600, width=400) 2667 self.ccnbase.pack() # ccnbase = Premier Canvas original (pack_forget ou pas) 2668 self.ccnbase.delete(ALL) 2669 c_x, c_y, c_z = 30, 60, 0 2670 c_ii2 = 'Chrome en cours ' + str(c_ii) 2671 self.ccnbase.create_text(112, 8, font=self.f_bt, text=c_ii2, fill='blue') 2672 for i in range(12): 2673 c_i = i * 40 2674 c_rop = [] 2675 for j in range(12): 2676 c_j = j * 30 2677 c_ripaug = self.c_bb[i][j][0][0] # Signal augmenté : 0. ('+', 'C')... 2678 c_ripmin = self.c_bb[i][j][0][1] # Balance mineure : 0. ('-', 'D')... 2679 c_riplen = len(c_ripmin) 2680 if c_riplen == 1: 2681 c_rip0 = self.c_bb[i][j][0][0] # Signal 2682 c_rip1 = c_ripmin # Note 2683 self.ccnbase.create_text(c_x + c_j, c_y + c_i - 10, font=self.f_bu, text=c_rip0, 2684 fill='black') 2685 self.ccnbase.create_text(c_x + c_j, c_y + c_i, font=self.f_bs, text=c_rip1, 2686 fill='black') 2687 else: 2688 c_rip1 = c_ripmin 2689 self.ccnbase.create_text(c_x + c_j, c_y + c_i - 5, font=self.f_bv, text=c_rip1, 2690 fill='red') 2691 c_rip2 = c_ripaug 2692 self.ccnbase.create_text(c_x + c_j, c_y + c_i + 5, font=self.f_bv, text=c_rip2, 2693 fill='blue') 2694 c_rop2 = self.c_cc[i][j][0][2] # Formule inter modale : ('', 1). ('+', 1)... 2695 self.ccnbase.create_text(c_x + c_j, c_y + c_i + 20, font=self.f_bt, text=c_rop2, 2696 fill='olive') 2697 c_rop.append(c_rop2) 2698 self.ctb_form[i].append(c_rop) 2699 # Inversion du sens de lecture pour une écriture classique 2700 c_finv = [0] 2701 cfi_alt = [0] 2702 cfi_not = [0] 2703 c_form = [0] 2704 cfi_org = [] 2705 c_yn1 = c_yn2 = 0 2706 for i in range(12): 2707 i2n = i - (i * 2) 2708 c_valo = self.coo_valone[i], self.coo_valpos[i][0][0] 2709 self.ctb_finv[i].append(c_valo) # 0 0 self.ctb_finv[i] [([(0, 'C')], 'g')] 2710 c_formi2n = self.ctb_form[i2n] # 0 0 c_form ('', 1) | 0 1 c_form ('+', 1)... 2711 for j in range(12): 2712 c_form[0] = c_formi2n[0][j] 2713 c_finv[0] = self.ctb_finv[i] 2714 cfi_ggg = c_finv[0][0][1] 2715 if j == 0: 2716 if i == 0: 2717 # Enregistrement self.coo_gym[] 2718 cfi_org.append(c_formi2n) # "i" = "j" = nul 2719 cfi_y = c_finv[0][0][0][0][1] # cfi_not 0 0 C (cfi_not[0]) 2720 c_cfy = -1 2721 c_yy = 0 2722 for y in range(7): 2723 if self.coo_gam[y] == cfi_y: 2724 c_yy = 1 2725 if c_yy == 1: 2726 c_cfy += 1 2727 y2 = self.coo_gam[y] # self.coo_gam[y] = ['C','D','E','F','G','A','B'] 2728 self.coo_gym[c_cfy] = y2 # self.coo_gym[z] = ['','','','','','',''] 2729 if y == 6 and c_cfy < 6: 2730 cfy_ = y - c_cfy 2731 for cy_ in range(cfy_): 2732 c_cfy += 1 2733 self.coo_gym[c_cfy] = self.coo_gam[cy_] 2734 if cfi_ggg == 'g': 2735 cfi_ng0 = cfi_org[0][0][i][1] 2736 cfi_alt[0] = c_finv[0][0][0][0][0] # cfi_alt 0 0 [(0, 'C')] 2737 cfi_not[0] = cfi_ng0, c_finv[0][0][0][0][1] # cfi_not 0 0 C 2738 # print('*****1') 2739 else: 2740 cfi_n10 = c_finv[0][0][0][0][1][1] # cfi_n10 0 0 D 2741 cfi_n20 = c_finv[0][0][0][0][0][1] # cfi_n20 0 0 C 2742 for cy in range(7): 2743 if self.coo_gym[cy] == cfi_n10: 2744 c_yn1 = cy + 1 2745 if self.coo_gym[cy] == cfi_n20: 2746 c_yn2 = cy + 1 2747 cfi_a1 = c_finv[0][0][0][0][1][0] 2748 cfi_a2 = c_finv[0][0][0][0][0][0] 2749 cfi_alt[0] = cfi_a1, cfi_a2 2750 cfi_n1 = c_finv[0][0][0][0][1][1] 2751 cfi_n2 = c_finv[0][0][0][0][0][1] 2752 cfi_not[0] = c_yn1, cfi_n1, c_yn2, cfi_n2 2753 # print('*****2') 2754 # print('cy', '/', i, j, "c_finv's ", cfi_ggg, '/', cfi_alt[0], '/', cfi_not[0]) 2755 print('ctb_form', i, self.ctb_form[i]) 2756 else: 2757 pass 2758 # print('1er mode ctb_finv', self.ctb_finv) 2759 2760 # class Gammique 2761 Gammique().mainloop() 2762