Steve Daulton's patch for fractional BPM
This commit is contained in:
parent
89b2005e49
commit
e2f272890c
|
@ -45,8 +45,8 @@
|
||||||
EffectChangeTempo::EffectChangeTempo()
|
EffectChangeTempo::EffectChangeTempo()
|
||||||
{
|
{
|
||||||
m_PercentChange = 0.0;
|
m_PercentChange = 0.0;
|
||||||
m_FromBPM = 0; // indicates not yet set
|
m_FromBPM = 0.0; // indicates not yet set
|
||||||
m_ToBPM = 0; // indicates not yet set
|
m_ToBPM = 0.0; // indicates not yet set
|
||||||
m_FromLength = 0.0;
|
m_FromLength = 0.0;
|
||||||
m_ToLength = 0.0;
|
m_ToLength = 0.0;
|
||||||
}
|
}
|
||||||
|
@ -164,8 +164,8 @@ ChangeTempoDialog::ChangeTempoDialog(EffectChangeTempo *effect, wxWindow *parent
|
||||||
|
|
||||||
// effect parameters
|
// effect parameters
|
||||||
m_PercentChange = 0.0;
|
m_PercentChange = 0.0;
|
||||||
m_FromBPM = 0; // indicates not yet set
|
m_FromBPM = 0.0; // indicates not yet set
|
||||||
m_ToBPM = 0; // indicates not yet set
|
m_ToBPM = 0.0; // indicates not yet set
|
||||||
m_FromLength = 0.0;
|
m_FromLength = 0.0;
|
||||||
m_ToLength = 0.0;
|
m_ToLength = 0.0;
|
||||||
|
|
||||||
|
@ -245,15 +245,15 @@ bool ChangeTempoDialog::TransferDataToWindow()
|
||||||
// from/to BPM controls
|
// from/to BPM controls
|
||||||
wxString str;
|
wxString str;
|
||||||
if (m_pTextCtrl_FromBPM) {
|
if (m_pTextCtrl_FromBPM) {
|
||||||
if (m_FromBPM != 0)
|
if (m_FromBPM != 0.0)
|
||||||
str.Printf(wxT("%d"), m_FromBPM);
|
str.Printf(wxT("%.3f"), m_FromBPM);
|
||||||
else
|
else
|
||||||
str = wxT("");
|
str = wxT("");
|
||||||
m_pTextCtrl_FromBPM->SetValue(str);
|
m_pTextCtrl_FromBPM->SetValue(str);
|
||||||
}
|
}
|
||||||
if (m_pTextCtrl_ToBPM) {
|
if (m_pTextCtrl_ToBPM) {
|
||||||
if (m_ToBPM != 0)
|
if (m_ToBPM != 0.0)
|
||||||
str.Printf(wxT("%d"), m_ToBPM);
|
str.Printf(wxT("%.3f"), m_ToBPM);
|
||||||
else
|
else
|
||||||
str = wxT("");
|
str = wxT("");
|
||||||
m_pTextCtrl_ToBPM->SetValue(str);
|
m_pTextCtrl_ToBPM->SetValue(str);
|
||||||
|
@ -291,24 +291,24 @@ bool ChangeTempoDialog::TransferDataFromWindow()
|
||||||
// always tracks it & is more precise (decimal points).
|
// always tracks it & is more precise (decimal points).
|
||||||
|
|
||||||
// from/to BPM controls
|
// from/to BPM controls
|
||||||
long newLong;
|
double newValue;
|
||||||
if (m_pTextCtrl_FromBPM) {
|
if (m_pTextCtrl_FromBPM) {
|
||||||
str = m_pTextCtrl_FromBPM->GetValue();
|
str = m_pTextCtrl_FromBPM->GetValue();
|
||||||
str.ToLong(&newLong);
|
str.ToDouble(&newValue);
|
||||||
m_FromBPM = (unsigned int)(newLong);
|
m_FromBPM = newValue;
|
||||||
}
|
}
|
||||||
if (m_pTextCtrl_ToBPM) {
|
if (m_pTextCtrl_ToBPM) {
|
||||||
str = m_pTextCtrl_ToBPM->GetValue();
|
str = m_pTextCtrl_ToBPM->GetValue();
|
||||||
str.ToLong(&newLong);
|
str.ToDouble(&newValue);
|
||||||
m_ToBPM = (unsigned int)(newLong);
|
m_ToBPM = newValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
// from/to Length controls
|
// from/to Length controls
|
||||||
// Don't do m_pTextCtrl_ToLength. It's disabled.
|
// Don't do m_pTextCtrl_ToLength. It's disabled.
|
||||||
if (m_pTextCtrl_ToLength) {
|
if (m_pTextCtrl_ToLength) {
|
||||||
str = m_pTextCtrl_ToLength->GetValue();
|
str = m_pTextCtrl_ToLength->GetValue();
|
||||||
str.ToLong(&newLong);
|
str.ToDouble(&newValue);
|
||||||
m_ToLength = (int)(newLong);
|
m_ToLength = newValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
@ -316,7 +316,7 @@ bool ChangeTempoDialog::TransferDataFromWindow()
|
||||||
|
|
||||||
// handler implementations for ChangeTempoDialog
|
// handler implementations for ChangeTempoDialog
|
||||||
|
|
||||||
void ChangeTempoDialog::OnText_PercentChange(wxCommandEvent & event)
|
void ChangeTempoDialog::OnText_PercentChange(wxCommandEvent & WXUNUSED(event))
|
||||||
{
|
{
|
||||||
if (m_bLoopDetect)
|
if (m_bLoopDetect)
|
||||||
return;
|
return;
|
||||||
|
@ -337,7 +337,7 @@ void ChangeTempoDialog::OnText_PercentChange(wxCommandEvent & event)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ChangeTempoDialog::OnSlider_PercentChange(wxCommandEvent & event)
|
void ChangeTempoDialog::OnSlider_PercentChange(wxCommandEvent & WXUNUSED(event))
|
||||||
{
|
{
|
||||||
if (m_bLoopDetect)
|
if (m_bLoopDetect)
|
||||||
return;
|
return;
|
||||||
|
@ -356,16 +356,16 @@ void ChangeTempoDialog::OnSlider_PercentChange(wxCommandEvent & event)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ChangeTempoDialog::OnText_FromBPM(wxCommandEvent & event)
|
void ChangeTempoDialog::OnText_FromBPM(wxCommandEvent & WXUNUSED(event))
|
||||||
{
|
{
|
||||||
if (m_bLoopDetect)
|
if (m_bLoopDetect)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (m_pTextCtrl_FromBPM) {
|
if (m_pTextCtrl_FromBPM) {
|
||||||
wxString str = m_pTextCtrl_FromBPM->GetValue();
|
wxString str = m_pTextCtrl_FromBPM->GetValue();
|
||||||
long newValue;
|
double newValue;
|
||||||
str.ToLong(&newValue);
|
str.ToDouble(&newValue);
|
||||||
m_FromBPM = (unsigned int)(newValue);
|
m_FromBPM = newValue;
|
||||||
|
|
||||||
m_bLoopDetect = true;
|
m_bLoopDetect = true;
|
||||||
|
|
||||||
|
@ -375,22 +375,22 @@ void ChangeTempoDialog::OnText_FromBPM(wxCommandEvent & event)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ChangeTempoDialog::OnText_ToBPM(wxCommandEvent & event)
|
void ChangeTempoDialog::OnText_ToBPM(wxCommandEvent & WXUNUSED(event))
|
||||||
{
|
{
|
||||||
if (m_bLoopDetect)
|
if (m_bLoopDetect)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (m_pTextCtrl_ToBPM) {
|
if (m_pTextCtrl_ToBPM) {
|
||||||
wxString str = m_pTextCtrl_ToBPM->GetValue();
|
wxString str = m_pTextCtrl_ToBPM->GetValue();
|
||||||
long newValue;
|
double newValue;
|
||||||
str.ToLong(&newValue);
|
str.ToDouble(&newValue);
|
||||||
m_ToBPM = (unsigned int)(newValue);
|
m_ToBPM = newValue;
|
||||||
|
|
||||||
m_bLoopDetect = true;
|
m_bLoopDetect = true;
|
||||||
|
|
||||||
// If FromBPM has already been set, then there's a new percent change.
|
// If FromBPM has already been set, then there's a new percent change.
|
||||||
if (m_FromBPM != 0) {
|
if (m_FromBPM != 0.0) {
|
||||||
m_PercentChange = (((double)(m_ToBPM) * 100.0) / (double)(m_FromBPM)) - 100.0;
|
m_PercentChange = ((m_ToBPM * 100.0) / m_FromBPM) - 100.0;
|
||||||
|
|
||||||
this->Update_Text_PercentChange();
|
this->Update_Text_PercentChange();
|
||||||
this->Update_Slider_PercentChange();
|
this->Update_Slider_PercentChange();
|
||||||
|
@ -402,7 +402,7 @@ void ChangeTempoDialog::OnText_ToBPM(wxCommandEvent & event)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ChangeTempoDialog::OnText_ToLength(wxCommandEvent & event)
|
void ChangeTempoDialog::OnText_ToLength(wxCommandEvent & WXUNUSED(event))
|
||||||
{
|
{
|
||||||
if (m_bLoopDetect)
|
if (m_bLoopDetect)
|
||||||
return;
|
return;
|
||||||
|
@ -426,7 +426,7 @@ void ChangeTempoDialog::OnText_ToLength(wxCommandEvent & event)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ChangeTempoDialog::OnPreview(wxCommandEvent &event)
|
void ChangeTempoDialog::OnPreview(wxCommandEvent & WXUNUSED(event))
|
||||||
{
|
{
|
||||||
TransferDataFromWindow();
|
TransferDataFromWindow();
|
||||||
|
|
||||||
|
@ -471,15 +471,13 @@ void ChangeTempoDialog::Update_Text_ToBPM()
|
||||||
// Use m_FromBPM & m_PercentChange to set new m_ToBPM & control.
|
// Use m_FromBPM & m_PercentChange to set new m_ToBPM & control.
|
||||||
{
|
{
|
||||||
// Update ToBPM iff FromBPM has been set.
|
// Update ToBPM iff FromBPM has been set.
|
||||||
if (m_FromBPM == 0)
|
if (m_FromBPM == 0.0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
m_ToBPM = (unsigned int)((((double)(m_FromBPM) *
|
m_ToBPM = (((m_FromBPM * (100.0 + m_PercentChange)) / 100.0));
|
||||||
(100.0 + m_PercentChange)) / 100.0) +
|
|
||||||
0.5); // Add 0.5 so trunc -> round.
|
|
||||||
if (m_pTextCtrl_ToBPM) {
|
if (m_pTextCtrl_ToBPM) {
|
||||||
wxString str;
|
wxString str;
|
||||||
str.Printf(wxT("%d"), m_ToBPM);
|
str.Printf(wxT("%.3f"), m_ToBPM);
|
||||||
m_pTextCtrl_ToBPM->SetValue(str);
|
m_pTextCtrl_ToBPM->SetValue(str);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -65,8 +65,8 @@ class EffectChangeTempo : public EffectSoundTouch {
|
||||||
private:
|
private:
|
||||||
double m_PercentChange; // percent change to apply to tempo
|
double m_PercentChange; // percent change to apply to tempo
|
||||||
// -100% is meaningless, but sky's the upper limit
|
// -100% is meaningless, but sky's the upper limit
|
||||||
unsigned int m_FromBPM; // user-set beats-per-minute. Zero means not yet set.
|
double m_FromBPM; // user-set beats-per-minute. Zero means not yet set.
|
||||||
unsigned int m_ToBPM; // Zero value means not yet set.
|
double m_ToBPM; // Zero value means not yet set.
|
||||||
double m_FromLength; // starting length of selection
|
double m_FromLength; // starting length of selection
|
||||||
double m_ToLength; // target length of selection
|
double m_ToLength; // target length of selection
|
||||||
|
|
||||||
|
@ -119,8 +119,8 @@ class ChangeTempoDialog:public EffectDialog {
|
||||||
double m_PercentChange; // percent change to apply to tempo
|
double m_PercentChange; // percent change to apply to tempo
|
||||||
// -100% is meaningless, but sky's the upper limit.
|
// -100% is meaningless, but sky's the upper limit.
|
||||||
// Slider is (-100, 200], but textCtrls can set higher.
|
// Slider is (-100, 200], but textCtrls can set higher.
|
||||||
unsigned int m_FromBPM; // user-set beats-per-minute. Zero means not yet set.
|
double m_FromBPM; // user-set beats-per-minute. Zero means not yet set.
|
||||||
unsigned int m_ToBPM; // Zero value means not yet set.
|
double m_ToBPM; // Zero value means not yet set.
|
||||||
double m_FromLength; // starting length of selection
|
double m_FromLength; // starting length of selection
|
||||||
double m_ToLength; // target length of selection
|
double m_ToLength; // target length of selection
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user