Exemplo n.º 1
0
def main(argv):
    args = parseArgs()

    level = logging.DEBUG if args.debug else logging.WARNING
    logging.basicConfig(level=level)

    if args.list_ports:
        probeMidiAndPrint()
        sys.exit(0)

    midiout = midi.OutputConnection()
    outPorts = midiout.probeMidiPorts()
    midiout.openPort(outPorts[args.out_port])

    midiplayer = MidiPlayer(midiout, args.song_path)
    midiplayer.attach(PlayingSongState)

    noteSequence = midiplayer.getNoteSequence()
    PlayingSongState.setTicksPerBeat(noteSequence.ticksPerBeat)
    app = CheckTracksApplicationWindow(noteSequence)

    playerThread = threading.Thread(target=midiplayer.play)
    playerThread.start()

    app.start()

    midiplayer.stop()
    playerThread.join()
    midiout.closePort()
Exemplo n.º 2
0
 def _updateState(self):
     self._log.debug("_updateState()")
     self._windowTickMin = PlayingSongState.getCurrentTick()
     ticksOnScreen = self._beatsOnScreen * PlayingSongState.getTicksPerBeat(
     )
     self._windowTickMax = self._windowTickMin + ticksOnScreen
     self._log.debug(
         "windowTickMin={} windowTickMax={} ticksOnScreen={}".format(
             self._windowTickMin, self._windowTickMax, ticksOnScreen))
Exemplo n.º 3
0
    def update(self, drawingSurface):
        # TODO: this is computed for each track/channel/program tuple. It should
        # be done once per frame.
        self.minVisibleTick = PlayingSongState.getCurrentTick()
        ticksOnScreen = self._beatsOnScreen * PlayingSongState.getTicksPerBeat()
        self.maxVisibleTick = self.minVisibleTick + ticksOnScreen

        drawingSurface.drawBox(
            self._x, self._y, self._x + self._width, self._y + self._height, colour=(128, 128, 128, 255)
        )

        for note in self._guiNotes:
            note.update(drawingSurface)
Exemplo n.º 4
0
    def update(self, drawingSurface):
        # TODO: this is computed for each track/channel/program tuple. It should
        # be done once per frame.
        self.minVisibleTick = PlayingSongState.getCurrentTick()
        ticksOnScreen = self._beatsOnScreen * PlayingSongState.getTicksPerBeat()
        self.maxVisibleTick = self.minVisibleTick + ticksOnScreen

        drawingSurface.drawBox(self._x, self._y,
                               self._x + self._width, self._y + self._height,
                               colour=(128, 128, 128, 255))

        for note in self._guiNotes:
            note.update(drawingSurface)
Exemplo n.º 5
0
def main(argv):


    args = parseArgs()

    level = logging.DEBUG if args.debug else logging.WARNING
    logging.basicConfig(level=level)

    if args.list_ports:
        probeMidiAndPrint()
        sys.exit(0)

    if args.list_tracks:
        extractTracksAndPrint(args.song_path)
        sys.exit(0)

    midiin = midi.InputConnection()
    inPorts = midiin.probeMidiPorts()
    midiin.attach(InstrumentState)
    midiin.openPort(inPorts[args.in_port])

    midiout = midi.OutputConnection()
    outPorts = midiout.probeMidiPorts()
    midiout.openPort(outPorts[args.out_port])
    midiplayer = MidiPlayer(midiout, args.song_path, args.speed)
    midiplayer.attach(PlayingSongState)

    # TODO: consider moving note sequence and ticks per beat out of
    # PlayingSongState. Pass these to components that need them and
    # store only what is necessary in the global object (things that
    # change).
    noteSequence = midiplayer.getNoteSequence()
    noteSequenceForGui = noteSequence[args.track][args.channel].getNotesForProgram(args.program)
    PlayingSongState.setTicksPerBeat(noteSequence.ticksPerBeat)
    PlayingSongState.setNotes(noteSequenceForGui)

    Assets.loadAssets()
    app = ApplicationWindow()
    playerThread = threading.Thread(target=midiplayer.play)
    playerThread.start()

    app.start()
    midiplayer.stop()
    playerThread.join()
    midiin.closePort()
    midiout.closePort()
Exemplo n.º 6
0
 def _initializeScoreNotes(self):
     self._notes = [ScoreNote(note)
                    for note in PlayingSongState.getNotes()]
Exemplo n.º 7
0
 def _updateState(self):
     self._log.debug("_updateState()")
     self._windowTickMin = PlayingSongState.getCurrentTick()
     ticksOnScreen = self._beatsOnScreen * PlayingSongState.getTicksPerBeat()
     self._windowTickMax = self._windowTickMin + ticksOnScreen
     self._log.debug("windowTickMin={} windowTickMax={} ticksOnScreen={}".format(self._windowTickMin, self._windowTickMax, ticksOnScreen))
Exemplo n.º 8
0
 def _initializeScoreNotes(self):
     self._notes = [ScoreNote(note) for note in PlayingSongState.getNotes()]