IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

Contribuez Python Discussion :

python musique


Sujet :

Contribuez Python

  1. #1
    Invité
    Invité(e)
    Par défaut python musique
    Un cadeau pour les professeurs
    Ils vont pouvoir expliquer le développement diatonique à leurs élèves
    Mais avant il falloir décrypter ce code Open source en Do majeur
    BON VOYAGE parmi les gammes musicales...

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    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
    # Développement diatonique élémentaire
    # Version 1 : Calculer les modulations majeures
    # pr0diat zéro
     
    gnat = ['C','D','E','F','G','A','B']    # Notes diatoniques
    gmaj = [1,1,0,1,1,1,0]                  # Formule majeure
    gdeg = [0,1,2,3,4,5,6]                  # Degrés modal
    nordiese = [' ','+','x','^','+^','x^']      # Altérations augmentées
    subemol = [' ','°*','-*','*','°','-']       # Altérations diminuées
    deg = 0
    while deg < 7 :             # Lecture diatonique tonale de "gdeg"
        # Une tournée produit une tonalité modale de 7 notes
        nat = gdeg[deg]         # Degré tonal en question
        cri = gimj = gmod = maj = 0
        #
        while maj < 7 :   # Tonalité modale du degré
            #
            gmj = gmaj[maj]     # Forme majeure
            imaj = gmaj[nat]    # Forme modale
            gnt = gnat[nat]     # Forme tonale
            #print ("gmj,imaj,gnt ",gmj,imaj,gnt)
            cri = cri + gimj    # Tonalité cumulée
            gimj = imaj - gmj   # Calcul tonal PAS/PAS
            #print ("gimj,cri,gnt ",gimj,cri,gnt)
            cmod = gmod = cri
            #print ("gmod ",gmod,gnt)
            if gmod > 0 :
                imod = nordiese[cmod]
                #print ("imod+cmod",imod,cmod,gnt)
            if gmod < 0 :
                imod = subemol[cmod]
                #print ("imod-cmod",imod,cmod,gnt)
            if gmod == 0 :
                imod = subemol[cmod]
                #print ("imod,cmod ",imod,cmod,gnt)
            gmod = gmod + cri   # Transition tonale
            nat = nat + 1
            if nat > 6 : nat = 0
            maj = maj + 1 
            print ("imod,maj,gnt ",imod,maj,gnt)
            #
        print ("___",deg)
        deg = deg + 1
        #

  2. #2
    Expert éminent

    Homme Profil pro
    Inscrit en
    Octobre 2008
    Messages
    4 300
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Belgique

    Informations forums :
    Inscription : Octobre 2008
    Messages : 4 300
    Points : 6 780
    Points
    6 780
    Par défaut
    Salut,

    Le cadeau pour les profs c'est un exemple de ce qu'il ne faut pas faire en Python.

    J'ai déjà proposé un corrigé hier.

  3. #3
    Invité
    Invité(e)
    Par défaut
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    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
     
    # -*- coding: utf-8 -*-
     
    # Développement diatonique élémentaire
    # Version 1 : Calculer les modulations majeures
    # pr0diat zéro
     
    diatoniques = ['C','D','E','F','G','A','B']    # Notes diatoniques
    majeures = [1,1,0,1,1,1,0]                  # Formule majeure
    degres = [0,1,2,3,4,5,6]                  # Degrés modal
    dieses = [' ','+','x','^','+^','x^']      # Altérations augmentées
    bemols = [' ','°*','-*','*','°','-']       # Altérations diminuées
    degre = 0
    for degre in degres:
        # Une tournée produit une tonalité modale de 7 notes
        tonal = degres[degre]
        ton_cumule = delta_tonal = maj = 0
        for maj in degres:
            forme_majeur = majeures[maj]
            forme_modale = majeures[tonal]
            forme_tonale = diatoniques[tonal]
            ton_cumule += delta_tonal
            # Calcul tonal PAS/PAS
            delta_tonal = forme_modale - forme_majeur
            alter = transition = ton_cumule
            if transition > 0:
                alteration = dieses[alter]
     
            elif transition < 0:
                alteration = bemols[alter]
     
            else:
                alteration = bemols[alter]
     
            transition += ton_cumule
            tonal += 1
            if tonal > 6: 
                tonal = 0
            print ("alteration, maj, forme_tonale ",alteration, maj + 1, forme_tonale)
     
        print ("___", degre + 1)
    La ligne "for maj in degres:" n'est pas convenable. Puisque le traitement est porté sur la gamme et non pas le degré.
    Même si le résultat est bon, le terme syntaxique ( degres:" n'est pas ) n'est pas correctement distribué.

  4. #4
    Expert éminent

    Homme Profil pro
    Inscrit en
    Octobre 2008
    Messages
    4 300
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Belgique

    Informations forums :
    Inscription : Octobre 2008
    Messages : 4 300
    Points : 6 780
    Points
    6 780
    Par défaut
    degres ne désigne qu'un range(0, 7) dans ce code.

    Et, en français, les étapes d'une succession de choses peuvent être nommées degrés.

    Ma remarque concernant l'horrible syntaxe de ton code n'est pas du pédantisme. Python est un langage dont la qualité première est la lisibilité, pourquoi le rendre obscur avec des noms incompréhensibles et des procédure inutiles.

    Il faut bien comprendre qu'une fois transformé en bytecode, il ne restera rien de cette littérature. Seul le bytecode est chargé en mémoire lors de l'exécution du code.

    À tenir sous le coude: PEP-8

  5. #5
    Invité
    Invité(e)
    Par défaut
    Python est un langage dont la qualité première est la lisibilité, pourquoi le rendre obscur avec des noms incompréhensibles et des procédure inutiles.
    Je suis un programmeur débutant, et la seule envie qui me dit d'aller plus loin c'est cette musique quantique.
    Au risque de paraitre " obscur, incompréhensible, inutile " :
    Puisque je débute en ayant des difficultés à résoudre mes problèmes de programmation, mes lacunes sont nombreuses.
    L'obscurantisme vient de l'incompréhension du code, donc python est plus flexible que certains programmeurs.
    Python comprend mon code, et vous pas !

    Un conseil acceptez les largesses des erreurs que je commets, mais en aucun cas ne les tournez en dérision.
    J'ai déjà eu de la difficulté a écrire une application, qui calcule les gammes en langage gammologique.
    Ce qui pour ce fait, est bien une exception. Profitez de la quantique musicale, elle vous le rendra...

    Mai autrement, vous avez raison de publier le code de façon populaire, c'est bien ou pas çà dépend

  6. #6
    Invité
    Invité(e)
    Par défaut
    Juste un grand plus de plus, de fil en aiguille l'expression des gammes évolue dans ce petit programme...

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    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
     
    #!/usr/bin/env python3 
    # -*- coding: utf-8 -*-
    # *
    # Application gammique évolutive
    # Version 1 : Calculer les gammes
    #
    from tkinter import *
     
    class Gammique(Tk):
        """ Ramification Gammique """
        def __init__(self):
            Tk.__init__(self)
            "Tableau de bord"
            self.title('Entité Gammique :')
    # Fenêtre écran_résultat
            self.can=Canvas(self,bg='white', height=500,width=750)
            self.can.pack(side=RIGHT)
            self.cad=Frame(self,width=200,height=600)
            self.cad.pack(side=LEFT)
            self.can.delete(ALL)
            # Tracé d'encadrement
            # Données de l'encadré : Axes(x,y)=365(x),220(y)
            self.can.create_line(10, 0, 10, 450, fill ='black')
            self.can.create_line(740, 10, 0, 10, fill ='blue')
            self.can.create_line(740, 450, 740, 10, fill ='black')
            self.can.create_line(10, 450, 740, 450, fill ='blue')
            # Bouton gamme_audio
            Button(self.cad,text ='Radio_inactive',width=25,bg='light yellow').pack()
            # Bouton choix chromatique
            Button(self.cad,text ='Chrome_inactif',width=25,bg='light yellow').pack()
            # Bouton tableaux instruments
            Button(self.cad,text ='Tabla_inactif',width=25,bg='light yellow').pack()
            # Bouton accords1357
            Button(self.cad,text ='A1357_inactif',width=25,bg='light yellow').pack()
    # Les notes cursives scalpha : Graduations gérées.
            self.sca1=Scale(self,length =250,orient = HORIZONTAL,label ='C',
                  troughcolor ='black',sliderlength =20,showvalue =1,
                  from_ =0,to =5,tickinterval =1,command=self.scanote1)
            self.sca1.pack()
            self.sca2=Scale(self,length =250,orient = HORIZONTAL,label ='D',
                  troughcolor ='green',sliderlength =20,showvalue =1,
                  from_ =-1,to =4,tickinterval =1,command=self.scanote2)
            self.sca2.pack()
            self.sca3=Scale(self,length =250,orient = HORIZONTAL,label ='E',
                  troughcolor ='blue',sliderlength =20,showvalue =1,
                  from_ =-2,to =3,tickinterval =1,command=self.scanote3)
            self.sca3.pack()
            self.sca4=Scale(self,length =250,orient = HORIZONTAL,label ='F',
                  troughcolor ='grey',sliderlength =20,showvalue =1,
                  from_ =-2,to =3,tickinterval =1,command=self.scanote4)
            self.sca4.pack()
            self.sca5=Scale(self,length =250,orient = HORIZONTAL,label ='G',
                  troughcolor ='red',sliderlength =20,showvalue =1,
                  from_ =-3,to =2,tickinterval =1,command=self.scanote5)
            self.sca5.pack()
            self.sca6=Scale(self,length =250,orient = HORIZONTAL,label ='A',
                  troughcolor ='orange',sliderlength =20,showvalue =1,
                  from_ =-4,to =1,tickinterval =1,command=self.scanote6)
            self.sca6.pack()
            self.sca7=Scale(self,length =250,orient = HORIZONTAL,label ='B',
                  troughcolor ='yellow',sliderlength =20,showvalue =1,
                  from_ =-5,to =0,tickinterval =1,command=self.scanote7)
            self.sca7.pack()
    # Concerne les notes scahuit : Graduations gérées.
            self.sca8=Scale(self,length =250,orient = HORIZONTAL,label ='CDEFGAB',
                  troughcolor ='ivory',sliderlength =20,showvalue =1,
                  from_ =-5,to =5,tickinterval =1,command=self.scanote8)
            self.sca8.pack()
            # Bouton gamme_naturelle
            Button(self,text ='Zéro',width=25,command=self.zero).pack()
            # Bouton gamme_calculée
            Button(self,text ='Gamme',width=25,command=self.gama).pack()
    # Définition des curseurs
        def scanote1(self,xc):
            do=int(xc)
            fromdo=do-(do*2)
            self.sca8.configure(from_ = fromdo)
            xsi=self.sca7.get()
            xre=self.sca2.get()
            if do<xsi:self.sca7.set(do)
            if do>xre+1 :self.sca2.set(do-1)
        def scanote2(self,xd):
            re=int(xd)
            xdo=self.sca1.get()
            xmi=self.sca3.get()
            if re<xdo-1:self.sca1.set(re+1)
            if re>xmi+1 :self.sca3.set(re-1)
        def scanote3(self,xe):
            mi=int(xe)
            xre=self.sca2.get()
            xfa=self.sca4.get()
            if mi<xre-1:self.sca2.set(mi+1)
            if mi>xfa:self.sca4.set(mi)
        def scanote4(self,xf):
            fa=int(xf)
            xmi=self.sca3.get()
            xsol=self.sca5.get()
            if fa<xmi:self.sca3.set(fa)
            if fa>xsol+1:self.sca5.set(fa-1)
        def scanote5(self,xg):
            sol=int(xg)
            xfa=self.sca4.get()
            xla=self.sca6.get()
            if sol<xfa-1:self.sca4.set(sol+1)
            if sol>xla+1:self.sca6.set(sol-1)
        def scanote6(self,xa):
            la=int(xa)
            xsol=self.sca5.get()
            xsi=self.sca7.get()
            if la<xsol-1:self.sca5.set(la+1)
            if la>xsi+1:self.sca7.set(la-1)
        def scanote7(self,xb):
            si=int(xb)
            tosi=si-(si*2)
            self.sca8.configure(to = tosi)
            xla=self.sca6.get()
            xdo=self.sca1.get()
            if si<xla-1:self.sca6.set(si+1)
            if si>xdo:self.sca1.set(si)
        def scanote8(self,xh):
            sch=int(xh)
            xdo=self.sca1.get()
            xre=self.sca2.get()
            xmi=self.sca3.get()
            xfa=self.sca4.get()
            xsol=self.sca5.get()
            xla=self.sca6.get()
            xsi=self.sca7.get()
            self.sca1.set(xdo+sch)
            self.sca2.set(xre+sch)
            self.sca3.set(xmi+sch)
            self.sca4.set(xfa+sch)
            self.sca5.set(xsol+sch)
            self.sca6.set(xla+sch)
            self.sca7.set(xsi+sch)
        def zero(self):
            self.can.delete(ALL)
            # Tracé d'encadrement
            # Données de l'encadré : Axes(x,y)=365(x),220(y)
            self.can.create_line(10, 0, 10, 450, fill ='black')
            self.can.create_line(740, 10, 0, 10, fill ='blue')
            self.can.create_line(740, 450, 740, 10, fill ='black')
            self.can.create_line(10, 450, 740, 450, fill ='blue')
            self.can.create_line(360, 450, 360, 10, fill ='olive')
            self.can.create_line(10, 220, 740, 220, fill ='olive')
            self.sca1.set(0)
            self.can.create_oval(300-5,220-5,300+5,220+5,fill='black')
            self.sca2.set(0)
            self.can.create_oval(320-5,220-5,320+5,220+5,fill='green')
            self.sca3.set(0)
            self.can.create_oval(340-5,220-5,340+5,220+5,fill='blue')
            self.sca4.set(0)
            self.can.create_oval(350-5,220-5,350+5,220+5,fill='grey')
            self.sca5.set(0)
            self.can.create_oval(370-5,220-5,370+5,220+5,fill='red')
            self.sca6.set(0)
            self.can.create_oval(390-5,220-5,390+5,220+5,fill='orange')
            self.sca7.set(0)
            self.can.create_oval(410-5,220-5,410+5,220+5,fill='yellow')
        def gama(self):
            self.can.delete(ALL)
            # Tracé d'encadrement
            # Données de l'encadré : Axes(x,y)=365(x),220(y)
            self.can.create_line(10, 0, 10, 450, fill ='black')
            self.can.create_line(740, 10, 0, 10, fill ='blue')
            self.can.create_line(740, 450, 740, 10, fill ='black')
            self.can.create_line(10, 450, 740, 450, fill ='blue')
            self.can.create_line(360, 450, 360, 110, fill ='olive')
            self.can.create_line(220, 220, 740, 220, fill ='olive')
    # De la table gammique aux tables diatoniques surnommées
            gammes =[[1,1,0,1,1,1,0],[0,2,0,1,1,1,0],[2,0,0,1,1,1,0],[4,0,0,0,0,1,0],[1,0,1,1,1,1,0],[0,1,1,1,1,1,0],
                     [1,0,3,0,0,1,0],[1,2,1,0,0,1,0],[2,2,0,0,0,1,0],[0,0,1,2,1,1,0],[1,3,0,0,0,1,0],[0,0,2,1,1,1,0],
                     [1,2,2,0,0,0,0],[0,0,4,0,0,1,0],[1,4,0,0,0,0,0],[1,0,0,2,1,1,0],[0,1,0,2,1,1,0],[1,1,3,0,0,0,0],
                     [0,0,0,3,1,1,0],[1,1,0,0,2,1,0],[0,2,0,0,2,1,0],[0,2,0,2,0,1,0],[2,0,0,0,2,1,0],[1,0,1,0,2,1,0],
                     [1,0,1,2,0,1,0],[1,1,1,2,0,0,0],[2,0,0,3,0,0,0],[0,0,2,0,2,1,0],[1,2,0,2,0,0,0],[1,0,0,3,0,1,0],
                     [1,0,0,1,2,1,0],[1,1,0,3,0,0,0],[1,1,2,1,0,0,0],[0,1,0,0,3,1,0],[0,0,1,0,3,1,0],[0,0,0,1,3,1,0],
                     [0,0,0,2,2,1,0],[1,0,0,0,3,1,0],[0,0,2,2,0,1,0],[0,0,0,0,4,1,0],[0,0,2,3,0,0,0],[1,0,0,4,0,0,0],
                     [0,0,0,5,0,0,0],[1,1,0,1,0,2,0],[1,1,0,1,2,0,0],[0,2,0,1,0,2,0],[0,2,0,1,2,0,0],[2,0,0,1,0,2,0],
                     [2,0,0,1,2,0,0],[1,0,1,1,0,2,0],[1,0,1,1,2,0,0],[1,1,0,0,1,2,0],[1,1,0,0,3,0,0],[1,1,0,2,1,0,0],
                     [1,1,2,0,1,0,0],[0,2,0,0,0,3,0],[1,0,0,2,2,0,0],[1,0,0,1,0,3,0],[1,3,0,0,1,0,0],[1,0,0,0,1,3,0],
                     [0,0,0,3,0,2,0],[0,0,2,1,2,0,0],[1,0,0,0,0,4,0],[0,0,0,3,2,0,0],[1,1,0,0,0,3,0],[3,0,0,0,0,2,0]]
            gamnoms =['0','-2','+2','^2','-3','-23','-34x','+34','+23x','-34','x3','°3','+34x','°34x','^3',
                      '-4','-24','^4','°4','-5','-25','-25+','+25-','-35','-35+','+45x','+25x','°35-','+35x',
                      '-45+','-45','x5','x45+','-25°','-35°','-45°','°45-','°5','°35+','*5','°35x','-45x',
                      '°45x','-6','+6','-26','-26+','+26-','+26','-36','-36+','-56','-56+','+56','x46+',
                      '-26°','-46+','-46°','x36+','-56°','°46-','°36+','*6','°46+','°6','x26-']
    # Récupération des notes cursives
            ydo=self.sca1.get()
            xcpos_=300
            ycpos_=220
            xc_=xcpos_+(ydo*10)
            yc_=ycpos_-(ydo*10)
            rc_=5
            self.can.create_oval(xc_-rc_,yc_-rc_,xc_+rc_,yc_+rc_,fill='black')
            yre=self.sca2.get()
            xcpos_=320
            ycpos_=220
            xd_=xcpos_+(yre*10)
            yd_=ycpos_-(yre*10)
            rd_=5
            self.can.create_oval(xd_-rd_,yd_-rd_,xd_+rd_,yd_+rd_,fill='green')
            ymi=self.sca3.get()
            xcpos_=340
            ycpos_=220
            xe_=xcpos_+(ymi*10)
            ye_=ycpos_-(ymi*10)
            re_=5
            self.can.create_oval(xe_-re_,ye_-re_,xe_+re_,ye_+re_,fill='blue')
            yfa=self.sca4.get()
            xcpos_=350
            ycpos_=220
            xf_=xcpos_+(yfa*10)
            yf_=ycpos_-(yfa*10)
            rf_=5
            self.can.create_oval(xf_-rf_,yf_-rf_,xf_+rf_,yf_+rf_,fill='grey')
            ysol=self.sca5.get()
            xcpos_=370
            ycpos_=220
            xg_=xcpos_+(ysol*10)
            yg_=ycpos_-(ysol*10)
            rg_=5
            self.can.create_oval(xg_-rg_,yg_-rg_,xg_+rg_,yg_+rg_,fill='red')
            yla=self.sca6.get()
            xcpos_=390
            ycpos_=220
            xa_=xcpos_+(yla*10)
            ya_=ycpos_-(yla*10)
            ra_=5
            self.can.create_oval(xa_-ra_,ya_-ra_,xa_+ra_,ya_+ra_,fill='orange')
            ysi=self.sca7.get()
            xcpos_=410
            ycpos_=220
            xb_=xcpos_+(ysi*10)
            yb_=ycpos_-(ysi*10)
            rb_=5
            self.can.create_oval(xb_-rb_,yb_-rb_,xb_+rb_,yb_+rb_,fill='yellow')
    # Mesure de l'intervalle tempéré
            c1=(yre+1)-ydo
            d2=(ymi+1)-yre
            e3=yfa-ymi
            f4=(ysol+1)-yfa
            g5=(yla+1)-ysol
            a6=(ysi+1)-yla
            b7=i=cum_diat=ok=x=0
            diata=[c1,d2,e3,f4,g5,a6,b7]
            while i < 6:
                cum_diat += diata[i]
                i+=1        
            diata[i]=5-cum_diat
    # Recherche diatonique par l'itération
            cc1=dd2=ee3=ff4=gg5=aa6=bb7=0
            diata2=[cc1,dd2,ee3,ff4,gg5,aa6,bb7]
            while x < 7:
                m=x
                y=0
                while y < 7:
                    diata2[y]=diata[m]
                    y+=1
                    m+=1
                    if m > 6:
                        m=0            
                myx=myx2=0
                for my in gammes:
                    if diata2 == my:
                        degre=x
                        myx2=myx
                        x=7
                    myx+=1
                x+=1
    # Ici : diata(original cursif).degre(tonique).my(gamme)
    # Définition diatonique
            # GMAJ= gammes[0]
            gmaj = [1,1,0,1,1,1,0]      # Forme majeure simplifiée
            # GNAT= Ordre cursif comme diata[]
            gnat = ['C','D','E','F','G','A','B']        # Forme alphabétique
            cnat = ['','','','','','','']
            # Niveaux d'altérations
            nordiese = ['','+','x','^','+^','x^','^^','+^^','x^^','^^^','+^^^','x^^^','^^^^']
            subemol = ['','****','°***','-***','***','°**','-**','**','°*','-*','*','°','-']
            # Configuration modale
            gdeg = ['I','II','III','IV','V','VI','VII']
            # Définition des notes cursives
            cursifs=[ydo,yre,ymi,yfa,ysol,yla,ysi]
            ynat=ymod=0
            for ycurs in cursifs:
                if ycurs > 0 :
                    ymod=nordiese[ycurs]
                if ycurs < 0 :
                    ymod=subemol[ycurs]
                if ycurs == 0 :
                    ymod=subemol[ycurs]
                cnat[ynat]=ymod
                ynat+=1
    # Une tournée produit une tonalité modale de 7 notes
            nat2=degre
            deg = nom = 0
            ynote = xgdeg = 30
            ytone = 50
            while deg < 7 :
                nat = deg               # Degré tonal en question
                cri = gimj = gmod = maj = 0
                xdeg = 60
                text0 = gdeg[deg]
                self.can.create_text(xgdeg,ynote+10,text=text0,
                                     font='bold',fill='black')
                while maj < 7 :         # Tonalité modale du degré
                    gmj = gmaj[maj]     # Forme majeure (1101110)
                    imaj = diata2[nat]  # Forme modale (DIATA[DEGRE])
                    ynt = cnat[nat2]    # Forme altérative des notes
                    gnt = gnat[nat2]    # Forme tonale (CDEFGAB)
                    ideg = gdeg[deg]
                    cri = cri + gimj    # Tonalité cumulée
                    gimj = imaj - gmj   # Calcul tonal PAS/PAS
                    cmod = gmod = cri
                    if gmod > 0 :       # Forme altérative des tonalités
                        imod = nordiese[cmod]
                    if gmod < 0 :
                        imod = subemol[cmod]
                    if gmod == 0 :
                        imod = subemol[cmod]
                    gmod = gmod + cri   # Transition tonale
                    # Construction du nom de la gamme
                    if nom == 0 :
                        ynom = ynt
                        gnom = gnt
                        tnom=ynom,gnom,gamnoms[myx2]
                        self.can.create_text(xdeg+250,ynote,text=tnom,
                                             font='bold',fill='black')
                    nat+=1
                    nat2+=1
                    if nat > 6 :
                        nat = 0
                    if nat2 > 6 :
                        nat2 = 0
                    maj = maj + 1
                    text1=[ynt,gnt]
                    text2=[imod,maj]
                    self.can.create_text(xdeg,ynote,text=text1)
                    self.can.create_text(xdeg,ytone,text=text2,fill='blue')
                    xdeg+=30
                    nom=1
                    #
                ynote+=60
                ytone+=60
                nat2+=1
                if nat2 > 6 :
                        nat2 = 0
                deg = deg + 1
                #
    Gammique().mainloop()

  7. #7
    Invité
    Invité(e)
    Par défaut
    L'automatisation est devenue possible à l'aide d'une invocation "invoke()", voir dans les fonctions
    self.
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    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
     
    #!/usr/bin/env python3 
    # -*- coding: utf-8 -*-
    # *
    # Application gammique évolutive
    # Version 1 : Calculer les gammes
    #
    from tkinter import *
    import winsound
     
    class Gammique(Tk):
        """ Ramification Gammique """
        def __init__(self):
            Tk.__init__(self)
            "Tableau de bord"
            self.title('Entité Gammique :')
    # Fenêtre écran_résultat
            self.can=Canvas(self,bg='white', height=500,width=750)
            self.can.pack(side=RIGHT)
            self.cad=Frame(self,width=200,height=600)
            self.cad.pack(side=LEFT)
            self.can.delete(ALL)
            # Tracé d'encadrement
            # Données de l'encadré : Axes(x,y)=365(x),220(y)
            self.can.create_line(10, 0, 10, 450, fill ='black')
            self.can.create_line(740, 10, 0, 10, fill ='blue')
            self.can.create_line(740, 450, 740, 10, fill ='black')
            self.can.create_line(10, 450, 740, 450, fill ='blue')
            # Bouton gamme_audio
            #winsound.Beep(frequency, duration)
            Button(self.cad,text ='Radio_inactive',width=15,bg='light yellow').pack()
            # Bouton choix chromatique
            Button(self.cad,text ='Chrome_inactif',width=15,bg='light yellow').pack()
            # Bouton tableaux instruments
            Button(self.cad,text ='Tabla_inactif',width=15,bg='light yellow').pack()
            # Bouton accords1357
            Button(self.cad,text ='A1357_inactif',width=15,bg='light yellow').pack()
    # Les notes cursives scalpha : Graduations gérées.
            self.sca1=Scale(self,length =250,orient = HORIZONTAL,label ='C',
                  troughcolor ='black',sliderlength =20,showvalue =1,
                  from_ =0,to =5,tickinterval =1,command=self.scanote1)
            self.sca1.pack()
            self.sca2=Scale(self,length =250,orient = HORIZONTAL,label ='D',
                  troughcolor ='green',sliderlength =20,showvalue =1,
                  from_ =-1,to =4,tickinterval =1,command=self.scanote2)
            self.sca2.pack()
            self.sca3=Scale(self,length =250,orient = HORIZONTAL,label ='E',
                  troughcolor ='blue',sliderlength =20,showvalue =1,
                  from_ =-2,to =3,tickinterval =1,command=self.scanote3)
            self.sca3.pack()
            self.sca4=Scale(self,length =250,orient = HORIZONTAL,label ='F',
                  troughcolor ='grey',sliderlength =20,showvalue =1,
                  from_ =-2,to =3,tickinterval =1,command=self.scanote4)
            self.sca4.pack()
            self.sca5=Scale(self,length =250,orient = HORIZONTAL,label ='G',
                  troughcolor ='red',sliderlength =20,showvalue =1,
                  from_ =-3,to =2,tickinterval =1,command=self.scanote5)
            self.sca5.pack()
            self.sca6=Scale(self,length =250,orient = HORIZONTAL,label ='A',
                  troughcolor ='orange',sliderlength =20,showvalue =1,
                  from_ =-4,to =1,tickinterval =1,command=self.scanote6)
            self.sca6.pack()
            self.sca7=Scale(self,length =250,orient = HORIZONTAL,label ='B',
                  troughcolor ='yellow',sliderlength =20,showvalue =1,
                  from_ =-5,to =0,tickinterval =1,command=self.scanote7)
            self.sca7.pack()
    # Concerne les notes scahuit : Graduations gérées.
            self.sca8=Scale(self,length =250,orient = HORIZONTAL,label ='CDEFGAB',
                  troughcolor ='ivory',sliderlength =20,showvalue =1,
                  from_ =-5,to =5,tickinterval =1,command=self.scanote8)
            self.sca8.pack()
            # Bouton gamme_naturelle
            Button(self,text ='Zéro',width=25,command=self.zero).pack()
            # Bouton gamme_calculée
            self.btgama=Button(self,width=0,command=self.gama)
            self.btgama.pack()
    # Définition des curseurs
        def scanote1(self,xc):
            do=int(xc)
            # Initialise sca8(from_)
            fromdo=do-(do*2)
            self.sca8.configure(from_ = fromdo)
            xsi=self.sca7.get()
            xre=self.sca2.get()
            if do<xsi:self.sca7.set(do)
            if do>xre+1 :self.sca2.set(do-1)
            self.btgama.invoke()
        def scanote2(self,xd):
            re=int(xd)
            xdo=self.sca1.get()
            xmi=self.sca3.get()
            if re<xdo-1:self.sca1.set(re+1)
            if re>xmi+1 :self.sca3.set(re-1)
            self.btgama.invoke()
        def scanote3(self,xe):
            mi=int(xe)
            xre=self.sca2.get()
            xfa=self.sca4.get()
            if mi<xre-1:self.sca2.set(mi+1)
            if mi>xfa:self.sca4.set(mi)
            self.btgama.invoke()
        def scanote4(self,xf):
            fa=int(xf)
            xmi=self.sca3.get()
            xsol=self.sca5.get()
            if fa<xmi:self.sca3.set(fa)
            if fa>xsol+1:self.sca5.set(fa-1)
            self.btgama.invoke()
        def scanote5(self,xg):
            sol=int(xg)
            xfa=self.sca4.get()
            xla=self.sca6.get()
            if sol<xfa-1:self.sca4.set(sol+1)
            if sol>xla+1:self.sca6.set(sol-1)
            self.btgama.invoke()
        def scanote6(self,xa):
            la=int(xa)
            xsol=self.sca5.get()
            xsi=self.sca7.get()
            if la<xsol-1:self.sca5.set(la+1)
            if la>xsi+1:self.sca7.set(la-1)
            self.btgama.invoke()
        def scanote7(self,xb):
            si=int(xb)
            # Initialise sca8(to)
            tosi=si-(si*2)
            self.sca8.configure(to = tosi)
            xla=self.sca6.get()
            xdo=self.sca1.get()
            if si<xla-1:self.sca6.set(si+1)
            if si>xdo:self.sca1.set(si)
            self.btgama.invoke()
        def scanote8(self,xh):
            sch=int(xh)
            xdo=self.sca1.get()
            xre=self.sca2.get()
            xmi=self.sca3.get()
            xfa=self.sca4.get()
            xsol=self.sca5.get()
            xla=self.sca6.get()
            xsi=self.sca7.get()
            self.sca1.set(xdo+sch)
            self.sca2.set(xre+sch)
            self.sca3.set(xmi+sch)
            self.sca4.set(xfa+sch)
            self.sca5.set(xsol+sch)
            self.sca6.set(xla+sch)
            self.sca7.set(xsi+sch)
            self.btgama.invoke()
        def zero(self):
            self.can.delete(ALL)
            # Tracé d'encadrement
            # Données de l'encadré : Axes(x,y)=365(x),220(y)
            self.can.create_line(10, 0, 10, 450, fill ='black')
            self.can.create_line(740, 10, 0, 10, fill ='blue')
            self.can.create_line(740, 450, 740, 10, fill ='black')
            self.can.create_line(10, 450, 740, 450, fill ='blue')
            self.can.create_line(360, 450, 360, 10, fill ='olive')
            self.can.create_line(10, 220, 740, 220, fill ='olive')
            self.sca1.set(0)
            self.can.create_oval(300-5,220-5,300+5,220+5,fill='black')
            self.sca2.set(0)
            self.can.create_oval(320-5,220-5,320+5,220+5,fill='green')
            self.sca3.set(0)
            self.can.create_oval(340-5,220-5,340+5,220+5,fill='blue')
            self.sca4.set(0)
            self.can.create_oval(350-5,220-5,350+5,220+5,fill='grey')
            self.sca5.set(0)
            self.can.create_oval(370-5,220-5,370+5,220+5,fill='red')
            self.sca6.set(0)
            self.can.create_oval(390-5,220-5,390+5,220+5,fill='orange')
            self.sca7.set(0)
            self.can.create_oval(410-5,220-5,410+5,220+5,fill='yellow')
            self.btgama.invoke()
        def gama(self):
            self.can.delete(ALL)
            # Tracé d'encadrement
            # Données de l'encadré : Axes(x,y)=365(x),220(y)
            self.can.create_line(10, 0, 10, 450, fill ='black')
            self.can.create_line(740, 10, 0, 10, fill ='blue')
            self.can.create_line(740, 450, 740, 10, fill ='black')
            self.can.create_line(10, 450, 740, 450, fill ='blue')
            self.can.create_line(360, 450, 360, 110, fill ='olive')
            self.can.create_line(220, 220, 740, 220, fill ='olive')
    # De la table gammique aux tables diatoniques surnommées
            gammes =[[1,1,0,1,1,1,0],[0,2,0,1,1,1,0],[2,0,0,1,1,1,0],[4,0,0,0,0,1,0],[1,0,1,1,1,1,0],[0,1,1,1,1,1,0],
                     [1,0,3,0,0,1,0],[1,2,1,0,0,1,0],[2,2,0,0,0,1,0],[0,0,1,2,1,1,0],[1,3,0,0,0,1,0],[0,0,2,1,1,1,0],
                     [1,2,2,0,0,0,0],[0,0,4,0,0,1,0],[1,4,0,0,0,0,0],[1,0,0,2,1,1,0],[0,1,0,2,1,1,0],[1,1,3,0,0,0,0],
                     [0,0,0,3,1,1,0],[1,1,0,0,2,1,0],[0,2,0,0,2,1,0],[0,2,0,2,0,1,0],[2,0,0,0,2,1,0],[1,0,1,0,2,1,0],
                     [1,0,1,2,0,1,0],[1,1,1,2,0,0,0],[2,0,0,3,0,0,0],[0,0,2,0,2,1,0],[1,2,0,2,0,0,0],[1,0,0,3,0,1,0],
                     [1,0,0,1,2,1,0],[1,1,0,3,0,0,0],[1,1,2,1,0,0,0],[0,1,0,0,3,1,0],[0,0,1,0,3,1,0],[0,0,0,1,3,1,0],
                     [0,0,0,2,2,1,0],[1,0,0,0,3,1,0],[0,0,2,2,0,1,0],[0,0,0,0,4,1,0],[0,0,2,3,0,0,0],[1,0,0,4,0,0,0],
                     [0,0,0,5,0,0,0],[1,1,0,1,0,2,0],[1,1,0,1,2,0,0],[0,2,0,1,0,2,0],[0,2,0,1,2,0,0],[2,0,0,1,0,2,0],
                     [2,0,0,1,2,0,0],[1,0,1,1,0,2,0],[1,0,1,1,2,0,0],[1,1,0,0,1,2,0],[1,1,0,0,3,0,0],[1,1,0,2,1,0,0],
                     [1,1,2,0,1,0,0],[0,2,0,0,0,3,0],[1,0,0,2,2,0,0],[1,0,0,1,0,3,0],[1,3,0,0,1,0,0],[1,0,0,0,1,3,0],
                     [0,0,0,3,0,2,0],[0,0,2,1,2,0,0],[1,0,0,0,0,4,0],[0,0,0,3,2,0,0],[1,1,0,0,0,3,0],[3,0,0,0,0,2,0]]
            gamnoms =['0','-2','+2','^2','-3','-23','-34x','+34','+23x','-34','x3','°3','+34x','°34x','^3',
                      '-4','-24','^4','°4','-5','-25','-25+','+25-','-35','-35+','+45x','+25x','°35-','+35x',
                      '-45+','-45','x5','x45+','-25°','-35°','-45°','°45-','°5','°35+','*5','°35x','-45x',
                      '°45x','-6','+6','-26','-26+','+26-','+26','-36','-36+','-56','-56+','+56','x46+',
                      '-26°','-46+','-46°','x36+','-56°','°46-','°36+','*6','°46+','°6','x26-']
    # Récupération des notes cursives
            ydo=self.sca1.get()
            xcpos_=300
            ycpos_=220
            xc_=xcpos_+(ydo*10)
            yc_=ycpos_-(ydo*10)
            rc_=5
            self.can.create_oval(xc_-rc_,yc_-rc_,xc_+rc_,yc_+rc_,fill='black')
            yre=self.sca2.get()
            xcpos_=320
            ycpos_=220
            xd_=xcpos_+(yre*10)
            yd_=ycpos_-(yre*10)
            rd_=5
            self.can.create_oval(xd_-rd_,yd_-rd_,xd_+rd_,yd_+rd_,fill='green')
            ymi=self.sca3.get()
            xcpos_=340
            ycpos_=220
            xe_=xcpos_+(ymi*10)
            ye_=ycpos_-(ymi*10)
            re_=5
            self.can.create_oval(xe_-re_,ye_-re_,xe_+re_,ye_+re_,fill='blue')
            yfa=self.sca4.get()
            xcpos_=350
            ycpos_=220
            xf_=xcpos_+(yfa*10)
            yf_=ycpos_-(yfa*10)
            rf_=5
            self.can.create_oval(xf_-rf_,yf_-rf_,xf_+rf_,yf_+rf_,fill='grey')
            ysol=self.sca5.get()
            xcpos_=370
            ycpos_=220
            xg_=xcpos_+(ysol*10)
            yg_=ycpos_-(ysol*10)
            rg_=5
            self.can.create_oval(xg_-rg_,yg_-rg_,xg_+rg_,yg_+rg_,fill='red')
            yla=self.sca6.get()
            xcpos_=390
            ycpos_=220
            xa_=xcpos_+(yla*10)
            ya_=ycpos_-(yla*10)
            ra_=5
            self.can.create_oval(xa_-ra_,ya_-ra_,xa_+ra_,ya_+ra_,fill='orange')
            ysi=self.sca7.get()
            xcpos_=410
            ycpos_=220
            xb_=xcpos_+(ysi*10)
            yb_=ycpos_-(ysi*10)
            rb_=5
            self.can.create_oval(xb_-rb_,yb_-rb_,xb_+rb_,yb_+rb_,fill='yellow')
    # Mesure de l'intervalle tempéré
            c1=(yre+1)-ydo
            d2=(ymi+1)-yre
            e3=yfa-ymi
            f4=(ysol+1)-yfa
            g5=(yla+1)-ysol
            a6=(ysi+1)-yla
            b7=i=cum_diat=ok=x=0
            diata=[c1,d2,e3,f4,g5,a6,b7]
            while i < 6:
                cum_diat += diata[i]
                i+=1        
            diata[i]=5-cum_diat
    # Recherche diatonique par l'itération
            cc1=dd2=ee3=ff4=gg5=aa6=bb7=0
            diata2=[cc1,dd2,ee3,ff4,gg5,aa6,bb7]
            while x < 7:
                m=x
                y=0
                while y < 7:
                    diata2[y]=diata[m]
                    y+=1
                    m+=1
                    if m > 6:
                        m=0            
                myx=myx2=0
                for my in gammes:
                    if diata2 == my:
                        degre=x
                        myx2=myx
                        x=7
                    myx+=1
                x+=1
    # Ici : diata(original cursif).degre(tonique).my(gamme)
    # Définition diatonique
            # GMAJ= gammes[0]
            gmaj = [1,1,0,1,1,1,0]      # Forme majeure simplifiée
            # GNAT= Ordre cursif comme diata[]
            gnat = ['C','D','E','F','G','A','B']        # Forme alphabétique
            cnat = ['','','','','','','']
            # Niveaux d'altérations
            nordiese = ['','+','x','^','+^','x^','^^','+^^','x^^','^^^','+^^^','x^^^','^^^^']
            subemol = ['','****','°***','-***','***','°**','-**','**','°*','-*','*','°','-']
            # Configuration modale
            gdeg = ['I','II','III','IV','V','VI','VII']
            # Définition des notes cursives
            cursifs=[ydo,yre,ymi,yfa,ysol,yla,ysi]
            ynat=ymod=0
            for ycurs in cursifs:
                if ycurs > 0 :
                    ymod=nordiese[ycurs]
                if ycurs < 0 :
                    ymod=subemol[ycurs]
                if ycurs == 0 :
                    ymod=subemol[ycurs]
                cnat[ynat]=ymod
                ynat+=1
    # Une tournée produit une tonalité modale de 7 notes
            nat2=degre
            deg = nom = 0
            ynote = xgdeg = 30
            ytone = 50
            while deg < 7 :
                nat = deg               # Degré tonal en question
                cri = gimj = gmod = maj = 0
                xdeg = 60
                text0 = gdeg[deg]
                self.can.create_text(xgdeg,ynote+10,text=text0,
                                     font='bold',fill='black')
                while maj < 7 :         # Tonalité modale du degré
                    gmj = gmaj[maj]     # Forme majeure (1101110)
                    imaj = diata2[nat]  # Forme modale (DIATA[DEGRE])
                    ynt = cnat[nat2]    # Forme altérative des notes
                    gnt = gnat[nat2]    # Forme tonale (CDEFGAB)
                    ideg = gdeg[deg]
                    cri = cri + gimj    # Tonalité cumulée
                    gimj = imaj - gmj   # Calcul tonal PAS/PAS
                    cmod = gmod = cri
                    if gmod > 0 :       # Forme altérative des tonalités
                        imod = nordiese[cmod]
                    if gmod < 0 :
                        imod = subemol[cmod]
                    if gmod == 0 :
                        imod = subemol[cmod]
                    gmod = gmod + cri   # Transition tonale
                    # Construction du nom de la gamme
                    if nom == 0 :
                        ynom = ynt
                        gnom = gnt
                        tnom=ynom,gnom,gamnoms[myx2]
                        self.can.create_text(xdeg+250,ynote,text=tnom,
                                             font='bold',fill='black')
                    nat+=1
                    nat2+=1
                    if nat > 6 :
                        nat = 0
                    if nat2 > 6 :
                        nat2 = 0
                    maj = maj + 1
                    text1=[ynt,gnt]
                    text2=[imod,maj]
                    self.can.create_text(xdeg,ynote,text=text1)
                    self.can.create_text(xdeg,ytone,text=text2,fill='blue')
                    xdeg+=30
                    nom=1
                    #
                ynote+=60
                ytone+=60
                nat2+=1
                if nat2 > 6 :
                        nat2 = 0
                deg = deg + 1
                #
    Gammique().mainloop()

  8. #8
    Invité
    Invité(e)
    Par défaut
    L'élémentarisme de la gamme est dans une autre dimension, un truc qui ne sert à rien et dont on ne comprend pas. On aura beau déclarer toute sa splendeur (complexité), que dans ce monde obscur des inutilités classées Open File, elle (gamme) est ainsi occultée.

    Pourquoi me pose-je cette question : Il dit ne pas comprendre, et il ne pose pas de question. Il veut peut être comprendre tout d'un seul coup ??? Ou bien... Je ne sais quoi d'autre

    La musicalité de la vie naturelle des gens normaux, vivent une harmonie humaine. Nous ne pourrions pas nous taire éternellement, ne plus faire de bruit. Pour créer un moment de silence, dans lequel nous rêverions à des sons imaginaires. Puis cet exemple de vide élémentaire, est comme un tableau noir par lequel surviennent les découvertes. Lorsqu'on cherche à comprendre, on commence par faire un exercice de développement personnel. De bien ajuster ses marques en rapport avec cette matière, pour ainsi se lancer avec des bonnes bases. On est pas vraiment nés pour programmer, voire écrire, mais quelque soit le chemin emprunté. Nous sommes capables de vivre un rêve éveillé, il suffit pour ceci d'être en accord commun. Ce qui implique un monde complexe et même incompréhensible parfois.

    Rien ne changera dorénavant, la machine humaine est lancée. Son système social a des difficultés pour freiner tous les élans, des compétences toujours nouvelles c'est dire combien l'être humain est imaginatif. Toutes ces perturbations sont effectives, aussi par un effet secondaire, elles ne laissent guère de choix à certaines activités. Il est dommageable à notre tranquillité spirituelle, de voir que le produit d'un miséreux puisse enrichir outrageusement un futur possesseur.
    C'est faire du copié-collé, de l'Open Source aujourd'hui copié. Collé en Open €☺ en ayant des droits d'auteur, comme par une simple magie commerciale...

    Lorsqu'on me dit : Je ne comprend rien à ce que vous dites...
    Je me dis : Comme c'est dommage

  9. #9
    Invité
    Invité(e)
    Par défaut Je continue
    Le site de développement http://www.developpez.com entraide les visites intéressées :

    Pour le développeur cette aide est nécessaire à son développement, et parmi les éléments les plus marquants, il y a nos chers assistants correcteurs de code. Qui avec précision, nous expliquent la réalité "pythonique" du code erroné en question. Tout ceci bien sûr faisant évoluer le présent. Ce qu'on peut remarquer en la teneur des discussions, c'est la forte technicité relative à la syntaxe du code python. La partie algorithmique du codage est rarement en cause, ou plus contrario pour sa forme d'exprimée qui n'est pas adaptée à l'échange des informations entre les fonctions.

    Tout çà pour dire, que le débutant est une source d'erreur riche en informations. Et, que le principal obstacle à son éducation vient de python, et non pas de son désir de concrétiser un code source complexe. D'où l'avancée technologique des accessoires ajoutés, relatifs aux aides de conceptions des programmes dans leurs constructions. Si bien qu'un jour, le débutant pourra écrire son algorithme sans se soucier de la syntaxe de son interprétation.

    De fil en aiguille on en est a combler le manque de correctifs automatiques... En attendant, pour actualiser cette discussion...

    Open Source d'un des déploiements de musique avec python.
    Je rappelle que ce programme est à tout le monde, et que ce que je gagne à le déposer, n'est pas financier mais culturel
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    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
    1001
    1002
    1003
    1004
    1005
    1006
    1007
    1008
    1009
    1010
    1011
    1012
    1013
    1014
    1015
    1016
    1017
    1018
    1019
    1020
    1021
    1022
    1023
     
    #!/usr/bin/env python 
    # -*- coding: utf-8 -*-
    # *
    # Application gammique évolutive
    # Opération = Envol système
    # ProgamV3epyco
    #
    from tkinter import *
    from tkinter.font import Font
    import winsound
    import wave, math, binascii
     
    class Gammique(Tk):
            """ Ramification Gammique """
            def __init__(self):
                    Tk.__init__(self)
                    "Tableau de bord"
                    # Titre principal
                    self.title('Entité Gammique :')
     
                    # Fenêtre écran_résultat
                    self.can=Canvas(self,bg='white', height=550,width=800)
                    self.can.pack(side=RIGHT)
                    # Fenêtre des utilités
                    self.cad=Frame(self, width=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
                    ##self.fichnom = les noms des fichiers audio_notes (communs)
                    self.presaudio = 0      # Utile au bouton accord/sans le résultat "winsound"
                    self.gamula = ['C','D','E','F','G','A','B']
                    self.framno = ['','','','','','','']
                    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()
                    self.btaud2.pack_forget()               # Pantomime
     
                    # Bouton choix chromatique
                    self.btchr=Button(self.cad,text ='Chrome_inactif',width=15,bg='light blue')
                    self.btchr.pack()
     
                    # Bouton tableaux instruments
                    self.bttab=Button(self.cad,text ='Tabla_inactif',width=15,bg='light blue')
                    self.bttab.pack()
     
                    # Bouton accords
                    ##self.fichacc = les noms des fichiers audio_accords (communs)
                    self.presens = [0]
                    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 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=[
                            Radiobutton(
                                    self.cad,
                                    variable=variable,
                                    text=text,
                                    value=value,
                                    command=command,
                            )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),
                            )
                    ]
                    for i in self.rad: i.pack()
                    self.rad[1].select()
     
                    # Les notes cursives scalpha : Graduations gérées.
                    self.sca=[
                            Scale(
                                    self,
                                    length=300,
                                    orient=HORIZONTAL,
                                    label=label,
                                    troughcolor=color,
                                    sliderlength=20,
                                    showvalue=1,
                                    from_=f,
                                    to=t,
                                    tickinterval=1,
                                    command=command,
                            ) for (label, color, f, t, command) in (
                                    ("C", "black", 0, 5, self.scanote1),
                                    ("D", "green", -1, 4, self.scanote2),
                                    ("E", "blue", -2, 3, self.scanote3),
                                    ("F", "grey", -2, 3, self.scanote4),
                                    ("G", "red", -3, 2, self.scanote5),
                                    ("A", "orange", -4, 1, self.scanote6),
                                    ("B", "yellow", -5, 0, self.scanote7),
                                    ("CDEFGAB", "ivory", -12, 12, self.scanote8),
                            )
                    ]
                    for x in self.sca: x.pack()
     
                    # Bouton gamme_naturelle
                    self.btzer=Button(self,text ='Zéro',width=25,command=self.zero)
                    self.btzer.pack()
                    # Bouton gamme_calculée
                    self.declare = {}        # Base (degrés - altérations - notes)
                    self.decore = []
                    self.btgama=Button(self,text='gamme',width=25,command=self.gama)
                    self.btgama.pack()
                    self.btgama.pack_forget()               # Pantomime
            # __init__()
     
            def wavacc(self,w):
                    nbOctet = nbCanal = 1
                    fech = 64000
                    niveau = float(1)
                    duree = float(1/2)
                    nbEch = int(duree*fech) 
                    waplo = self.fichacc[w]
                    monac = wave.open(waplo,'wb')
                    param = (nbCanal,nbOctet,fech,nbEch,'NONE','not compressed')
                    monac.setparams(param)
                    amp = 127.5*niveau
                    vacc = [0,0,0,0]
                    ww = w
                    for vv in range(4):
                            if ww == 7:
                                    ww = 0
                                    vacc[vv] = self.framno[ww]*2
                            elif ww == 8:
                                    ww = 1
                                    vacc[vv] = self.framno[ww]*2
                            else: vacc[vv] = self.framno[ww]
                            ww +=2
                    freq1 = vacc[0]*2
                    freq2 = vacc[1]*2
                    freq3 = vacc[2]*2
                    freq4 = vacc[3]*2
                    for i in range(0,nbEch):
                            val1 = wave.struct.pack('B',int(128.0 + amp*math.sin(2.0*math.pi*freq1*i/fech)))
                            val2 = wave.struct.pack('B',int(128.0 + amp*math.sin(2.0*math.pi*freq2*i/fech)))
                            val3 = wave.struct.pack('B',int(128.0 + amp*math.sin(2.0*math.pi*freq3*i/fech)))
                            val4 = wave.struct.pack('B',int(128.0 + amp*math.sin(2.0*math.pi*freq4*i/fech)))
                            monac.writeframes(val1+val2+val3+val4)
                    monac.close()
                    accwav = self.fichacc[w]
                    winsound.PlaySound(accwav,winsound.SND_FILENAME)
     
            def actuac(self,a):
                    if a == 5:                      # def accord/Bouton fermer
                            self.acc.destroy()
                            self.presens[0]=0
                    elif a == 3:                    # def accord/Bouton actualiser
                            self.acc.destroy()
                            self.presens[0]=0
                            self.btaud2.invoke()
                            self.btacc.invoke()
                    elif a == 1:                    # def audio/Bouton audio
                            self.presaudio = 0
                            self.btaud2.invoke()
     
            # L'harmonie des accords
            def accord(self):
                    if self.presens[0] == 1:
                            self.acc.destroy()
                            self.presens[0]=0
                            self.btaud2.invoke()
                            self.btacc.invoke()
                    else:
                            self.acc = Toplevel(self)
                            self.acc.title('Entité Gammique : Harmonie')
                            self.presens[0]=1
                            if self.presaudio == 0:
                                    self.presaudio = 1
                                    self.btaud2.invoke()
                            # Définition du style d'écriture
                            fotyp = Font(family='Liberation Serif', size=12)
                            fofin = Font(family='Liberation Serif', size=8)
                            fonot = Font(family='Liberation Serif', size=14)
                            # Fenêtrage des widgets
                            fra = Frame(self.acc,width=100,height=50)
                            fra.pack(side=BOTTOM)
                            fraleft = Frame(self.acc,width=30,height=30)
                            fraleft.pack(side=LEFT)
                            fraright = Frame(self.acc,width=30,height=30)
                            fraright.pack(side=RIGHT)
                            # Les accords 1357 de la gamme en cours (partie gauche(left))
                            self.bt1357 = Button(fra,text ='Actualiser',width=20,command=lambda: self.actuac(3))
                            self.bt1357.pack(side=LEFT)
                            lableft = Label(fraleft, text ='Accords 1357', fg = 'red').pack()
                            btaccleft = ['','','','','','','']
                            for i in range(7):
                                    btaccleft[i] = Button(fraleft,text='',bg='light blue',width=10,
                                                          command = lambda w=i: self.wavacc (w))
                                    btaccleft[i].pack()
                            # Les autres accords de la gamme en cours (partie droite(right))
                            btferm = Button(fra,text ='Fermer',width=20,bg ='light grey', command = lambda: self.actuac(5))
                            btferm.pack(side=RIGHT)
                            labrigh = Label(fraright, text ='Autre accord', fg = 'blue').pack()
                            btautq = Button(fraright,text ='inactif',bg='light blue',width=10).pack()
                            # L'espace blanc central pour écrire l'accord
                            caaacc = Canvas(self.acc,bg='white', height=300,width=300)
                            caaacc.pack()
                            caaacc.delete(ALL)
                            # Types d'accords 1357 : chr(248) = ( ø )
                            # Majeur_7ème(maj7). Mineur_7ème(7). Demi-diminué_7ème(ø7). Diminué_7ème(°7)
                            # Tableaux des accords et des altérations
                            accdiese = ['','+','x','^','+^','x^','^^']
                            accbemol = ['','**','°*','-*','*','°','-']
                            accmaj7 = [0,0,0,0] ; acc7 = [0,0,0,-1]
                            accdd7 = [0,-1,-1,-1] ; accd7 = [0,-1,-1,-2]
                            tbtxgd = ['1','3','5','7']
                            tbacc7 = []     # Tableau de l'accord forme(str)
                            tbsign = []     # Tableau de l'accord forme(int)
                            tbfine = []     # Tableau des accords forme fine
                            tbgene = []     # Tableau des accords forme écriture
                            tblect = []     # Tableau des accords forme lecture
                            # self.decore[] = altération et note tonique de l'accord
                            xcc, ycc = 120, 80 ; xtt = 20
                            ypos = 26 ; xdd = ydd = 0
                            for decdegre in range(7):
                                    accnote = self.decore[decdegre][1:]
                                    accsign = self.decore[decdegre][:1]
                                    # self.declare[] = altérations "3.5.7" en rang
                                    decnote = 1
                                    t_fin = 0 ; txga = txdr = ''
                                    ydd = ycc+(ypos*decdegre)
                                    xdd = xcc + 30
                                    xgg = xcc - 30
                                    while decnote < 8:      # Définition de l'accord modal(str)
                                            decalt = self.declare[(decdegre,decnote)]
                                            tbacc7.append(decalt)
                                            decnote += 2
                                    # Transcodage de l'accord de type original(str)
                                    for a_ in range(4):
                                            z_ = -1
                                            a_acc = tbacc7[a_]
                                            for b_ in range(7):     # Lecture et transformation
                                                    if a_acc == '':
                                                            b_alt = 0
                                                            tbsign.append(b_alt)
                                                            break
                                                    if a_acc == accdiese[b_]:
                                                            b_alt = b_
                                                            tbsign.append(b_alt)
                                                            break
                                                    if a_acc == accbemol[z_]:
                                                            b_alt = z_
                                                            tbsign.append(b_alt)
                                                            break
                                                    z_ += -1
                                    # Définition des accords de 7ème
                                    if tbsign[3] == 0:
                                            # L'accord est majeur 7(maj7)
                                            typacc = 'maj7'
                                            finacc = tbsign
                                            for t_ in range(4):
                                                    txsg = '' ; zone = 0
                                                    if accmaj7[t_] == tbsign[t_]:
                                                            t_fin = 0
                                                    else:
                                                            t_fin = tbsign[t_]-accmaj7[t_]
                                                    if t_ == 1 and t_fin != 0:
                                                            if t_fin < -1:          # Zone de droite
                                                                    txsg = accbemol[t_fin]+tbtxgd[t_]
                                                                    zone = 1
                                                            elif t_fin > -1 :       # Zone de droite
                                                                    txsg = accdiese[t_fin]+tbtxgd[t_]
                                                                    zone = 1
                                                            else:                   # Zone de gauche
                                                                    txsg = accbemol[t_fin]
                                                                    zone = -1
                                                    if t_ == 2 and t_fin != 0:
                                                            if t_fin < 0:           # Zone de droite
                                                                    txsg = accbemol[t_fin]+tbtxgd[t_]
                                                                    zone = 1
                                                            elif t_fin > 2:         # Zone de droite
                                                                    txsg = accdiese[t_fin]+tbtxgd[t_]
                                                                    zone = 1
                                                            else:                   # Zone de gauche
                                                                    txsg = accdiese[t_fin]
                                                                    zone = -1
                                                    if t_ == 3 and t_fin != 0:      # Zone de droite
                                                            txsg = accbemol[t_fin]+tbtxgd[t_]
                                                            zone = 1
                                                    if zone == 1:                   # Zone de droite
                                                            txdr += txsg
                                                            caaacc.create_text(xdd,ydd,text=txsg,font=fofin,fill='blue')
                                                            xdd += 20
                                                    if zone == -1:                  # Zone de gauche
                                                            txga += txsg
                                                            caaacc.create_text(xgg,ydd,text=txsg,font=fofin,fill='blue')
                                                            xgg -= 20
                                                    tbfine.append(t_fin)
                                            txbadr = txga + 'maj7' + txdr
                                            btaccleft[decdegre].configure(text = txbadr)
                                            caaacc.create_text(xcc,ydd,text='maj7',font=fotyp,fill='black')
                                            caaacc.create_text(xtt,ydd,text=accsign,font=fofin,fill='blue')
                                            caaacc.create_text(xtt+20,ydd,text=accnote,font=fonot,fill='black')                                        
                                    if (tbsign[3] == -1):
                                            if (tbsign[1] or tbsign[2] >= 0) or ((tbsign[1] or tbsign[2]) < 0):
                                                    if tbsign[1] and tbsign[2] < 0: pass
                                                    else :
                                                            # L'accord est demi-diminué 7(7)
                                                            typacc = '7'
                                                            finacc = tbsign
                                                            for t_ in range(4):
                                                                    txsg = '' ; zone = 0
                                                                    if acc7[t_] == tbsign[t_]:
                                                                            t_fin = 0
                                                                    else:
                                                                            t_fin = tbsign[t_]-acc7[t_]
                                                                    if t_ == 1 and t_fin != 0:
                                                                            if t_fin < -1:          # Zone de droite
                                                                                    txsg = accbemol[t_fin]+tbtxgd[t_]
                                                                                    zone = 1
                                                                            elif t_fin > -1 :       # Zone de droite
                                                                                    txsg = accdiese[t_fin]+tbtxgd[t_]
                                                                                    zone = 1
                                                                            else:                   # Zone de gauche
                                                                                    txsg = accbemol[t_fin]
                                                                                    zone = -1
                                                                    if t_ == 2 and t_fin != 0:
                                                                            if t_fin < 0:           # Zone de droite
                                                                                    txsg = accbemol[t_fin]+tbtxgd[t_]
                                                                                    zone = 1
                                                                            elif t_fin > 2:         # Zone de droite
                                                                                    txsg = accdiese[t_fin]+tbtxgd[t_]
                                                                                    zone = 1
                                                                            else:                   # Zone de gauche
                                                                                    txsg = accdiese[t_fin]
                                                                                    zone = -1
                                                                    if t_ == 3 and t_fin != 0:      # Zone de droite
                                                                            txsg = accbemol[t_fin]+tbtxgd[t_]
                                                                            zone = 1
                                                                    if zone == 1:                   # Zone de droite
                                                                            txdr += txsg
                                                                            caaacc.create_text(xdd,ydd,text=txsg,font=fofin,fill='blue')
                                                                            xdd += 20
                                                                    if zone == -1:                  # Zone de gauche
                                                                            txga += txsg
                                                                            caaacc.create_text(xgg,ydd,text=txsg,font=fofin,fill='blue')
                                                                            xgg -= 20
                                                                    tbfine.append(t_fin)
                                                            txbadr = txga + '7' + txdr
                                                            btaccleft[decdegre].configure(text = txbadr)
                                                            caaacc.create_text(xcc,ydd,text='7',font=fotyp,fill='black')
                                                            caaacc.create_text(xtt,ydd,text=accsign,font=fofin,fill='blue')
                                                            caaacc.create_text(xtt+20,ydd,text=accnote,font=fonot,fill='black')
                                    if (tbsign[3] == -1) and (tbsign[1] and tbsign[2] < 0):
                                            # L'accord est demi-diminué 7(ø7)
                                            typacc = 'ø7'
                                            finacc = tbsign
                                            for t_ in range(4):
                                                    txsg = '' ; zone = 0
                                                    if accdd7[t_] == tbsign[t_]:
                                                            t_fin = 0
                                                    else:
                                                            t_fin = tbsign[t_]-accdd7[t_]
                                                    if t_ == 1 and t_fin != 0:
                                                            if t_fin < -1:          # Zone de droite
                                                                    txsg = accbemol[t_fin]+tbtxgd[t_]
                                                                    zone = 1
                                                            elif t_fin > -1 :       # Zone de droite
                                                                    txsg = accdiese[t_fin]+tbtxgd[t_]
                                                                    zone = 1
                                                            else:                   # Zone de gauche
                                                                    txsg = accbemol[t_fin]
                                                                    zone = -1
                                                    if t_ == 2 and t_fin != 0:
                                                            if t_fin < 0:           # Zone de droite
                                                                    txsg = accbemol[t_fin]+tbtxgd[t_]
                                                                    zone = 1
                                                            elif t_fin > 2:         # Zone de droite
                                                                    txsg = accdiese[t_fin]+tbtxgd[t_]
                                                                    zone = 1
                                                            else:                   # Zone de gauche
                                                                    txsg = accdiese[t_fin]
                                                                    zone = -1
                                                    if t_ == 3 and t_fin != 0:      # Zone de droite
                                                            txsg = accbemol[t_fin]+tbtxgd[t_]
                                                            zone = 1
                                                    if zone == 1:                   # Zone de droite
                                                            txdr += txsg
                                                            caaacc.create_text(xdd,ydd,text=txsg,font=fofin,fill='blue')
                                                            xdd += 20
                                                    if zone == -1:                  # Zone de gauche
                                                            txga += txsg
                                                            caaacc.create_text(xgg,ydd,text=txsg,font=fofin,fill='blue')
                                                            xgg -= 20
                                                    tbfine.append(t_fin)
                                                    txbadr = txga + 'ø7' + txdr
                                                    btaccleft[decdegre].configure(text = txbadr)
                                                    caaacc.create_text(xcc,ydd,text='ø7',font=fotyp,fill='black')
                                                    caaacc.create_text(xtt,ydd,text=accsign,font=fofin,fill='blue')
                                                    caaacc.create_text(xtt+20,ydd,text=accnote,font=fonot,fill='black')
                                    if tbsign[3] < -1:
                                            # L'accord est diminué 7(°7)
                                            typacc = '°7'
                                            finacc = tbsign
                                            for t_ in range(4):
                                                    txsg = '' ; zone = 0
                                                    if accd7[t_] == tbsign[t_]:
                                                            t_fin = 0
                                                    else:
                                                            t_fin = tbsign[t_]-accd7[t_]
                                                    if t_ == 1 and t_fin != 0:
                                                            if t_fin < -1:          # Zone de droite
                                                                    txsg = accbemol[t_fin]+tbtxgd[t_]
                                                                    zone = 1
                                                            elif t_fin > -1 :       # Zone de droite
                                                                    txsg = accdiese[t_fin]+tbtxgd[t_]
                                                                    zone = 1
                                                            else:                   # Zone de gauche
                                                                    txsg = accbemol[t_fin]
                                                                    zone = -1
                                                    if t_ == 2 and t_fin != 0:
                                                            if t_fin < 0:           # Zone de droite
                                                                    txsg = accbemol[t_fin]+tbtxgd[t_]
                                                                    zone = 1
                                                            elif t_fin > 2:         # Zone de droite
                                                                    txsg = accdiese[t_fin]+tbtxgd[t_]
                                                                    zone = 1
                                                            else:                   # Zone de gauche
                                                                    txsg = accdiese[t_fin]
                                                                    zone = -1
                                                    if t_ == 3 and t_fin != 0:      # Zone de droite
                                                            txsg = accbemol[t_fin]+tbtxgd[t_]
                                                            zone = 1
                                                            xdd += 20
                                                    if zone == -1:                  # Zone de gauche
                                                            txga += txsg
                                                            caaacc.create_text(xgg,ydd,text=txsg,font=fofin,fill='blue')
                                                            xgg -= 20
                                                    tbfine.append(t_fin)
                                            txbadr = txga + '°7' + txdr
                                            btaccleft[decdegre].configure(text = txbadr)
                                            caaacc.create_text(xcc,ydd,text='°7',font=fotyp,fill='black')
                                            caaacc.create_text(xtt,ydd,text=accsign,font=fofin,fill='blue')
                                            caaacc.create_text(xtt+20,ydd,text=accnote,font=fonot,fill='black')
                                    tblect.append(tbsign[:4])
                                    tbgene.append(tbfine[:4])
                                    del(tbsign[:])     # Remise à zéro de l'accord(int)
                                    del(tbacc7[:])     # Remise à zéro de l'accord(str)
                                    del(tbfine[:])     # Remise à zéro de l'accord écriture
                            del(tblect[:])     # Remise à zéro forme lecture
                            del(tbgene[:])     # Remise à zéro forme écriture
     
            # Premiers pixels acoustiques
            def radio(self):
                    ay = '0'
                    ayay = self.tbdegre[0]
                    for n in range(7):
                            freqhtz=self.tablenotes[ayay]
                            if ay == '0': pass
                            else: freqhtz += 120
                            ayay += 1
                            if ayay > 6:
                                    ayay = 0
                                    ay = '1'
                            duration=240
                            winsound.Beep(freqhtz, duration)
     
            # Premières notes acoustiques
            def audio(self):
                    LA440 = 440 ; la2 = LA440/2 ; ula = 220/12
                    fabula = ['A','_','B','C','_','D','_','E','F','_','G','_','A']
                    # FC # Fréquences cursives (pixels)
                    notula = [] ; modula = []
                    for az in range(7):     # Construction tableau FC
                            notula.append(self.tablenotes[az])
                            mula = notula[az]/10-25         # Transition vers l'indice
                            modula.append(mula)             # Indice du tableau "sequla[]"
                    # TM # Tableau majeur
                    tabula = []
                    for ai in range(13):    # Construction tableau TM
                            paula=ai*ula+la2        # Calcul fréquence
                            tabula.append(paula)    # Tableau en écriture TM
                    # TF # Table des fréquences (1/12)
                    sequla = [] ; nomula = []
                    for ay in range(40):    # Construction tableau TF
                            if ay < 12:             # Niveau -1: Octave basse
                                    yula = tabula[ay]/2     # yula: TM/2
                                    nula = fabula[ay]       # nula: Notes naturelles
                            elif 11 < ay < 24:      # Niveau 0: Octave naturelle
                                    yula = tabula[ay-12]    # yula: Déviation de l'indice(ay)
                                    nula = fabula[ay-12]
                            elif 23 < ay < 37:      # Niveau 1: Octave haute
                                    yula = tabula[ay-24]*2  # yula: Déviation de l'indice(ay)+TM*2
                                    nula = fabula[ay-24]
                            elif 36 < ay < 41:      # Niveau 2: Octave relative
                                    yula = tabula[ay-36]*4  # yula: Déviation de l'indice(ay)+TM*4
                                    nula = fabula[ay-36]
                            sequla.append(yula)     # Tableau en écriture TF
                            nomula.append(nula)     # Tableau en écriture TF
                    # TR # Tableau des résultats (fréquences cursives)
                    freula = []
                    for ax in range(7):     # Construction tableau TR
                            xula = int(modula[ax])          # xula: Lecture indice-entier FC
                            qula = sequla[xula]             # qula: Lecture de fréquence TF
                            freula.append(qula)             # Tableau en écriture TR
                    aw2 = self.tbdegre[0]
                    diato = [] ; opoto = []
                    ax = '0'
                    for aw in range(7):     # Construction tableau TR-tonique
                            freqhtz = freula[aw2]
                            if ax == '0': diato.append(freqhtz)
                            else: diato.append(freqhtz*2)
                            opoto.append(self.gamula[aw2])
                            aw2 += 1
                            if aw2 > 6:
                                    aw2 = 0
                                    ax = '1'
                    # Partie échantillonnage
                    nbOctet = nbCanal = 1
                    fech = 64000
                    niveau = float(1/2)
                    duree = float(1/6)
                    nbEch = int(duree*fech) 
                    for fy in range(7):
                            toplo = self.fichnom[fy]
                            manote = wave.open(toplo,'wb')
                            param = (nbCanal,nbOctet,fech,nbEch,'NONE','not compressed')
                            manote.setparams(param)
                            freq = diato[fy]
                            self.framno[fy] = freq
                            amp = 127.5*niveau
                            for i in range(0,nbEch):
                                    val = wave.struct.pack('B',int(128.0 + amp*math.sin(2.0*math.pi*freq*i/fech)))
                                    manote.writeframes(val)
                            manote.close()
                    if self.presaudio == 0:
                            self.presaudio = 1
                            for fu in self.fichnom:
                                    winsound.PlaySound(fu,winsound.SND_FILENAME)
                    del(modula[:]) ; del(tabula[:]) ; del(sequla[:])
                    del(nomula[:]) ; del(freula[:]) ; del(diato[:])
            # audio()
     
            # Les octaves du groupe RADIO
            def yoiioiioy(self):
                    xradfan=self.entfan.get()
                    xrad=self.variable.get()
                    mqdo=self.sca[0].get()
                    mqsi=self.sca[6].get()
                    yo=yoc=yod=yoe=yof=yog=yoa=yob=0
                    fyoc=fyod=fyoe=fyof=fyog=fyoa=fyob=0
                    tyoc=tyod=tyoe=tyof=tyog=tyoa=tyob=0
                    topgam=[yoc,yod,yoe,yof,yog,yoa,yob]
                    topform=[fyoc,fyod,fyoe,fyof,fyog,fyoa,fyob]
                    topto=[tyoc,tyod,tyoe,tyof,tyog,tyoa,tyob]
                    while yo < 7:
                            yioiy=yotop=topf=topt=0
                            yotop=topgam[yo]=self.sca[yo].get()                        
                            topf=topform[yo]=self.sca[yo].cget("from")
                            topt=topto[yo]=self.sca[yo].cget("to")
                            if xradfan == "IOI":
                                    if xrad == "YOI":
                                            if (mqdo>-1)and(mqsi<1): yioiy=yotop
                                            else:
                                                    yioiy=yotop+12
                                                    topf=topf+12
                                                    topt=topt+12
                                    elif xrad == "IOY":
                                            if (mqdo>-1)and(mqsi<1): yioiy= yotop
                                            else :
                                                    yioiy=yotop-12
                                                    topf=topf-12
                                                    topt=topt-12
                                    else : yioiy = yotop
                            elif xradfan == "YOI":
                                    if xrad == "IOI":
                                            if (mqdo>-1)and(mqsi<1): yioiy= yotop
                                            else :
                                                    yioiy=yotop-12
                                                    topf=topf-12
                                                    topt=topt-12
                                    elif xrad == "IOY":
                                            if (mqdo>-1)and(mqsi<1): yioiy= yotop
                                            else :
                                                    yioiy=yotop-24
                                                    topf=topf-24
                                                    topt=topt-24
                                    else : yioiy=yotop
                            else :
                                    if xrad == "YOI":
                                            if (mqdo>-1)and(mqsi<1): yioiy= yotop
                                            else :
                                                    yioiy=yotop+24
                                                    topf=topf+24
                                                    topt=topt+24
                                    elif xrad == "IOI":
                                            if (mqdo>-1)and(mqsi<1): yioiy= yotop
                                            else :
                                                    yioiy=yotop+12
                                                    topf=topf+12
                                                    topt=topt+12
                                    else : yioiy=yotop
                            if yo == 0: mqdo1 = yioiy
                            if yo == 6: mqsi1 = yioiy
                            self.sca[yo].configure(from_ = topf, to = topt)
                            self.sca[yo].set(yioiy)
                            yo+=1
                    # while yo
                    if xrad == "YOI": self.sca[7].configure(from_ = 0-mqdo1, to = 24-mqsi1)
                    elif xrad == "IOI": self.sca[7].configure(from_ = -12-mqdo1, to = 12-mqsi1)
                    elif xrad == "IOY": self.sca[7].configure(from_ = -24-mqdo1, to = 0-mqsi1)
                    xradfan=xrad
                    self.entfan.delete(0,END)
                    self.entfan.insert(END,xradfan)
                    self.btgama.invoke()
                    # print ('*')
            # yoiioiioy()
     
            # Moment self.gama
            def momentgama(self,event):
                    self.btgama.invoke()
     
            # Définition des curseurs
            def scanote1(self,xc):
                    do=int(xc)
                    xsi=self.sca[6].get()
                    xre=self.sca[1].get()
                    if do<xsi:self.sca[6].set(do)
                    if do>xre+1 :self.sca[1].set(do-1)
                    # Initialise sca[7](from_)
                    xxrad=self.variable.get()
                    if xxrad == "YOI": self.sca[7].configure(from_ = 0-do, to = 24-xsi)
                    elif xxrad == "IOI": self.sca[7].configure(from_ = -12-do, to = 12-xsi)
                    elif xxrad == "IOY": self.sca[7].configure(from_ = -24-do, to = 0-xsi)
                    self.bind('<ButtonRelease-1>',self.momentgama)
            # scanote1()
     
            def scanote2(self,xd):
                    re=int(xd)
                    xdo=self.sca[0].get()
                    xmi=self.sca[2].get()
                    if re<xdo-1:self.sca[0].set(re+1)
                    if re>xmi+1 :self.sca[2].set(re-1)
            # scanote2()
     
            def scanote3(self,xe):
                    mi=int(xe)
                    xre=self.sca[1].get()
                    xfa=self.sca[3].get()
                    if mi<xre-1:self.sca[1].set(mi+1)
                    if mi>xfa:self.sca[3].set(mi)
            # scanote3()
     
            def scanote4(self,xf):
                    fa=int(xf)
                    xmi=self.sca[2].get()
                    xsol=self.sca[4].get()
                    if fa<xmi:self.sca[2].set(fa)
                    if fa>xsol+1:self.sca[4].set(fa-1)
            # scanote4()
     
            def scanote5(self,xg):
                    sol=int(xg)
                    xfa=self.sca[3].get()
                    xla=self.sca[5].get()
                    if sol<xfa-1:self.sca[3].set(sol+1)
                    if sol>xla+1:self.sca[5].set(sol-1)
            # scanote5()
     
            def scanote6(self,xa):
                    la=int(xa)
                    xsol=self.sca[4].get()
                    xsi=self.sca[6].get()
                    if la<xsol-1:self.sca[4].set(la+1)
                    if la>xsi+1:self.sca[6].set(la-1)
            # scanote6()
     
            def scanote7(self,xb):
                    si=int(xb)
                    xla=self.sca[5].get()
                    xdo=self.sca[0].get()
                    if si<xla-1:self.sca[5].set(si+1)
                    if si>xdo:self.sca[0].set(si)
                    # Initialise sca[7](from_)
                    xxxrad=self.variable.get()
                    if xxxrad == "YOI": self.sca[7].configure(from_ = 0-xdo, to = 24-si)
                    elif xxxrad == "IOI": self.sca[7].configure(from_ = -12-xdo, to = 12-si)
                    elif xxxrad == "IOY": self.sca[7].configure(from_ = -24-xdo, to = 0-si)
            # scanote7()
     
            def scanote8(self,xh):
                    sch=int(xh)
                    f_t=0                
                    xsi=self.sca[6].get()
                    tosi=t_si=self.sca[6].cget("to")
                    if (xsi+sch > t_si):f_t=-1                        
                    xdo=self.sca[0].get()
                    fromdo=f_do=self.sca[0].cget("from")
                    todo=t_do=self.sca[0].cget("to")
                    if (xdo+sch<f_do)or(f_t==-1):
                            fromdo = f_do+sch
                            todo = t_do+sch
                            f_t = -1                        
                    xre=self.sca[1].get()
                    fromre=f_re=self.sca[1].cget("from")
                    tore=t_re=self.sca[1].cget("to")
                    if f_t==-1:
                            fromre = f_re+sch
                            tore = t_re+sch                        
                    xmi=self.sca[2].get()
                    frommi=f_mi=self.sca[2].cget("from")
                    tomi=t_mi=self.sca[2].cget("to")
                    if f_t==-1:
                            frommi = f_mi+sch
                            tomi = t_mi+sch                        
                    xfa=self.sca[3].get()
                    fromfa=f_fa=self.sca[3].cget("from")
                    tofa=t_fa=self.sca[3].cget("to")
                    if f_t==-1:
                            fromfa = f_fa+sch
                            tofa = t_fa+sch                        
                    xsol=self.sca[4].get()
                    fromsol=f_sol=self.sca[4].cget("from")
                    tosol=t_sol=self.sca[4].cget("to")
                    if f_t==-1:
                            fromsol = f_sol+sch
                            tosol = t_sol+sch                        
                    xla=self.sca[5].get()
                    fromla=f_la=self.sca[5].cget("from")
                    tola=t_la=self.sca[5].cget("to")
                    if f_t==-1:
                            fromla = f_la+sch
                            tola = t_la+sch                        
                    xsi=self.sca[6].get()
                    fromsi=f_si=self.sca[6].cget("from")
                    tosi=t_si=self.sca[6].cget("to")
                    if (xsi+sch > t_si)or(f_t==-1):
                            fromsi = f_si+sch
                            tosi = t_si+sch
                            f_t=-1                        
                    self.sca[0].configure(from_ = fromdo, to = todo)
                    self.sca[0].set(xdo+sch)                
                    self.sca[1].configure(from_ = fromre, to = tore)
                    self.sca[1].set(xre+sch)                
                    self.sca[2].configure(from_ = frommi, to = tomi)
                    self.sca[2].set(xmi+sch)                
                    self.sca[3].configure(from_ = fromfa, to = tofa)
                    self.sca[3].set(xfa+sch)                
                    self.sca[4].configure(from_ = fromsol, to = tosol)
                    self.sca[4].set(xsol+sch)                
                    self.sca[5].configure(from_ = fromla, to = tola)
                    self.sca[5].set(xla+sch)                
                    self.sca[6].configure(from_ = fromsi, to = tosi)
                    self.sca[6].set(xsi+sch)
                    self.btgama.invoke()
            # scanote8()
     
            def zero(self):
                    fnotes=[0,-1,-2,-2,-3,-4,-5]
                    tnotes=[+5,+4,+3,+3,+2,+1,0]
                    for z in range(7):
                            self.sca[z].configure(from_ = fnotes[z], to = tnotes[z])
                            self.sca[z].set(0)
                    self.sca[7].configure(from_ = -12, to = 12)
                    self.sca[7].set(0)
                    self.rad[1].invoke()                    # Remise à l'octave zéro ou "ioi"
                    self.btgama.invoke()
            # zero()
     
            def gama(self):
                    del(self.decore[:])     # Remise au zéro tonique des accords
                    self.can.delete(ALL)
                    # Tracé d'encadrement
                    # Données de l'encadré : Axes(x,y)=365(x),220(y)
                    self.can.create_line(10, 450, 740, 450, fill ='blue')
                    self.can.create_line(460, 450, 460, 110, fill ='green')
                    self.can.create_line(390, 220, 520, 220, fill ='green')
                    self.can.create_line(270, 340, 400, 340, fill ='green')
                    self.can.create_line(510, 100, 640, 100, fill ='green')
                    # De la table gammique aux tables diatoniques surnommées
                    gammes =[[1,1,0,1,1,1,0],[0,2,0,1,1,1,0],[2,0,0,1,1,1,0],[4,0,0,0,0,1,0],[1,0,1,1,1,1,0],[0,1,1,1,1,1,0],
                                     [1,0,3,0,0,1,0],[1,2,1,0,0,1,0],[2,2,0,0,0,1,0],[0,0,1,2,1,1,0],[1,3,0,0,0,1,0],[0,0,2,1,1,1,0],
                                     [1,2,2,0,0,0,0],[0,0,4,0,0,1,0],[1,4,0,0,0,0,0],[1,0,0,2,1,1,0],[0,1,0,2,1,1,0],[1,1,3,0,0,0,0],
                                     [0,0,0,3,1,1,0],[1,1,0,0,2,1,0],[0,2,0,0,2,1,0],[0,2,0,2,0,1,0],[2,0,0,0,2,1,0],[1,0,1,0,2,1,0],
                                     [1,0,1,2,0,1,0],[1,1,1,2,0,0,0],[2,0,0,3,0,0,0],[0,0,2,0,2,1,0],[1,2,0,2,0,0,0],[1,0,0,3,0,1,0],
                                     [1,0,0,1,2,1,0],[1,1,0,3,0,0,0],[1,1,2,1,0,0,0],[0,1,0,0,3,1,0],[0,0,1,0,3,1,0],[0,0,0,1,3,1,0],
                                     [0,0,0,2,2,1,0],[1,0,0,0,3,1,0],[0,0,2,2,0,1,0],[0,0,0,0,4,1,0],[0,0,2,3,0,0,0],[1,0,0,4,0,0,0],
                                     [0,0,0,5,0,0,0],[1,1,0,1,0,2,0],[1,1,0,1,2,0,0],[0,2,0,1,0,2,0],[0,2,0,1,2,0,0],[2,0,0,1,0,2,0],
                                     [2,0,0,1,2,0,0],[1,0,1,1,0,2,0],[1,0,1,1,2,0,0],[1,1,0,0,1,2,0],[1,1,0,0,3,0,0],[1,1,0,2,1,0,0],
                                     [1,1,2,0,1,0,0],[0,2,0,0,0,3,0],[1,0,0,2,2,0,0],[1,0,0,1,0,3,0],[1,3,0,0,1,0,0],[1,0,0,0,1,3,0],
                                     [0,0,0,3,0,2,0],[0,0,2,1,2,0,0],[1,0,0,0,0,4,0],[0,0,0,3,2,0,0],[1,1,0,0,0,3,0],[3,0,0,0,0,2,0]]
                    gamnoms =['0','-2','+2','^2','-3','-23','-34x','+34','+23x','-34','x3','°3','+34x','°34x','^3',
                                      '-4','-24','^4','°4','-5','-25','-25+','+25-','-35','-35+','+45x','+25x','°35-','+35x',
                                      '-45+','-45','x5','x45+','-25°','-35°','-45°','°45-','°5','°35+','*5','°35x','-45x',
                                      '°45x','-6','+6','-26','-26+','+26-','+26','-36','-36+','-56','-56+','+56','x46+',
                                      '-26°','-46+','-46°','x36+','-56°','°46-','°36+','*6','°46+','°6','x26-']
     
                    # Récupération des notes cursives
                    xxx=0
                    xxrad0=self.variable.get()
                    if xxrad0 == "YOI": xxx=+120
                    elif xxrad0 == "IOI": xxx=0
                    elif xxrad0 == "IOY": xxx=-120
     
                    ydo=self.sca[0].get()
                    xcpos_=400-xxx
                    ycpos_=220+xxx
                    xc_=xcpos_+(ydo*10)
                    yc_=ycpos_-(ydo*10)
                    rc_=5
                    self.tablenotes[0]=xc_
                    self.can.create_line(xc_, 350, xc_, 40, fill ='black')
                    self.can.create_oval(xc_-rc_,yc_-rc_,xc_+rc_,yc_+rc_,fill='black')
                    yre=self.sca[1].get()
                    xcpos_=420-xxx
                    ycpos_=220+xxx
                    xd_=xcpos_+(yre*10)
                    yd_=ycpos_-(yre*10)
                    rd_=5
                    self.tablenotes[1]=xd_
                    self.can.create_line(xd_, 360, xd_, 50, fill ='green')
                    self.can.create_oval(xd_-rd_,yd_-rd_,xd_+rd_,yd_+rd_,fill='green')
                    ymi=self.sca[2].get()
                    xcpos_=440-xxx
                    ycpos_=220+xxx
                    xe_=xcpos_+(ymi*10)
                    ye_=ycpos_-(ymi*10)
                    re_=5
                    self.tablenotes[2]=xe_
                    self.can.create_line(xe_, 370, xe_, 60, fill ='blue')
                    self.can.create_oval(xe_-re_,ye_-re_,xe_+re_,ye_+re_,fill='blue')
                    yfa=self.sca[3].get()
                    xcpos_=450-xxx
                    ycpos_=220+xxx
                    xf_=xcpos_+(yfa*10)
                    yf_=ycpos_-(yfa*10)
                    rf_=5
                    self.tablenotes[3]=xf_
                    self.can.create_line(xf_, 370, xf_, 60, fill ='grey')
                    self.can.create_oval(xf_-rf_,yf_-rf_,xf_+rf_,yf_+rf_,fill='grey')
                    ysol=self.sca[4].get()
                    xcpos_=470-xxx
                    ycpos_=220+xxx
                    xg_=xcpos_+(ysol*10)
                    yg_=ycpos_-(ysol*10)
                    rg_=5
                    self.tablenotes[4]=xg_
                    self.can.create_line(xg_, 380, xg_, 70, fill ='red')
                    self.can.create_oval(xg_-rg_,yg_-rg_,xg_+rg_,yg_+rg_,fill='red')
                    yla=self.sca[5].get()
                    xcpos_=490-xxx
                    ycpos_=220+xxx
                    xa_=xcpos_+(yla*10)
                    ya_=ycpos_-(yla*10)
                    ra_=5
                    self.tablenotes[5]=xa_
                    self.can.create_line(xa_, 390, xa_, 80, fill ='orange')
                    self.can.create_oval(xa_-ra_,ya_-ra_,xa_+ra_,ya_+ra_,fill='orange')
                    ysi=self.sca[6].get()
                    xcpos_=510-xxx
                    ycpos_=220+xxx
                    xb_=xcpos_+(ysi*10)
                    yb_=ycpos_-(ysi*10)
                    rb_=5
                    self.tablenotes[6]=xb_
                    self.can.create_line(xb_, 400, xb_, 90, fill ='yellow')
                    self.can.create_oval(xb_-rb_,yb_-rb_,xb_+rb_,yb_+rb_,fill='yellow')
     
                    # Mesure de l'intervalle tempéré
                    c1=(yre+1)-ydo
                    d2=(ymi+1)-yre
                    e3=yfa-ymi
                    f4=(ysol+1)-yfa
                    g5=(yla+1)-ysol
                    a6=(ysi+1)-yla
                    b7=i=cum_diat=ok=x=0
                    diata=[c1,d2,e3,f4,g5,a6,b7]
                    while i < 6:
                            cum_diat += diata[i]
                            i+=1            
                    # while i
                    diata[i]=5-cum_diat
     
                    # Recherche diatonique par l'itération
                    cc1=dd2=ee3=ff4=gg5=aa6=bb7=0
                    diata2=[cc1,dd2,ee3,ff4,gg5,aa6,bb7]
                    while x < 7:
                            m=x
                            y=0
                            while y < 7:
                                    diata2[y]=diata[m]
                                    y+=1
                                    m+=1
                                    if m > 6: m=0                   
                            # while
                            myx=myx2=0
                            for my in gammes:
                                    if diata2 == my:
                                            degre=x
                                            myx2=myx
                                            x=7
                                    # if diata2
                                    myx+=1
                            # for my
                            x+=1
                    # while x
                    # Ici : diata(original cursif).degre(tonique).my(gamme)
     
                    # Définition diatonique
                    # GMAJ= gammes[0]
                    gmaj = [1,1,0,1,1,1,0]    # Forme majeure simplifiée
                    # GNAT= Ordre cursif comme diata[]
                    gnat = ['C','D','E','F','G','A','B']    # Forme alphabétique
                    cnat = ['','','','','','','']
                    # Niveaux d'altérations
                    nordiese = ['','+','x','^','+^','x^','^^','+^^','x^^','^^^','+^^^','x^^^','^^^^','13(#)','14(#)','15(#)',
                                '16(#)','17(#)','18(#)','19(#)','20(#)','21(#)','22(#)','23(#)','24(#)',
                                '25(#)','26(#)','27(#)','28(#)','29(#)','30(#)','31(#)','32(#)']
                    subemol = ['','32(b)','31(b)','30(b)','29(b)','28(b)','27(b)','26(b)','25(b)','24(b)','23(b)','22(b)',
                               '21(b)','20(b)','19(b)','18(b)','17(b)','16(b)','15(b)','14(b)','13(b)',
                               '****','°***','-***','***','°**','-**','**','°*','-*','*','°','-']
                    # Configuration modale
                    gdeg = ['I','II','III','IV','V','VI','VII']
                    # Définition du style d'écriture
                    font = Font(family='Liberation Serif', size=9)
                    font2 = Font(family='Liberation Serif', size=12)
                    # Définition des notes cursives
                    cursifs=[ydo,yre,ymi,yfa,ysol,yla,ysi]
                    ynat=ymod=0
                    for ycurs in cursifs:
                            if ycurs > 0 :
                                    ymod=nordiese[ycurs]
                            if ycurs < 0 :
                                    ymod=subemol[ycurs]
                            if ycurs == 0 :
                                    ymod=subemol[ycurs]
                            cnat[ynat]=ymod
                            ynat+=1
                    # for ycurs
     
                    # Une tournée produit une tonalité modale de 7 notes
                    nat2=degre
                    deg = nom = 0
                    ynote = xgdeg = 30
                    ytone = 50
                    while deg < 7 :
                            nat = deg                       # Degré tonal en question
                            cri = gimj = gmod = maj = 0
                            xdeg = 80
                            text0 = gdeg[deg]
                            self.can.create_text(xgdeg+25,ynote+10,text=text0,
                                                 font='bold',fill='black')
                            while maj < 7 :                 # Tonalité modale du degré
                                    gmj = gmaj[maj]         # Forme majeure (1101110)
                                    imaj = diata2[nat]      # Forme modale (DIATA[DEGRE])
                                    ynt = cnat[nat2]        # Forme altérative des notes
                                    gnt = gnat[nat2]        # Forme tonale (CDEFGAB)
                                    ideg = gdeg[deg]
                                    cri = cri + gimj        # Tonalité cumulée
                                    gimj = imaj - gmj       # Calcul tonal PAS/PAS
                                    cmod = gmod = cri
                                    if maj == 0:
                                            yntgnt = ynt,gnt
                                            self.decore.append(yntgnt)
                                    if gmod > 0 :           # Forme altérative des tonalités
                                            imod = nordiese[cmod]
                                    if gmod < 0 :
                                            imod = subemol[cmod]
                                    if gmod == 0 :
                                            imod = subemol[cmod]
                                    gmod = gmod + cri       # Transition tonale
                                    # Construction du nom de la gamme
                                    if nom == 0 :
                                            ynom = ynt
                                            gnom = gnt
                                            tnom=gnom,gamnoms[myx2]
                                            self.can.create_text(28,10,text=ynom,font=font,fill='red')
                                            self.can.create_text(28,25,text=tnom,font=font2,fill='black')
                                    # if nom
                                    nat+=1
                                    nat2+=1
                                    if nat > 6 :
                                            nat = 0
                                    if nat2 > 6 :
                                            nat2 = 0
                                    maj = maj + 1
                                    text1= gnt
                                    text2=[imod,maj]
                                    self.can.create_text(xdeg,ynote-12,text=ynt,font=font,fill='red')
                                    self.can.create_text(xdeg,ynote,text=text1)
                                    self.can.create_text(xdeg,ytone,text=text2,fill='blue')
                                    xdeg+=30
                                    nom=1
                                    self.declare[(deg,maj)] = imod
                                    #maj = maj + 1
                            # while maj
                            ynote+=60
                            ytone+=60
                            nat2+=1
                            if nat2 > 6 :
                                    nat2 = 0
                            deg = deg + 1
                    # while deg
                    self.tbdegre[0]=degre
            # gamma()
    # class Gammique 
    Gammique().mainloop()

  10. #10
    Membre chevronné
    Homme Profil pro
    Enseignant
    Inscrit en
    Juin 2013
    Messages
    1 608
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations professionnelles :
    Activité : Enseignant
    Secteur : Enseignement

    Informations forums :
    Inscription : Juin 2013
    Messages : 1 608
    Points : 2 072
    Points
    2 072
    Par défaut
    Tu as essayé avec pyaudio ?
    Son avantage est de fonctionner sur tous les OS et pas uniquement sous windows comme winsound.
    Pas d'aide par mp.

  11. #11
    Expert éminent sénior
    Homme Profil pro
    Architecte technique retraité
    Inscrit en
    Juin 2008
    Messages
    21 282
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Manche (Basse Normandie)

    Informations professionnelles :
    Activité : Architecte technique retraité
    Secteur : Industrie

    Informations forums :
    Inscription : Juin 2008
    Messages : 21 282
    Points : 36 769
    Points
    36 769
    Par défaut
    Salut,

    Citation Envoyé par toumic Voir le message
    Tout çà pour dire, que le débutant est une source d'erreur riche en informations. Et, que le principal obstacle à son éducation vient de python, et non pas de son désir de concrétiser un code source complexe.
    Si vous pratiquez un instrument de musique, j'aimerai bien savoir le temps que vous avez passé à apprendre à le maîtriser avant de pouvoir jouer des mélodies de façon satisfaisante. Au début, c'est couacs et cacophonies qui ne ravissent pas trop les voisins. Et c'est rarement la faute de l'instrument que vous jouez.

    - W
    Architectures post-modernes.
    Python sur DVP c'est aussi des FAQs, des cours et tutoriels

  12. #12
    Membre chevronné
    Homme Profil pro
    Enseignant
    Inscrit en
    Juin 2013
    Messages
    1 608
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations professionnelles :
    Activité : Enseignant
    Secteur : Enseignement

    Informations forums :
    Inscription : Juin 2013
    Messages : 1 608
    Points : 2 072
    Points
    2 072
    Par défaut
    Citation Envoyé par wiztricks Voir le message
    Salut,



    Si vous pratiquez un instrument de musique, j'aimerai bien savoir le temps que vous avez passé à apprendre à le maîtriser avant de pouvoir jouer des mélodies de façon satisfaisante. Au début, c'est couacs et cacophonies qui ne ravissent pas trop les voisins. Et c'est rarement la faute de l'instrument que vous jouez.

    - W
    Pas d'aide par mp.

  13. #13
    Invité
    Invité(e)
    Par défaut
    Citation Envoyé par wiztricks Voir le message
    Salut, .
    Si vous pratiquez un instrument de musique, j'aimerai bien savoir le temps que vous avez passé à apprendre à le maîtriser avant de pouvoir jouer des mélodies de façon satisfaisante. Au début, c'est couacs et cacophonies qui ne ravissent pas trop les voisins. Et c'est rarement la faute de l'instrument que vous jouez.

    - W
    Vous me surprenez dans la réponse, mais d'un autre côté vous connaissez pas mon vécu. Contrairement à ce que vous dites, la musique a toujours été un bénéfice pour moi et pour tous. Si l'inspiration musicale vient de la motivation exercée à créer de la magie musicale, je connais une société qui n'entretien pas exactement les mêmes motivations artistiques. C'est qu'à ce niveau la société se prive de trop nombreuses musiques, qui va sans dire que de nombreux musiciens ne font pas partie du décors musical. Ce qui ressemble énormément au monde de la programmation...

    Puis, cette critique au sujet du contrôle syntaxique de l'algorithme assisté du widget. Elle est réelle, il y a des langages de programmation qui proposent des widgets plus complets, comme les visuals machin-chose à paramétrer. En musique c'est pareil. Les séquenceurs proposent des outils d'aide à la conception, qui ne vont pas jusqu'à réparer les grands couacs. Je vous parlais de motivation, et je rajoute du travail donné par les différentes occupations individuelles. Le temps qui passe est aussi un espace de travail, tout comme l'avenir. Ce qui va m'arriver c'est donc le travail, ce que je fais déjà. Vous voyez comme j'ai réussi à écrire un programme assez compliqué, pourtant mon expérience en la matière est insignifiante. Avec mon instrument c'était identique, même au début on a plaisir à m'écouter seulement si je suis motivé. Croyez vous que mon père qui m'écoutait lors de mes premières notes est venu me dire ce que vous dites dans votre message ?
    Au début, c'est couacs et cacophonies qui ne ravissent pas trop les voisins
    Vous vous trompez de phrase wiztricks. marco056

    Astuce : Si vous ne savez pas, faites le en silence et à l'abris des regards

  14. #14
    Membre chevronné
    Homme Profil pro
    Enseignant
    Inscrit en
    Juin 2013
    Messages
    1 608
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations professionnelles :
    Activité : Enseignant
    Secteur : Enseignement

    Informations forums :
    Inscription : Juin 2013
    Messages : 1 608
    Points : 2 072
    Points
    2 072
    Par défaut
    Ce n 'est pas une bonne idée de fumer aussi tôt le matin.
    Pas d'aide par mp.

  15. #15
    Invité
    Invité(e)
    Par défaut


    http://www.cabviva.com/programs/progamv3epyco.txt

    @urémail

    Je regrette le fait que winsound ne soit pas "open", ce programme a évolué grâce à vous. J'aimerais aussi bien qu'il soit un peu plus partagé, car il est copiable. Vous pouvez le retourner dans tous les sens si vous le voulez. Je sais que le sujet est intéressant, puis moi de mon côté. Je continue de le faire évoluer à ma façon néanmoins un peu dictée. Si vous avez un moyen de faire en sorte qu'il puisse devenir "open", vous pouvez même me donner la solution codée à copier/coller. Pour finir le programme finira toujours par revenir, à savoir que le moteur principal du développement gammique est posé "open source" ici même
    Dernière modification par Invité ; 10/10/2015 à 18h52. Motif: Le côté négatif du prog.

  16. #16
    Invité
    Invité(e)
    Par défaut
    C'est à propos des erreurs à la conception de ce programme

    Juste un aperçu de la zone ayant des erreurs à corriger à partir de maintenant (je m'en occupe)
    En prenant un peu de distance à ce problème, on comprend que pour comprendre le problème il faut se rapprocher.
    Puis, de redéfinir ce traitement. Mais il est assez important pour que je le copie ici, car dans son sein il y a un indice qui permet d'en créer un autre...

    J'explique: On a deux tableaux pour les altérations (b/#), l'un se lit de 0 à +32 et l'autre de -1 à -32
    Comment:
    Comme çà:
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
     
    for ca in range(33):
                                                            cga = self.nordiese[ca] # Altération côté dièse
                                                            ca2 = 34-(34+ca)
                                                            cgm = self.subemol[ca2] # Altération côté bémol
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    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
     
            def chrome(self):
                    if self.pretrans[0] == 1:
                            self.chm.destroy()
                            self.pretrans[0] = 0
                            self.btchr.invoke()
                    else:
                            self.pretrans[0] = 1
                            ch0 = 0
                            self.chm = Toplevel(self)
                            self.chm.title('Entité Gammique : Chromatisme')
                            # Sélection du mode chromatique (naturel) ou (atonale)
                            frchm = Frame(self.chm,width=200,height=10)
                            frchm.pack(side=BOTTOM)
                            btchn = Button(frchm,text ='Chrome Naturel',width=30,bg ='ivory', command=lambda: self.actuac(2))
                            btchn.pack(side = LEFT)
                            btcha = Button(frchm,text ='Chrome Atonal',width=30,bg ='ivory', command=lambda: self.actuac(4))
                            btcha.pack(side = RIGHT)
                            frchm_ = Frame(self.chm,width=200,height=10)
                            frchm_.pack(side=TOP)
                            lbchtxt = Label(frchm_, text ="Chromatismes", fg = 'red').pack()
                            # Le pas graphique entre 2 notes = 10, en cotation horizontale
                            # self.tablenotes : Conteneur diatonique | Calcul graphique horizontal
                            # self.tablehaute : Conteneur diatonique | Calcul graphique vertical
                            # self.tbdegre : Contient le mode tonique en cours
                            # self.chrgen : Tableau graphique chromatique( chr_note, chr_signe )
                            chrmaj = [0,20,40,50,70,90,110]         # Forme graphique majeure
                            chnat_aug = [1,2,4,5,6] ; chnat_min = [2,3,5,6,7]
                            chr_trans = []
                            chrselect = self.btchr.cget('text')
                            chr_lepas = 10
                            # self.tablenotes : Conteneur diatonique | Calcul graphique horizontal
                            cy_zer = self.tbdegre[0]        # Premier degré de la gamme
                            for cy_ in range(7):
                                    if cy_ == 0:
                                            cy_inter = self.tablenotes[cy_zer]-0
                                    if self.tablenotes[cy_zer] < cy_inter:
                                            cy_trans = self.tablenotes[cy_zer] - cy_inter + 120
                                    else:
                                            cy_trans = self.tablenotes[cy_zer] - cy_inter
                                    chr_trans.append(cy_trans)      # Transformé élémentaire
                                    #(chr_trans[cy_])               # Contenu graphique diatonique
                                    cy_zer +=1
                                    if cy_zer > 6: cy_zer = 0
                            # Génération élémentaire du tableau chromatique
                            cz_ = cx_tr = cn_ = 0 ; cx_uu = 1
                            for cx_ in range(12):
                                    c1_ = c2_ = c3_ = c4_ = c5_ = c6_ = c7_ = -1      # -1 = Emplacement chromatique
                                    stop_a = stop_m = comp = ch_comp = 0
                                    tg_a2 = tg_m2 = c2_a2 = c2_m2 = c4_a = c4_m = 0
                                    if cx_ == 0:
                                            c1_ = chr_trans[cx_tr]          # Incrustation diatonique
                                            c2_ = self.decore[cx_tr][:1]    # Signature naturelle
                                            c3_ = self.decore[cx_tr][1:]    # Note naturelle
                                            c4_ =  self.dechire[(0, cx_uu)] # Note tonalité
                                            cx_tr += 1 ; cx_uu += 1
                                    else:
                                            if chr_trans[cx_tr] == cx_*10:
                                                    c1_ = chr_trans[cx_tr]
                                                    c2_ = self.decore[cx_tr][:1]
                                                    c3_ = self.decore[cx_tr][1:]
                                                    c4_ =  self.dechire[(0, cx_uu)]
                                                    cx_tr += 1 ; cx_uu += 1
                                            else:
                                                    comp = -1
                                                    ch_comp = cx_
                                            if comp == -1 and cn_ < 5:
                                                    id_a = chnat_aug[cn_]-1         # Ordre chromatique majeur(#)(7)
                                                    id_m = chnat_min[cn_]-1         # Ordre chromatique mineur(b)(7)
                                                    #print('id_',id_a,id_m)
                                                    c2_a = self.decore[id_a][:1]    # Signature naturelle(b ou #)(7)
                                                    c2_m = self.decore[id_m][:1]
                                                    #print('c2_',c2_a,c2_m)
                                                    c3_a = self.decore[id_a][1:]    # La naturelle chrome majeur(7)
                                                    c3_m = self.decore[id_m][1:]    
                                                    tg_a = chr_trans[id_a]//10      # Indice pour valeur tonale majeure(12)
                                                    tg_m = chr_trans[id_m]//10
                                                    #print('tg_a',tg_a,'tg_m',tg_m)
                                                    tg_a1 = chrmaj[id_a]//10        # Mesure du rapport majeur(7)
                                                    tg_m1 = chrmaj[id_m]//10
                                                    #print('tg_a1',tg_a1,'tg_m1',tg_m1)
                                                    if tg_a1 > ch_comp:
                                                            tg_a2 = tg_a1 - ch_comp
                                                            #print('1',tg_a2)
                                                    elif tg_a1 < ch_comp:
                                                            tg_a2 = ch_comp - tg_a1
                                                            #print('2',tg_a2)
                                                    elif tg_m1 > ch_comp:
                                                            tg_m2 = tg_m1 - ch_comp
                                                            #print('3',tg_m2)
                                                    elif tg_m1 < ch_comp:
                                                            tg_m2 = ch_comp - tg_m1
                                                            #print('4',tg_m2)
                                                    pos_a = id_a*10 ; pos_m = id_m*10       # Positions chromatiques
                                                    posit = cz_          
                                                    p_a = (posit - pos_a)/10        # Différence de niveau majeur
                                                    p_m = (posit - pos_m)/10        
                                                    for ca in range(33):
                                                            cga = self.nordiese[ca] # Altération côté dièse
                                                            ca2 = 34-(34+ca)
                                                            cgm = self.subemol[ca2] # Altération côté bémol
                                                            if c2_a == cga and c2_a != 0:                         # Signature ?                       
                                                                    c2_a1 = ca + p_a        # Valeur à ajouter
                                                                    c2_a2 = self.nordiese[c2_a1]    # Résultat signé(#)
                                                                    stop_a = 1
                                                            elif c2_a == cgm and stop_a == 0 and c2_a != 0:
                                                                    c2_a1 = ca + p_m
                                                                    c2_a2 = self.subemol[c2_a1]     # Résultat signé(b)
                                                                    stop_a = 1
                                                            elif c2_m == cga and c2_m != 0:
                                                                    c2_m1 = ca + p_a
                                                                    c2_m2 = self.nordiese[c2_m1]    # Résultat signé(#)
                                                                    stop_m = 1
                                                            elif c2_m == cgm and stop_m == 0 and c2_m != 0:
                                                                    c2_m1 = ca + p_m
                                                                    c2_m2 = self.subemol[c2_m1]     # Résultat signé(b)
                                                                    stop_m = 1
                                                            if stop_a and stop_m == 1:
                                                                    print('cou')
                                                                    break
                                                    if tg_a2 > 0:
                                                            c4_a = self.nordiese[tg_a2]
                                                    elif tg_a2 < 0:
                                                            c4_a = self.subemol[tg_a2]
                                                    elif tg_m2 > 0:
                                                            c4_m = self.nordiese[tg_m2]
                                                    elif tg_m2 < 0:
                                                            c4_m = self.subemol[tg_m2]
                                                    c2_ = c2_a2
                                                    c3_ = c3_a
                                                    c4_ = c4_a
                                                    c5_ = c2_m2
                                                    c6_ = c3_m
                                                    c7_ = c4_m
                                                    cn_ +=1
                                    self.chrgen[(cx_)] = [cz_],[c1_],[c2_],[c3_],[c4_],[c5_],[c6_],[c7_]
                                    #print('gen',self.chrgen[(cx_)])      # Local graphique octave
                                    cz_ += chr_lepas
                            # Génération analogique du tableau chromatique
                            del(chr_trans[:])       # Remise à zéro diatonique(int)
                            print('*')
    J'apporte une correction qui semble fonctionner au quart de tour, les gammes chromatiques n'ont qu'à bien se tenir
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    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
     
            # __init__()
     
            def chrome(self):
                    if self.pretrans[0] == 1:
                            self.chm.destroy()
                            self.pretrans[0] = 0
                            self.btchr.invoke()
                    else:
                            self.pretrans[0] = 1
                            ch0 = 0
                            self.chm = Toplevel(self)
                            self.chm.title('Entité Gammique : Chromatisme')
                            # Sélection du mode chromatique (naturel) ou (atonale)
                            frchm = Frame(self.chm,width=200,height=10)
                            frchm.pack(side=BOTTOM)
                            btchn = Button(frchm,text ='Chrome Naturel',width=30,bg ='ivory', command=lambda: self.actuac(2))
                            btchn.pack(side = LEFT)
                            btcha = Button(frchm,text ='Chrome Atonal',width=30,bg ='ivory', command=lambda: self.actuac(4))
                            btcha.pack(side = RIGHT)
                            frchm_ = Frame(self.chm,width=200,height=10)
                            frchm_.pack(side=TOP)
                            # Fenêtre écran_résultat
                            chrcan = Canvas(self.chm,bg='white', height=300,width=600)
                            chrcan.pack()
                            lbchtxt = Label(frchm_, text ="Chromatismes", fg = 'red').pack()
                            # Le pas graphique entre 2 notes = 10, en cotation horizontale
                            # self.tablenotes : Conteneur diatonique | Calcul graphique horizontal
                            # self.tablehaute : Conteneur diatonique | Calcul graphique vertical
                            # self.tbdegre : Contient le mode tonique en cours
                            # self.chrgen : Tableau graphique chromatique( chr_note, chr_signe )
                            chrmaj = [0,20,40,50,70,90,110]         # Forme graphique majeure
                            chnat_aug = [1,2,4,5,6] ; chnat_min = [2,3,5,6,7]
                            chr_trans = []
                            chrselect = self.btchr.cget('text')
                            chr_lepas = 10
                            # self.tablenotes : Conteneur diatonique | Calcul graphique horizontal
                            cy_zer = self.tbdegre[0]        # Premier degré de la gamme
                            for cy_ in range(7):
                                    if cy_ == 0:
                                            cy_inter = self.tablenotes[cy_zer]-0
                                    if self.tablenotes[cy_zer] < cy_inter:
                                            cy_trans = self.tablenotes[cy_zer] - cy_inter + 120
                                    else:
                                            cy_trans = self.tablenotes[cy_zer] - cy_inter
                                    chr_trans.append(cy_trans)      # Transformé élémentaire
                                    #(chr_trans[cy_])               # Contenu graphique diatonique
                                    cy_zer +=1
                                    if cy_zer > 6: cy_zer = 0
                            # Génération élémentaire du tableau chromatique
                            cz_ = cx_tr = cn_ = 0 ; cx_uu = 1
                            for cx_ in range(12):
                                    c1_ = c2_ = c3_ = c4_ = c5_ = c6_ = c7_ = -1      # -1 = Emplacement chromatique
                                    stop_a = stop_m = comp = ch_comp = 0
                                    tg_a2 = tg_m2 = c2_a2 = c2_m2 = c4_a = c4_m = 0
                                    if cx_ == 0:
                                            c1_ = chr_trans[cx_tr]          # Incrustation diatonique
                                            c2_ = self.cursifs[cx_tr]       # Hauteur tonale
                                            c3_ = self.decore[cx_tr][1:]    # Note naturelle
                                            c4_ =  self.dechire[(0, cx_uu)] # Valeur tonale
                                            cx_tr += 1 ; cx_uu += 1
                                    else:
                                            if chr_trans[cx_tr] == cx_*10:
                                                    c1_ = chr_trans[cx_tr]
                                                    c2_ = self.cursifs[cx_tr]
                                                    c3_ = self.decore[cx_tr][1:]
                                                    c4_ =  self.dechire[(0, cx_uu)]
                                                    cx_tr += 1 ; cx_uu += 1
                                            else:
                                                    comp = -1
                                                    ch_comp = cx_
                                            if comp == -1 and cn_ < 5:
                                                    id_a = chnat_aug[cn_]-1         # Ordre chromatique majeur(#)(7)
                                                    id_m = chnat_min[cn_]-1         # Ordre chromatique mineur(b)(7)
                                                    c2_a = self.cursifs[id_a]       # Hauteur tonale(b ou #)(7)
                                                    c2_m = self.cursifs[id_m]
                                                    c3_a = self.decore[id_a][1:]    # Note naturelle(7)
                                                    c3_m = self.decore[id_m][1:]
                                                    tg_a = chr_trans[id_a]//10      # Hauteur graphique originale(12)
                                                    tg_m = chr_trans[id_m]//10
                                                    tg_a1 = chrmaj[id_a]//10        # Hauteur graphique majeure(7)(c4_a)
                                                    tg_m1 = chrmaj[id_m]//10
                                                    tg_a2 = cx_ - tg_a              # Hauteur tonale signée, non nulle
                                                    tg_m2 = cx_ - tg_m
                                                    c2_ax =  tg_a2 + c2_a           # Hauteur tonale en arrivée signée
                                                    c2_mx = c2_m + tg_m2
                                                    if c2_ax >= 0:
                                                            c2_a1 = self.nordiese[c2_ax]    # Table des altérations utiles
                                                    else:
                                                            c2_a1 = self.subemol[c2_ax]
                                                    if c2_mx >= 0:
                                                            c2_m1 = self.nordiese[c2_mx]
                                                    else:
                                                            c2_m1 = self.subemol[c2_mx]
                                                    c4_a = cx_ - tg_a1                      # Valeur tonale (tg_a1 = maj)
                                                    c4_m = cx_ - tg_m1
                                                    if c4_a >= 0:
                                                            c4_a1 = self.nordiese[c4_a]
                                                    else:
                                                            c4_a1 = self.subemol[c4_a]
                                                    if c4_m >= 0:
                                                            c4_m1 = self.nordiese[c4_m]
                                                    else:
                                                            c4_m1 = self.subemol[c4_m]
                                                    c2_ = c2_a1
                                                    c3_ = c3_a
                                                    c4_ = c4_a1
                                                    c5_ = c2_m1
                                                    c6_ = c3_m
                                                    c7_ = c4_m1
                                                    cn_ +=1
                                                    #print('c2:',c2_,'c3:',c3_,'c4:',c4_,'c5:',c5_,'c6:',c6_,'c7:',c7_)
                                    self.chrgen[(cx_)] = [cz_],[c1_],[c2_],[c3_],[c4_],[c5_],[c6_],[c7_]
                                    print('gen',self.chrgen[(cx_)])      # Local graphique octave
                                    cz_ += chr_lepas
                            # Génération analogique du tableau chromatique
                            chrcan.create_line(5, 15, 5, 5, fill ='black')
                            del(chr_trans[:])       # Remise à zéro diatonique(int)
                            print('*')
     
            def actuac(self,a):
    Dernière modification par Invité ; 26/10/2015 à 21h40. Motif: Mise à jour corrective

  17. #17
    Invité
    Invité(e)
    Par défaut
    Supplément de la correction qui n'avait pas accusé def actuac(self,a): d'absentéisme
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
     
            def actuac(self,a):
                    if a == 5:                      # def accord/Bouton fermer
                            self.acc.destroy()
                            self.presens[0]=0
                    elif a == 3:                    # def accord/Bouton actualiser
                            self.acc.destroy()
                            self.presens[0]=0
                            self.btaud2.invoke()
                            self.btacc.invoke()
                    elif a == 1:                    # def audio/Bouton audio
                            self.presaudio = 0
                            self.btaud2.invoke()
                    elif a == 2:
                            self.btchr.configure(text= 'Chrome naturel')    # def chrome/Bouton C_n
                            self.chm.destroy()
                            self.btchr.invoke()
                    elif a == 4:
                            self.btchr.configure(text= 'Chrome atonal')     # def chrome/Bouton C_a
                            self.chm.destroy()
                            self.btchr.invoke()

  18. #18
    Expert éminent

    Homme Profil pro
    Inscrit en
    Octobre 2008
    Messages
    4 300
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Belgique

    Informations forums :
    Inscription : Octobre 2008
    Messages : 4 300
    Points : 6 780
    Points
    6 780
    Par défaut
    Citation Envoyé par toumic Voir le message
    ...
    En prenant un peu de distance à ce problème, on comprend que pour comprendre le problème il faut se rapprocher.
    En fait, tu peux être brillant parfois. Sincèrement.

  19. #19
    Invité
    Invité(e)
    Par défaut
    Citation Envoyé par VinsS Voir le message
    En fait, tu peux être brillant parfois. Sincèrement.
    Tout ce qui brille n'est pas or... Le langage python m'a beaucoup aidé de son côté "programmation facile", et en même temps la théorie de la musique...
    Comment situer cette expérience parmi nos journées passantes, faire en sorte de se contenter des meilleurs moments... Pour en arriver à la rencontre de cette culture, pour ceux qui l'on côtoyé, ont vécus des instants de lumière. On ne peut pas jouer avec les objets, sans penser aux mouvements dans le temps. On ne peut pas non plus, découvrir un système complexe et parfait et faire comme si de rien était... Notre époque est faite de trop de questions imprécises, trop de réponses approximatives. Comme si on pouvait monnayer la pensée, avec des actes politiques (n'importe quoi)

    Moi, je suis un de ceux qui travaillent pour une vie de nouvelles terres virtuelles
    Mais, pas pour ceux qui travaillent pour une vie qui restera toujours un rêve

  20. #20
    Invité
    Invité(e)
    Par défaut De mieux en mieux
    Laissez moi travailler, je dors. Car, en chiffonnant le côté brillant de l'histoire. Elle retrouve tout son éclat
    Laissez les mystères chromatiques de la musique de côté, en prenant l'air du grand large de l'ère chromane.
    C'est qu'à cette époque :
    Il n'y avait qu'une seule gamme chromatique majeur, elle menait l'empire chromatique de son premier pas.
    La gamme chromatique majeure est en relation avec la gamme naturelle, elle déploie deux pôles altératifs.
    Il y a un deuxième choix de chromatisme, la gamme chromatique atonale qui ne réagit pas aux mêmes règles.
    En gros, c'est facile à comprendre
    1 Le dédoublement chromatique
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    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
     
            def chrome(self):
                    if self.pretrans[0] == 1:
                            self.chm.destroy()
                            self.pretrans[0] = 0
                            self.btchr.invoke()
                    else:
                            self.pretrans[0] = 1
                            ch0 = 0
                            self.chm = Toplevel(self)
                            self.chm.title('Entité Gammique : Chromatisme')
                            # Sélection du mode chromatique (naturel) ou (atonal)
                            frchm = Frame(self.chm,width=200,height=10)
                            frchm.pack(side=BOTTOM)
                            btchn = Button(frchm,text ='Chrome naturel',width=30,bg ='ivory', command=lambda: self.actuac(2))
                            btchn.pack(side = LEFT)
                            btcha = Button(frchm,text ='Chrome atonal',width=30,bg ='ivory', command=lambda: self.actuac(4))
                            btcha.pack(side = RIGHT)
                            frchm_ = Frame(self.chm,width=200,height=10)
                            frchm_.pack(side=TOP)
                            # Fenêtre écran_résultat
                            chrcan = Canvas(self.chm,bg='white', height=300,width=600)
                            chrcan.pack()
                            lbchtxt = Label(frchm_, text ="Chromatismes", fg = 'red').pack()
                            # Le pas graphique entre 2 notes = 10, en cotation horizontale
                            # self.tablenotes : Conteneur diatonique | Calcul graphique horizontal
                            # self.tablehaute : Conteneur diatonique | Calcul graphique vertical
                            # self.tbdegre : Contient le mode tonique en cours
                            # self.chrgen : Tableau graphique chromatique( note , signe ,,, )
                            chrmaj = [0,20,40,50,70,90,110]         # Forme graphique majeure
                            chnat_aug = [1,2,4,5,6] ; chnat_min = [2,3,5,6,7]
                            chr_trans = [] ; chr_curs = []
                            chr_lepas = 10
                            chrselect = self.btchr.cget('text')
                            # self.tablenotes : Conteneur diatonique | Calcul graphique horizontal
                            cy_zer = self.tbdegre[0]        # Premier degré de la gamme
                            for cy_ in range(7):
                                    if cy_ == 0:
                                            cy_inter = self.tablenotes[cy_zer]-0
                                    if self.tablenotes[cy_zer] < cy_inter:
                                            cy_trans = self.tablenotes[cy_zer] - cy_inter + 120
                                    else:
                                            cy_trans = self.tablenotes[cy_zer] - cy_inter
                                    chr_trans.append(cy_trans)      # Transformé élémentaire
                                    #(chr_trans[cy_])               # Contenu graphique diatonique
                                    chr_curs.append(self.cursifs[cy_zer])
                                    cy_zer +=1
                                    if cy_zer > 6: cy_zer = 0
                            # Génération élémentaire du tableau chromatique
                            cz_ = cx_tr = cn_ = 0 ; cx_uu = 1
                            chtop6 = chr_trans[6]//10
                            xcpos_=180 ; ycpos_=150 ; chposx = 0
                            rb_=15
                            chrcan.create_line(15, 150, 585, 150, fill ='blue')
                            for cx_ in range(12):
                                    c1_ = c2_ = c3_ = c4_ = c5_ = c6_ = c7_ = -1      # -1 = Emplacement chromatique
                                    c2_ax = c2_mx = c3_a = c3_m = c4_a = c4_m = comp = 0
                                    coltyp = coltyp2 = 'black'
                                    if cx_ == 0:
                                            c1_ = chr_trans[cx_tr]          # Incrustation diatonique
                                            c2_ = chr_curs[cx_tr]       # Hauteur tonale
                                            c3_ = self.decore[cx_tr][1:]    # Note naturelle
                                            c4_ =  self.dechire[(0, cx_uu)] # Valeur tonale
                                            cx_tr += 1 ; cx_uu += 1
                                            chposx += 1 ; chposyn = c4_
                                            xb_=xcpos_+(chposx*30)
                                            ybn_=ycpos_-(chposyn*30)
                                            chvow_n = c2_, c3_
                                            chrcan.create_oval(xb_-rb_,ybn_-rb_,xb_+rb_,ybn_+rb_,fill=coltyp)
                                            chrcan.create_text(xb_,ybn_,text=chvow_n,font='bold',fill='white')
                                    else:
                                            if chr_trans[cx_tr] == cx_*10:
                                                    c1_ = chr_trans[cx_tr]
                                                    c2_ = chr_curs[cx_tr]
                                                    c3_ = self.decore[cx_tr][1:]
                                                    c4_ =  self.dechire[(0, cx_uu)]
                                                    cx_tr += 1 ; cx_uu += 1
                                                    chposx += 1 ; chposyn = c4_
                                                    xb_=xcpos_+(chposx*30)
                                                    ybn_=ycpos_-(chposyn*30)
                                                    chvow_n = c2_, c3_
                                                    chrcan.create_oval(xb_-rb_,ybn_-rb_,xb_+rb_,ybn_+rb_,fill=coltyp)
                                                    chrcan.create_text(xb_,ybn_,text=chvow_n,font='bold',fill='white')
                                            else:
                                                    comp = -1
                                            if comp == -1 and cn_ < 5:
                                                    if chrselect == 'Chrome atonal':
                                                            if chtop6 < cx_:
                                                                    chpre = chr_trans[6]//10
                                                                    chsui = chr_trans[0]//10
                                                                    c2_pre = chr_curs[6]
                                                                    c2_sui = chr_curs[0]
                                                                    c3_pre = self.decore[6][1:]
                                                                    c3_sui = self.decore[0][1:]
                                                                    c4_pre = self.dechire[(0,7)]
                                                                    c4_sui = self.dechire[(0,1)]
                                                            else:
                                                                    chpre = chr_trans[cx_tr -1]//10
                                                                    chsui = chr_trans[cx_tr]//10
                                                                    c2_pre = chr_curs[cx_tr -1]
                                                                    c2_sui = chr_curs[cx_tr]
                                                                    c3_pre = self.decore[cx_tr -1][1:]
                                                                    c3_sui = self.decore[cx_tr][1:]
                                                                    c4_pre = self.dechire[(0,cx_tr)]
                                                                    c4_sui = self.dechire[(0,cx_tr +1)]
                                                            tg_pre = cx_ - chpre
                                                            tg_sui = cx_ - chsui
                                                            c2_ax = tg_pre + c2_pre
                                                            c2_mx = tg_sui + c2_sui
                                                            c3_a = c3_pre
                                                            c3_m = c3_sui
                                                            c4_a = c4_pre + tg_pre
                                                            c4_m = c4_sui + tg_sui
                                                    if chrselect == 'Chrome naturel':
                                                            id_a = chnat_aug[cn_]-1         # Ordre chromatique majeur(#)(7)
                                                            id_m = chnat_min[cn_]-1         # Ordre chromatique mineur(b)(7)
                                                            c2_a = chr_curs[id_a]       # Hauteur tonale(b ou #)(7)
                                                            c2_m = chr_curs[id_m]
                                                            c3_a = self.decore[id_a][1:]    # Note naturelle(7)
                                                            c3_m = self.decore[id_m][1:]
                                                            tg_a = chr_trans[id_a]//10      # Hauteur graphique originale(12)
                                                            tg_m = chr_trans[id_m]//10
                                                            tg_a1 = chrmaj[id_a]//10        # Hauteur graphique majeure(7)(c4_a)
                                                            tg_m1 = chrmaj[id_m]//10
                                                            tg_a2 = cx_ - tg_a              # Hauteur tonale signée, non nulle
                                                            tg_m2 = cx_ - tg_m
                                                            c2_ax =  tg_a2 + c2_a           # Hauteur tonale en arrivée signée
                                                            c2_mx = c2_m + tg_m2
                                                            c4_a = cx_ - tg_a1              # Valeur tonale (tg_a1 = maj)
                                                            c4_m = cx_ - tg_m1
                                                    # c2_ax | mx : Altération Hauteur
                                                    if c2_ax >= 0:                          # Table des altérations utiles
                                                            c2_a1 = self.nordiese[c2_ax]
                                                            coltyp1 = 'blue'
                                                    else:
                                                            c2_a1 = self.subemol[c2_ax]
                                                            coltyp1 = 'blue'
                                                    if c2_mx >= 0:
                                                            c2_m1 = self.nordiese[c2_mx]
                                                            coltyp2 = 'orange'
                                                    else:
                                                            c2_m1 = self.subemol[c2_mx]
                                                            coltyp2 = 'orange'
                                                    # c4_a | m : Altération Valeur
                                                    if c4_a >= 0:
                                                            c4_a1 = self.nordiese[c4_a]
                                                    else:
                                                            c4_a1 = self.subemol[c4_a]
                                                    if c4_m >= 0:
                                                            c4_m1 = self.nordiese[c4_m]
                                                    else:
                                                            c4_m1 = self.subemol[c4_m]
                                                    cn_ +=1 ; chposx += 1
                                                    c2_ = c2_a1
                                                    c3_ = c3_a
                                                    c4_ = c4_a1
                                                    c5_ = c2_m1
                                                    c6_ = c3_m
                                                    c7_ = c4_m1
                                                    chposya = c4_a ; chposym = c4_m
                                                    #print('c2x :',c2_a1,'mx :',c2_m1)
                                                    xb_=xcpos_+(chposx*30)
                                                    yb1_=ycpos_-(chposya*30)
                                                    chvow_a = c3_,c4_
                                                    chrcan.create_oval(xb_-rb_,yb1_-rb_,xb_+rb_,yb1_+rb_,fill=coltyp1)
                                                    chrcan.create_text(xb_,yb1_,text=chvow_a,font='bold',fill='white')
                                                    yb2_=ycpos_-(chposym*30)
                                                    chvow_m = c6_,c7_
                                                    chrcan.create_oval(xb_-rb_,yb2_-rb_,xb_+rb_,yb2_+rb_,fill=coltyp2)
                                                    chrcan.create_text(xb_,yb2_,text=chvow_m,font='bold',fill='white')
                                    self.chrgen[(cx_)] = [cz_],[c1_],[c2_],[c3_],[c4_],[c5_],[c6_],[c7_]
                                    cz_ += chr_lepas
                                    #print(self.chrgen[(cx_)])
                                    # Génération analogique du tableau chromatique
                                    #chrcan = Canvas(height=300,width=600)
                                    chvow = 'Gamme chromatique :', chrselect
                                    chrcan.create_line(5, 15, 5, 5, fill ='black')
                                    chrcan.create_text(120,10,text=chvow,fill='red')
                            del(chr_trans[:])       # Remise à zéro diatonique(int)
    2 Le total dédoublement chromatique
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    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
    1001
    1002
    1003
    1004
    1005
    1006
    1007
    1008
    1009
    1010
    1011
    1012
    1013
    1014
    1015
    1016
    1017
    1018
    1019
    1020
    1021
    1022
    1023
    1024
    1025
    1026
    1027
    1028
    1029
    1030
    1031
    1032
    1033
    1034
    1035
    1036
    1037
    1038
    1039
    1040
    1041
    1042
    1043
    1044
    1045
    1046
    1047
    1048
    1049
    1050
    1051
    1052
    1053
    1054
    1055
    1056
    1057
    1058
    1059
    1060
    1061
    1062
    1063
    1064
    1065
    1066
    1067
    1068
    1069
    1070
    1071
    1072
    1073
    1074
    1075
    1076
    1077
    1078
    1079
    1080
    1081
    1082
    1083
    1084
    1085
    1086
    1087
    1088
    1089
    1090
    1091
    1092
    1093
    1094
    1095
    1096
    1097
    1098
    1099
    1100
    1101
    1102
    1103
    1104
    1105
    1106
    1107
    1108
    1109
    1110
    1111
    1112
    1113
    1114
    1115
    1116
    1117
    1118
    1119
    1120
    1121
    1122
    1123
    1124
    1125
    1126
    1127
    1128
    1129
    1130
    1131
    1132
    1133
    1134
    1135
    1136
    1137
    1138
    1139
    1140
    1141
    1142
    1143
    1144
    1145
    1146
    1147
    1148
    1149
    1150
    1151
    1152
    1153
    1154
    1155
    1156
    1157
    1158
    1159
    1160
    1161
    1162
    1163
    1164
    1165
    1166
    1167
    1168
    1169
    1170
    1171
    1172
    1173
    1174
    1175
    1176
    1177
    1178
    1179
    1180
    1181
    1182
    1183
    1184
    1185
    1186
    1187
    1188
    1189
    1190
    1191
    1192
    1193
    1194
    1195
    1196
    1197
    1198
    1199
    1200
    1201
    1202
    1203
    1204
    1205
    1206
    1207
    1208
    1209
    1210
    1211
    1212
    1213
    1214
    1215
    1216
    1217
    1218
    1219
    1220
    1221
    1222
    1223
    1224
    1225
    1226
    1227
    1228
    1229
    1230
     
    #!/usr/bin/env python 
    # -*- coding: utf-8 -*-
    # *
    # Application gammique évolutive
    # Opération = Envol système
    # ProgamV3epyco
    #
    from tkinter import *
    from tkinter.font import Font
    import winsound
    import wave, math, binascii
     
    class Gammique(Tk):
            """ Ramification Gammique """
            def __init__(self):
                    Tk.__init__(self)
                    "Tableau de bord"
                    # Titre principal
                    self.title('Entité Gammique :')
     
                    # Fenêtre écran_résultat
                    self.can=Canvas(self,bg='white', height=550,width=800)
                    self.can.pack(side=RIGHT)
                    # Fenêtre des utilités
                    self.cad=Frame(self, width=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
                    ##self.fichnom = les noms des fichiers audio_notes (communs)
                    self.presaudio = 0      # Utile au bouton accord/sans le résultat "winsound"
                    self.gamula = ['C','D','E','F','G','A','B']
                    self.framno = ['','','','','','','']
                    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()
                    self.btaud2.pack_forget()               # Pantomime
     
                    # Bouton choix chromatique
                    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.chrgen = {}        # Tableau chromatique généré
                    self.pretrans = [0]
                    ntchtxt = 'Chromes'
                    self.btchr=Button(self.cad,text = ntchtxt,width=15,bg='light blue', command=self.chrome)
                    self.btchr.pack()
     
                    # Bouton tableaux instruments
                    self.bttab=Button(self.cad,text ='Tabla_inactif',width=15,bg='light blue')
                    self.bttab.pack()
     
                    # Bouton accords
                    ##self.fichacc = les noms des fichiers audio_accords (communs)
                    self.presens = [0]
                    self.accdiese = ['','+','x','^','+^','x^','^^']         # Tableaux des accords et des altérations
                    self.accbemol = ['','**','°*','-*','*','°','-']         # Tableaux des accords et des altérations
                    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 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=[
                            Radiobutton(
                                    self.cad,
                                    variable=variable,
                                    text=text,
                                    value=value,
                                    command=command,
                            )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),
                            )
                    ]
                    for i in self.rad: i.pack()
                    self.rad[1].select()
     
                    # Les notes cursives scalpha : Graduations gérées.
                    self.sca=[
                            Scale(
                                    self,
                                    length=300,
                                    orient=HORIZONTAL,
                                    label=label,
                                    troughcolor=color,
                                    sliderlength=20,
                                    showvalue=1,
                                    from_=f,
                                    to=t,
                                    tickinterval=1,
                                    command=command,
                            ) for (label, color, f, t, command) in (
                                    ("C", "black", 0, 5, self.scanote1),
                                    ("D", "green", -1, 4, self.scanote2),
                                    ("E", "blue", -2, 3, self.scanote3),
                                    ("F", "grey", -2, 3, self.scanote4),
                                    ("G", "red", -3, 2, self.scanote5),
                                    ("A", "orange", -4, 1, self.scanote6),
                                    ("B", "yellow", -5, 0, self.scanote7),
                                    ("CDEFGAB", "ivory", -12, 12, self.scanote8),
                            )
                    ]
                    for x in self.sca: x.pack()
     
                    # Bouton gamme_naturelle
                    self.btzer=Button(self,text ='Zéro',width=25,command=self.zero)
                    self.btzer.pack()
                    # Bouton gamme_calculée
                    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()
                    self.btgama.pack_forget()               # Pantomime
            # __init__()
     
            def chrome(self):
                    if self.pretrans[0] == 1:
                            self.chm.destroy()
                            self.pretrans[0] = 0
                            self.btchr.invoke()
                    else:
                            self.pretrans[0] = 1
                            ch0 = 0
                            self.chm = Toplevel(self)
                            self.chm.title('Entité Gammique : Chromatisme')
                            # Sélection du mode chromatique (naturel) ou (atonal)
                            frchm = Frame(self.chm,width=200,height=10)
                            frchm.pack(side=BOTTOM)
                            btchn = Button(frchm,text ='Chrome naturel',width=30,bg ='ivory', command=lambda: self.actuac(2))
                            btchn.pack(side = LEFT)
                            btcha = Button(frchm,text ='Chrome atonal',width=30,bg ='ivory', command=lambda: self.actuac(4))
                            btcha.pack(side = RIGHT)
                            frchm_ = Frame(self.chm,width=200,height=10)
                            frchm_.pack(side=TOP)
                            # Fenêtre écran_résultat
                            chrcan = Canvas(self.chm,bg='white', height=300,width=600)
                            chrcan.pack()
                            lbchtxt = Label(frchm_, text ="Chromatismes", fg = 'red').pack()
                            # Le pas graphique entre 2 notes = 10, en cotation horizontale
                            # self.tablenotes : Conteneur diatonique | Calcul graphique horizontal
                            # self.tablehaute : Conteneur diatonique | Calcul graphique vertical
                            # self.tbdegre : Première note du mode tonique en cours
                            # self.chrgen : Tableau graphique chromatique( note , signe ,,, )
                            chrmaj = [0,20,40,50,70,90,110]         # Forme graphique majeure
                            chnat_aug = [1,2,4,5,6] ; chnat_min = [2,3,5,6,7]
                            chr_trans = [] ; chr_curs = []
                            chr_lepas = 10
                            chrselect = self.btchr.cget('text')
                            # self.tablenotes : Conteneur diatonique | Calcul graphique horizontal
                            cy_zer = self.tbdegre[0]        # Premier degré de la gamme
                            for cy_ in range(7):
                                    if cy_ == 0:
                                            cy_inter = self.tablenotes[cy_zer]-0
                                    if self.tablenotes[cy_zer] < cy_inter:
                                            cy_trans = self.tablenotes[cy_zer] - cy_inter + 120
                                    else:
                                            cy_trans = self.tablenotes[cy_zer] - cy_inter
                                    chr_trans.append(cy_trans)      # Transformé élémentaire
                                    #(chr_trans[cy_])               # Contenu graphique diatonique
                                    chr_curs.append(self.cursifs[cy_zer])
                                    cy_zer +=1
                                    if cy_zer > 6: cy_zer = 0
                            # Génération élémentaire du tableau chromatique
                            cz_ = cx_tr = cn_ = 0 ; cx_uu = 1
                            chtop6 = chr_trans[6]//10
                            xcpos_=180 ; ycpos_=150 ; chposx = 0
                            rb_=15
                            chrcan.create_line(15, 150, 585, 150, fill ='blue')
                            for cx_ in range(12):
                                    c1_ = c2_ = c3_ = c4_ = c5_ = c6_ = c7_ = -1      # -1 = Emplacement chromatique
                                    c2_ax = c2_mx = c3_a = c3_m = c4_a = c4_m = comp = 0
                                    coltyp = coltyp2 = 'black'
                                    if cx_ == 0:
                                            c1_ = chr_trans[cx_tr]          # Incrustation diatonique
                                            c2_ = chr_curs[cx_tr]       # Hauteur tonale
                                            c3_ = self.decore[cx_tr][1:]    # Note naturelle
                                            c4_ =  self.dechire[(0, cx_uu)] # Valeur tonale
                                            cx_tr += 1 ; cx_uu += 1
                                            chposx += 1 ; chposyn = c4_
                                            xb_=xcpos_+(chposx*30)
                                            ybn_=ycpos_-(chposyn*30)
                                            chvow_n = c2_, c3_
                                            chrcan.create_oval(xb_-rb_,ybn_-rb_,xb_+rb_,ybn_+rb_,fill=coltyp)
                                            chrcan.create_text(xb_,ybn_,text=chvow_n,font='bold',fill='white')
                                    else:
                                            if chr_trans[cx_tr] == cx_*10:
                                                    c1_ = chr_trans[cx_tr]
                                                    c2_ = chr_curs[cx_tr]
                                                    c3_ = self.decore[cx_tr][1:]
                                                    c4_ =  self.dechire[(0, cx_uu)]
                                                    cx_tr += 1 ; cx_uu += 1
                                                    chposx += 1 ; chposyn = c4_
                                                    xb_=xcpos_+(chposx*30)
                                                    ybn_=ycpos_-(chposyn*30)
                                                    chvow_n = c2_, c3_
                                                    chrcan.create_oval(xb_-rb_,ybn_-rb_,xb_+rb_,ybn_+rb_,fill=coltyp)
                                                    chrcan.create_text(xb_,ybn_,text=chvow_n,font='bold',fill='white')
                                            else:
                                                    comp = -1
                                            if comp == -1 and cn_ < 5:
                                                    if chrselect == 'Chrome atonal':
                                                            if chtop6 < cx_:
                                                                    chpre = chr_trans[6]//10
                                                                    chsui = chr_trans[0]//10
                                                                    c2_pre = chr_curs[6]
                                                                    c2_sui = chr_curs[0]
                                                                    c3_pre = self.decore[6][1:]
                                                                    c3_sui = self.decore[0][1:]
                                                                    c4_pre = self.dechire[(0,7)]
                                                                    c4_sui = self.dechire[(0,1)]
                                                            else:
                                                                    chpre = chr_trans[cx_tr -1]//10
                                                                    chsui = chr_trans[cx_tr]//10
                                                                    c2_pre = chr_curs[cx_tr -1]
                                                                    c2_sui = chr_curs[cx_tr]
                                                                    c3_pre = self.decore[cx_tr -1][1:]
                                                                    c3_sui = self.decore[cx_tr][1:]
                                                                    c4_pre = self.dechire[(0,cx_tr)]
                                                                    c4_sui = self.dechire[(0,cx_tr +1)]
                                                            tg_pre = cx_ - chpre
                                                            tg_sui = cx_ - chsui
                                                            c2_ax = tg_pre + c2_pre
                                                            c2_mx = tg_sui + c2_sui
                                                            c3_a = c3_pre
                                                            c3_m = c3_sui
                                                            c4_a = c4_pre + tg_pre
                                                            c4_m = c4_sui + tg_sui
                                                    if chrselect == 'Chrome naturel' or 'Chromes':
                                                            id_a = chnat_aug[cn_]-1         # Ordre chromatique majeur(#)(7)
                                                            id_m = chnat_min[cn_]-1         # Ordre chromatique mineur(b)(7)
                                                            c2_a = chr_curs[id_a]       # Hauteur tonale(b ou #)(7)
                                                            c2_m = chr_curs[id_m]
                                                            c3_a = self.decore[id_a][1:]    # Note naturelle(7)
                                                            c3_m = self.decore[id_m][1:]
                                                            tg_a = chr_trans[id_a]//10      # Hauteur graphique originale(12)
                                                            tg_m = chr_trans[id_m]//10
                                                            tg_a1 = chrmaj[id_a]//10        # Hauteur graphique majeure(7)(c4_a)
                                                            tg_m1 = chrmaj[id_m]//10
                                                            tg_a2 = cx_ - tg_a              # Hauteur tonale signée, non nulle
                                                            tg_m2 = cx_ - tg_m
                                                            c2_ax =  tg_a2 + c2_a           # Hauteur tonale en arrivée signée
                                                            c2_mx = c2_m + tg_m2
                                                            c4_a = cx_ - tg_a1              # Valeur tonale (tg_a1 = maj)
                                                            c4_m = cx_ - tg_m1
                                                    # c2_ax | mx : Altération Hauteur
                                                    if c2_ax >= 0:                          # Table des altérations utiles
                                                            c2_a1 = self.nordiese[c2_ax]
                                                            coltyp1 = 'blue'
                                                    else:
                                                            c2_a1 = self.subemol[c2_ax]
                                                            coltyp1 = 'blue'
                                                    if c2_mx >= 0:
                                                            c2_m1 = self.nordiese[c2_mx]
                                                            coltyp2 = 'orange'
                                                    else:
                                                            c2_m1 = self.subemol[c2_mx]
                                                            coltyp2 = 'orange'
                                                    # c4_a | m : Altération Valeur
                                                    if c4_a >= 0:
                                                            c4_a1 = self.nordiese[c4_a]
                                                    else:
                                                            c4_a1 = self.subemol[c4_a]
                                                    if c4_m >= 0:
                                                            c4_m1 = self.nordiese[c4_m]
                                                    else:
                                                            c4_m1 = self.subemol[c4_m]
                                                    cn_ +=1 ; chposx += 1
                                                    c2_ = c2_a1
                                                    c3_ = c3_a
                                                    c4_ = c4_a1
                                                    c5_ = c2_m1
                                                    c6_ = c3_m
                                                    c7_ = c4_m1
                                                    chposya = c4_a ; chposym = c4_m
                                                    #print('c2x :',c2_a1,'mx :',c2_m1)
                                                    xb_=xcpos_+(chposx*30)
                                                    yb1_=ycpos_-(chposya*30)
                                                    chvow_a = c3_,c4_
                                                    chrcan.create_oval(xb_-rb_,yb1_-rb_,xb_+rb_,yb1_+rb_,fill=coltyp1)
                                                    chrcan.create_text(xb_,yb1_,text=chvow_a,font='bold',fill='white')
                                                    yb2_=ycpos_-(chposym*30)
                                                    chvow_m = c6_,c7_
                                                    chrcan.create_oval(xb_-rb_,yb2_-rb_,xb_+rb_,yb2_+rb_,fill=coltyp2)
                                                    chrcan.create_text(xb_,yb2_,text=chvow_m,font='bold',fill='white')
                                    self.chrgen[(cx_)] = [cz_],[c1_],[c2_],[c3_],[c4_],[c5_],[c6_],[c7_]
                                    cz_ += chr_lepas
                                    #print(self.chrgen[(cx_)])
                                    # Génération analogique du tableau chromatique
                                    #chrcan = Canvas(height=300,width=600)
                                    chvow = 'Gamme chromatique :', chrselect
                                    chrcan.create_line(5, 15, 5, 5, fill ='black')
                                    chrcan.create_text(120,10,text=chvow,fill='red')
                            del(chr_trans[:])       # Remise à zéro diatonique(int)
     
            def actuac(self,a):
                    if a == 5:                      # def accord/Bouton fermer
                            self.acc.destroy()
                            self.presens[0]=0
                    elif a == 3:                    # def accord/Bouton actualiser
                            self.acc.destroy()
                            self.presens[0]=0
                            self.btaud2.invoke()
                            self.btacc.invoke()
                    elif a == 1:                    # def audio/Bouton audio
                            self.presaudio = 0
                            self.btaud2.invoke()
                    elif a == 2:
                            self.btchr.configure(text= 'Chrome naturel')    # def chrome/Bouton C_n
                            self.chm.destroy()
                            self.btchr.invoke()
                    elif a == 4:
                            self.btchr.configure(text= 'Chrome atonal')     # def chrome/Bouton C_a
                            self.chm.destroy()
                            self.btchr.invoke()
     
            def wavacc(self,w):
                    nbOctet = nbCanal = 1
                    fech = 64000
                    niveau = float(1)
                    duree = float(1/2)
                    nbEch = int(duree*fech) 
                    waplo = self.fichacc[w]
                    monac = wave.open(waplo,'wb')
                    param = (nbCanal,nbOctet,fech,nbEch,'NONE','not compressed')
                    monac.setparams(param)
                    amp = 127.5*niveau
                    vacc = [0,0,0,0]
                    ww = w
                    for vv in range(4):
                            if ww == 7:
                                    ww = 0
                                    vacc[vv] = self.framno[ww]*2
                            elif ww == 8:
                                    ww = 1
                                    vacc[vv] = self.framno[ww]*2
                            else: vacc[vv] = self.framno[ww]
                            ww +=2
                    freq1 = vacc[0]*2
                    freq2 = vacc[1]*2
                    freq3 = vacc[2]*2
                    freq4 = vacc[3]*2
                    for i in range(0,nbEch):
                            val1 = wave.struct.pack('B',int(128.0 + amp*math.sin(2.0*math.pi*freq1*i/fech)))
                            val2 = wave.struct.pack('B',int(128.0 + amp*math.sin(2.0*math.pi*freq2*i/fech)))
                            val3 = wave.struct.pack('B',int(128.0 + amp*math.sin(2.0*math.pi*freq3*i/fech)))
                            val4 = wave.struct.pack('B',int(128.0 + amp*math.sin(2.0*math.pi*freq4*i/fech)))
                            monac.writeframes(val1+val2+val3+val4)
                    monac.close()
                    accwav = self.fichacc[w]
                    winsound.PlaySound(accwav,winsound.SND_FILENAME)
                    # Windsound : Ne peut être utilisé qu'avec windows
     
            # L'harmonie des accords
            def accord(self):
                    if self.presens[0] == 1:
                            self.acc.destroy()
                            self.presens[0]=0
                            self.btaud2.invoke()
                            self.btacc.invoke()
                    else:
                            self.acc = Toplevel(self)
                            self.acc.title('Entité Gammique : Harmonie')
                            self.presens[0]=1
                            if self.presaudio == 0:
                                    self.presaudio = 1
                            self.btaud2.invoke()
                            # Définition du style d'écriture
                            fotyp = Font(family='Liberation Serif', size=12)
                            fofin = Font(family='Liberation Serif', size=8)
                            fonot = Font(family='Liberation Serif', size=14)
                            # Fenêtrage des widgets
                            fra = Frame(self.acc,width=100,height=50)
                            fra.pack(side=BOTTOM)
                            fraleft = Frame(self.acc,width=30,height=30)
                            fraleft.pack(side=LEFT)
                            fraright = Frame(self.acc,width=30,height=30)
                            fraright.pack(side=RIGHT)
                            # Les accords 1357 de la gamme en cours (partie gauche(left))
                            self.bt1357 = Button(fra,text ='Actualiser',width=20,command=lambda: self.actuac(3))
                            self.bt1357.pack(side=LEFT)
                            lableft = Label(fraleft, text ='Accords 1357', fg = 'red').pack()
                            btaccleft = ['','','','','','','']
                            for i in range(7):
                                    btaccleft[i] = Button(fraleft,text='',bg='light blue',width=10,
                                                          command = lambda w=i: self.wavacc (w))
                                    btaccleft[i].pack()
                            # Les autres accords de la gamme en cours (partie droite(right))
                            btferm = Button(fra,text ='Fermer',width=20,bg ='light grey', command = lambda: self.actuac(5))
                            btferm.pack(side=RIGHT)
                            labrigh = Label(fraright, text ='Autre accord', fg = 'blue').pack()
                            btautq = Button(fraright,text ='inactif',bg='light blue',width=10).pack()
                            # L'espace blanc central pour écrire l'accord
                            caaacc = Canvas(self.acc,bg='white', height=300,width=300)
                            caaacc.pack()
                            caaacc.delete(ALL)
                            # Types d'accords 1357 : chr(248) = ( ø )
                            # Majeur_7ème(maj7). Mineur_7ème(7). Demi-diminué_7ème(ø7). Diminué_7ème(°7)
                            accmaj7 = [0,0,0,0] ; acc7 = [0,0,0,-1]
                            accdd7 = [0,-1,-1,-1] ; accd7 = [0,-1,-1,-2]
                            tbtxgd = ['1','3','5','7']
                            tbacc7 = []     # Tableau de l'accord forme(str)
                            tbsign = []     # Tableau de l'accord forme(int)
                            tbfine = []     # Tableau des accords forme fine
                            tbgene = []     # Tableau des accords forme écriture
                            tblect = []     # Tableau des accords forme lecture
                            # self.decore[] = altération et note tonique de l'accord
                            xcc, ycc = 120, 80 ; xtt = 20
                            ypos = 26 ; xdd = ydd = 0
                            for decdegre in range(7):
                                    accnote = self.decore[decdegre][1:]
                                    accsign = self.decore[decdegre][:1]
                                    # self.declare[] = altérations "3.5.7" en rang
                                    decnote = 1
                                    t_fin = 0 ; txga = txdr = ''
                                    ydd = ycc+(ypos*decdegre)
                                    xdd = xcc + 30
                                    xgg = xcc - 30
                                    while decnote < 8:      # Définition de l'accord modal(str)
                                            decalt = self.declare[(decdegre,decnote)]
                                            tbacc7.append(decalt)
                                            decnote += 2
                                    # Transcodage de l'accord de type original(str)
                                    for a_ in range(4):
                                            z_ = -1
                                            a_acc = tbacc7[a_]
                                            for b_ in range(7):     # Lecture et transformation
                                                    if a_acc == '':
                                                            b_alt = 0
                                                            tbsign.append(b_alt)
                                                            break
                                                    if a_acc == self.accdiese[b_]:
                                                            b_alt = b_
                                                            tbsign.append(b_alt)
                                                            break
                                                    if a_acc == self.accbemol[z_]:
                                                            b_alt = z_
                                                            tbsign.append(b_alt)
                                                            break
                                                    z_ += -1
                                    # Définition des accords de 7ème
                                    if tbsign[3] == 0:
                                            # L'accord est majeur 7(maj7)
                                            typacc = 'maj7'
                                            finacc = tbsign
                                            for t_ in range(4):
                                                    txsg = '' ; zone = 0
                                                    if accmaj7[t_] == tbsign[t_]:
                                                            t_fin = 0
                                                    else:
                                                            t_fin = tbsign[t_]-accmaj7[t_]
                                                    if t_ == 1 and t_fin != 0:
                                                            if t_fin < -1:          # Zone de droite
                                                                    txsg = self.accbemol[t_fin]+tbtxgd[t_]
                                                                    zone = 1
                                                            elif t_fin > -1 :       # Zone de droite
                                                                    txsg = self.accdiese[t_fin]+tbtxgd[t_]
                                                                    zone = 1
                                                            else:                   # Zone de gauche
                                                                    txsg = self.accbemol[t_fin]
                                                                    zone = -1
                                                    if t_ == 2 and t_fin != 0:
                                                            if t_fin < 0:           # Zone de droite
                                                                    txsg = self.accbemol[t_fin]+tbtxgd[t_]
                                                                    zone = 1
                                                            elif t_fin > 2:         # Zone de droite
                                                                    txsg = self.accdiese[t_fin]+tbtxgd[t_]
                                                                    zone = 1
                                                            else:                   # Zone de gauche
                                                                    txsg = self.accdiese[t_fin]
                                                                    zone = -1
                                                    if t_ == 3 and t_fin != 0:      # Zone de droite
                                                            txsg = self.accbemol[t_fin]+tbtxgd[t_]
                                                            zone = 1
                                                    if zone == 1:                   # Zone de droite
                                                            txdr += txsg
                                                            caaacc.create_text(xdd,ydd,text=txsg,font=fofin,fill='blue')
                                                            xdd += 20
                                                    if zone == -1:                  # Zone de gauche
                                                            txga += txsg
                                                            caaacc.create_text(xgg,ydd,text=txsg,font=fofin,fill='blue')
                                                            xgg -= 20
                                                    tbfine.append(t_fin)
                                            txbadr = txga + 'maj7' + txdr
                                            btaccleft[decdegre].configure(text = txbadr)
                                            caaacc.create_text(xcc,ydd,text='maj7',font=fotyp,fill='black')
                                            caaacc.create_text(xtt,ydd,text=accsign,font=fofin,fill='blue')
                                            caaacc.create_text(xtt+20,ydd,text=accnote,font=fonot,fill='black')                                        
                                    if (tbsign[3] == -1):
                                            if (tbsign[1] or tbsign[2] >= 0) or ((tbsign[1] or tbsign[2]) < 0):
                                                    if tbsign[1] and tbsign[2] < 0: pass
                                                    else :
                                                            # L'accord est demi-diminué 7(7)
                                                            typacc = '7'
                                                            finacc = tbsign
                                                            for t_ in range(4):
                                                                    txsg = '' ; zone = 0
                                                                    if acc7[t_] == tbsign[t_]:
                                                                            t_fin = 0
                                                                    else:
                                                                            t_fin = tbsign[t_]-acc7[t_]
                                                                    if t_ == 1 and t_fin != 0:
                                                                            if t_fin < -1:          # Zone de droite
                                                                                    txsg = self.accbemol[t_fin]+tbtxgd[t_]
                                                                                    zone = 1
                                                                            elif t_fin > -1 :       # Zone de droite
                                                                                    txsg = self.accdiese[t_fin]+tbtxgd[t_]
                                                                                    zone = 1
                                                                            else:                   # Zone de gauche
                                                                                    txsg = self.accbemol[t_fin]
                                                                                    zone = -1
                                                                    if t_ == 2 and t_fin != 0:
                                                                            if t_fin < 0:           # Zone de droite
                                                                                    txsg = self.accbemol[t_fin]+tbtxgd[t_]
                                                                                    zone = 1
                                                                            elif t_fin > 2:         # Zone de droite
                                                                                    txsg = self.accdiese[t_fin]+tbtxgd[t_]
                                                                                    zone = 1
                                                                            else:                   # Zone de gauche
                                                                                    txsg = self.accdiese[t_fin]
                                                                                    zone = -1
                                                                    if t_ == 3 and t_fin != 0:      # Zone de droite
                                                                            txsg = self.accbemol[t_fin]+tbtxgd[t_]
                                                                            zone = 1
                                                                    if zone == 1:                   # Zone de droite
                                                                            txdr += txsg
                                                                            caaacc.create_text(xdd,ydd,text=txsg,font=fofin,fill='blue')
                                                                            xdd += 20
                                                                    if zone == -1:                  # Zone de gauche
                                                                            txga += txsg
                                                                            caaacc.create_text(xgg,ydd,text=txsg,font=fofin,fill='blue')
                                                                            xgg -= 20
                                                                    tbfine.append(t_fin)
                                                            txbadr = txga + '7' + txdr
                                                            btaccleft[decdegre].configure(text = txbadr)
                                                            caaacc.create_text(xcc,ydd,text='7',font=fotyp,fill='black')
                                                            caaacc.create_text(xtt,ydd,text=accsign,font=fofin,fill='blue')
                                                            caaacc.create_text(xtt+20,ydd,text=accnote,font=fonot,fill='black')
                                    if (tbsign[3] == -1) and (tbsign[1] and tbsign[2] < 0):
                                            # L'accord est demi-diminué 7(ø7)
                                            typacc = 'ø7'
                                            finacc = tbsign
                                            for t_ in range(4):
                                                    txsg = '' ; zone = 0
                                                    if accdd7[t_] == tbsign[t_]:
                                                            t_fin = 0
                                                    else:
                                                            t_fin = tbsign[t_]-accdd7[t_]
                                                    if t_ == 1 and t_fin != 0:
                                                            if t_fin < -1:          # Zone de droite
                                                                    txsg = self.accbemol[t_fin]+tbtxgd[t_]
                                                                    zone = 1
                                                            elif t_fin > -1 :       # Zone de droite
                                                                    txsg = self.accdiese[t_fin]+tbtxgd[t_]
                                                                    zone = 1
                                                            else:                   # Zone de gauche
                                                                    txsg = self.accbemol[t_fin]
                                                                    zone = -1
                                                    if t_ == 2 and t_fin != 0:
                                                            if t_fin < 0:           # Zone de droite
                                                                    txsg = self.accbemol[t_fin]+tbtxgd[t_]
                                                                    zone = 1
                                                            elif t_fin > 2:         # Zone de droite
                                                                    txsg = self.accdiese[t_fin]+tbtxgd[t_]
                                                                    zone = 1
                                                            else:                   # Zone de gauche
                                                                    txsg = self.accdiese[t_fin]
                                                                    zone = -1
                                                    if t_ == 3 and t_fin != 0:      # Zone de droite
                                                            txsg = self.accbemol[t_fin]+tbtxgd[t_]
                                                            zone = 1
                                                    if zone == 1:                   # Zone de droite
                                                            txdr += txsg
                                                            caaacc.create_text(xdd,ydd,text=txsg,font=fofin,fill='blue')
                                                            xdd += 20
                                                    if zone == -1:                  # Zone de gauche
                                                            txga += txsg
                                                            caaacc.create_text(xgg,ydd,text=txsg,font=fofin,fill='blue')
                                                            xgg -= 20
                                                    tbfine.append(t_fin)
                                                    txbadr = txga + 'ø7' + txdr
                                                    btaccleft[decdegre].configure(text = txbadr)
                                                    caaacc.create_text(xcc,ydd,text='ø7',font=fotyp,fill='black')
                                                    caaacc.create_text(xtt,ydd,text=accsign,font=fofin,fill='blue')
                                                    caaacc.create_text(xtt+20,ydd,text=accnote,font=fonot,fill='black')
                                    if tbsign[3] < -1:
                                            # L'accord est diminué 7(°7)
                                            typacc = '°7'
                                            finacc = tbsign
                                            for t_ in range(4):
                                                    txsg = '' ; zone = 0
                                                    if accd7[t_] == tbsign[t_]:
                                                            t_fin = 0
                                                    else:
                                                            t_fin = tbsign[t_]-accd7[t_]
                                                    if t_ == 1 and t_fin != 0:
                                                            if t_fin < -1:          # Zone de droite
                                                                    txsg = self.accbemol[t_fin]+tbtxgd[t_]
                                                                    zone = 1
                                                            elif t_fin > -1 :       # Zone de droite
                                                                    txsg = self.accdiese[t_fin]+tbtxgd[t_]
                                                                    zone = 1
                                                            else:                   # Zone de gauche
                                                                    txsg = self.accbemol[t_fin]
                                                                    zone = -1
                                                    if t_ == 2 and t_fin != 0:
                                                            if t_fin < 0:           # Zone de droite
                                                                    txsg = self.accbemol[t_fin]+tbtxgd[t_]
                                                                    zone = 1
                                                            elif t_fin > 2:         # Zone de droite
                                                                    txsg = self.accdiese[t_fin]+tbtxgd[t_]
                                                                    zone = 1
                                                            else:                   # Zone de gauche
                                                                    txsg = self.accdiese[t_fin]
                                                                    zone = -1
                                                    if t_ == 3 and t_fin != 0:      # Zone de droite
                                                            txsg = self.accbemol[t_fin]+tbtxgd[t_]
                                                            zone = 1
                                                            xdd += 20
                                                    if zone == -1:                  # Zone de gauche
                                                            txga += txsg
                                                            caaacc.create_text(xgg,ydd,text=txsg,font=fofin,fill='blue')
                                                            xgg -= 20
                                                    tbfine.append(t_fin)
                                            txbadr = txga + '°7' + txdr
                                            btaccleft[decdegre].configure(text = txbadr)
                                            caaacc.create_text(xcc,ydd,text='°7',font=fotyp,fill='black')
                                            caaacc.create_text(xtt,ydd,text=accsign,font=fofin,fill='blue')
                                            caaacc.create_text(xtt+20,ydd,text=accnote,font=fonot,fill='black')
                                    tblect.append(tbsign[:4])
                                    tbgene.append(tbfine[:4])
                                    del(tbsign[:])     # Remise à zéro de l'accord(int)
                                    del(tbacc7[:])     # Remise à zéro de l'accord(str)
                                    del(tbfine[:])     # Remise à zéro de l'accord écriture
                            del(tblect[:])     # Remise à zéro forme lecture
                            del(tbgene[:])     # Remise à zéro forme écriture
     
            # Premiers pixels acoustiques
            def radio(self):
                    ay = '0'
                    ayay = self.tbdegre[0]
                    for n in range(7):
                            freqhtz=self.tablenotes[ayay]
                            if ay == '0': pass
                            else: freqhtz += 120
                            ayay += 1
                            if ayay > 6:
                                    ayay = 0
                                    ay = '1'
                            duration=240
                            winsound.Beep(freqhtz, duration)
     
            # Premières notes acoustiques
            def audio(self):
                    LA440 = 440 ; la2 = LA440/2 ; ula = 220/12
                    fabula = ['A','_','B','C','_','D','_','E','F','_','G','_','A']
                    # FC # Fréquences cursives (pixels)
                    notula = [] ; modula = []
                    for az in range(7):     # Construction tableau FC
                            notula.append(self.tablenotes[az])
                            mula = notula[az]/10-25         # Transition vers l'indice
                            modula.append(mula)             # Indice du tableau "sequla[]"
                    # TM # Tableau majeur
                    tabula = []
                    for ai in range(13):    # Construction tableau TM
                            paula=ai*ula+la2        # Calcul fréquence
                            tabula.append(paula)    # Tableau en écriture TM
                    # TF # Table des fréquences (1/12)
                    sequla = [] ; nomula = []
                    for ay in range(40):    # Construction tableau TF
                            if ay < 12:             # Niveau -1: Octave basse
                                    yula = tabula[ay]/2     # yula: TM/2
                                    nula = fabula[ay]       # nula: Notes naturelles
                            elif 11 < ay < 24:      # Niveau 0: Octave naturelle
                                    yula = tabula[ay-12]    # yula: Déviation de l'indice(ay)
                                    nula = fabula[ay-12]
                            elif 23 < ay < 37:      # Niveau 1: Octave haute
                                    yula = tabula[ay-24]*2  # yula: Déviation de l'indice(ay)+TM*2
                                    nula = fabula[ay-24]
                            elif 36 < ay < 41:      # Niveau 2: Octave relative
                                    yula = tabula[ay-36]*4  # yula: Déviation de l'indice(ay)+TM*4
                                    nula = fabula[ay-36]
                            sequla.append(yula)     # Tableau en écriture TF
                            nomula.append(nula)     # Tableau en écriture TF
                    # TR # Tableau des résultats (fréquences cursives)
                    freula = []
                    for ax in range(7):     # Construction tableau TR
                            xula = int(modula[ax])          # xula: Lecture indice-entier FC
                            qula = sequla[xula]             # qula: Lecture de fréquence TF
                            freula.append(qula)             # Tableau en écriture TR
                    aw2 = self.tbdegre[0]
                    diato = [] ; opoto = []
                    ax = '0'
                    for aw in range(7):     # Construction tableau TR-tonique
                            freqhtz = freula[aw2]
                            if ax == '0': diato.append(freqhtz)
                            else: diato.append(freqhtz*2)
                            opoto.append(self.gamula[aw2])
                            aw2 += 1
                            if aw2 > 6:
                                    aw2 = 0
                                    ax = '1'
                    # Partie échantillonnage
                    nbOctet = nbCanal = 1
                    fech = 64000
                    niveau = float(1/2)
                    duree = float(1/6)
                    nbEch = int(duree*fech) 
                    for fy in range(7):
                            toplo = self.fichnom[fy]
                            manote = wave.open(toplo,'wb')
                            param = (nbCanal,nbOctet,fech,nbEch,'NONE','not compressed')
                            manote.setparams(param)
                            freq = diato[fy]
                            self.framno[fy] = freq
                            amp = 127.5*niveau
                            for i in range(0,nbEch):
                                    val = wave.struct.pack('B',int(128.0 + amp*math.sin(2.0*math.pi*freq*i/fech)))
                                    manote.writeframes(val)
                            manote.close()
                    if self.presaudio == 0:
                            self.presaudio = 1
                            for fu in self.fichnom:
                                    winsound.PlaySound(fu,winsound.SND_FILENAME)
                                    # Windsound : Ne peut être utilisé qu'avec windows
                    del(modula[:]) ; del(tabula[:]) ; del(sequla[:])
                    del(nomula[:]) ; del(freula[:]) ; del(diato[:])
            # audio()
     
            # Les octaves du groupe RADIO
            def yoiioiioy(self):
                    xradfan=self.entfan.get()
                    xrad=self.variable.get()
                    mqdo=self.sca[0].get()
                    mqsi=self.sca[6].get()
                    yo=yoc=yod=yoe=yof=yog=yoa=yob=0
                    fyoc=fyod=fyoe=fyof=fyog=fyoa=fyob=0
                    tyoc=tyod=tyoe=tyof=tyog=tyoa=tyob=0
                    topgam=[yoc,yod,yoe,yof,yog,yoa,yob]
                    topform=[fyoc,fyod,fyoe,fyof,fyog,fyoa,fyob]
                    topto=[tyoc,tyod,tyoe,tyof,tyog,tyoa,tyob]
                    while yo < 7:
                            yioiy=yotop=topf=topt=0
                            yotop=topgam[yo]=self.sca[yo].get()                        
                            topf=topform[yo]=self.sca[yo].cget("from")
                            topt=topto[yo]=self.sca[yo].cget("to")
                            if xradfan == "IOI":
                                    if xrad == "YOI":
                                            if (mqdo>-1)and(mqsi<1): yioiy=yotop
                                            else:
                                                    yioiy=yotop+12
                                                    topf=topf+12
                                                    topt=topt+12
                                    elif xrad == "IOY":
                                            if (mqdo>-1)and(mqsi<1): yioiy= yotop
                                            else :
                                                    yioiy=yotop-12
                                                    topf=topf-12
                                                    topt=topt-12
                                    else : yioiy = yotop
                            elif xradfan == "YOI":
                                    if xrad == "IOI":
                                            if (mqdo>-1)and(mqsi<1): yioiy= yotop
                                            else :
                                                    yioiy=yotop-12
                                                    topf=topf-12
                                                    topt=topt-12
                                    elif xrad == "IOY":
                                            if (mqdo>-1)and(mqsi<1): yioiy= yotop
                                            else :
                                                    yioiy=yotop-24
                                                    topf=topf-24
                                                    topt=topt-24
                                    else : yioiy=yotop
                            else :
                                    if xrad == "YOI":
                                            if (mqdo>-1)and(mqsi<1): yioiy= yotop
                                            else :
                                                    yioiy=yotop+24
                                                    topf=topf+24
                                                    topt=topt+24
                                    elif xrad == "IOI":
                                            if (mqdo>-1)and(mqsi<1): yioiy= yotop
                                            else :
                                                    yioiy=yotop+12
                                                    topf=topf+12
                                                    topt=topt+12
                                    else : yioiy=yotop
                            if yo == 0: mqdo1 = yioiy
                            if yo == 6: mqsi1 = yioiy
                            self.sca[yo].configure(from_ = topf, to = topt)
                            self.sca[yo].set(yioiy)
                            yo+=1
                    # while yo
                    if xrad == "YOI": self.sca[7].configure(from_ = 0-mqdo1, to = 24-mqsi1)
                    elif xrad == "IOI": self.sca[7].configure(from_ = -12-mqdo1, to = 12-mqsi1)
                    elif xrad == "IOY": self.sca[7].configure(from_ = -24-mqdo1, to = 0-mqsi1)
                    xradfan=xrad
                    self.entfan.delete(0,END)
                    self.entfan.insert(END,xradfan)
                    self.btgama.invoke()
                    # print ('*')
            # yoiioiioy()
     
            # Moment self.gama
            def momentgama(self,event):
                    self.btgama.invoke()
     
            # Définition des curseurs
            def scanote1(self,xc):
                    do=int(xc)
                    xsi=self.sca[6].get()
                    xre=self.sca[1].get()
                    if do<xsi:self.sca[6].set(do)
                    if do>xre+1 :self.sca[1].set(do-1)
                    # Initialise sca[7](from_)
                    xxrad=self.variable.get()
                    if xxrad == "YOI": self.sca[7].configure(from_ = 0-do, to = 24-xsi)
                    elif xxrad == "IOI": self.sca[7].configure(from_ = -12-do, to = 12-xsi)
                    elif xxrad == "IOY": self.sca[7].configure(from_ = -24-do, to = 0-xsi)
                    self.bind('<ButtonRelease-1>',self.momentgama)
            # scanote1()
     
            def scanote2(self,xd):
                    re=int(xd)
                    xdo=self.sca[0].get()
                    xmi=self.sca[2].get()
                    if re<xdo-1:self.sca[0].set(re+1)
                    if re>xmi+1 :self.sca[2].set(re-1)
            # scanote2()
     
            def scanote3(self,xe):
                    mi=int(xe)
                    xre=self.sca[1].get()
                    xfa=self.sca[3].get()
                    if mi<xre-1:self.sca[1].set(mi+1)
                    if mi>xfa:self.sca[3].set(mi)
            # scanote3()
     
            def scanote4(self,xf):
                    fa=int(xf)
                    xmi=self.sca[2].get()
                    xsol=self.sca[4].get()
                    if fa<xmi:self.sca[2].set(fa)
                    if fa>xsol+1:self.sca[4].set(fa-1)
            # scanote4()
     
            def scanote5(self,xg):
                    sol=int(xg)
                    xfa=self.sca[3].get()
                    xla=self.sca[5].get()
                    if sol<xfa-1:self.sca[3].set(sol+1)
                    if sol>xla+1:self.sca[5].set(sol-1)
            # scanote5()
     
            def scanote6(self,xa):
                    la=int(xa)
                    xsol=self.sca[4].get()
                    xsi=self.sca[6].get()
                    if la<xsol-1:self.sca[4].set(la+1)
                    if la>xsi+1:self.sca[6].set(la-1)
            # scanote6()
     
            def scanote7(self,xb):
                    si=int(xb)
                    xla=self.sca[5].get()
                    xdo=self.sca[0].get()
                    if si<xla-1:self.sca[5].set(si+1)
                    if si>xdo:self.sca[0].set(si)
                    # Initialise sca[7](from_)
                    xxxrad=self.variable.get()
                    if xxxrad == "YOI": self.sca[7].configure(from_ = 0-xdo, to = 24-si)
                    elif xxxrad == "IOI": self.sca[7].configure(from_ = -12-xdo, to = 12-si)
                    elif xxxrad == "IOY": self.sca[7].configure(from_ = -24-xdo, to = 0-si)
            # scanote7()
     
            def scanote8(self,xh):
                    sch=int(xh)
                    f_t=0                
                    xsi=self.sca[6].get()
                    tosi=t_si=self.sca[6].cget("to")
                    if (xsi+sch > t_si):f_t=-1                        
                    xdo=self.sca[0].get()
                    fromdo=f_do=self.sca[0].cget("from")
                    todo=t_do=self.sca[0].cget("to")
                    if (xdo+sch<f_do)or(f_t==-1):
                            fromdo = f_do+sch
                            todo = t_do+sch
                            f_t = -1                        
                    xre=self.sca[1].get()
                    fromre=f_re=self.sca[1].cget("from")
                    tore=t_re=self.sca[1].cget("to")
                    if f_t==-1:
                            fromre = f_re+sch
                            tore = t_re+sch                        
                    xmi=self.sca[2].get()
                    frommi=f_mi=self.sca[2].cget("from")
                    tomi=t_mi=self.sca[2].cget("to")
                    if f_t==-1:
                            frommi = f_mi+sch
                            tomi = t_mi+sch                        
                    xfa=self.sca[3].get()
                    fromfa=f_fa=self.sca[3].cget("from")
                    tofa=t_fa=self.sca[3].cget("to")
                    if f_t==-1:
                            fromfa = f_fa+sch
                            tofa = t_fa+sch                        
                    xsol=self.sca[4].get()
                    fromsol=f_sol=self.sca[4].cget("from")
                    tosol=t_sol=self.sca[4].cget("to")
                    if f_t==-1:
                            fromsol = f_sol+sch
                            tosol = t_sol+sch                        
                    xla=self.sca[5].get()
                    fromla=f_la=self.sca[5].cget("from")
                    tola=t_la=self.sca[5].cget("to")
                    if f_t==-1:
                            fromla = f_la+sch
                            tola = t_la+sch                        
                    xsi=self.sca[6].get()
                    fromsi=f_si=self.sca[6].cget("from")
                    tosi=t_si=self.sca[6].cget("to")
                    if (xsi+sch > t_si)or(f_t==-1):
                            fromsi = f_si+sch
                            tosi = t_si+sch
                            f_t=-1                        
                    self.sca[0].configure(from_ = fromdo, to = todo)
                    self.sca[0].set(xdo+sch)                
                    self.sca[1].configure(from_ = fromre, to = tore)
                    self.sca[1].set(xre+sch)                
                    self.sca[2].configure(from_ = frommi, to = tomi)
                    self.sca[2].set(xmi+sch)                
                    self.sca[3].configure(from_ = fromfa, to = tofa)
                    self.sca[3].set(xfa+sch)                
                    self.sca[4].configure(from_ = fromsol, to = tosol)
                    self.sca[4].set(xsol+sch)                
                    self.sca[5].configure(from_ = fromla, to = tola)
                    self.sca[5].set(xla+sch)                
                    self.sca[6].configure(from_ = fromsi, to = tosi)
                    self.sca[6].set(xsi+sch)
                    self.btgama.invoke()
            # scanote8()
     
            def zero(self):
                    fnotes=[0,-1,-2,-2,-3,-4,-5]
                    tnotes=[+5,+4,+3,+3,+2,+1,0]
                    for z in range(7):
                            self.sca[z].configure(from_ = fnotes[z], to = tnotes[z])
                            self.sca[z].set(0)
                    self.sca[7].configure(from_ = -12, to = 12)
                    self.sca[7].set(0)
                    self.rad[1].invoke()                    # Remise à l'octave zéro ou "ioi"
                    self.btgama.invoke()
            # zero()
     
            def gama(self):
                    self.decore = {}        # Remise au zéro tonique des accords
                    self.can.delete(ALL)
                    # Tracé d'encadrement
                    # Données de l'encadré : Axes(x,y)=365(x),220(y)
                    self.can.create_line(10, 450, 740, 450, fill ='blue')
                    self.can.create_line(390, 220, 520, 220, fill ='green')
                    self.can.create_line(270, 340, 400, 340, fill ='red')
                    self.can.create_line(510, 100, 640, 100, fill ='blue')
                    # De la table gammique aux tables diatoniques surnommées
                    gammes =[[1,1,0,1,1,1,0],[0,2,0,1,1,1,0],[2,0,0,1,1,1,0],[4,0,0,0,0,1,0],[1,0,1,1,1,1,0],[0,1,1,1,1,1,0],
                                     [1,0,3,0,0,1,0],[1,2,1,0,0,1,0],[2,2,0,0,0,1,0],[0,0,1,2,1,1,0],[1,3,0,0,0,1,0],[0,0,2,1,1,1,0],
                                     [1,2,2,0,0,0,0],[0,0,4,0,0,1,0],[1,4,0,0,0,0,0],[1,0,0,2,1,1,0],[0,1,0,2,1,1,0],[1,1,3,0,0,0,0],
                                     [0,0,0,3,1,1,0],[1,1,0,0,2,1,0],[0,2,0,0,2,1,0],[0,2,0,2,0,1,0],[2,0,0,0,2,1,0],[1,0,1,0,2,1,0],
                                     [1,0,1,2,0,1,0],[1,1,1,2,0,0,0],[2,0,0,3,0,0,0],[0,0,2,0,2,1,0],[1,2,0,2,0,0,0],[1,0,0,3,0,1,0],
                                     [1,0,0,1,2,1,0],[1,1,0,3,0,0,0],[1,1,2,1,0,0,0],[0,1,0,0,3,1,0],[0,0,1,0,3,1,0],[0,0,0,1,3,1,0],
                                     [0,0,0,2,2,1,0],[1,0,0,0,3,1,0],[0,0,2,2,0,1,0],[0,0,0,0,4,1,0],[0,0,2,3,0,0,0],[1,0,0,4,0,0,0],
                                     [0,0,0,5,0,0,0],[1,1,0,1,0,2,0],[1,1,0,1,2,0,0],[0,2,0,1,0,2,0],[0,2,0,1,2,0,0],[2,0,0,1,0,2,0],
                                     [2,0,0,1,2,0,0],[1,0,1,1,0,2,0],[1,0,1,1,2,0,0],[1,1,0,0,1,2,0],[1,1,0,0,3,0,0],[1,1,0,2,1,0,0],
                                     [1,1,2,0,1,0,0],[0,2,0,0,0,3,0],[1,0,0,2,2,0,0],[1,0,0,1,0,3,0],[1,3,0,0,1,0,0],[1,0,0,0,1,3,0],
                                     [0,0,0,3,0,2,0],[0,0,2,1,2,0,0],[1,0,0,0,0,4,0],[0,0,0,3,2,0,0],[1,1,0,0,0,3,0],[3,0,0,0,0,2,0]]
                    gamnoms =['0','-2','+2','^2','-3','-23','-34x','+34','+23x','-34','x3','°3','+34x','°34x','^3',
                                      '-4','-24','^4','°4','-5','-25','-25+','+25-','-35','-35+','+45x','+25x','°35-','+35x',
                                      '-45+','-45','x5','x45+','-25°','-35°','-45°','°45-','°5','°35+','*5','°35x','-45x',
                                      '°45x','-6','+6','-26','-26+','+26-','+26','-36','-36+','-56','-56+','+56','x46+',
                                      '-26°','-46+','-46°','x36+','-56°','°46-','°36+','*6','°46+','°6','x26-']
     
                    # Récupération des notes cursives
                    xxx=0
                    xxrad0=self.variable.get()
                    if xxrad0 == "YOI": xxx=+120
                    elif xxrad0 == "IOI": xxx=0
                    elif xxrad0 == "IOY": xxx=-120
     
                    ydo=self.sca[0].get()
                    xcpos_=400-xxx
                    ycpos_=220+xxx
                    xc_=xcpos_+(ydo*10)
                    yc_=ycpos_-(ydo*10)
                    rc_=5
                    self.tablenotes[0]=xc_
                    self.tablehaute[0]=yc_
                    self.can.create_line(xc_, 350, xc_, 40, fill ='black')
                    self.can.create_oval(xc_-rc_,yc_-rc_,xc_+rc_,yc_+rc_,fill='black')
                    yre=self.sca[1].get()
                    xcpos_=420-xxx
                    ycpos_=220+xxx
                    xd_=xcpos_+(yre*10)
                    yd_=ycpos_-(yre*10)
                    rd_=5
                    self.tablenotes[1]=xd_
                    self.tablehaute[1]=yd_
                    self.can.create_line(xd_, 360, xd_, 50, fill ='green')
                    self.can.create_oval(xd_-rd_,yd_-rd_,xd_+rd_,yd_+rd_,fill='green')
                    ymi=self.sca[2].get()
                    xcpos_=440-xxx
                    ycpos_=220+xxx
                    xe_=xcpos_+(ymi*10)
                    ye_=ycpos_-(ymi*10)
                    re_=5
                    self.tablenotes[2]=xe_
                    self.tablehaute[2]=ye_
                    self.can.create_line(xe_, 370, xe_, 60, fill ='blue')
                    self.can.create_oval(xe_-re_,ye_-re_,xe_+re_,ye_+re_,fill='blue')
                    yfa=self.sca[3].get()
                    xcpos_=450-xxx
                    ycpos_=220+xxx
                    xf_=xcpos_+(yfa*10)
                    yf_=ycpos_-(yfa*10)
                    rf_=5
                    self.tablenotes[3]=xf_
                    self.tablehaute[3]=yf_
                    self.can.create_line(xf_, 370, xf_, 60, fill ='grey')
                    self.can.create_oval(xf_-rf_,yf_-rf_,xf_+rf_,yf_+rf_,fill='grey')
                    ysol=self.sca[4].get()
                    xcpos_=470-xxx
                    ycpos_=220+xxx
                    xg_=xcpos_+(ysol*10)
                    yg_=ycpos_-(ysol*10)
                    rg_=5
                    self.tablenotes[4]=xg_
                    self.tablehaute[4]=yg_
                    self.can.create_line(xg_, 380, xg_, 70, fill ='red')
                    self.can.create_oval(xg_-rg_,yg_-rg_,xg_+rg_,yg_+rg_,fill='red')
                    yla=self.sca[5].get()
                    xcpos_=490-xxx
                    ycpos_=220+xxx
                    xa_=xcpos_+(yla*10)
                    ya_=ycpos_-(yla*10)
                    ra_=5
                    self.tablenotes[5]=xa_
                    self.tablehaute[5]=ya_
                    self.can.create_line(xa_, 390, xa_, 80, fill ='orange')
                    self.can.create_oval(xa_-ra_,ya_-ra_,xa_+ra_,ya_+ra_,fill='orange')
                    ysi=self.sca[6].get()
                    xcpos_=510-xxx
                    ycpos_=220+xxx
                    xb_=xcpos_+(ysi*10)
                    yb_=ycpos_-(ysi*10)
                    rb_=5
                    self.tablenotes[6]=xb_
                    self.tablehaute[6]=yb_
                    self.can.create_line(xb_, 400, xb_, 90, fill ='yellow')
                    self.can.create_oval(xb_-rb_,yb_-rb_,xb_+rb_,yb_+rb_,fill='yellow')
     
                    # Mesure de l'intervalle tempéré
                    c1=(yre+1)-ydo
                    d2=(ymi+1)-yre
                    e3=yfa-ymi
                    f4=(ysol+1)-yfa
                    g5=(yla+1)-ysol
                    a6=(ysi+1)-yla
                    b7=i=cum_diat=ok=x=0
                    diata=[c1,d2,e3,f4,g5,a6,b7]
                    while i < 6:
                            cum_diat += diata[i]
                            i+=1            
                    # while i
                    diata[i]=5-cum_diat
     
                    # Recherche diatonique par l'itération
                    cc1=dd2=ee3=ff4=gg5=aa6=bb7=0
                    diata2=[cc1,dd2,ee3,ff4,gg5,aa6,bb7]
                    while x < 7:
                            m=x
                            y=0
                            while y < 7:
                                    diata2[y]=diata[m]
                                    y+=1
                                    m+=1
                                    if m > 6: m=0                   
                            # while
                            myx=myx2=0
                            for my in gammes:
                                    if diata2 == my:
                                            degre=x
                                            myx2=myx
                                            x=7
                                    # if diata2
                                    myx+=1
                            # for my
                            x+=1
                    # while x
                    # Ici : diata(original cursif).degre(tonique).my(gamme)
     
                    # Définition diatonique
                    # GMAJ= gammes[0]
                    gmaj = [1,1,0,1,1,1,0]    # Forme majeure simplifiée
                    # GNAT= Ordre cursif comme diata[]
                    gnat = ['C','D','E','F','G','A','B']    # Forme alphabétique
                    cnat = ['','','','','','','']
                    # Niveaux d'altérations
                    self.nordiese = ['','+','x','^','+^','x^','^^','+^^','x^^','^^^','+^^^','x^^^','^^^^','13(#)','14(#)','15(#)',
                                '16(#)','17(#)','18(#)','19(#)','20(#)','21(#)','22(#)','23(#)','24(#)',
                                '25(#)','26(#)','27(#)','28(#)','29(#)','30(#)','31(#)','32(#)']
                    self.subemol = ['','32(b)','31(b)','30(b)','29(b)','28(b)','27(b)','26(b)','25(b)','24(b)','23(b)','22(b)',
                               '21(b)','20(b)','19(b)','18(b)','17(b)','16(b)','15(b)','14(b)','13(b)',
                               '****','°***','-***','***','°**','-**','**','°*','-*','*','°','-']
                    # Configuration modale
                    gdeg = ['I','II','III','IV','V','VI','VII']
                    # Définition du style d'écriture
                    font = Font(family='Liberation Serif', size=9)
                    font2 = Font(family='Liberation Serif', size=12)
                    # Définition des notes cursives
                    self.cursifs=[ydo,yre,ymi,yfa,ysol,yla,ysi]
                    ynat=ymod=0
                    for ycurs in self.cursifs:
                            if ycurs > 0 :
                                    ymod=self.nordiese[ycurs]
                                    ycurs2 = ycurs
                            if ycurs < 0 :
                                    ymod=self.subemol[ycurs]
                                    ycurs2 = ycurs
                            if ycurs == 0 :
                                    ymod=self.subemol[ycurs]
                                    ycurs2 = ycurs
                            cnat[ynat]=ymod
                            ynat+=1
                    # for ycurs
     
                    # Une tournée produit une tonalité modale de 7 notes
                    nat2=degre
                    deg = nom = 0
                    ynote = xgdeg = 30
                    ytone = 50
                    while deg < 7 :
                            nat = deg                       # Degré tonal en question
                            cri = gimj = gmod = maj = 0
                            xdeg = 80
                            text0 = gdeg[deg]
                            self.can.create_text(xgdeg+25,ynote+10,text=text0,
                                                 font='bold',fill='black')
                            while maj < 7 :                 # Tonalité modale du degré
                                    gmj = gmaj[maj]         # Forme majeure (1101110)
                                    imaj = diata2[nat]      # Forme modale (DIATA[DEGRE])
                                    ynt = cnat[nat2]        # Forme altérative des notes
                                    gnt = gnat[nat2]        # Forme tonale (CDEFGAB)
                                    ideg = gdeg[deg]
                                    cri = cri + gimj        # Tonalité cumulée
                                    gimj = imaj - gmj       # Calcul tonal PAS/PAS
                                    cmod = gmod = cri
                                    if maj == 0:
                                            yntgnt = ynt, gnt
                                            self.decore[deg] = yntgnt
                                    if gmod > 0 :           # Forme altérative des tonalités
                                            imod = self.nordiese[cmod]
                                            cmod2 = cmod
                                    if gmod < 0 :
                                            imod = self.subemol[cmod]
                                            cmod2 = cmod
                                    if gmod == 0 :
                                            imod = self.subemol[cmod]
                                            cmod2 = cmod
                                    gmod = gmod + cri       # Transition tonale
                                    # Construction du nom de la gamme
                                    if nom == 0 :
                                            ynom = ynt
                                            gnom = gnt
                                            tnom=gnom,gamnoms[myx2]
                                            self.can.create_text(28,10,text=ynom,font=font,fill='red')
                                            self.can.create_text(28,25,text=tnom,font=font2,fill='black')
                                    # if nom
                                    nat+=1
                                    nat2+=1
                                    if nat > 6 :
                                            nat = 0
                                    if nat2 > 6 :
                                            nat2 = 0
                                    maj = maj + 1
                                    text1= gnt
                                    text2=[imod,maj]
                                    self.can.create_text(xdeg,ynote-12,text=ynt,font=font,fill='red')
                                    self.can.create_text(xdeg,ynote,text=text1)
                                    self.can.create_text(xdeg,ytone,text=text2,fill='blue')
                                    xdeg+=30
                                    nom=1
                                    self.declare[(deg,maj)] = imod
                                    self.dechire[(deg,maj)] = cmod2
                                    #print(deg,maj,self.dechire[(deg,maj)])
                            # while maj
                            ynote+=60
                            ytone+=60
                            nat2+=1
                            if nat2 > 6 :
                                    nat2 = 0
                            deg = deg + 1
                    # while deg
                    self.tbdegre[0]=degre
            # gamma()
    # class Gammique 
    Gammique().mainloop()
    Dernière modification par Invité ; 02/11/2015 à 20h07. Motif: Maintenant le bouton accords fonctionne mieux

Discussions similaires

  1. Lecteur de musique avec Python 3
    Par Lyyn- dans le forum PyQt
    Réponses: 4
    Dernier message: 25/04/2013, 21h05
  2. acoustique, musique sur Python
    Par Papou_28 dans le forum Programmation multimédia/Jeux
    Réponses: 7
    Dernier message: 25/04/2007, 08h12
  3. CORBA & PYTHON
    Par stan91stan dans le forum CORBA
    Réponses: 5
    Dernier message: 10/06/2004, 12h32
  4. Note de musique
    Par DelphiCool dans le forum Composants VCL
    Réponses: 52
    Dernier message: 30/06/2003, 15h54
  5. [TP]faire la musique
    Par kgahi dans le forum Turbo Pascal
    Réponses: 12
    Dernier message: 17/12/2002, 03h21

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo