Skip to content

Commit

Permalink
Add record count down
Browse files Browse the repository at this point in the history
  • Loading branch information
liushuyu committed Mar 30, 2017
1 parent fc272d7 commit b816c87
Show file tree
Hide file tree
Showing 5 changed files with 73 additions and 7 deletions.
9 changes: 9 additions & 0 deletions include/MainWindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@

#include "ConfigManager.h"
#include "SubWindow.h"
#include "LcdSpinBox.h"

class QAction;
class QDomElement;
Expand Down Expand Up @@ -168,6 +169,7 @@ public slots:
void toggleFxMixerWin();
void togglePianoRollWin();
void toggleControllerRack();
void updateCountDownDuration();

void updatePlayPauseIcons();

Expand Down Expand Up @@ -224,6 +226,7 @@ public slots:

QBasicTimer m_updateTimer;
QTimer m_autoSaveTimer;
QTimer m_recordCountDownTimer;
int m_autoSaveInterval;

friend class GuiApplication;
Expand All @@ -232,6 +235,10 @@ public slots:

ToolButton * m_metronomeToggle;

LcdSpinBox * m_countDownClock;

LcdSpinBoxModel * m_countDownValue;

SessionState m_session;

private slots:
Expand All @@ -243,6 +250,8 @@ private slots:
void updateViewMenu( void );
void updateConfig( QAction * _who );
void onToggleMetronome();
void startRecordCountDown();
void decrementRecordCountDown();


signals:
Expand Down
6 changes: 6 additions & 0 deletions include/Song.h
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,10 @@ class EXPORT Song : public TrackContainer
return m_timeSigModel;
}

void setRecordDelay( int time );
int getRecordDelay();
void startRecordCountDown();


public slots:
void playSong();
Expand Down Expand Up @@ -358,6 +362,7 @@ private slots:
PlayModes m_playMode;
PlayPos m_playPos[Mode_Count];
tact_t m_length;
int m_recordDelay;

const Pattern* m_patternToPlay;
bool m_loopPattern;
Expand All @@ -384,6 +389,7 @@ private slots:
void controllerAdded( Controller * );
void controllerRemoved( Controller * );
void updateSampleTracks();
void recordCoundDown();

} ;

Expand Down
16 changes: 15 additions & 1 deletion src/core/Song.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ Song::Song() :
m_errors( new QList<QString>() ),
m_playMode( Mode_None ),
m_length( 0 ),
m_recordDelay( 0 ),
m_patternToPlay( NULL ),
m_loopPattern( false ),
m_elapsedMilliSeconds( 0 ),
Expand Down Expand Up @@ -1545,10 +1546,23 @@ void Song::removeController( Controller * controller )
delete controller;

this->setModified();
}
}
}

void Song::setRecordDelay(int time)
{
m_recordDelay = time;
}

int Song::getRecordDelay()
{
return m_recordDelay;
}

void Song::startRecordCountDown()
{
emit recordCoundDown();
}


void Song::clearErrors()
Expand Down
43 changes: 39 additions & 4 deletions src/gui/MainWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ MainWindow::MainWindow() :
m_recentlyOpenedProjectsMenu( NULL ),
m_toolsMenu( NULL ),
m_autoSaveTimer( this ),
m_recordCountDownTimer( this ),
m_viewMenu( NULL ),
m_metronomeToggle( 0 ),
m_session( Normal )
Expand Down Expand Up @@ -209,11 +210,13 @@ MainWindow::MainWindow() :

connect( Engine::getSong(), SIGNAL( playbackStateChanged() ),
this, SLOT( updatePlayPauseIcons() ) );
connect( &m_recordCountDownTimer, SIGNAL( timeout()), this, SLOT(decrementRecordCountDown()) );
connect( Engine::getSong(), SIGNAL( recordCoundDown()), this, SLOT(startRecordCountDown()) );
m_countDownValue = new LcdSpinBoxModel();
m_countDownValue->setRange( 0, 99 );
}




MainWindow::~MainWindow()
{
for( PluginView *view : m_tools )
Expand Down Expand Up @@ -552,13 +555,20 @@ void MainWindow::finalize()
m_toolBar );
controllers_window->setShortcut( Qt::Key_F11 );

m_countDownClock = new LcdSpinBox(2, this, tr("Count Down Clock"));

m_countDownClock->setLabel( tr("SEC") );
m_countDownClock->setModel( m_countDownValue );
connect( m_countDownValue, SIGNAL(dataChanged()), this, SLOT( updateCountDownDuration() ) );

m_toolBarLayout->addWidget( song_editor_window, 1, 1 );
m_toolBarLayout->addWidget( bb_editor_window, 1, 2 );
m_toolBarLayout->addWidget( piano_roll_window, 1, 3 );
m_toolBarLayout->addWidget( automation_editor_window, 1, 4 );
m_toolBarLayout->addWidget( fx_mixer_window, 1, 5 );
m_toolBarLayout->addWidget( project_notes_window, 1, 6 );
m_toolBarLayout->addWidget( controllers_window, 1, 7 );
m_toolBarLayout->addWidget( m_countDownClock, 1, 8 );
m_toolBarLayout->setColumnStretch( 100, 1 );

// setup-dialog opened before?
Expand Down Expand Up @@ -1295,15 +1305,40 @@ void MainWindow::onToggleMetronome()
{
Mixer * mixer = Engine::mixer();

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

void MainWindow::startRecordCountDown()
{
if ( !m_recordCountDownTimer.isActive() )
{
m_recordCountDownTimer.start( 1000 );
}

}

void MainWindow::decrementRecordCountDown()
{
int currentReadOut = m_countDownValue->value();
if ( currentReadOut - 1 < 0) {
m_recordCountDownTimer.stop();
return;
}
m_countDownValue->setValue( currentReadOut - 1 );

}




void MainWindow::toggleControllerRack()
{
toggleWindow( gui->getControllerRackView() );
toggleWindow( gui->getControllerRackView() );
}

void MainWindow::updateCountDownDuration()
{
Engine::getSong()->setRecordDelay( m_countDownValue->value() );
}


Expand Down
6 changes: 4 additions & 2 deletions src/gui/editors/PianoRoll.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4357,15 +4357,17 @@ void PianoRollWindow::stop()

void PianoRollWindow::record()
{
m_editor->record();
Engine::getSong()->startRecordCountDown();
QTimer::singleShot( Engine::getSong()->getRecordDelay() * 1000 , m_editor, SLOT( record() ) );
}




void PianoRollWindow::recordAccompany()
{
m_editor->recordAccompany();
Engine::getSong()->startRecordCountDown();
QTimer::singleShot( Engine::getSong()->getRecordDelay() * 1000 , m_editor, SLOT( recordAccompany() ) );
}


Expand Down

0 comments on commit b816c87

Please sign in to comment.