Skip to content

Commit

Permalink
Add loop playback feature
Browse files Browse the repository at this point in the history
  • Loading branch information
vgstef committed Jul 31, 2013
1 parent a3b7c01 commit 3543170
Show file tree
Hide file tree
Showing 13 changed files with 114 additions and 5 deletions.
9 changes: 9 additions & 0 deletions mscore/actions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
60 changes: 60 additions & 0 deletions mscore/data/icons/media-playback-loop.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions mscore/data/shortcuts.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
1 change: 1 addition & 0 deletions mscore/icons.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion mscore/icons.h
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
6 changes: 6 additions & 0 deletions mscore/musescore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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") {
Expand Down
2 changes: 2 additions & 0 deletions mscore/musescore.h
Original file line number Diff line number Diff line change
Expand Up @@ -342,6 +342,7 @@ class MuseScore : public QMainWindow, public MuseScoreCore {
Shortcut* lastShortcut;

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

QLabel* cornerLabel;
Expand Down Expand Up @@ -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();
Expand Down
1 change: 1 addition & 0 deletions mscore/musescore.qrc
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
1 change: 1 addition & 0 deletions mscore/playpanel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)));
Expand Down
7 changes: 7 additions & 0 deletions mscore/playpanel.ui
Original file line number Diff line number Diff line change
Expand Up @@ -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">
Expand Down
2 changes: 1 addition & 1 deletion mscore/revision.h
Original file line number Diff line number Diff line change
@@ -1 +1 @@
Unknown
e47d9de
23 changes: 20 additions & 3 deletions mscore/seq.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,17 @@ void Seq::rewindStart()
{
seek(0);
}

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

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

//---------------------------------------------------------
// canStart
Expand Down Expand Up @@ -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');
}
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -696,7 +713,7 @@ void Seq::process(unsigned n, float* buffer)
peakTimer[1] = 0;
}
}

//---------------------------------------------------------
// initInstruments
//---------------------------------------------------------
Expand Down
1 change: 1 addition & 0 deletions mscore/seq.h
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,7 @@ class Seq : public QObject, public Sequencer {
~Seq();
bool canStart();
void rewindStart();
void loopStart();
void seekEnd();
void nextMeasure();
void nextChord();
Expand Down

0 comments on commit 3543170

Please sign in to comment.