Skip to content

Commit

Permalink
Improved metronome (on/off during song, pattern and bb playback)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
michaelgregorius committed Aug 17, 2015
1 parent 5449706 commit a4ae549
Show file tree
Hide file tree
Showing 6 changed files with 39 additions and 7 deletions.
Binary file added data/themes/default/metronome.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions include/MainWindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,8 @@ public slots:

QMenu * m_viewMenu;

ToolButton * m_metronomeToggle;

private slots:
void browseHelp();
void fillTemplatesMenu();
Expand All @@ -192,6 +194,7 @@ private slots:
void updateRecentlyOpenedProjectsMenu();
void updateViewMenu( void );
void updateConfig( QAction * _who );
void onToggleMetronome();


void autoSave();
Expand Down
5 changes: 5 additions & 0 deletions include/Mixer.h
Original file line number Diff line number Diff line change
Expand Up @@ -355,6 +355,9 @@ class EXPORT Mixer : public QObject

void changeQuality( const struct qualitySettings & _qs );

inline bool isMetronomeActive() const { return m_metronomeActive; }
inline void setMetronomeActive(bool value = true) { m_metronomeActive = value; }


signals:
void qualitySettingsChanged();
Expand Down Expand Up @@ -457,6 +460,8 @@ class EXPORT Mixer : public QObject

MixerProfiler m_profiler;

bool m_metronomeActive;

friend class Engine;
friend class MixerWorkerThread;

Expand Down
14 changes: 9 additions & 5 deletions src/core/Mixer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,8 @@ Mixer::Mixer( bool renderOnly ) :
m_audioDev( NULL ),
m_oldAudioDev( NULL ),
m_globalMutex( QMutex::Recursive ),
m_profiler()
m_profiler(),
m_metronomeActive(false)
{
for( int i = 0; i < 2; ++i )
{
Expand Down Expand Up @@ -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 )
{
if ( p.getTicks() % (MidiTime::ticksPerTact() / 1 ) == 0 )
Expand Down
22 changes: 21 additions & 1 deletion src/gui/MainWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,8 @@ MainWindow::MainWindow() :
m_recentlyOpenedProjectsMenu( NULL ),
m_toolsMenu( NULL ),
m_autoSaveTimer( this ),
m_viewMenu( NULL )
m_viewMenu( NULL ),
m_metronomeToggle( 0 )
{
setAttribute( Qt::WA_DeleteOnClose );

Expand Down Expand Up @@ -425,6 +426,13 @@ void MainWindow::finalize()
this, SLOT( enterWhatsThisMode() ),
m_toolBar );

m_metronomeToggle = new ToolButton(
embed::getIconPixmap( "metronome" ),
tr( "Toggle metronome" ),
this, SLOT( onToggleMetronome() ),
m_toolBar );
m_metronomeToggle->setCheckable(true);
m_metronomeToggle->setChecked(Engine::mixer()->isMetronomeActive());

m_toolBarLayout->setColumnMinimumWidth( 0, 5 );
m_toolBarLayout->addWidget( project_new, 0, 1 );
Expand All @@ -434,6 +442,7 @@ void MainWindow::finalize()
m_toolBarLayout->addWidget( project_save, 0, 5 );
m_toolBarLayout->addWidget( project_export, 0, 6 );
m_toolBarLayout->addWidget( whatsthis, 0, 7 );
m_toolBarLayout->addWidget( m_metronomeToggle, 0, 8 );


// window-toolbar
Expand Down Expand Up @@ -1187,6 +1196,17 @@ void MainWindow::updateConfig( QAction * _who )
}



void MainWindow::onToggleMetronome()
{
Mixer * mixer = Engine::mixer();

mixer->setMetronomeActive( m_metronomeToggle->isChecked() );
}




void MainWindow::toggleControllerRack()
{
toggleWindow( gui->getControllerRackView() );
Expand Down
2 changes: 1 addition & 1 deletion src/gui/editors/SongEditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ SongEditor::SongEditor( Song * _song ) :
// add some essential widgets to global tool-bar
QWidget * tb = gui->mainWindow()->toolBar();

gui->mainWindow()->addSpacingToToolBar( 10 );
gui->mainWindow()->addSpacingToToolBar( 40 );

m_tempoSpinBox = new LcdSpinBox( 3, tb, tr( "Tempo" ) );
m_tempoSpinBox->setModel( &m_song->m_tempoModel );
Expand Down

0 comments on commit a4ae549

Please sign in to comment.