Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add record count down #3467

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Add record count down #3467

wants to merge 1 commit into from

Conversation

liushuyu
Copy link
Member

@liushuyu liushuyu commented Mar 30, 2017

Do not merge this until it is told to do so

Tagging my "mentor" @jasp00

In respond to #3394


This change is Reviewable

@liushuyu liushuyu requested a review from jasp00 March 30, 2017 19:53
include/MainWindow.h Outdated Show resolved Hide resolved
@@ -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") );
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The countdown should really be in bars/beats, not seconds. When you record you always want to be relative to the beat, because the countdown actually gives musicians time to align themselves with the beat. An arbitrary second value can't do that.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, in this case, we may want to implement a conversion algorithm and makes it public in Engine or somewhere, this problem was also a headache in my previous PR (Go to feature), it will introduce offsets when doing the conversions.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And maybe here we can toggle on the metronome automatically to assist the recording preparation even better?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, absolutely. The metronome ought to be more intuitive, that's a step in the right direction.

Copy link
Member Author

@liushuyu liushuyu Mar 30, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because I think we are going to use QTimer to do the delay process, and QTimer only accepts milliseconds, so we need to first convert ticks into milliseconds.
I came up with such conversion method:
image

The equation (1) is our original algorithm found in TimeDisplayWidget.cpp:112
The equation (2) is to solve the equation (1) given Tick value to express Msec as a function of Tick tempo and TicksPerTack
The equation (4) is to ease manual verification of whether the equation (2) works correctly.
As far as I could tell, given the precise value of ticks (preserving at least 1 decimal point) can give the very close output (around +- 3 msec at 999 BPM)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the final version don't use 1250 like a magic number, cause the TicksPerTact can change in the future. It's better to have a constant that's 24000/TicksPerTact



void MainWindow::toggleControllerRack()
{
toggleWindow( gui->getControllerRackView() );
toggleWindow( gui->getControllerRackView() );
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

missed one spot with spaces here

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 );
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

spaces

Copy link
Member

@jasp00 jasp00 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Countdown should be based on the rendering process, without timers.

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 );
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add

// TODO: Support -1 for automatic

@@ -232,6 +235,10 @@ public slots:

ToolButton * m_metronomeToggle;

LcdSpinBox * m_countDownClock;

LcdSpinBoxModel * m_countDownValue;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You would probably like to have this model in Song because the feature should work with any interface.


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

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should only connect the manualChange signal.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ahh, there's a small problem, I don't know why the manualChange wasn't fired during my testing.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

manualChange works. What object were you connecting?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

manualChange works. What object were you connecting?

I was connectingm_countDownClock, and I found the slot is never got called.

src/gui/MainWindow.cpp Show resolved Hide resolved
@@ -224,6 +226,7 @@ public slots:

QBasicTimer m_updateTimer;
QTimer m_autoSaveTimer;
QTimer m_recordCountDownTimer;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These timer facilities are not needed in the GUI, the model should handle the countdown.

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

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These are not needed.

@@ -254,6 +254,10 @@ class EXPORT Song : public TrackContainer
return m_timeSigModel;
}

void setRecordDelay( int time );
int getRecordDelay();
void startRecordCountDown();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

startRecordCountDown would be private because the countdown should be integrated with record.

@@ -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() ) );
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since the countdown will be based on bars and the metronome is going to play, you should rely on the rendering process and tick count instead of timers.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is because I haven't familiar with the rendering process of LMMS, I will try to understand it before doing this.

@liushuyu
Copy link
Member Author

liushuyu commented Apr 1, 2017

@jasp00 Thanks for your feedback! I will fix the code accordingly.

@liushuyu
Copy link
Member Author

liushuyu commented Apr 8, 2017

Well, I am writing to let you guys know I am still alive and I just have been fully occupied, hopefully I will have some time this weekend.
And I don't know how to make metronome tick while hold the record process, but I'll try to figure this out myself first before asking for help.

@liushuyu
Copy link
Member Author

Okay, I feel like to ditch all the work here, because I think I need a clear mind to implement a better approach.
So I think the implementation should go as follows:

  1. Add count down clock This can be preserved, but the model should be in Song class
  2. In Mixer class, add an exception to metronome trigger condition to make it tick when counting down, and together a count down process here. (IIRC, should be in Mixer::renderNextBuffer() ?)
  3. To prevent note input during count down, we need to modify eachrecord() implementation to block input when in counting down status?

@Umcaruje Umcaruje changed the title [WIP] Add record count down Add record count down May 14, 2017
@Umcaruje Umcaruje added this to the 1.3.0 milestone May 14, 2017
@tresf tresf mentioned this pull request Feb 25, 2018
@mirk0dex
Copy link
Contributor

Any updates?

@Rossmaxx
Copy link
Contributor

Any updates?

Looks like this PR is dead

@Rossmaxx Rossmaxx modified the milestones: 1.3, 1.3+ Jun 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants