Browse Source

new: playback from current block

master
Nils 4 years ago
parent
commit
4452678428
  1. 13
      engine/api.py
  2. 7
      qtgui/designer/mainwindow.py
  3. 9
      qtgui/designer/mainwindow.ui
  4. 1
      qtgui/menu.py

13
engine/api.py

@ -319,6 +319,19 @@ def setMetadata(data):
def playFromCursor(): def playFromCursor():
playFrom(ticks=session.data.cursorExport()["tickindex"]) playFrom(ticks=session.data.cursorExport()["tickindex"])
def playFromBlockStart():
tr = session.data.currentTrack()
ticks = 0
for idx, bl in enumerate(tr.blocks):
if idx == tr.state.blockindex:
playFrom(ticks)
return
else:
ticks += bl.duration()
else:
raise RuntimeError("reached end of blocks without matchin current block index")
topLevelFunction = None topLevelFunction = None
def simpleCommand(function, autoStepLeft = True, forceReturnToItem = None): def simpleCommand(function, autoStepLeft = True, forceReturnToItem = None):
""" """

7
qtgui/designer/mainwindow.py

@ -2,7 +2,7 @@
# Form implementation generated from reading ui file 'mainwindow.ui' # Form implementation generated from reading ui file 'mainwindow.ui'
# #
# Created by: PyQt5 UI code generator 5.15.1 # Created by: PyQt5 UI code generator 5.15.2
# #
# WARNING: Any manual changes made to this file will be lost when pyuic5 is # WARNING: Any manual changes made to this file will be lost when pyuic5 is
# run again. Do not edit this file unless you know what you are doing. # run again. Do not edit this file unless you know what you are doing.
@ -662,6 +662,8 @@ class Ui_MainWindow(object):
self.actionZoom_Out_Score_View.setObjectName("actionZoom_Out_Score_View") self.actionZoom_Out_Score_View.setObjectName("actionZoom_Out_Score_View")
self.actionQuit = QtWidgets.QAction(MainWindow) self.actionQuit = QtWidgets.QAction(MainWindow)
self.actionQuit.setObjectName("actionQuit") self.actionQuit.setObjectName("actionQuit")
self.actionPlay_from_Block = QtWidgets.QAction(MainWindow)
self.actionPlay_from_Block.setObjectName("actionPlay_from_Block")
self.menuObjects.addAction(self.actionMetrical_Instruction) self.menuObjects.addAction(self.actionMetrical_Instruction)
self.menuObjects.addAction(self.actionClef) self.menuObjects.addAction(self.actionClef)
self.menuObjects.addAction(self.actionKey_Signature) self.menuObjects.addAction(self.actionKey_Signature)
@ -798,6 +800,7 @@ class Ui_MainWindow(object):
self.menuView.addSeparator() self.menuView.addSeparator()
self.menuView.addAction(self.actionPlayPause) self.menuView.addAction(self.actionPlayPause)
self.menuView.addAction(self.actionPlayFromEditCursor) self.menuView.addAction(self.actionPlayFromEditCursor)
self.menuView.addAction(self.actionPlay_from_Block)
self.menuView.addAction(self.actionPlayFromBeginning) self.menuView.addAction(self.actionPlayFromBeginning)
self.menuView.addAction(self.actionMetronome_Enabled) self.menuView.addAction(self.actionMetronome_Enabled)
self.menuView.addSeparator() self.menuView.addSeparator()
@ -989,3 +992,5 @@ class Ui_MainWindow(object):
self.actionZoom_Out_Score_View.setText(_translate("MainWindow", "Zoom Out Score View")) self.actionZoom_Out_Score_View.setText(_translate("MainWindow", "Zoom Out Score View"))
self.actionQuit.setText(_translate("MainWindow", "Quit (without saving)")) self.actionQuit.setText(_translate("MainWindow", "Quit (without saving)"))
self.actionQuit.setShortcut(_translate("MainWindow", "Ctrl+Q")) self.actionQuit.setShortcut(_translate("MainWindow", "Ctrl+Q"))
self.actionPlay_from_Block.setText(_translate("MainWindow", "Play from Block"))
self.actionPlay_from_Block.setShortcut(_translate("MainWindow", "Alt+Space"))

9
qtgui/designer/mainwindow.ui

@ -225,6 +225,7 @@
<addaction name="separator"/> <addaction name="separator"/>
<addaction name="actionPlayPause"/> <addaction name="actionPlayPause"/>
<addaction name="actionPlayFromEditCursor"/> <addaction name="actionPlayFromEditCursor"/>
<addaction name="actionPlay_from_Block"/>
<addaction name="actionPlayFromBeginning"/> <addaction name="actionPlayFromBeginning"/>
<addaction name="actionMetronome_Enabled"/> <addaction name="actionMetronome_Enabled"/>
<addaction name="separator"/> <addaction name="separator"/>
@ -1742,6 +1743,14 @@
<string>Ctrl+Q</string> <string>Ctrl+Q</string>
</property> </property>
</action> </action>
<action name="actionPlay_from_Block">
<property name="text">
<string>Play from Block</string>
</property>
<property name="shortcut">
<string>Alt+Space</string>
</property>
</action>
</widget> </widget>
<resources/> <resources/>
<connections/> <connections/>

1
qtgui/menu.py

@ -207,6 +207,7 @@ class MenuActionDatabase(object):
self.mainWindow.ui.actionPlayFromBeginning : api.playFromStart, self.mainWindow.ui.actionPlayFromBeginning : api.playFromStart,
self.mainWindow.ui.actionPlayPause : api.playPause, self.mainWindow.ui.actionPlayPause : api.playPause,
self.mainWindow.ui.actionPlayFromEditCursor : api.playFromCursor, self.mainWindow.ui.actionPlayFromEditCursor : api.playFromCursor,
self.mainWindow.ui.actionPlay_from_Block : api.playFromBlockStart,
self.mainWindow.ui.actionMetronome_Enabled : api.toggleMetronome, #toggle is enough. The callback makes sure all the checkboxes have the correct value. self.mainWindow.ui.actionMetronome_Enabled : api.toggleMetronome, #toggle is enough. The callback makes sure all the checkboxes have the correct value.
} }

Loading…
Cancel
Save