06e33f703f150bd636246e8567a8d5aedf930ff8
[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.launch import LaunchScreen
13 from widgets.home import Home
14 from widgets.playingscreen import SongPlayingScreen, PlayingScreen
15 from widgets.instrumentselector import InstrumentSelector
16 from synth import Synth
17 from eventutils import EventDispatcher
18 from musicxml import musicXml2Song
19 from config import SONG_FILE_PATH
20 from time import sleep
21
22 class MinWii(object):
23
24 def __init__(self) :
25 LaunchScreen()
26 app = Desktop()
27 synth = Synth()
28
29 modeResolution = (1024,768)
30 pygame.display.set_mode(modeResolution)
31 pygame.display.set_caption('MinWii')
32
33 while True :
34 # sélection de la chanson
35 home = Home(songPath=SONG_FILE_PATH)
36 home.connect(QUIT, app.quit)
37 app.run(home)
38 app.close(home)
39 returnValue = home.returnValue
40 if not returnValue :
41 break
42
43 # sélection de l'instrument
44 selector = InstrumentSelector()
45 selector.run()
46 selector.stop()
47 pygame.event.clear()
48 EventDispatcher.reset()
49 instrumentDescription = selector.selectedInstrument
50
51 # lancement du lecteur / clavier
52 song = musicXml2Song(home.songFile)
53 bank, preset = instrumentDescription['bank'], instrumentDescription['preset']
54 synth.program_select(0, bank, preset)
55 playingScreen = SongPlayingScreen(synth, song)
56 playingScreen.run()
57 pygame.event.clear()
58 EventDispatcher.reset()