Improved metronome (on/off during song, pattern and bb playback) #2278

Merged
merged 1 commit into from Aug 29, 2015

Projects

None yet

4 participants

@michaelgregorius
Contributor

There is a new tool button that can be used to turn the metronome on and
off. Per default the metronome is turned off. When enabled the metronome
will play during on song playback, pattern playback and BB playback. During
export it is ignored.

A new icon was added as well.

The state is currently stored in the Mixer. It might make sense to put
the metronome configuration in its own class in the future. The state is
currently not stored in the file but this might be a good choice for now
until a better place is found for the metronome data.

@michaelgregorius
Contributor

I saw in the forum that there seems to be a need for an improved metronome functionality so I thought to give it a first shot. :)
metronome-icon

Also related to #475.

@tresf
Member
tresf commented Aug 17, 2015

Well need addition!

Also related: #869 (@musikBear), #1357 (@Reaper10)

@Wallacoloo Wallacoloo commented on an outdated diff Aug 28, 2015
src/core/Mixer.cpp
@@ -318,10 +319,13 @@ const surroundSampleFrame * Mixer::renderNextBuffer()
static Song::PlayPos last_metro_pos = -1;
- Song::PlayPos p = Engine::getSong()->getPlayPos(
- Song::Mode_PlayPattern );
- if( Engine::getSong()->playMode() == Song::Mode_PlayPattern &&
- gui->pianoRoll()->isRecording() == true &&
+ Song::PlayModes currentPlayMode = Engine::getSong()->playMode();
+ Song::PlayPos p = Engine::getSong()->getPlayPos( currentPlayMode );
+
+ if( ( currentPlayMode == Song::Mode_PlayPattern || currentPlayMode == Song::Mode_PlaySong
+ || currentPlayMode == Song::Mode_PlayBB ) &&
+ m_metronomeActive &&
+ !Engine::getSong()->isExporting() &&
p != last_metro_pos )
{
@Wallacoloo
Wallacoloo Aug 28, 2015 Member

What do you think of decomposing the conditional a bit? Maybe something like:

bool isPlaying = currentPlayMode == Song::Mode_PlayPattern || currentPlayMode == Song::Mode_PlaySong
         || currentPlayMode == Song::Mode_PlayBB;
if (isPlaying && m_metronomeActive && !Engine::getSong()->isExporting() &&
        p != last_metro_pos) ...

Hope I'm not being too pedantic. Everything else looks good.

@Wallacoloo
Member

Tested & works as described (via git checkout michaelgregorius/metronome-improvements && git rebase master && make install).

I've left one code comment for @michaelgregorius to address. Pending further feedback, this should be good to merge.

@musikBear

@michaelgregorius Big 👍 The metronome has been one of the most criticized features, and a toggle options is brilliant. The Master's two different sounds, and yours toggle-option, makes metronome a really good feature in lmms!

@michaelgregorius michaelgregorius Improved metronome (on/off during song, pattern and bb playback)
There is a new tool button that can be used to turn the metronome on and
off. Per default the metronome is turned off. When enabled the metronome
will during on song playback, pattern playback and BB playback. During
export it is ignored.

A new icon was added as well.

The state is currently stored in the Mixer. It might make sense to put
the metronome configuration in its own class in the future. The state is
currently not stored in the file but this might be a good choice for now
until a better place is found for the metronome data.

Also removed some repeated calls to Engine::getSong() and
Engine::fxMixer().
5b2e77b
@michaelgregorius
Contributor

@Wallacoloo I have incorporated your proposal for a decomposition of the conditional. I have also rebased against master and squashed the commit.

@michaelgregorius
Contributor

@musikBear Thanks for the kind words! Knowing that a feature is wanted by users and therefore is also used is always a great motivation. 😃

@Wallacoloo
Member

👍

@Wallacoloo Wallacoloo merged commit 45c4aa6 into LMMS:master Aug 29, 2015

1 check passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details
@michaelgregorius michaelgregorius deleted the michaelgregorius:metronome-improvements branch Aug 29, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment