-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprogamv6encore.py
2799 lines (2732 loc) · 125 KB
/
progamv6encore.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
# !/usr/bin/env python 3.10
# * Mercredi 18 mai 2022.
# -*- coding: utf-8 -*-
# Application gammique évolutive
# Operate Envol sysTM
# ProgamV6encore 1.0
# Approche commatique (Empreinte chromatique)
from tkinter import *
from tkinter.font import Font
from wave import struct, open
from pyaudio import PyAudio
from math import sin, pi
class Gammique(Tk):
""" Ramification Gammique """
def __init__(self):
Tk.__init__(self)
"Tableau de bord"
# Titre principal
self.title('Entité Gammique :')
self.geometry('1200x700+77+7')
# Fenêtre écran_résultat
self.can = Canvas(self, bg='white', height=550, width=700)
self.can.pack(side=RIGHT)
# Fenêtre des utilités
self.cad = Frame(self, width=30, height=80)
self.cad.pack(side=LEFT)
# Bouton gamme_radio
tab_do = tab_re = tab_mi = tab_fa = tab_so = tab_la = tab_si = 0
# self.tablenotes = les positions du cours self.gama
self.tablenotes = [tab_do, tab_re, tab_mi, tab_fa, tab_so, tab_la, tab_si]
self.tbdegre = [0] # Contient le mode tonique en cours
self.btrad = Button(self.cad, text='Radio', width=15, bg='light blue', command=self.radio)
self.btrad.pack()
# Bouton gamme_audio avec écriture sur le disque dur
# self.fichnom = les noms des fichiers audio_notes (communs)
self.presaudio = 0 # Utile au bouton accord/sans le résultat audio
self.gamula = ['C', 'D', 'E', 'F', 'G', 'A', 'B']
self.framno = [0, 0, 0, 0, 0, 0, 0]
# self.fichnom : Ces fichiers vont être écrits sur votre disque dur
self.fichnom = ['a1.wav', 'a2.wav', 'a3.wav', 'a4.wav', 'a5.wav', 'a6.wav', 'a7.wav']
self.btaud = Button(self.cad, text='Audio', width=15, bg='light blue', command=lambda: self.actuac(1))
self.btaud.pack()
self.btaud2 = Button(self.cad, command=self.audio)
self.btaud2.pack_forget() # Pantomime
# Bouton choix chromatique
self.chm = None
hau_do = hau_re = hau_mi = hau_fa = hau_so = hau_la = hau_si = 0
# self.tablehaute = les hauteurs (y) des notes graphiques
self.tablehaute = [hau_do, hau_re, hau_mi, hau_fa, hau_so, hau_la, hau_si]
self.chrmaj = [0, 20, 40, 50, 70, 90, 110] # Forme graphique majeure
self.chrgen = {} # Tableau chromatique généré
# self.ntchtxt = 'Chrome naturel'
self.btchr = Button(self.cad, text='Chrome naturel', width=15, bg='light blue', command=self.chrome)
self.btchr.pack()
# Bouton tableaux instruments
# self.piano_wav : Ces fichiers vont être écrits sur votre disque dur
self.tur = None
self.sel_nbr = -1
self.sel_stp = 0
self.tbltr_nom = ['Tonice', 'Tonale', 'Mélodie', 'Médiane', 'Domine', 'Harmonie']
self.piano_wav = ['p_w1.wav', 'p_w2.wav']
self.seldiaton = []
self.bttab = Button(self.cad, text='Tablature', width=15, bg='light blue', command=lambda: self.actuac(9))
self.bttab.pack()
self.bttab_2 = Button(self.cad, text='Tablature', width=15, bg='light blue', command=self.tabla)
self.bttab_2.pack_forget() # Pantomime
# Bouton accords avec écriture sur le disque dur
# self.fichacc = les noms des fichiers audio_accords (communs)
self.acc = None
self.accdiese = ['', '+', 'x', '^', '+^', 'x^', '^^'] # Tableaux des accords - altérations
self.accbemol = ['', '**', 'o*', '-*', '*', 'o', '-'] # Tableaux des accords - altérations
# self.fichacc : Ces fichiers vont être écrits sur votre disque dur
self.fichacc = ['acc1.wav', 'acc2.wav', 'acc3.wav', 'acc4.wav', 'acc5.wav', 'acc6.wav', 'acc7.wav']
self.btacc = Button(self.cad, text='Accords', width=15, bg='light blue', command=self.accord)
self.btacc.pack()
# Bouton tables tétracordiques
self.ttt = None
# self.tet_maj = {}
self.pretetutil = 0
self.bttet = Button(self.cad, text='Tétracorde', width=15, bg='ivory', command=self.tetra)
self.bttet.pack()
# Bouton tables commatiques
self.ccc = None
self.btcom = Button(self.cad, text='Commatisme', width=15, bg='ivory', command=self.comma)
self.btcom.pack()
self.comchr = []
self.comgen = []
self.co_tbgen = [], [], [], [], [], [], [], [], [], [], [], [] # Table des notes altérées
self.co_tbval = [], [], [], [], [], [], [], [], [], [], [], [] # Table des valeurs tonales
self.comfdb = [0] # Ligne diatone, forme: dia ou/et com
self.comfcb = [0] # Ligne chrome, forme : com ou/et dia
self.comfct = [0] # -1: formulé chromatique total
self.compy_ = [0] # Les 2 niveaux chromatiques
self.prescomma = 0
self.btcom3color = self.btcom4color = 'light grey'
self.com2 = Commatique()
# Bouton quitter
self.btquit = Button(self.cad, text='Quitter', bg='light grey', width=15, command=self.destroy)
self.btquit.pack(side=BOTTOM)
# Mémoire fantomatique
self.entfan = Entry(self)
# self.entfan.pack()
self.entfan.pack_forget() # Pantomime
self.entfan.delete(0, END)
self.entfan.insert(END, "IOI")
# Groupe Octave RADIO
etiqs = ["Octave -1", "Octave 0", "Octave +1"]
valse = ["YOI", "IOI", "IOY"]
self.variable = StringVar()
self.rad = []
for (variable, text, value, command) in (
(self.variable, etiqs[2], valse[2], self.yoiioiioy),
(self.variable, etiqs[1], valse[1], self.yoiioiioy),
(self.variable, etiqs[0], valse[0], self.yoiioiioy),
):
self.rad.append(Radiobutton(
self.cad,
variable=self.variable,
text=text,
value=value,
command=command,
))
for i in self.rad: i.pack()
self.rad[1].select()
# Bouton sélection diatonique
self.preselect = [0]
self.sel_bon = []
self.select = []
self.sel_yes = 0
self.sel_myx = [0]
# Tables gen* : Contient les indices des fréquences "tab_freqs"
self.gen_b = [3, 5, 7, 8, 10, 12, 14, 15, 17, 19, 20, 22, 24, 26, 27, 29, 31, 32, 34, 36, 38]
self.gen_n = [4, 6, -1, 9, 11, 13, -1, 16, 18, -1, 21, 23, 25, -1, 28, 30, -1, 33, 35, 37]
# Tables gen**: Contient les indices des touches
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]
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]
self.sel_gam = [12, 14, 16, 17, 19, 21, 23] # Positions relatives majeures
self.btsel = Button(self.cad, text='Sélectif', width=15, bg='orange', command=lambda: self.actuac(8))
self.btsel.pack()
# Les notes cursives scalpha : Graduations gérées.
self.sca = []
for (label, color, f, t, command) in (
("C", "black", 0, 5, self.scanote1),
("D", "green", -1, 4, self.scanote2),
("E", "blue", -2, 3, self.scanote3),
("F", "grey", -2, 3, self.scanote4),
("G", "red", -3, 2, self.scanote5),
("A", "orange", -4, 1, self.scanote6),
("B", "yellow", -5, 0, self.scanote7),
("CDEFGAB", "ivory", -12, 12, self.scanote8),
):
self.sca.append(Scale(
self,
length=300,
orient=HORIZONTAL,
label=label,
troughcolor=color,
sliderlength=20,
from_=f,
to=t,
tickinterval=1,
command=command,
))
for x in self.sca: x.pack()
# Case à cocher de conversion scanote8(CDEFGAB) vers l'octave majeure
# Car, la gamme de bCmaj(scanote8) = Bmaj à l'octave principale
# Exemple : bC,bD,bE,bF,bG,bA,bB = B,#C,#D,E,#F,#G,#A
self.fr_8 = [0, 0, 0, 0, 0, 0, 0] # Les tableaux self.(fr/to/sc/_8)
self.to_8 = [0, 0, 0, 0, 0, 0, 0] # Sont utilisés à def self.scanote8(_8)
self.sc_8 = [0, 0, 0, 0, 0, 0, 0] # from_(fr), to(to), .set(sc)
self.cb_chk = IntVar()
self.cbchk8 = Checkbutton(self, text='Conversion Octave Majeure',
variable=self.cb_chk, fg='black', command=self.convers)
self.cbchk8.pack()
self.cbchk8.deselect()
# Bouton gamme_naturelle
self.scolors = ['black', 'green', 'blue', 'grey', 'red', 'orange', 'yellow']
self.fnotes = [0, -1, -2, -2, -3, -4, -5] # Les from_'s majeurs
self.tnotes = [+5, +4, +3, +3, +2, +1, 0] # Les to's majeurs
self.btzer = Button(self, text='Zéro', width=25, command=self.zero)
self.btzer.pack()
# Bouton gamme_calculée
self.nordiese = []
self.subemol = []
self.cursifs = []
self.gammescopie = []
self.gamnomscopie = []
self.decore = {} # Base du zéro tonique des accords
self.declare = {} # Base (degrés - notes - altérations)
self.dechire = {} # Base avec l'indice adapté aux tableaux(b/#)
self.btgama = Button(self, text='gamme', width=25, command=self.gama)
self.btgama.pack_forget() # Pantomime
self.btgama.invoke()
# Section com
def comma(self):
""" La fonction commatique dépend de la définition chromatique """
# global c_deg0
if self.ccc is not None:
self.ccc.destroy()
self.ccc = Toplevel(self)
self.ccc.title('Entité Gammique : Chromatisme')
self.ccc.geometry('600x666+300+30')
frcom_up = Frame(self.ccc, width=30, height=3) # Partie haute
frcom_up.pack()
c_oo = []
c_pp = []
c_ii = []
# Traitement d'accrochage de la gamme (nom et type)
# self.tbdegre : Première note du mode tonique en cours
# self.gamula = ['C','D','E','F','G','A','B']
# self.sel_myx[0] : Est l'indice [i] en cours, dans self.gamnomscopie[i]
c_gam = self.gamnomscopie[self.sel_myx[0]] # c_gam = Rapport du Type
if c_gam == '0':
c_gam = "Majeur"
c_deg = self.tbdegre[0] # c_deg = Rapport du Degré
c_not = self.gamula[c_deg] # c_not = Rapport du Nom
c_ide = c_not + ' ' + c_gam
c_ii.append(c_ide)
btcom_id = Button(frcom_up, text=c_ide, height=1, width=15, bg='light green')
btcom_id.pack(side=RIGHT)
btcom_up = Button(frcom_up, text='Commane', height=1, width=15, bg='pink',
command=lambda: self.com2.brnch_1(c_oo, c_pp, c_ii))
btcom_up.pack(side=LEFT)
frcom_gaup = Frame(self.ccc, width=30, height=3) # Partie gauche
frcom_gaup.place(x=20, y=10, anchor='nw')
btcom_ga0up = Button(frcom_gaup, text='Console', height=1, width=15, bg='yellow')
btcom_ga0up.pack()
frcom_ga = Frame(self.ccc, width=30, height=3) # Partie gauche
frcom_ga.pack(side=LEFT)
btcom_ga0 = Button(frcom_ga, text='Forme totale', height=1, width=15, bg='white',
command=lambda: compyac(0))
btcom_ga0.pack()
btcom_ga01 = Button(frcom_ga, text='Forme augmentée', height=1, width=18, bg='orange',
command=lambda: compyac(1))
btcom_ga01.pack()
btcom_ga02 = Button(frcom_ga, text='Forme diminuée', height=1, width=18, bg='light blue',
command=lambda: compyac(2))
btcom_ga02.pack()
btcom_ga03 = Button(frcom_ga, text='Chrome naturel', height=1, width=15, bg=self.btcom3color,
command=lambda: compyac(3))
btcom_ga03.pack()
btcom_ga04 = Button(frcom_ga, text='Chrome atonal', height=1, width=15, bg=self.btcom4color,
command=lambda: compyac(4))
btcom_ga04.pack()
def compyac(y):
if y == 0:
self.compy_[0] = 0 # Intègres
elif y == 1:
self.compy_[0] = 1 # Augmentations
elif y == 2:
self.compy_[0] = 2 # Diminutions
elif y == 3:
self.btchr.configure(text='Chrome naturel')
self.btcom3color = 'ivory'
self.btcom4color = 'light grey'
elif y == 4:
self.btchr.configure(text='Chrome atonal')
self.btcom3color = 'light grey'
self.btcom4color = 'ivory'
self.ccc.destroy()
self.btcom.invoke()
frcom_drup2 = Frame(self.ccc, width=20, height=3) # Partie droite
frcom_drup2.place(x=468, y=10, anchor='nw')
btcom_dr0up = Button(frcom_drup2, text='Scalaire', height=1, width=15, bg='yellow')
btcom_dr0up.pack()
frcom_dr = Frame(self.ccc, width=30, height=3) # Partie droite
frcom_dr.pack(side=RIGHT)
btcom_dr0 = Button(frcom_dr, text='Toutes les lignes', height=1, width=15, bg='white',
command=lambda: commuac(-1))
btcom_dr0.pack()
btcom_dr01 = Button(frcom_dr, text='Ligne diatone.diatone', height=1, width=18, bg='light grey',
command=lambda: commuac(1))
btcom_dr01.pack()
btcom_dr02 = Button(frcom_dr, text='Ligne diatone.chrome', height=1, width=18, bg='light grey',
command=lambda: commuac(2))
btcom_dr02.pack()
btcom_dr03 = Button(frcom_dr, text='Ligne chrome.chrome', height=1, width=18, bg='light grey',
command=lambda: commuac(3))
btcom_dr03.pack()
btcom_dr04 = Button(frcom_dr, text='Ligne chrome.diatone', height=1, width=18, bg='light grey',
command=lambda: commuac(4))
btcom_dr04.pack()
btcom_dr05 = Button(frcom_dr, text='Lignes diatones', height=1, width=15, bg='pink',
command=lambda: commuac(5))
btcom_dr05.pack()
btcom_dr06 = Button(frcom_dr, text='Lignes chromes', height=1, width=15, bg='light green',
command=lambda: commuac(6))
btcom_dr06.pack()
def commuac(c):
self.comfct[0] = 0 # Toute. Ligne
self.comfdb[0] = 0 # Ligne dia.dia et/ou com
self.comfcb[0] = 0 # Ligne com.com et/ou dia
if c == -1:
self.comfct[0] = -1 # Toute. Ligne
elif c == 0:
pass
elif c == 1:
self.comfdb[0] = 1 # Ligne dia.dia
elif c == 2:
self.comfdb[0] = 2 # Ligne dia.com
elif c == 3:
self.comfcb[0] = 3 # Ligne com.com
elif c == 4:
self.comfcb[0] = 4 # Ligne com.dia
elif c == 5:
self.comfdb[0] = 5 # Ligne dia.dia/com
elif c == 6:
self.comfcb[0] = 6 # Ligne com.com/dia
self.ccc.destroy()
self.btcom.invoke()
# (self.comfct[0],self.comfdb[0],self.comfcb[0])
comcan_1 = Canvas(self.ccc, bg='ivory', height=600, width=300)
comcan_1.place(x=150, y=30, anchor='nw')
comcan_1.delete(ALL)
frcom_bo = Frame(self.ccc, width=30, height=3) # Partie basse
frcom_bo.pack(side=BOTTOM)
btcom_bo = Button(frcom_bo, text='Changer', height=1, width=15, bg='light grey',
command=self.ccc.destroy)
btcom_bo.pack()
fontval = Font(family='Liberation Serif', size=8)
fontchr = Font(family='Liberation Serif', size=7)
fontcom = Font(family='Liberation Serif', size=9)
# self.scolors = ['black','green','blue','grey','red','orange','yellow']# Couleurs usuelles
# self.chrgen : Dictionnaire du premier mode chromatique en cours
# self.comchr : Premier mode chromatique indexé
commaj_gam = [0, 2, 4, 5, 7, 9, 11] # Forme majeure
# self.commaj_com = [1, 3, 6, 8, 10] # Forme de l'indice chrome
self.prescomma = 1
self.btchr.invoke()
self.comchr = [], []
self.comgen = [], [], [], [], [], [], [], [], [], [], [], []
compro = [0]
# Prélèvement des primitives chromatiques
for ci in self.chrgen:
change = self.chrgen[ci][7]
if change[0] == 'n':
cochr = 'gam', self.chrgen[ci][2], self.chrgen[ci][3]
self.comchr[0].append(cochr)
else:
cochr = 'com', self.chrgen[ci][2], self.chrgen[ci][3], self.chrgen[ci][5], \
self.chrgen[ci][6]
self.comchr[0].append(cochr)
# print('comchr', self.comchr[0])
compro[0] = self.comchr[0]
# ('compro',compro[0]) # Forme d'écriture et de lecture
# Composition du modèle chrome diatonique
for ci in range(12):
count = ci
for co in range(12):
self.comgen[ci].append(compro[0][count])
count += 1
if count > 11:
count = 0
# ('comgen', ci, self.comgen[ci])
# écriture du modèle chrome diatonique
# self.dechire[(deg,maj)] # Tableau des tonalités diatoniques
# c_deg = indice de tonalité
c_deg0 = 0
co_d1 = -1
co_tbnat = [1, 2, 3, 4, 5, 6, 7]
self.co_tbgen = [], [], [], [], [], [], [], [], [], [], [], [] # Table des notes altérées
self.co_tbval = [], [], [], [], [], [], [], [], [], [], [], [] # Table des valeurs tonales
for ci in range(12):
co_d2i = co_d2 = co_d3 = 0
c_zer = [0]
c_zof = 0
co_tbmod = [], [], [], [], [], [], [], [], [], [], [], [] # Passe les notes altérées
co_tbdif = [], [], [], [], [], [], [], [], [], [], [], [] # Passe les valeurs tonales
for co in range(12):
compris = self.comgen[ci][co][0]
if co == 0 and compris == 'gam':
co_c1 = 0
co_c0 = self.comgen[ci][co][2]
for c_ in self.gamula:
if c_ == co_c0[0][0]:
c_deg0 = co_c1
break
co_c1 += 1
co_d1 += 1
c_zer[0] = 'on'
elif co == 0 and compris == 'com':
co_c1 = 0
co_c0 = self.comgen[ci][co][2]
for c_ in self.gamula:
if c_ == co_c0[0][0]:
c_deg0 = co_c1
break
co_c1 += 1
c_zof = 1
c_zer[0] = 'of'
# ('compris', compris)
if compris == 'gam':
co_sign0 = self.comgen[ci][co][1]
comcan_1.create_text(12 + co * 25, (30 + ci * 49) - 10, font=fontchr,
text=co_sign0[0], fill='black')
co_note0 = self.comgen[ci][co][2]
comcan_1.create_text(12 + co * 25, 30 + ci * 49, font=fontcom,
text=co_note0[0], fill='black')
# méthode 7 notes ("déchire")
if co_d2 < 7 and c_zer[0] == 'on': # Ligne diatonique : dia
co_d2 += 1 # co_d2 = degré
co_d0 = self.dechire[(co_d1, co_d2)] # co_d0 = signe (+/-)
if co_d0 >= 0:
co_d01 = "{0}{1}".format(self.nordiese[co_d0], co_d2)
else:
co_d01 = "{0}{1}".format(self.subemol[co_d0], co_d2)
# Selon l'activité demandée
if self.comfdb[0] == 2 or self.comfcb[0] != 0:
pass
else:
comcan_1.create_text(12 + co * 25, (30 + ci * 49) + 20,
font=fontval, text=co_d01, fill='magenta')
co_d012 = 'g', co, co_d01
co_tbdif[co].append(co_d012)
elif co_d2i < 7 and c_zer[0] == 'of': # Ligne chromatique : dia
co_d2i += 1 # co_d2i = degré
co_n0 = 0
for c_ in self.gamula: # obtenir tonique
if c_ == co_note0[0][0]:
if c_deg0 == 0:
c_dif = co_n0 + c_deg0
else:
c_dif = co_n0 - c_deg0
c_ree = int(commaj_gam[co_tbnat[c_dif] - 1])
co_s2 = co - c_ree # (+1/-1)
# ('ci',ci,'co',co,'co_s2',co_s2) # (+1/-1)
if co_s2 >= 0:
co_res = self.nordiese[co_s2]
else:
co_res = self.subemol[co_s2]
co_s1 = "{0}{1}".format(co_res, co_tbnat[c_dif])
# Selon l'activité demandée
if self.comfdb[0] != 0 or self.comfcb[0] == 3:
pass
else:
comcan_1.create_text(12 + co * 25, (30 + ci * 49) + 22,
font=fontchr, text=co_s1, fill='magenta')
co_s12 = 'c', co, co_s1
co_tbdif[co].append(co_s12)
co_n0 += 1
co_tbgam = co_sign0[0], co_note0[0][0]
co_tbmod[co].append(co_tbgam)
if compris == 'com':
co_sign1 = self.comgen[ci][co][1] # augmentation chromatique (signe)
co_note1 = self.comgen[ci][co][2] # augmentation chromatique (note)
co_sign2 = self.comgen[ci][co][3:4] # diminution chromatique (signe)
co_note2 = self.comgen[ci][co][4:] # diminution chromatique (note)
if self.compy_[0] == 0 or self.compy_[0] == 1:
comcan_1.create_text(12 + co * 25, (30 + ci * 49) + 12, font=fontval,
text=co_sign1[0], fill='red')
comcan_1.create_text(12 + co * 25, (30 + ci * 49) + 4, font=fontchr,
text=co_note1[0][0], fill='red')
if self.compy_[0] == 0 or self.compy_[0] == 2:
comcan_1.create_text(12 + co * 25, (30 + ci * 49) - 15, font=fontval,
text=co_sign2[0][0], fill='blue')
comcan_1.create_text(12 + co * 25, (30 + ci * 49) - 5, font=fontchr,
text=co_note2[0][0][0], fill='blue')
if co_d3 < 5 and c_zer[0] == 'on' or c_zof == 1: # degré chromatique diatonique
# commaj_gam = forme majeure
co_d3 += 1
co_n0 = c_sauf = 0
for c_ in self.gamula: # obtenir tonique
if c_ == co_note1[0][0]:
if c_deg0 == 0:
c_dif = co_n0 + c_deg0
else:
c_dif = co_n0 - c_deg0
c_ree = int(commaj_gam[co_tbnat[c_dif] - 1])
co_s2 = co - c_ree # (+1/-1)
# ('ci',ci,'co',co,'co_s2',co_s2) # (+1/-1)
if co_s2 >= 0:
co_res = self.nordiese[co_s2]
else:
co_res = self.subemol[co_s2]
co_s1 = "{}{}".format(co_res, co_tbnat[c_dif])
# Selon l'activité demandée
if c_zer[0] == 'on' and self.comfct[0] == 0:
if self.comfdb[0] == 1 or self.comfcb[0] != 0:
c_sauf = -1
elif c_zof == 1 and self.comfct[0] == 0:
if self.comfdb[0] != 0 or self.comfcb[0] == 4:
c_sauf = -1
if c_sauf == 0:
comcan_1.create_text(12 + co * 25, (30 + ci * 49) + 22,
font=fontchr, text=co_s1, fill='green')
co_s12 = '', co, co_s1
co_tbdif[co].append(co_s12)
co_n0 += 1
co_tbplus = co_sign1[0], co_note1[0][0]
co_tbmoins = co_sign2[0][0], co_note2[0][0][0]
co_tbplns = co_tbplus, co_tbmoins
co_tbmod[co].append(co_tbplns)
self.co_tbgen[ci].append(co_tbmod)
self.co_tbval[ci].append(co_tbdif)
# print('\n\n__co_tbgen', ci, self.co_tbgen[ci])
# print('520\n\n__co_tbval', ci, self.co_tbval[ci])
c_oo.append(self.co_tbgen)
c_pp.append(self.co_tbval)
# cob2 = self.co_tbval
# Self.co_tbgen, self.co_tbval: Utilisation au rapport commatique
# (ci,co,self.co_tbgen[ci][co]) # Remplacer "#" par "print" pour la forme
# (ci,co,self.co_tbval[ci][co])
# Panoplie tétracordique
def tetra(self):
""" La fonction tétracordique et les forces heptatoniques """
if self.ttt is not None:
self.ttt.destroy()
self.ttt = Toplevel(self)
self.ttt.title('Entité Gammique : Tétracorde')
self.ttt.geometry('600x666+300+50')
fonttt = Font(size=7)
frtet = Frame(self.ttt, width=30, height=3, bg='green')
frtet.pack(side=RIGHT)
bttet1 = Button(frtet, text='Tétras', height=1, width=10, bg='orange', command=lambda: ttractuac(1))
bttet1.pack()
bttet2 = Button(frtet, text='Utiles', height=1, width=10, bg='orange', command=lambda: ttractuac(2))
bttet2.pack()
bttet3 = Button(frtet, text='Clones', height=1, width=10, bg='orange', command=lambda: ttractuac(3))
bttet3.pack()
frtet_ = Frame(self.ttt, width=30, height=1)
frtet_.pack(side=BOTTOM)
bttet_ = Button(frtet_, text='Quitter', height=1, width=15, bg='lightgrey', command=self.ttt.destroy)
bttet_.pack()
tetcan = Canvas(self.ttt, bg='ivory', height=500, width=300)
tetcan.place(x=30, y=30, anchor='nw')
tetcan_ = Canvas(self.ttt, bg='pink', height=500, width=150)
tetcan_.place(x=350, y=30, anchor='nw')
tetcan.create_line(50, 30, 250, 30, fill='blue')
txlgh = 50
txldh = 250
tylgh = tyldh = 60 # Axe horizontal
tylgv = 50
tyldv = 460
txlgv = txldv = 30 # Axe vertical
for i in range(66):
tetcan.create_line(txlgh, tylgh + i * 6, txldh, tyldh + i * 6, fill='lightgrey')
for i in range(13):
tetcan.create_line(txlgv + i * 20, tylgv, txldv + i * 20, tyldv, fill='lightgrey')
# Le pas : (horizontal = *20)(vertical = *6)
r1 = 3
x1 = 150
y1 = 15
tetcan.create_oval(x1 - r1, y1 - r1, x1 + r1, y1 + r1, fill='white')
r2 = 2
x2 = 150
y2 = 24
tetcan.create_oval(x2 - r2, y2 - r2, x2 + r2, y2 + r2, fill='white')
# Label(self.ttt, text="Tétra's", font='bold', fg='blue')
tetcan.create_text(66, 15, text='Système tétracordique', fill='black')
self.pretetutil = 0
def ttractuac(t1):
tetcan.delete(ALL)
tetcan.create_line(50, 30, 250, 30, fill='blue')
for i1 in range(66):
tetcan.create_line(txlgh, tylgh + i1 * 6, txldh, tyldh + i1 * 6, fill='lightgrey')
for i2 in range(13):
tetcan.create_line(txlgv + i2 * 20, tylgv, txldv + i2 * 20, tyldv, fill='lightgrey')
if self.pretetutil == 1:
self.fr_sup.destroy()
self.fr_inf.destroy()
self.btpont.destroy()
xh = 30
yh = 60 # Départ Axe horizontal
if t1 == 0:
pass
elif t1 == 1: # Bouton tétras (tgam_tet = [])
# xh= 30; yh= 60 # Départ Axe horizontal(x)/vertical(y)
tetcan.create_text(150, 15, text='Système tétracordique ordonné', fill='grey')
tv = 0
for tt in tgam_tet:
th = 0
tt_inf = tt[0]
tt_sup = tt[1]
td = 13 - len(tt_inf + tt_sup)
for tti in tt_inf:
if tti == 1:
tetcan.create_oval(xh + th * 20 - r1, yh + tv * 6 - r1,
xh + th * 20 + r1, yh + tv * 6 + r1,
fill='red')
th += 1
else:
tetcan.create_oval(xh + th * 20 - r2, yh + tv * 6 - r2,
xh + th * 20 + r2, yh + tv * 6 + r2,
fill='yellow')
th += 1
if td > 0:
th1 = th
for td_ in range(td):
tetcan.create_oval(xh + th1 * 20 - r1, yh + tv * 6 - r1,
xh + th1 * 20 + r1, yh + tv * 6 + r1,
fill='white')
th1 += 1
th = th1
for tts in tt_sup:
if tts == 1:
tetcan.create_oval(xh + th * 20 - r1, yh + tv * 6 - r1,
xh + th * 20 + r1, yh + tv * 6 + r1,
fill='blue')
th += 1
else:
tetcan.create_oval(xh + th * 20 - r2, yh + tv * 6 - r2,
xh + th * 20 + r2, yh + tv * 6 + r2,
fill='yellow')
th += 1
tv += 1
elif t1 == 2: # Bouton utiles (tet_is:inf/sup/nom,tet_tt:ordre,tgam_util:clone)
# xh= 30; yh= 60 # Départ Axe horizontal(x)/vertical(y)
tetcan.create_text(150, 15, text='Système tétracordique utilisé', fill='grey')
if self.pretetutil == 1:
self.fr_sup.destroy()
self.fr_inf.destroy()
self.btpont.destroy()
self.btpont = Button(self.ttt, text='Pont', height=1, width=5, bg='ivory')
self.btpont.pack(side=RIGHT)
self.fr_sup = Frame(self.ttt, width=3, height=1, )
self.fr_sup.pack(side=RIGHT)
self.fr_inf = Frame(self.ttt, width=3, height=1)
self.fr_inf.pack(side=RIGHT)
tu = x_01i = x_01s = 0 # x_01:Jeux de marges du texte
for tt in tgam_util: # tt:clone(tt)=[1, 1, 1, 1]
t_is = tet_is[tu] # t_is:"inf/sup"/nom(tu):"L'horizontale(x)":=('Inf', '0')
t_tt = tet_tt[tu] # t_tt:ordre(tu):La verticale(y):=zéro à 66
t_ut = tt
th = 0
tis0i = tis0s = 0 # Compteurs des tétras(inf/sup)
if t_is[0] == 'Inf':
tis0i += 1
if x_01i == 1:
x10 = 7 # Marges de principe(x)
x_01i = 0
else:
x10 = 17 # Marges de principe(x)
x_01i = 1
for t2 in t_ut:
if t2 == 1:
tetcan.create_oval(xh + th * 20 - r1,
yh + t_tt * 6 - r1,
xh + th * 20 + r1,
yh + t_tt * 6 + r1, fill='red')
else:
tetcan.create_oval(xh + th * 20 - r2,
yh + t_tt * 6 - r2,
xh + th * 20 + r2,
yh + t_tt * 6 + r2, fill='yellow')
th += 1
tetcan.create_text(x10, yh + t_tt * 6, text=t_is[1], font=fonttt, fill='red')
Button(self.fr_inf, text=t_is[1], height=1, width=5, bg='lightblue').pack()
elif t_is[0] == 'Sup':
tis0s += 1
if x_01s == 1:
x290 = 284 # Marges de principe(x)
x_01s = 0
else:
x290 = 292 # Marges de principe(x)
x_01s = 1
t_len = 13 - len(tt)
th += t_len
for t3 in t_ut:
if t3 == 1:
tetcan.create_oval(xh + th * 20 - r1,
yh + t_tt * 6 - r1,
xh + th * 20 + r1,
yh + t_tt * 6 + r1, fill='blue')
else:
tetcan.create_oval(xh + th * 20 - r2,
yh + t_tt * 6 - r2,
xh + th * 20 + r2,
yh + t_tt * 6 + r2, fill='yellow')
th += 1
tetcan.create_text(x290, yh + t_tt * 6, text=t_is[1], font=fonttt, fill='blue')
Button(self.fr_sup, text=t_is[1], height=1, width=5, bg='pink').pack()
tu += 1
self.pretetutil = 1
elif t1 == 3: # Bouton clones (ts_simil = [])
# ts_simil[0] = [('Inf', 'Inf', 0, '0'),]
# tg_tra[0] = [([1, 0, 1, 0, 1, 1], [1, 0, 1, 0, 1, 1])] gamme en cours
# self.sel_myx[0] : Est l'indice [i] en cours, dans self.gamnomscopie[i]
# xh= 30; yh= 60 # Départ Axe horizontal(x)/vertical(y)
tetcan.create_text(150, 15, text='Système tétracordique cloné', fill='grey')
if self.pretetutil == 1:
self.fr_sup.destroy()
self.fr_inf.destroy()
self.btpont.destroy()
teg = te_ts = 0
te = -1
te_pos = self.sel_myx[0]
tetcan.create_line(30, tylgh + te_pos * 6, 270, tyldh + te_pos * 6, fill='grey')
x_01i = x_01s = 0
te_ego = self.gamnomscopie[self.sel_myx[0]] # Nom en cours
tetcan.create_text(50, 44, text=te_ego, font='bold', fill='black')
tg_in = tgam_tet[te_pos][0]
tg_su = tgam_tet[te_pos][1]
t_colinf = [0]
t_colsup = [0]
for te_ in tgam_tet:
te += 1
th = te_one = 0
teg_in = []
teg_su = []
te_fix = 0
teg_inf = ''
teg_sup = ''
te_in = te_[0]
te_su = te_[1]
t_tt = te
if tg_in == te_in:
teg += 1 # Compteur teg inutilisé
te_one += 1 # Recherche diatonique
teg_in = te_in # L'égalité rentrante(te_in)
teg_inf = 'inf' # Le côté sortant (position)
t_colinf[0] = 'red'
if tg_in == te_su:
teg += 1
te_one += 1
teg_su = te_su
teg_sup = 'sup' # Le côté sortant
t_colsup[0] = 'red'
if tg_su == te_in:
teg += 1
te_one += 1
teg_in = te_in
teg_inf = 'inf' # Le côté sortant
t_colinf[0] = 'blue'
if tg_su == te_su:
teg += 1
te_one += 1
teg_su = te_su
teg_sup = 'sup' # Le côté sortant
t_colsup[0] = 'blue'
if 0 < te_one:
te_ts = self.gamnomscopie[te]
te_ninf = len(teg_in)
te_nsup = len(teg_su)
te_fix = te_ninf + te_nsup
if teg_inf == 'inf':
if x_01i == 1:
x10 = 7 # Marges de principe(x)
x_01i = 0
else:
x10 = 17 # Marges de principe(x)
x_01i = 1
for t4 in teg_in:
if t4 == 1:
tetcan.create_oval(xh + th * 20 - r1,
yh + t_tt * 6 - r1,
xh + th * 20 + r1,
yh + t_tt * 6 + r1, fill=t_colinf[0])
else:
tetcan.create_oval(xh + th * 20 - r2,
yh + t_tt * 6 - r2,
xh + th * 20 + r2,
yh + t_tt * 6 + r2, fill='yellow')
th += 1
tetcan.create_text(x10, yh + t_tt * 6, text=te_ts, font=fonttt, fill='red')
if teg_sup == 'sup':
# nel = 0
nel = 13 - te_fix
th += nel
if x_01s == 1:
x290 = 284 # Marges de principe(x)
x_01s = 0
else:
x290 = 292 # Marges de principe(x)
x_01s = 1
for t5 in teg_su:
if t5 == 1:
tetcan.create_oval(xh + th * 20 - r1,
yh + t_tt * 6 - r1,
xh + th * 20 + r1,
yh + t_tt * 6 + r1, fill=t_colsup[0])
else:
tetcan.create_oval(xh + th * 20 - r2,
yh + t_tt * 6 - r2,
xh + th * 20 + r2,
yh + t_tt * 6 + r2, fill='yellow')
th += 1
tetcan.create_text(x290, yh + t_tt * 6, text=te_ts, font=fonttt,
fill='blue')
# La gamme en cours comme élément - système de définition tétracordique
# Développé tétra similaire diatonique : TETRA/CLONE/DIATONE
# self.gamnomscopie[]:(noms[+2])gammes - signatures(int)
# self.gammescopie[] :(valeurs[1,1,0,,,])gammes - intervalles(int)
# self.accdiese[(de 0 à +6)]: Table des altérations/str(+)
# self.accbemol[(de -1 à -6)]: Table des altérations/str(-)
# self.sel_myx[0] : Est l'indice [i] en cours, dans self.gamnomscopie[i]
# La transition modifie [1,1,0,1,1,1,0] en ([1,0,1,0,1,1],[1,0,1,0,1,1])
tginf_tra = []
tgsup_tra = [] # Tables transitives (inf/sup)
tgam_tet = [] # tgam_tet : Table tétra's complète
tg_tra = [0] # tg_tra[0] : Table tétra en cours
ts_simil = [] # Table des similaires
tgam_util = [] # Tables des utilités
tginf_nbr = tgsup_nbr = 0
t_gam = self.gammescopie[self.sel_myx[0]]
tgam_inf = t_gam[:4]
tgam_sup = t_gam[4:]
for tg_i in tgam_inf:
if tg_i > 0:
for tg_ii in range(tg_i + 1):
if tg_ii == 0:
tginf_tra.append(1)
tginf_nbr += 1
elif tginf_nbr < 4:
tginf_tra.append(0)
else:
tginf_tra.append(1)
tginf_nbr += 1
for tg_s in tgam_sup:
if tg_s > 0:
for tg_ss in range(tg_s + 1):
if tg_ss == 0:
tgsup_tra.append(1)
tgsup_nbr += 1
elif tgsup_nbr < 4:
tgsup_tra.append(0)
if tgsup_nbr == 4:
tgsup_tra.append(1)
tgsup_nbr += 1
if tg_s == 0:
tgsup_tra.append(1)
tgsup_nbr += 1
tgsup_tra.append(1)
tgsup_nbr += 1
tg_tra[0] = tginf_tra, tgsup_tra
# (tg_tra) # Remplacer "#" par "print" pour la forme
# Bouton tétras : L'ensemble tétracordique
t = 0
for t_ in self.gammescopie:
tinf_tra = []
tsup_tra = []
tinf_nbr = tsup_nbr = 0
t_tra = [0]
t += 1
t_inf = t_[:4]
t_sup = t_[4:]
for t_i in t_inf:
if t_i > 0:
for t_ii in range(t_i + 1):
if t_ii == 0:
tinf_tra.append(1)
tinf_nbr += 1
elif tinf_nbr < 4:
tinf_tra.append(0)
else:
tinf_tra.append(1)
tinf_nbr += 1
for t_s in t_sup:
if t_s > 0:
for t_ss in range(t_s + 1):
if t_ss == 0:
tsup_tra.append(1)
tsup_nbr += 1
elif tsup_nbr < 4:
tsup_tra.append(0)
if tsup_nbr == 4:
tsup_tra.append(1)
tsup_nbr += 1
if t_s == 0:
tsup_tra.append(1)
tsup_nbr += 1
tsup_tra.append(1)
tsup_nbr += 1
t_tra[0] = tinf_tra, tsup_tra
tgam_tet.append(t_tra[0]) # tgam_tet : Table tétra's complète
# (t, tgam_tet) # Remplacer "#" par "print" pour la forme
# Bouton clones : Les clones dans le système
tin_f = tg_tra[0][0]
tsu_p = tg_tra[0][1]
ts = ts_t = 0 # ts = Quantité de similitudes
for t_ in tgam_tet:
ts_eti = t_[0]
ts_ets = t_[1]
if tin_f == ts_eti:
tin_nom = 'Inf', 'Inf', ts_t, self.gamnomscopie[ts_t]
ts_simil.append(tin_nom)
ts += 1
if tin_f == ts_ets:
tin_nom = 'Inf', 'Sup', ts_t, self.gamnomscopie[ts_t]
ts_simil.append(tin_nom)
ts += 1
if tsu_p == ts_ets:
tin_nom = 'Sup', 'Sup', ts_t, self.gamnomscopie[ts_t]
ts_simil.append(tin_nom)
ts += 1
if tsu_p == ts_eti:
tin_nom = 'Sup', 'Inf', ts_t, self.gamnomscopie[ts_t]
ts_simil.append(tin_nom)
ts += 1
ts_t += 1
# (ts,ts_simil) # Remplacer "#" par "print" pour la forme
# Boutons utiles : Sans les clones de l'ensemble tétracordique
tet_is = []
tet_tt = []
t = t_t = 0 # t = compteur pouvant être utilisé
for t_ in tgam_tet:
ti_egal = ts_egal = 0
if t == 0:
ti_nom = 'Inf', self.gamnomscopie[t_t]
tet_is.append(ti_nom)
tet_tt.append(t_t)
tet_i = t_[0]
tgam_util.append(tet_i)
t += 1
tet_s = t_[1]
if tet_i != tet_s:
ts_nom = 'Sup', self.gamnomscopie[t_t]
tet_is.append(ts_nom)
tet_tt.append(t_t)
tgam_util.append(tet_s)
t += 1
else:
tet_i = t_[0]
tet_s = t_[1]
for t_u in tgam_util:
if t_u == tet_i:
ti_egal = 1
if t_u == tet_s:
ts_egal = 1
if ti_egal == 0:
ti_nom = 'Inf', self.gamnomscopie[t_t]
tet_is.append(ti_nom)
tet_tt.append(t_t)
tgam_util.append(tet_i)
t += 1
if ts_egal == 0:
ts_nom = 'Sup', self.gamnomscopie[t_t]
tet_is.append(ts_nom)
tet_tt.append(t_t)
tgam_util.append(tet_s)
t += 1
t_t += 1
# (t,tet_is,tet_tt,tgam_util) # Remplacer "#" par "print" pour la forme
# Version con
def convers(self):
con_chk = self.cb_chk.get()
if con_chk == 1:
# self.tablenotes : Conteneur diatonique | Calcul graphique horizontal
del (self.sel_bon[:])
for y in range(7):
con_m = (self.tablenotes[y] // 10) - 28
con_ = con_m
if con_m < 12:
con_ += 12
if con_m > 23:
con_ -= 12
self.sel_bon.append(con_)
self.sel_bon.sort()
self.select = self.sel_bon
for z in range(7):
sel_z = self.select[z] - self.sel_gam[z]
# (z,sel_z) # Remplacer "#" par "print" pour la forme
self.sca[z].configure(from_=self.fnotes[z], to=self.tnotes[z])
self.sca[z].set(sel_z)
self.sca[7].configure(from_=-12, to=12)
self.sca[7].set(0)
else:
pass
self.rad[1].invoke() # Remise à l'octave zéro ou "ioi"
# Sel de fonction
def selection(self):
# ('yes',self.select[0]) # Remplacer "#" par "print" pour la forme
for z in range(7):
sel_z = self.select[z] - self.sel_gam[z]
self.sca[z].configure(from_=self.fnotes[z], to=self.tnotes[z])
self.sca[z].set(sel_z)
self.sca[7].configure(from_=-12, to=12)
self.sca[7].set(0)
self.tur.destroy()
self.rad[1].invoke() # Remise à l'octave zéro ou "ioi"
self.btgama.invoke()