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')
44 conf
.set('playingscreen', 'SCREEN_RESOLUTION', '(1024, 768)')
46 conf
.add_section('locations')
47 conf
.set('locations', 'notes_font_file', _computePath('fonts/Arial Unicode.ttf'))
48 conf
.set('locations', 'SONG_FILE_PATH', _computePath('../chansons'))
49 conf
.set('locations', 'LOGS_DIR', os
.path
.join(os
.path
.expanduser('~'), 'minwii_logs'))
50 conf
.set('locations', 'SOUND_FONT', _computePath('soundfonts/Minwii-light-soundfont.sf2'))
53 conf
.read(_computePath('../minwii.ini'))
55 FRAMERATE
= conf
.getint('playingscreen', 'FRAMERATE')
56 FIRST_HUE
= conf
.getfloat('playingscreen', 'FIRST_HUE')
57 OFF_LUMINANCE
= conf
.getfloat('playingscreen', 'OFF_LUMINANCE',)
58 OFF_SATURATION
= conf
.getfloat('playingscreen', 'OFF_SATURATION')
59 ON_TOP_LUMINANCE
= conf
.getfloat('playingscreen', 'ON_TOP_LUMINANCE')
60 ON_BOTTOM_LUMINANCE
= conf
.getfloat('playingscreen', 'ON_BOTTOM_LUMINANCE')
61 ON_SATURATION
= conf
.getfloat('playingscreen', 'ON_SATURATION')
62 ON_COLUMN_OVERSIZING
= conf
.getfloat('playingscreen', 'ON_COLUMN_OVERSIZING')
63 ON_COLUMN_ALPHA
= conf
.getfloat('playingscreen', 'ON_COLUMN_ALPHA')
64 FONT_COLOR
= str2IntTuple(conf
.get('playingscreen', 'FONT_COLOR'))
65 MIDI_VELOCITY_RANGE
= str2IntTuple(conf
.get('playingscreen', 'MIDI_VELOCITY_RANGE'))
66 MIDI_PAN_RANGE
= str2IntTuple(conf
.get('playingscreen', 'MIDI_PAN_RANGE'))
67 MIDI_VELOCITY_WRONG_NOTE_ATTN
= conf
.getfloat('playingscreen', 'MIDI_VELOCITY_WRONG_NOTE_ATTN')
68 IR_POSITION
= conf
.get('playingscreen', 'IR_POSITION')
69 SCREEN_RESOLUTION
= str2IntTuple(conf
.get('playingscreen', 'SCREEN_RESOLUTION'))
71 SONG_FILE_PATH
= conf
.get('locations', 'SONG_FILE_PATH')
72 LOGS_DIR
= conf
.get('locations', 'LOGS_DIR')
73 SOUND_FONT
= conf
.get('locations', 'SOUND_FONT')
75 NOTES_FONT
= pygame
.font
.Font(conf
.get('locations', 'notes_font_file'), 50)
76 LYRICS_FONT
= pygame
.font
.Font(None, 80)
78 instruments
= ConfigParser()
79 instruments
.add_section('accordeon')
80 instruments
.set('accordeon', 'bank', '0')
81 instruments
.set('accordeon', 'preset', '23')
82 instruments
.set('accordeon', 'pos', '0')
84 instruments
.add_section('carillon')
85 instruments
.set('carillon', 'bank', '0')
86 instruments
.set('carillon', 'preset', '8')
87 instruments
.set('carillon', 'octave', '1')
88 instruments
.set('carillon', 'pos', '1')
90 instruments
.add_section('flute')
91 instruments
.set('flute', 'bank', '0')
92 instruments
.set('flute', 'preset', '73')
93 instruments
.set('flute', 'pos', '2')
95 instruments
.add_section('guitare')
96 instruments
.set('guitare', 'bank', '0')
97 instruments
.set('guitare', 'preset', '24')
98 instruments
.set('guitare', 'octave', '-1')
99 instruments
.set('guitare', 'pos', '3')
101 instruments
.add_section('orgue')
102 instruments
.set('orgue', 'bank', '0')
103 instruments
.set('orgue', 'preset', '19')
104 instruments
.set('orgue', 'pos', '4')
106 instruments
.add_section('piano')
107 instruments
.set('piano', 'bank', '0')
108 instruments
.set('piano', 'preset', '0')
109 instruments
.set('piano', 'pos', '5')
111 instruments
.add_section('tuba')
112 instruments
.set('tuba', 'bank', '0')
113 instruments
.set('tuba', 'preset', '58')
114 instruments
.set('tuba', 'octave', '-2')
115 instruments
.set('tuba', 'pos', '6')
118 instruments
.add_section('violon')
119 instruments
.set('violon', 'bank', '0')
120 instruments
.set('violon', 'preset', '40')
121 instruments
.set('violon', 'pos', '7')
123 instruments
.add_section('violoncelle')
124 instruments
.set('violoncelle', 'bank', '0')
125 instruments
.set('violoncelle', 'preset', '42')
126 instruments
.set('violoncelle', 'octave', '-2')
127 instruments
.set('violoncelle', 'pos', '8')
130 instruments
.read(_computePath('../instruments.ini'))
134 for section
in instruments
.sections() :
135 items
= instruments
.items(section
)
136 instru
= dict([(k
, int(v
)) for k
, v
in items
])
137 instru
['octave'] = instru
.get('octave', 0)
138 instru
['name'] = section
139 INSTRUMENTS
.append(instru
)
141 INSTRUMENTS
.sort(lambda a
, b
: cmp(a
['pos'], b
['pos']))
142 map(lambda a
: a
.pop('pos'), INSTRUMENTS
)
145 # {'name' : 'violoncelle',
152 #for i in INSTRUMENTS :
153 # i['octave'] = i.get('octave', 0)
156 if __name__
== '__main__' :
157 for f
in (conf
, instruments
) :
158 for section
in f
.sections() :
159 print '=== ', section
, ' ==='
160 for k
, v
in f
.items(section
) :
164 from pprint
import pprint