Skip to content
Permalink
Browse files

Add loop playback feature

  • Loading branch information...
vgstef committed Jul 31, 2013
1 parent a3b7c01 commit 3543170ae376e02485609c9569119751f10f8369
@@ -2006,6 +2006,15 @@ Shortcut Shortcut::sc[] = {
QT_TRANSLATE_NOOP("action","OmrPanel"),
QT_TRANSLATE_NOOP("action","Show OMR Panel")
),
Shortcut(
STATE_NORMAL | STATE_NOTE_ENTRY | STATE_PLAY | STATE_EDIT | STATE_LYRICS_EDIT,
0,
"loop",
QT_TRANSLATE_NOOP("action","Loop"),
QT_TRANSLATE_NOOP("action","Toggle loop"),
QT_TRANSLATE_NOOP("action","Playback will continuously restart"),
loop_ICON
),
Shortcut(
STATE_NORMAL | STATE_NOTE_ENTRY | STATE_PLAY | STATE_EDIT | STATE_LYRICS_EDIT,
0,
@@ -0,0 +1,60 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->

<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
width="16px"
height="16px"
id="svg2998"
version="1.1"
inkscape:version="0.48.4 r9939"
sodipodi:docname="media-playback-loop.svg">
<defs
id="defs3000" />
<sodipodi:namedview
id="base"
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1.0"
inkscape:pageopacity="0.0"
inkscape:pageshadow="2"
inkscape:zoom="16"
inkscape:cx="-5.5053789"
inkscape:cy="16.374596"
inkscape:current-layer="layer1"
showgrid="true"
inkscape:grid-bbox="true"
inkscape:document-units="px"
inkscape:window-width="1920"
inkscape:window-height="1123"
inkscape:window-x="0"
inkscape:window-y="25"
inkscape:window-maximized="1" />
<metadata
id="metadata3003">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
<dc:title />
</cc:Work>
</rdf:RDF>
</metadata>
<g
id="layer1"
inkscape:label="Layer 1"
inkscape:groupmode="layer">
<path
inkscape:connector-curvature="0"
d="M 8.0005168,12.43968 C 10.451589,12.434992 12.4351,10.451431 12.439755,8.0002587 12.435067,5.5480508 10.451589,3.5639406 8.0005168,3.5598023 5.5484109,3.563943 3.564382,5.5480508 3.5602445,8.0002587 c 0,0.9894687 0.3253266,1.8956632 0.8720211,2.6327213 L 5.3544562,9.7112695 6.5212882,14.071037 2.1627352,12.902088 3.140268,11.924515 C 2.2729016,10.852805 1.75,9.4847212 1.75,8.0002587 1.7515625,4.5482375 4.5486383,1.7510344 8.0005168,1.75 11.452913,1.7510312 14.25,4.5482375 14.25,8.0002587 14.25,11.45228 11.452913,14.25 8.0005168,14.25 l 0,-1.81032 z"
id="path4" />
</g>
</svg>
@@ -556,6 +556,10 @@
<key>play</key>
<seq>Space</seq>
</SC>
<SC>
<key>loop</key>
<seq>Shift+Space</seq>
</SC>
<SC>
<key>play-prev-chord</key>
<seq>Left</seq>
@@ -113,6 +113,7 @@ static const char* iconNames[] = {
"format-indent-more.svg",
"format-indent-less.svg",
"panel-community.svg",
"media-playback-loop.svg",
"media-playback-metronome.svg",
"vframe.svg",
"hframe.svg",
@@ -44,7 +44,7 @@ enum { longaUp_ICON, brevis_ICON, note_ICON, note2_ICON, note4_ICON, note8_ICON,
hraster_ICON, vraster_ICON, repitch_ICON,
formatListUnordered_ICON, formatListOrdered_ICON,
formatIndentMore_ICON, formatIndentLess_ICON, community_ICON,
metronome_ICON,
loop_ICON, metronome_ICON,
vframe_ICON, hframe_ICON, tframe_ICON, fframe_ICON, measure_ICON, checkmark_ICON,
helpContents_ICON, goHome_ICON, goPrevious_ICON, goNext_ICON, viewRefresh_ICON,
brackets_ICON,
@@ -456,6 +456,10 @@ MuseScore::MuseScore()
vRasterAction = getAction("vraster");
vRasterAction->setCheckable(true);

loopAction = getAction("loop");
loopAction->setCheckable(true);
loopAction->setChecked(false);

metronomeAction = getAction("metronome");
metronomeAction->setCheckable(true);
metronomeAction->setChecked(false);
@@ -4136,6 +4140,8 @@ void MuseScore::cmd(QAction* a, const QString& cmd)
cmdAddChordName2();
else if (cmd == "tempo")
addTempo();
else if (cmd == "loop") // no action
;
else if (cmd == "metronome") // no action
;
else if (cmd == "viewmode") {
@@ -342,6 +342,7 @@ class MuseScore : public QMainWindow, public MuseScoreCore {
Shortcut* lastShortcut;

QAction* metronomeAction;
QAction* loopAction;
QAction* panAction;

QLabel* cornerLabel;
@@ -603,6 +604,7 @@ class MuseScore : public QMainWindow, public MuseScoreCore {
NScrollArea* navigatorScrollArea() const { return _navigator; }
void updateLayer();
void updatePlayMode();
bool loop() const { return loopAction->isChecked(); }
bool metronome() const { return metronomeAction->isChecked(); }
bool panDuringPlayback() const { return panAction->isChecked(); }
void noteTooShortForTupletDialog();
@@ -124,6 +124,7 @@
<file>data/icons/help-contents.svg</file>
<file>data/icons/view-refresh.svg</file>
<file>data/icons/align-vertical-center.svg</file>
<file>data/icons/media-playback-loop.svg</file>
<file>data/icons/media-playback-metronome.svg</file>
<file>data/icons/midi-input.svg</file>
<file>data/icons/media-playback-pan.svg</file>
@@ -55,6 +55,7 @@ PlayPanel::PlayPanel(QWidget* parent)
playButton->setDefaultAction(getAction("play"));
rewindButton->setDefaultAction(getAction("rewind"));
metronomeButton->setDefaultAction(getAction("metronome"));
loopButton->setDefaultAction(getAction("loop"));

connect(volumeSlider, SIGNAL(valueChanged(double,int)), SLOT(volumeChanged(double,int)));
connect(posSlider, SIGNAL(sliderMoved(int)), SLOT(setPos(int)));
@@ -1238,6 +1238,13 @@
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="loopButton">
<property name="text">
<string notr="true">L</string>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="metronomeButton">
<property name="text">
@@ -1 +1 @@
Unknown
e47d9de
@@ -269,6 +269,17 @@ void Seq::rewindStart()
{
seek(0);
}

//---------------------------------------------------------
// loopStart
//---------------------------------------------------------

void Seq::loopStart()
{
seek(0);
start();
qDebug("LoopStart. playPos = %d\n", playPos);
}

//---------------------------------------------------------
// canStart
@@ -572,7 +583,13 @@ void Seq::process(unsigned n, float* buffer)
// TODO: channel?
putEvent(NPlayEvent(ME_CONTROLLER, 0, CTRL_SUSTAIN, 0));
if (playPos == events.cend())
emit toGui('2');
if (mscore->loop()) {
qDebug("MScore::Seq:: loop active. playPos = %d\n", playPos);
loopStart();
}
else {
emit toGui('2');
}
else
emit toGui('0');
}
@@ -600,7 +617,7 @@ void Seq::process(unsigned n, float* buffer)
int n = f - playTime;
if (n < 0) {
qDebug("%d: %d - %d\n", playPos->first, f, playTime);
n = 0;
n = 0;
}
if (n) {
if (cs->playMode() == PLAYMODE_SYNTHESIZER) {
@@ -696,7 +713,7 @@ void Seq::process(unsigned n, float* buffer)
peakTimer[1] = 0;
}
}

//---------------------------------------------------------
// initInstruments
//---------------------------------------------------------
@@ -162,6 +162,7 @@ class Seq : public QObject, public Sequencer {
~Seq();
bool canStart();
void rewindStart();
void loopStart();
void seekEnd();
void nextMeasure();
void nextChord();

0 comments on commit 3543170

Please sign in to comment.
You can’t perform that action at this time.