Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/modele_data.py
blob: 1d2ff3fe06d7d5eae2234d842bc0c8e6c572cba2 (plain)
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
#!/usr/bin/env python
# -*- coding: utf-8 -*-

#------------------------------------------------------------------------------

# Copyright 2008-2009 : François Sénéquier
# Email : francois.senequier@netcourrier.com

# This file is part of 'Theorie'.
#
# 'Theorie' is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# any later version.
#
# 'Theorie' is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with 'Theorie'.  If not, see <http://www.gnu.org/licenses/>.

#------------------------------------------------------------------------------s

from ConfigParser import *
from modele import *

from gettext import gettext as _

#------------------------------------------------------------------------------
# Classes des listes des gammes et des accords
#------------------------------------------------------------------------------

class ListeEchelles(ListeDegres):

	def __init__(self, ficCFG):
		ListeDegres.__init__(self)
		cfg = SafeConfigParser()
		cfg.read(ficCFG)
		lis = cfg.items('Echelles')
		for elt in lis:
			deg = elt[0].strip()
			val = elt[1].strip()
			tab = val.split('|')
			nom = _(tab[0].strip())
			nmd = None
			if len(tab) == 2:
				nmd = tab[1].split(',')
				nmd = map(lambda e:_(e.strip()), nmd)
			self.ajouter(Degres(deg, nom, nmd))
	
#------------------------------------------------------------------------------
# Classes des instruments
#------------------------------------------------------------------------------
	
class ListeHarmonicas:

	def __init__(self):
		self.__listeNOM = []
		self.__listeINS = []
		self.__listeNOM.append(_("Chromatic harmonica"))
		self.__listeINS.append(HarmonicaCHR())
		for ref in [0, 2, 4, 5, 7, 9, 11]:
			txt = "%s : %s" %(_("Diatonic harmonica"), LISTE_NOMS_NOTES[ref])
			self.__listeNOM.append(txt)
			self.__listeINS.append(HarmonicaDIA(ref))
	
	def getListeNoms(self):
		return self.__listeNOM
	
	def getInstrument(self, nom):
		ind = self.__listeNOM.index(nom)
		return self.__listeINS[ind]
	
class ListeFlutes:

	def __init__(self):
		self.__listeNOM = []
		self.__listeINS = []
		for ref in [_('C'), _('F')]:
			txt = "%s : %s" % (_("Recorder (baroque fingering)"), ref)
			self.__listeNOM.append(txt)
			self.__listeINS.append(Flute(ref, FLU_DGT_BAR))
			txt = "%s : %s" % (_("Recorder (modern fingering)"), ref)
			self.__listeNOM.append(txt)
			self.__listeINS.append(Flute(ref, FLU_DGT_MOD))

	def getListeNoms(self):
		return self.__listeNOM
	
	def getInstrument(self, nom):
		ind = self.__listeNOM.index(nom)
		return self.__listeINS[ind]

class ListeGuitares:

	def __init__(self, nbc = 19):
		self.__listeNOM = []
		self.__listeINS = []
		cfg = SafeConfigParser()
		cfg.read('./config/guitares.txt')
		lsc = cfg.sections()
		lis = []
		for elt in lsc:
			lis += cfg.items(elt)
		acc = {}
		for elt in lis:
			val = elt[0].strip().split(",")
			cle = elt[1].strip()
			val = map(lambda e:int(e.strip()), val)
			acc[_(cle)] = val
		fnc = lambda x: x-1
		lis = acc.keys()
		lis.sort()
		for obj in lis:
			ins = Guitare(nbc, map(fnc, acc[obj]))
			nom = obj + ' : ' + ins.getAccordageTexte()
			self.__listeNOM.append(nom)
			self.__listeINS.append(ins)

	def getListeNoms(self):
		return self.__listeNOM
	
	def getInstrument(self, nom):
		ind = self.__listeNOM.index(nom)
		return self.__listeINS[ind]

class ListeClarinettes:

	def __ajouter(self, nom, ref):
		self.__listeNOM.append("%s : %s" %(_("Clarinet"), nom))
		self.__listeINS.append(Clarinette(ref))

	def __init__(self):
		self.__listeNOM = []
		self.__listeINS = []
		self.__ajouter(_("B flat"), 10)
		self.__ajouter(_("A")     ,  9)
		self.__ajouter(_("G")     ,  7)
		self.__ajouter(_("F")     ,  5)
		self.__ajouter(_("E flat"),  3)
		self.__ajouter(_("D")     ,  2)
		self.__ajouter(_("C")     ,  0)
	
	def getListeNoms(self):
		return self.__listeNOM
	
	def getInstrument(self, nom):
		ind = self.__listeNOM.index(nom)
		return self.__listeINS[ind]

#------------------------------------------------------------------------------

LISTE_GAMMES  = ListeEchelles('./config/gammes.txt')
LISTE_ACCORDS = ListeEchelles('./config/accords.txt')