SONG_FILE_PATH = '../../chansons'
SONG_FILE_PATH = '../../chansons'
+INSTRUMENTS = (
+ {'name' : 'accordeon',
+ 'bank' : 0,
+ 'preset' : 23
+ },
+ {'name' : 'celesta',
+ 'bank' : 0,
+ 'preset' : 8
+ },
+ {'name' : 'flute',
+ 'bank' : 0,
+ 'preset' : 74
+ },
+ {'name' : 'guitare',
+ 'bank' : 0,
+ 'preset' : 24
+ },
+ {'name' : 'orgue',
+ 'bank' : 0,
+ 'preset' : 19
+ },
+ {'name' : 'piano',
+ 'bank' : 0,
+ 'preset' : 0
+ },
+ {'name' : 'tuba',
+ 'bank' : 0,
+ 'preset' : 58
+ },
+ {'name' : 'violon',
+ 'bank' : 0,
+ 'preset' : 40
+ },
+ {'name' : 'violoncelle',
+ 'bank' : 0,
+ 'preset' : 42
+ },
+)
+
# cuisine : ne pas modifier
_here = os.path.abspath(__file__).split(os.path.sep)[:-1]
SONG_FILE_PATH = SONG_FILE_PATH.split('/')
# cuisine : ne pas modifier
_here = os.path.abspath(__file__).split(os.path.sep)[:-1]
SONG_FILE_PATH = SONG_FILE_PATH.split('/')
home.connect(QUIT, app.quit)
app.run(home)
app.close(home)
home.connect(QUIT, app.quit)
app.run(home)
app.close(home)
+ returnValue = home.returnValue
+ if not returnValue :
+ break
selector = InstrumentSelector()
selector.run()
selector.stop()
pygame.event.clear()
EventDispatcher.reset()
selector = InstrumentSelector()
selector.run()
selector.stop()
pygame.event.clear()
EventDispatcher.reset()
+ instrumentDescription = selector.selectedInstrument
song = musicXml2Song(home.songFile, printNotes=True)
song = musicXml2Song(home.songFile, printNotes=True)
- synth.program_select(0, 0, 0)
+ bank, preset = instrumentDescription['bank'], instrumentDescription['preset']
+ synth.program_select(0, bank, preset)
playingScreen = SongPlayingScreen(synth, song)
playingScreen.run()
pygame.event.clear()
playingScreen = SongPlayingScreen(synth, song)
playingScreen.run()
pygame.event.clear()
def _initLocalListeners(self) :
self.browseButton.connect(CLICK, self.open_file_browser)
def _initLocalListeners(self) :
self.browseButton.connect(CLICK, self.open_file_browser)
- self.quitButton.connect(CLICK, self._exitHome)
+ self.quitButton.connect(CLICK, self._exitApp)
+ self.playButton.connect(CLICK, self._exitHome)
+
+ def _exitApp(self, data=None) :
+ self.returnValue = False
+ self.send(QUIT)
def _exitHome(self, data=None) :
def _exitHome(self, data=None) :
+ self.returnValue = True
self.send(QUIT)
def createLabel(self,text,font = None):
self.send(QUIT)
def createLabel(self,text,font = None):
from eventutils import event_handler, EventDispatcher, EventHandlerMixin
from cursors import WarpingCursor
from config import FRAMERATE
from eventutils import event_handler, EventDispatcher, EventHandlerMixin
from cursors import WarpingCursor
from config import FRAMERATE
+from config import INSTRUMENTS
from globals import BACKGROUND_LAYER
from globals import FOREGROUND_LAYER
from globals import CURSOR_LAYER
from globals import BACKGROUND_LAYER
from globals import FOREGROUND_LAYER
from globals import CURSOR_LAYER
- instruments = ['accordeon', 'celesta', 'flute', 'guitare', 'orgue', 'piano', 'tuba', 'violon', 'violoncelle']
+ instruments = INSTRUMENTS
def __init__(self) :
super(InstrumentSelector, self).__init__()
def __init__(self) :
super(InstrumentSelector, self).__init__()
tileHeight = int(round(float(screen.get_height()) / self.rows))
self.tiles = []
tileHeight = int(round(float(screen.get_height()) / self.rows))
self.tiles = []
- instrus = self.instruments[:]
+ instrus = list(self.instruments[:])
for y in range(self.cols) :
for x in range(self.rows) :
upperLeftCorner = (x * tileWidth, y * tileHeight)
rect = pygame.Rect(upperLeftCorner, (tileWidth, tileHeight))
for y in range(self.cols) :
for x in range(self.rows) :
upperLeftCorner = (x * tileWidth, y * tileHeight)
rect = pygame.Rect(upperLeftCorner, (tileWidth, tileHeight))
+ # !!! s'il y avait plus de 3x3 tuiles !!!, il faudrait alors
+ # changer le tuple (x,y) qui concerne le point d'application de l'homotétie.
+ # Cf. InstrumentTile.inflate
tile = InstrumentTile(instrus.pop(0), self, rect, (x,y))
self.add(tile, layer=BACKGROUND_LAYER)
self.tiles.append(tile)
tile = InstrumentTile(instrus.pop(0), self, rect, (x,y))
self.add(tile, layer=BACKGROUND_LAYER)
self.tiles.append(tile)
self.stop()
@event_handler(pygame.MOUSEMOTION)
self.stop()
@event_handler(pygame.MOUSEMOTION)
- #@event_handler(pygame.MOUSEBUTTONDOWN)
def onMouseMove(self, event) :
for tile in reversed(self.sprites()[:-1]) :
if tile.rect.collidepoint(*event.pos) :
def onMouseMove(self, event) :
for tile in reversed(self.sprites()[:-1]) :
if tile.rect.collidepoint(*event.pos) :
def selectInstrument(self, event) :
for tile in reversed(self.sprites()[:-1]) :
if tile.rect.collidepoint(*event.pos) :
def selectInstrument(self, event) :
for tile in reversed(self.sprites()[:-1]) :
if tile.rect.collidepoint(*event.pos) :
- self.selectedInstrument = tile
+ self.selectedInstrument = tile.instrumentDescription
BORDER = 10
INFLATE_ZOOM = 0.4
BORDER = 10
INFLATE_ZOOM = 0.4
- def __init__(self, name, group, rect, coords) :
+ def __init__(self, instrumentDescription, group, rect, coords) :
pygame.sprite.DirtySprite.__init__(self, group)
self.inflated = False
pygame.sprite.DirtySprite.__init__(self, group)
self.inflated = False
+ self.instrumentDescription = instrumentDescription
self.rect = rect
self._baseRect = rect.copy()
self.coords = coords
self.rect = rect
self._baseRect = rect.copy()
self.coords = coords
- imagePath = InstrumentTile._get_instrument_image(name)
+ imagePath = InstrumentTile._get_instrument_image(instrumentDescription['name'])
self._img = pygame.image.load(imagePath)
self.update()
self._img = pygame.image.load(imagePath)
self.update()