mirror of
https://github.com/cookiengineer/audacity
synced 2025-04-30 07:39:42 +02:00
I think this completes the refactoring for const-rate vs var-rate resampling.
This commit is contained in:
parent
1625b87aab
commit
ce9bd9fa90
@ -1319,7 +1319,7 @@ int AudioIO::StartStream(WaveTrackArray playbackTracks,
|
||||
|
||||
// Set everything to zero in case we have to delete these due to a memory exception.
|
||||
memset(mCaptureBuffers, 0, sizeof(RingBuffer*)*mCaptureTracks.GetCount());
|
||||
memset(mResample, 0, sizeof(Resample*)*mCaptureTracks.GetCount());
|
||||
memset(mResample, 0, sizeof(ConstRateResample*)*mCaptureTracks.GetCount());
|
||||
|
||||
for( unsigned int i = 0; i < mCaptureTracks.GetCount(); i++ )
|
||||
{
|
||||
|
43
src/Mix.cpp
43
src/Mix.cpp
@ -281,15 +281,17 @@ Mixer::Mixer(int numInputTracks, WaveTrack **inputTracks,
|
||||
mQueueStart = new int[mNumInputTracks];
|
||||
mQueueLen = new int[mNumInputTracks];
|
||||
mSampleQueue = new float *[mNumInputTracks];
|
||||
mSRC = new Resample*[mNumInputTracks]; //vvvvv
|
||||
mResample = new Resample*[mNumInputTracks];
|
||||
for(i=0; i<mNumInputTracks; i++) {
|
||||
double factor = (mRate / mInputTrack[i]->GetRate());
|
||||
double lowFactor = factor, highFactor = factor;
|
||||
if (timeTrack) {
|
||||
highFactor /= timeTrack->GetRangeLower() / 100.0;
|
||||
lowFactor /= timeTrack->GetRangeUpper() / 100.0;
|
||||
mResample[i] = new VarRateResample(highQuality, lowFactor, highFactor);
|
||||
} else {
|
||||
mResample[i] = new ConstRateResample(highQuality, factor);
|
||||
}
|
||||
mSRC[i] = new Resample(); //vvvvv
|
||||
mSampleQueue[i] = new float[mQueueMaxLen];
|
||||
mQueueStart[i] = 0;
|
||||
mQueueLen[i] = 0;
|
||||
@ -318,10 +320,10 @@ Mixer::~Mixer()
|
||||
delete[] mSamplePos;
|
||||
|
||||
for(i=0; i<mNumInputTracks; i++) {
|
||||
delete mSRC[i];
|
||||
delete mResample[i];
|
||||
delete[] mSampleQueue[i];
|
||||
}
|
||||
delete[] mSRC;
|
||||
delete[] mResample;
|
||||
delete[] mSampleQueue;
|
||||
delete[] mQueueStart;
|
||||
delete[] mQueueLen;
|
||||
@ -371,7 +373,7 @@ void MixBuffers(int numChannels, int *channelFlags, float *gains,
|
||||
sampleCount Mixer::MixVariableRates(int *channelFlags, WaveTrack *track,
|
||||
sampleCount *pos, float *queue,
|
||||
int *queueStart, int *queueLen,
|
||||
Resample *SRC)
|
||||
Resample * pResample)
|
||||
{
|
||||
double trackRate = track->GetRate();
|
||||
double initialWarp = mRate / trackRate;
|
||||
@ -436,12 +438,17 @@ sampleCount Mixer::MixVariableRates(int *channelFlags, WaveTrack *track,
|
||||
}
|
||||
|
||||
double factor = initialWarp;
|
||||
if (mTimeTrack) {
|
||||
double warpFactor = mTimeTrack->GetEnvelope()->GetValue(t);
|
||||
warpFactor = (mTimeTrack->GetRangeLower() * (1.0 - warpFactor) +
|
||||
warpFactor * mTimeTrack->GetRangeUpper()) / 100.0;
|
||||
if (mTimeTrack)
|
||||
{
|
||||
Envelope* pEnvelope = mTimeTrack->GetEnvelope();
|
||||
if (pEnvelope)
|
||||
{
|
||||
double warpFactor = pEnvelope->GetValue(t);
|
||||
warpFactor = (mTimeTrack->GetRangeLower() * (1.0 - warpFactor) +
|
||||
warpFactor * mTimeTrack->GetRangeUpper()) / 100.0;
|
||||
|
||||
factor /= warpFactor;
|
||||
factor /= warpFactor;
|
||||
}
|
||||
}
|
||||
|
||||
sampleCount thisProcessLen = mProcessLen;
|
||||
@ -451,13 +458,13 @@ sampleCount Mixer::MixVariableRates(int *channelFlags, WaveTrack *track,
|
||||
}
|
||||
|
||||
int input_used;
|
||||
int outgen = SRC->Process(factor,
|
||||
&queue[*queueStart],
|
||||
thisProcessLen,
|
||||
last,
|
||||
&input_used,
|
||||
&mFloatBuffer[out],
|
||||
mMaxOut - out);
|
||||
int outgen = pResample->Process(factor,
|
||||
&queue[*queueStart],
|
||||
thisProcessLen,
|
||||
last,
|
||||
&input_used,
|
||||
&mFloatBuffer[out],
|
||||
mMaxOut - out);
|
||||
|
||||
if (outgen < 0) {
|
||||
return 0;
|
||||
@ -577,7 +584,7 @@ sampleCount Mixer::Process(sampleCount maxToProcess)
|
||||
track->GetRate() != mRate)
|
||||
out = MixVariableRates(channelFlags, track,
|
||||
&mSamplePos[i], mSampleQueue[i],
|
||||
&mQueueStart[i], &mQueueLen[i], mSRC[i]);
|
||||
&mQueueStart[i], &mQueueLen[i], mResample[i]);
|
||||
else
|
||||
out = MixSameRate(channelFlags, track, &mSamplePos[i]);
|
||||
|
||||
|
@ -122,7 +122,7 @@ class AUDACITY_DLL_API Mixer {
|
||||
sampleCount MixVariableRates(int *channelFlags, WaveTrack *track,
|
||||
sampleCount *pos, float *queue,
|
||||
int *queueStart, int *queueLen,
|
||||
Resample *SRC);
|
||||
Resample * pResample);
|
||||
|
||||
private:
|
||||
// Input
|
||||
@ -136,7 +136,7 @@ class AUDACITY_DLL_API Mixer {
|
||||
double mT; // Current time
|
||||
double mT0; // Start time
|
||||
double mT1; // Stop time (none if mT0==mT1)
|
||||
Resample **mSRC;
|
||||
Resample **mResample;
|
||||
float **mSampleQueue;
|
||||
int *mQueueStart;
|
||||
int *mQueueLen;
|
||||
|
@ -126,7 +126,6 @@
|
||||
|
||||
|
||||
// variable-rate resampler(s)
|
||||
|
||||
#if USE_LIBRESAMPLE
|
||||
|
||||
#include "libresample.h"
|
||||
@ -138,7 +137,7 @@
|
||||
else
|
||||
mMethod = GetFastMethod();
|
||||
|
||||
mHandle = resample_open(mMethod, minFactor, maxFactor);
|
||||
mHandle = resample_open(mMethod, dMinFactor, dMaxFactor);
|
||||
}
|
||||
|
||||
VarRateResample::~VarRateResample()
|
||||
@ -265,12 +264,12 @@
|
||||
}
|
||||
|
||||
int VarRateResample::Process(double factor,
|
||||
float *inBuffer,
|
||||
int inBufferLen,
|
||||
bool lastFlag,
|
||||
int *inBufferUsed,
|
||||
float *outBuffer,
|
||||
int outBufferLen)
|
||||
float *inBuffer,
|
||||
int inBufferLen,
|
||||
bool lastFlag,
|
||||
int *inBufferUsed,
|
||||
float *outBuffer,
|
||||
int outBufferLen)
|
||||
{
|
||||
if (mInitial) {
|
||||
src_set_ratio((SRC_STATE *)mHandle, factor);
|
||||
@ -299,7 +298,7 @@
|
||||
}
|
||||
|
||||
#else // no var-rate resampler
|
||||
VarRateResample::VarRateResample(const bool useBestMethod, const double dFactor)
|
||||
VarRateResample::VarRateResample(const bool useBestMethod, const double dMinFactor, const double dMaxFactor)
|
||||
: Resample()
|
||||
{
|
||||
}
|
||||
|
@ -89,6 +89,8 @@ void TimeTrack::Init(const TimeTrack &orig)
|
||||
TimeTrack::~TimeTrack()
|
||||
{
|
||||
delete mEnvelope;
|
||||
mEnvelope = NULL;
|
||||
|
||||
delete mRuler;
|
||||
}
|
||||
|
||||
|
@ -346,7 +346,10 @@ WaveClip::WaveClip(WaveClip& orig, DirManager *projDirManager)
|
||||
WaveClip::~WaveClip()
|
||||
{
|
||||
delete mSequence;
|
||||
|
||||
delete mEnvelope;
|
||||
mEnvelope = NULL;
|
||||
|
||||
delete mWaveCache;
|
||||
delete mSpecCache;
|
||||
delete mSpecPxCache;
|
||||
|
@ -97,6 +97,7 @@ TranscriptionToolBar::~TranscriptionToolBar()
|
||||
#endif
|
||||
if (mTimeTrack) {
|
||||
delete mTimeTrack;
|
||||
mTimeTrack = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -21,6 +21,7 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Audacity", "Projects\Audaci
|
||||
{D96C7BE1-E3F1-4767-BBBB-320E082CE425} = {D96C7BE1-E3F1-4767-BBBB-320E082CE425}
|
||||
{7AA41BED-41B0-427A-9148-DEA40549D158} = {7AA41BED-41B0-427A-9148-DEA40549D158}
|
||||
{A61E2BF1-21AA-4118-B0D8-FD3D53DB892E} = {A61E2BF1-21AA-4118-B0D8-FD3D53DB892E}
|
||||
{F00717F2-67C8-44E1-AF00-541DFA9CB7F2} = {F00717F2-67C8-44E1-AF00-541DFA9CB7F2}
|
||||
{A939AAF8-44F1-4CE7-9DD0-7A6E99814857} = {A939AAF8-44F1-4CE7-9DD0-7A6E99814857}
|
||||
EndProjectSection
|
||||
EndProject
|
||||
|
@ -22,13 +22,13 @@
|
||||
// #define USE_LIBLRDF 1
|
||||
#define USE_LIBMAD 1
|
||||
|
||||
// Resamplers
|
||||
// Resamplers.
|
||||
// Only one of each type of resampler (constant or variable rate) should be defined.
|
||||
// libsoxr is used for constant-rate resampling.
|
||||
#define USE_LIBSOXR 1
|
||||
// Should build only one of libresample or libsamplerate for variable-rate resampling,
|
||||
// but if both are defined, USE_LIBRESAMPLE is used and USE_LIBSAMPLERATE is not.
|
||||
//vvvvv Turn back on after completing refactoring.
|
||||
#undef USE_LIBRESAMPLE
|
||||
#define USE_LIBRESAMPLE 1
|
||||
#undef USE_LIBSAMPLERATE
|
||||
|
||||
#define USE_LIBTWOLAME 1
|
||||
|
Loading…
x
Reference in New Issue
Block a user