mirror of
https://github.com/cookiengineer/audacity
synced 2025-12-19 23:21:33 +01:00
Lasse suggested the change to the BUF_SIZE (on http://forum.audacityteam.org/viewtopic.php?f=50&t=72371 and Steve passed it on. It improves the speed by an order of magnitude, or more.
Also made some int -> sampleCount changes as they looked dodgy. And removed some compiler messages.
This commit is contained in:
@@ -46,7 +46,7 @@
|
|||||||
* Common constants
|
* Common constants
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define BUF_SIZE 4096 // number of samples to process at once
|
#define BUF_SIZE 131072 // number of samples to process at once
|
||||||
#define RMS_WINDOW_SIZE 100 // samples in circular RMS window buffer
|
#define RMS_WINDOW_SIZE 100 // samples in circular RMS window buffer
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -214,7 +214,7 @@ bool EffectAutoDuck::PromptUser()
|
|||||||
|
|
||||||
bool EffectAutoDuck::Process()
|
bool EffectAutoDuck::Process()
|
||||||
{
|
{
|
||||||
int i;
|
sampleCount i;
|
||||||
|
|
||||||
if (GetNumWaveTracks() == 0 || !mControlTrack)
|
if (GetNumWaveTracks() == 0 || !mControlTrack)
|
||||||
return false;
|
return false;
|
||||||
@@ -383,11 +383,11 @@ bool EffectAutoDuck::ApplyDuckFade(int trackNumber, WaveTrack* t,
|
|||||||
{
|
{
|
||||||
bool cancel = false;
|
bool cancel = false;
|
||||||
|
|
||||||
int start = t->TimeToLongSamples(t0);
|
sampleCount start = t->TimeToLongSamples(t0);
|
||||||
int end = t->TimeToLongSamples(t1);
|
sampleCount end = t->TimeToLongSamples(t1);
|
||||||
|
|
||||||
float *buf = new float[BUF_SIZE];
|
float *buf = new float[BUF_SIZE];
|
||||||
int pos = start;
|
sampleCount pos = start;
|
||||||
|
|
||||||
int fadeDownSamples = t->TimeToLongSamples(
|
int fadeDownSamples = t->TimeToLongSamples(
|
||||||
mOuterFadeDownLen + mInnerFadeDownLen);
|
mOuterFadeDownLen + mInnerFadeDownLen);
|
||||||
@@ -408,9 +408,9 @@ bool EffectAutoDuck::ApplyDuckFade(int trackNumber, WaveTrack* t,
|
|||||||
if (len > BUF_SIZE)
|
if (len > BUF_SIZE)
|
||||||
len = BUF_SIZE;
|
len = BUF_SIZE;
|
||||||
|
|
||||||
t->Get((samplePtr)buf, floatSample, pos, (sampleCount)len);
|
t->Get((samplePtr)buf, floatSample, pos, len);
|
||||||
|
|
||||||
for (int i = pos; i < pos + len; i++)
|
for (sampleCount i = pos; i < pos + len; i++)
|
||||||
{
|
{
|
||||||
float gainDown = fadeDownStep * (i - start);
|
float gainDown = fadeDownStep * (i - start);
|
||||||
float gainUp = fadeUpStep * (end - i);;
|
float gainUp = fadeUpStep * (end - i);;
|
||||||
@@ -426,7 +426,7 @@ bool EffectAutoDuck::ApplyDuckFade(int trackNumber, WaveTrack* t,
|
|||||||
buf[i - pos] *= pow(10.0, gain / 20.0);
|
buf[i - pos] *= pow(10.0, gain / 20.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
t->Set((samplePtr)buf, floatSample, pos, (sampleCount)len);
|
t->Set((samplePtr)buf, floatSample, pos, len);
|
||||||
|
|
||||||
pos += len;
|
pos += len;
|
||||||
|
|
||||||
@@ -563,7 +563,7 @@ EffectAutoDuckDialog::EffectAutoDuckDialog(EffectAutoDuck* effect,
|
|||||||
Center();
|
Center();
|
||||||
}
|
}
|
||||||
|
|
||||||
void EffectAutoDuckDialog::OnOk(wxCommandEvent& evt)
|
void EffectAutoDuckDialog::OnOk(wxCommandEvent& WXUNUSED(event))
|
||||||
{
|
{
|
||||||
double duckAmountDb = 0, thresholdDb = 0;
|
double duckAmountDb = 0, thresholdDb = 0;
|
||||||
double innerFadeDownLen = 0, innerFadeUpLen = 0;
|
double innerFadeDownLen = 0, innerFadeUpLen = 0;
|
||||||
@@ -611,12 +611,12 @@ void EffectAutoDuckDialog::OnOk(wxCommandEvent& evt)
|
|||||||
EndModal(wxID_OK);
|
EndModal(wxID_OK);
|
||||||
}
|
}
|
||||||
|
|
||||||
void EffectAutoDuckDialog::OnCancel(wxCommandEvent& evt)
|
void EffectAutoDuckDialog::OnCancel(wxCommandEvent& WXUNUSED(event))
|
||||||
{
|
{
|
||||||
EndModal(wxID_CANCEL);
|
EndModal(wxID_CANCEL);
|
||||||
}
|
}
|
||||||
|
|
||||||
void EffectAutoDuckDialog::OnValueChanged(wxCommandEvent& evt)
|
void EffectAutoDuckDialog::OnValueChanged(wxCommandEvent& WXUNUSED(event))
|
||||||
{
|
{
|
||||||
mPanel->Refresh(false);
|
mPanel->Refresh(false);
|
||||||
}
|
}
|
||||||
@@ -687,7 +687,7 @@ void EffectAutoDuckPanel::ResetControlPoints()
|
|||||||
mControlPoints[duckAmount] = wxPoint(-100,-100);
|
mControlPoints[duckAmount] = wxPoint(-100,-100);
|
||||||
}
|
}
|
||||||
|
|
||||||
void EffectAutoDuckPanel::OnPaint(wxPaintEvent& evt)
|
void EffectAutoDuckPanel::OnPaint(wxPaintEvent& WXUNUSED(event))
|
||||||
{
|
{
|
||||||
int clientWidth, clientHeight;
|
int clientWidth, clientHeight;
|
||||||
GetSize(&clientWidth, &clientHeight);
|
GetSize(&clientWidth, &clientHeight);
|
||||||
@@ -853,14 +853,14 @@ void EffectAutoDuckPanel::OnPaint(wxPaintEvent& evt)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void EffectAutoDuckPanel::OnMouseCaptureChanged(
|
void EffectAutoDuckPanel::OnMouseCaptureChanged(
|
||||||
wxMouseCaptureChangedEvent &evt)
|
wxMouseCaptureChangedEvent& WXUNUSED(event))
|
||||||
{
|
{
|
||||||
SetCursor(wxNullCursor);
|
SetCursor(wxNullCursor);
|
||||||
mCurrentControlPoint = none;
|
mCurrentControlPoint = none;
|
||||||
}
|
}
|
||||||
|
|
||||||
void EffectAutoDuckPanel::OnMouseCaptureLost(
|
void EffectAutoDuckPanel::OnMouseCaptureLost(
|
||||||
wxMouseCaptureLostEvent &evt)
|
wxMouseCaptureLostEvent& WXUNUSED(event))
|
||||||
{
|
{
|
||||||
mCurrentControlPoint = none;
|
mCurrentControlPoint = none;
|
||||||
|
|
||||||
@@ -909,7 +909,7 @@ void EffectAutoDuckPanel::OnLeftDown(wxMouseEvent &evt)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void EffectAutoDuckPanel::OnLeftUp(wxMouseEvent &evt)
|
void EffectAutoDuckPanel::OnLeftUp(wxMouseEvent& WXUNUSED(event))
|
||||||
{
|
{
|
||||||
if (mCurrentControlPoint != none)
|
if (mCurrentControlPoint != none)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user