-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathIntervallo.py
51 lines (49 loc) · 1.42 KB
/
Intervallo.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
class Intervallo:
def __init__(self, intDistanzaGradi, intDistanzaSemitoni,intOttave=0):
self.dg = intDistanzaGradi
self.ds = intDistanzaSemitoni
self.do = intOttave
def __str__(self):
return "Intervallo "+ str(self.dg)+" gradi e "+str(self.ds)+" semitoni"
def __repr__(self):
return self.__str__()
@property
def maggiore(self):
maggiore = [secondaM, terzaM, sestaM, settimaM]
return (self.dg, self.ds) in maggiore
@property
def minore(self):
minore = [secondam,terzam,sestam,settimam]
return (self.dg, self.ds) in minore
@property
def giusto (self):
giusto = [unisonoG,quartaG,quintaG,ottavaG]
return (self.dg, self.ds) in giusto
@property
def consonante (self):
punteggio = 0
if self.maggiore or self.minore or self.giusto:
punteggio += 10
if self.ds == 3:
#nessun punto per gli unisoni!
punteggio = 0
if self.ds == 2:
punteggio -=4
if self.ds == 1:
punteggio -= 10
if self.ds == 11:
punteggio -= 10
return punteggio/10
semitono = (0,1)
unisonoG = (0,0)
secondam = (1,1)
secondaM = (1,2)
terzam = (2,3)
terzaM = (2,4)
quartaG = (3,5)
quintaG = (4,7)
sestam = (5,8)
sestaM = (5,9)
settimam = (6,10)
settimaM = (6,11)
ottavaG = (0,0,1)