1 # -*- coding: utf-8 -*-
3 constantes de configuration
11 from ConfigParser
import ConfigParser
13 _here
= os
.path
.abspath(__file__
).split(os
.path
.sep
)[:-1]
15 def _computePath(path
) :
16 path
= path
.split('/')
18 path
= os
.path
.abspath(os
.path
.sep
.join(path
))
22 return tuple(map(int, s
.strip('()').split(',')))
29 conf
.add_section('playingscreen')
30 conf
.set('playingscreen', 'FRAMERATE', '100')
31 conf
.set('playingscreen', 'FIRST_HUE', '0.6')
32 conf
.set('playingscreen', 'OFF_LUMINANCE', '0.2')
33 conf
.set('playingscreen', 'OFF_SATURATION', '1')
34 conf
.set('playingscreen', 'ON_TOP_LUMINANCE', '0.6')
35 conf
.set('playingscreen', 'ON_BOTTOM_LUMINANCE', '0.9')
36 conf
.set('playingscreen', 'ON_SATURATION', '1')
37 conf
.set('playingscreen', 'ON_COLUMN_OVERSIZING', '2')
38 conf
.set('playingscreen', 'ON_COLUMN_ALPHA', '1')
39 conf
.set('playingscreen', 'FONT_COLOR', '(0,0,0)')
40 conf
.set('playingscreen', 'MIDI_VELOCITY_RANGE', '(64, 127)')
41 conf
.set('playingscreen', 'MIDI_PAN_RANGE', '(32, 96)')
42 conf
.set('playingscreen', 'MIDI_VELOCITY_WRONG_NOTE_ATTN', '0.5')
43 conf
.set('playingscreen', 'IR_POSITION', 'ABOVE')
45 conf
.add_section('locations')
46 conf
.set('locations', 'notes_font_file', _computePath('fonts/Arial Unicode.ttf'))
47 conf
.set('locations', 'SONG_FILE_PATH', _computePath('../chansons'))
48 conf
.set('locations', 'LOGS_DIR', os
.path
.join(os
.path
.expanduser('~'), 'minwii_logs'))
49 conf
.set('locations', 'SOUND_FONT', _computePath('soundfonts/Minwii-light-soundfont.sf2'))
52 conf
.read(_computePath('../minwii.ini'))
54 FRAMERATE
= conf
.getint('playingscreen', 'FRAMERATE')
55 FIRST_HUE
= conf
.getfloat('playingscreen', 'FIRST_HUE')
56 OFF_LUMINANCE
= conf
.getfloat('playingscreen', 'OFF_LUMINANCE',)
57 OFF_SATURATION
= conf
.getfloat('playingscreen', 'OFF_SATURATION')
58 ON_TOP_LUMINANCE
= conf
.getfloat('playingscreen', 'ON_TOP_LUMINANCE')
59 ON_BOTTOM_LUMINANCE
= conf
.getfloat('playingscreen', 'ON_BOTTOM_LUMINANCE')
60 ON_SATURATION
= conf
.getfloat('playingscreen', 'ON_SATURATION')
61 ON_COLUMN_OVERSIZING
= conf
.getfloat('playingscreen', 'ON_COLUMN_OVERSIZING')
62 ON_COLUMN_ALPHA
= conf
.getfloat('playingscreen', 'ON_COLUMN_ALPHA')
63 FONT_COLOR
= str2IntTuple(conf
.get('playingscreen', 'FONT_COLOR'))
64 MIDI_VELOCITY_RANGE
= str2IntTuple(conf
.get('playingscreen', 'MIDI_VELOCITY_RANGE'))
65 MIDI_PAN_RANGE
= str2IntTuple(conf
.get('playingscreen', 'MIDI_PAN_RANGE'))
66 MIDI_VELOCITY_WRONG_NOTE_ATTN
= conf
.getfloat('playingscreen', 'MIDI_VELOCITY_WRONG_NOTE_ATTN')
67 IR_POSITION
= conf
.get('playingscreen', 'IR_POSITION')
69 SONG_FILE_PATH
= conf
.get('locations', 'SONG_FILE_PATH')
70 LOGS_DIR
= conf
.get('locations', 'LOGS_DIR')
71 SOUND_FONT
= conf
.get('locations', 'SOUND_FONT')
73 NOTES_FONT
= pygame
.font
.Font(conf
.get('locations', 'notes_font_file'), 50)
74 LYRICS_FONT
= pygame
.font
.Font(None, 80)
76 instruments
= ConfigParser()
77 instruments
.add_section('accordeon')
78 instruments
.set('accordeon', 'bank', '0')
79 instruments
.set('accordeon', 'preset', '23')
80 instruments
.set('accordeon', 'pos', '0')
82 instruments
.add_section('celesta')
83 instruments
.set('celesta', 'bank', '0')
84 instruments
.set('celesta', 'preset', '8')
85 instruments
.set('celesta', 'octave', '1')
86 instruments
.set('celesta', 'pos', '1')
88 instruments
.add_section('flute')
89 instruments
.set('flute', 'bank', '0')
90 instruments
.set('flute', 'preset', '73')
91 instruments
.set('flute', 'pos', '2')
93 instruments
.add_section('guitare')
94 instruments
.set('guitare', 'bank', '0')
95 instruments
.set('guitare', 'preset', '24')
96 instruments
.set('guitare', 'octave', '-1')
97 instruments
.set('guitare', 'pos', '3')
99 instruments
.add_section('orgue')
100 instruments
.set('orgue', 'bank', '0')
101 instruments
.set('orgue', 'preset', '19')
102 instruments
.set('orgue', 'pos', '4')
104 instruments
.add_section('piano')
105 instruments
.set('piano', 'bank', '0')
106 instruments
.set('piano', 'preset', '0')
107 instruments
.set('piano', 'pos', '5')
109 instruments
.add_section('tuba')
110 instruments
.set('tuba', 'bank', '0')
111 instruments
.set('tuba', 'preset', '58')
112 instruments
.set('tuba', 'octave', '-2')
113 instruments
.set('tuba', 'pos', '6')
116 instruments
.add_section('violon')
117 instruments
.set('violon', 'bank', '0')
118 instruments
.set('violon', 'preset', '40')
119 instruments
.set('violon', 'pos', '7')
121 instruments
.add_section('violoncelle')
122 instruments
.set('violoncelle', 'bank', '0')
123 instruments
.set('violoncelle', 'preset', '42')
124 instruments
.set('violoncelle', 'octave', '-2')
125 instruments
.set('violoncelle', 'pos', '8')
128 instruments
.read(_computePath('../instruments.ini'))
132 for section
in instruments
.sections() :
133 items
= instruments
.items(section
)
134 instru
= dict([(k
, int(v
)) for k
, v
in items
])
135 instru
['octave'] = instru
.get('octave', 0)
136 instru
['name'] = section
137 INSTRUMENTS
.append(instru
)
139 INSTRUMENTS
.sort(lambda a
, b
: cmp(a
['pos'], b
['pos']))
140 map(lambda a
: a
.pop('pos'), INSTRUMENTS
)
143 # {'name' : 'violoncelle',
150 #for i in INSTRUMENTS :
151 # i['octave'] = i.get('octave', 0)
154 if __name__
== '__main__' :
155 for f
in (conf
, instruments
) :
156 for section
in f
.sections() :
157 print '=== ', section
, ' ==='
158 for k
, v
in f
.items(section
) :
162 from pprint
import pprint