Ajout de commentaires.
[minwii.git] / src / app / minwii.py
1 # -*- coding: utf-8 -*-
2 """
3 l'application winwii
4
5 $Id$
6 $URL$
7 """
8
9 import pygame
10 from pgu.gui import Desktop
11 from pgu.gui import QUIT
12 from widgets.home import Home
13 from widgets.playingscreen import SongPlayingScreen, PlayingScreen
14 from widgets.instrumentselector import InstrumentSelector
15 from synth import Synth
16 from eventutils import EventDispatcher
17 from musicxml import musicXml2Song
18 from config import SONG_FILE_PATH
19
20 class MinWii(object):
21
22 def __init__(self) :
23 app = Desktop()
24 synth = Synth()
25
26 while True :
27 # sélection de la chanson
28 home = Home(songPath=SONG_FILE_PATH)
29 home.connect(QUIT, app.quit)
30 app.run(home)
31 app.close(home)
32 returnValue = home.returnValue
33 if not returnValue :
34 break
35
36 # sélection de l'instrument
37 selector = InstrumentSelector()
38 selector.run()
39 selector.stop()
40 pygame.event.clear()
41 EventDispatcher.reset()
42 instrumentDescription = selector.selectedInstrument
43
44 # lancement du lecteur / clavier
45 song = musicXml2Song(home.songFile, printNotes=True)
46 bank, preset = instrumentDescription['bank'], instrumentDescription['preset']
47 synth.program_select(0, bank, preset)
48 playingScreen = SongPlayingScreen(synth, song)
49 playingScreen.run()
50 pygame.event.clear()
51 EventDispatcher.reset()