1 # -*- coding: utf-8 -*-
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 globals import PLAYING_MODES_DICT
25 def __init__(self
, wimoteSupport
=True) :
30 modeResolution
= (1024,768)
33 from pywiiuse
import pygame_wiimouse
34 from pywiiuse
.PyWiiUse
import IR_BELOW
35 pygame_wiimouse
.init(1, 5) # look for 1, wait 5 seconds
36 n
= pygame_wiimouse
.get_count()
37 print '%d wiimotes' % n
38 WT
= pygame_wiimouse
.WT
40 wm
= pygame_wiimouse
.Wiimote(0) # access the wiimote object
41 wm
.enable_accels(0) # turn on acceleration reporting
42 wm
.enable_ir(1, vres
= modeResolution
, position
=IR_BELOW
)
51 pygame
.display
.set_mode(modeResolution
)
52 pygame
.display
.set_caption('MinWii')
55 # sélection de la chanson
56 home
= Home(songPath
=SONG_FILE_PATH
)
57 home
.connect(QUIT
, app
.quit
)
60 returnValue
= home
.returnValue
64 # sélection de l'instrument
66 selector
= InstrumentSelector()
70 EventDispatcher
.reset()
71 instrumentDescription
= selector
.selectedInstrument
73 # lancement du lecteur / clavier
74 songFile
= home
.songFile
75 playMode
= home
.modeSelect
.value
76 playMode
= PLAYING_MODES_DICT
[playMode
]
77 song
= musicXml2Song(songFile
)
78 bank
, preset
= instrumentDescription
['bank'], instrumentDescription
['preset']
79 octave
= instrumentDescription
.get('octave', 0)
80 synth
.adjust_octave(0, octave
)
81 synth
.program_select(0, bank
, preset
)
82 playingScreen
= SongPlayingScreen(synth
, song
, mode
=playMode
)
85 EventDispatcher
.reset()