mirror of
https://github.com/cookiengineer/audacity
synced 2025-09-17 16:50:26 +02:00
Remove naked new[] in: tracks
This commit is contained in:
parent
2b23667211
commit
18be1bdad6
@ -251,8 +251,8 @@ void TimeTrack::Draw(wxDC & dc, const wxRect & r, const ZoomInfo &zoomInfo) cons
|
|||||||
mRuler->SetFlip(GetHeight() > 75 ? true : true); // MB: so why don't we just call Invalidate()? :)
|
mRuler->SetFlip(GetHeight() > 75 ? true : true); // MB: so why don't we just call Invalidate()? :)
|
||||||
mRuler->Draw(dc, this);
|
mRuler->Draw(dc, this);
|
||||||
|
|
||||||
double *envValues = new double[mid.width];
|
Doubles envValues{ size_t(mid.width) };
|
||||||
GetEnvelope()->GetValues(envValues, mid.width, 0, zoomInfo);
|
GetEnvelope()->GetValues(envValues.get(), mid.width, 0, zoomInfo);
|
||||||
|
|
||||||
dc.SetPen(AColor::envelopePen);
|
dc.SetPen(AColor::envelopePen);
|
||||||
|
|
||||||
@ -267,9 +267,6 @@ void TimeTrack::Draw(wxDC & dc, const wxRect & r, const ZoomInfo &zoomInfo) cons
|
|||||||
int thisy = r.y + (int)y;
|
int thisy = r.y + (int)y;
|
||||||
AColor::Line(dc, mid.x + x, thisy - 1, mid.x + x, thisy+2);
|
AColor::Line(dc, mid.x + x, thisy - 1, mid.x + x, thisy+2);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (envValues)
|
|
||||||
delete[]envValues;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void TimeTrack::testMe()
|
void TimeTrack::testMe()
|
||||||
|
@ -1159,13 +1159,13 @@ void TrackArtist::DrawMinMaxRMS(wxDC &dc, const wxRect & rect, const double env[
|
|||||||
int lasth2 = std::numeric_limits<int>::min();
|
int lasth2 = std::numeric_limits<int>::min();
|
||||||
int h1;
|
int h1;
|
||||||
int h2;
|
int h2;
|
||||||
int *r1 = new int[rect.width];
|
ArrayOf<int> r1{ size_t(rect.width) };
|
||||||
int *r2 = new int[rect.width];
|
ArrayOf<int> r2{ size_t(rect.width) };
|
||||||
int *clipped = NULL;
|
ArrayOf<int> clipped;
|
||||||
int clipcnt = 0;
|
int clipcnt = 0;
|
||||||
|
|
||||||
if (mShowClipping) {
|
if (mShowClipping) {
|
||||||
clipped = new int[rect.width];
|
clipped.reinit( size_t(rect.width) );
|
||||||
}
|
}
|
||||||
|
|
||||||
long pixAnimOffset = (long)fabs((double)(wxDateTime::Now().GetTicks() * -10)) +
|
long pixAnimOffset = (long)fabs((double)(wxDateTime::Now().GetTicks() * -10)) +
|
||||||
@ -1296,13 +1296,6 @@ void TrackArtist::DrawMinMaxRMS(wxDC &dc, const wxRect & rect, const double env[
|
|||||||
AColor::Line(dc, xx, rect.y, xx, rect.y + rect.height);
|
AColor::Line(dc, xx, rect.y, xx, rect.y + rect.height);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mShowClipping) {
|
|
||||||
delete[] clipped;
|
|
||||||
}
|
|
||||||
|
|
||||||
delete [] r1;
|
|
||||||
delete [] r2;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void TrackArtist::DrawIndividualSamples(wxDC &dc, int leftOffset, const wxRect &rect,
|
void TrackArtist::DrawIndividualSamples(wxDC &dc, int leftOffset, const wxRect &rect,
|
||||||
@ -1330,16 +1323,16 @@ void TrackArtist::DrawIndividualSamples(wxDC &dc, int leftOffset, const wxRect &
|
|||||||
if (slen <= 0)
|
if (slen <= 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
float *buffer = new float[slen];
|
Floats buffer{ size_t(slen) };
|
||||||
clip->GetSamples((samplePtr)buffer, floatSample, s0, slen);
|
clip->GetSamples((samplePtr)buffer.get(), floatSample, s0, slen);
|
||||||
|
|
||||||
int *xpos = new int[slen];
|
ArrayOf<int> xpos{ size_t(slen) };
|
||||||
int *ypos = new int[slen];
|
ArrayOf<int> ypos{ size_t(slen) };
|
||||||
int *clipped = NULL;
|
ArrayOf<int> clipped;
|
||||||
int clipcnt = 0;
|
int clipcnt = 0;
|
||||||
|
|
||||||
if (mShowClipping)
|
if (mShowClipping)
|
||||||
clipped = new int[slen];
|
clipped.reinit( size_t(slen) );
|
||||||
|
|
||||||
dc.SetPen(muted ? muteSamplePen : samplePen);
|
dc.SetPen(muted ? muteSamplePen : samplePen);
|
||||||
|
|
||||||
@ -1394,14 +1387,6 @@ void TrackArtist::DrawIndividualSamples(wxDC &dc, int leftOffset, const wxRect &
|
|||||||
AColor::Line(dc, rect.x + s, rect.y, rect.x + s, rect.y + rect.height);
|
AColor::Line(dc, rect.x + s, rect.y, rect.x + s, rect.y + rect.height);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mShowClipping) {
|
|
||||||
delete [] clipped;
|
|
||||||
}
|
|
||||||
|
|
||||||
delete[]buffer;
|
|
||||||
delete[]xpos;
|
|
||||||
delete[]ypos;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void TrackArtist::DrawEnvelope(wxDC &dc, const wxRect &rect, const double env[],
|
void TrackArtist::DrawEnvelope(wxDC &dc, const wxRect &rect, const double env[],
|
||||||
@ -2216,8 +2201,7 @@ void TrackArtist::DrawClipSpectrum(WaveTrackCache &waveTrackCache,
|
|||||||
scale2 = (lmax - lmin) / log2,
|
scale2 = (lmax - lmin) / log2,
|
||||||
lmin2 = lmin / log2;
|
lmin2 = lmin / log2;
|
||||||
|
|
||||||
bool *yGrid;
|
ArrayOf<bool> yGrid{size_t(mid.height)};
|
||||||
yGrid = new bool[mid.height];
|
|
||||||
for (int yy = 0; yy < mid.height; ++yy) {
|
for (int yy = 0; yy < mid.height; ++yy) {
|
||||||
float n = (float(yy) / mid.height*scale2 - lmin2) * 12;
|
float n = (float(yy) / mid.height*scale2 - lmin2) * 12;
|
||||||
float n2 = (float(yy + 1) / mid.height*scale2 - lmin2) * 12;
|
float n2 = (float(yy + 1) / mid.height*scale2 - lmin2) * 12;
|
||||||
@ -2286,8 +2270,8 @@ void TrackArtist::DrawClipSpectrum(WaveTrackCache &waveTrackCache,
|
|||||||
i0 = expf(lmin) / binUnit,
|
i0 = expf(lmin) / binUnit,
|
||||||
i1 = expf(scale + lmin) / binUnit,
|
i1 = expf(scale + lmin) / binUnit,
|
||||||
minColor = 0.0f;
|
minColor = 0.0f;
|
||||||
const int maxTableSize = 1024;
|
const size_t maxTableSize = 1024;
|
||||||
int *indexes = new int[maxTableSize];
|
ArrayOf<int> indexes{ maxTableSize };
|
||||||
#endif //EXPERIMENTAL_FIND_NOTES
|
#endif //EXPERIMENTAL_FIND_NOTES
|
||||||
|
|
||||||
#ifdef _OPENMP
|
#ifdef _OPENMP
|
||||||
@ -2525,10 +2509,6 @@ void TrackArtist::DrawClipSpectrum(WaveTrackCache &waveTrackCache,
|
|||||||
memDC.SelectObject(converted);
|
memDC.SelectObject(converted);
|
||||||
|
|
||||||
dc.Blit(mid.x, mid.y, mid.width, mid.height, &memDC, 0, 0, wxCOPY, FALSE);
|
dc.Blit(mid.x, mid.y, mid.width, mid.height, &memDC, 0, 0, wxCOPY, FALSE);
|
||||||
|
|
||||||
#ifdef EXPERIMENTAL_FFT_Y_GRID
|
|
||||||
delete[] yGrid;
|
|
||||||
#endif //EXPERIMENTAL_FFT_Y_GRID
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef USE_MIDI
|
#ifdef USE_MIDI
|
||||||
|
@ -691,29 +691,31 @@ bool WaveClip::GetWaveDisplay(WaveDisplay &display, double t0,
|
|||||||
//wxCriticalSectionLocker locker(mAppendCriticalSection);
|
//wxCriticalSectionLocker locker(mAppendCriticalSection);
|
||||||
|
|
||||||
if (right > left) {
|
if (right > left) {
|
||||||
float *b;
|
Floats b;
|
||||||
|
float *pb{};
|
||||||
// left is nonnegative and at most mAppendBufferLen:
|
// left is nonnegative and at most mAppendBufferLen:
|
||||||
auto sLeft = left.as_size_t();
|
auto sLeft = left.as_size_t();
|
||||||
// The difference is at most mAppendBufferLen:
|
// The difference is at most mAppendBufferLen:
|
||||||
size_t len = ( right - left ).as_size_t();
|
size_t len = ( right - left ).as_size_t();
|
||||||
|
|
||||||
if (seqFormat == floatSample)
|
if (seqFormat == floatSample)
|
||||||
b = &((float *)mAppendBuffer.ptr())[sLeft];
|
pb = &((float *)mAppendBuffer.ptr())[sLeft];
|
||||||
else {
|
else {
|
||||||
b = new float[len];
|
b.reinit(len);
|
||||||
|
pb = b.get();
|
||||||
CopySamples(mAppendBuffer.ptr() + sLeft * SAMPLE_SIZE(seqFormat),
|
CopySamples(mAppendBuffer.ptr() + sLeft * SAMPLE_SIZE(seqFormat),
|
||||||
seqFormat,
|
seqFormat,
|
||||||
(samplePtr)b, floatSample, len);
|
(samplePtr)pb, floatSample, len);
|
||||||
}
|
}
|
||||||
|
|
||||||
float theMax, theMin, sumsq;
|
float theMax, theMin, sumsq;
|
||||||
{
|
{
|
||||||
const float val = b[0];
|
const float val = pb[0];
|
||||||
theMax = theMin = val;
|
theMax = theMin = val;
|
||||||
sumsq = val * val;
|
sumsq = val * val;
|
||||||
}
|
}
|
||||||
for(decltype(len) j = 1; j < len; j++) {
|
for(decltype(len) j = 1; j < len; j++) {
|
||||||
const float val = b[j];
|
const float val = pb[j];
|
||||||
theMax = std::max(theMax, val);
|
theMax = std::max(theMax, val);
|
||||||
theMin = std::min(theMin, val);
|
theMin = std::min(theMin, val);
|
||||||
sumsq += val * val;
|
sumsq += val * val;
|
||||||
@ -724,9 +726,6 @@ bool WaveClip::GetWaveDisplay(WaveDisplay &display, double t0,
|
|||||||
rms[i] = (float)sqrt(sumsq / len);
|
rms[i] = (float)sqrt(sumsq / len);
|
||||||
bl[i] = 1; //for now just fake it.
|
bl[i] = 1; //for now just fake it.
|
||||||
|
|
||||||
if (seqFormat != floatSample)
|
|
||||||
delete[] b;
|
|
||||||
|
|
||||||
didUpdate=true;
|
didUpdate=true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -934,21 +933,21 @@ bool SpecCache::CalculateOneSpectrum
|
|||||||
std::copy(scratch, scratch2, scratch3);
|
std::copy(scratch, scratch2, scratch3);
|
||||||
|
|
||||||
{
|
{
|
||||||
const float *const window = settings.window;
|
const float *const window = settings.window.get();
|
||||||
for (size_t ii = 0; ii < fftLen; ++ii)
|
for (size_t ii = 0; ii < fftLen; ++ii)
|
||||||
scratch[ii] *= window[ii];
|
scratch[ii] *= window[ii];
|
||||||
RealFFTf(scratch, hFFT);
|
RealFFTf(scratch, hFFT);
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
const float *const dWindow = settings.dWindow;
|
const float *const dWindow = settings.dWindow.get();
|
||||||
for (size_t ii = 0; ii < fftLen; ++ii)
|
for (size_t ii = 0; ii < fftLen; ++ii)
|
||||||
scratch2[ii] *= dWindow[ii];
|
scratch2[ii] *= dWindow[ii];
|
||||||
RealFFTf(scratch2, hFFT);
|
RealFFTf(scratch2, hFFT);
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
const float *const tWindow = settings.tWindow;
|
const float *const tWindow = settings.tWindow.get();
|
||||||
for (size_t ii = 0; ii < fftLen; ++ii)
|
for (size_t ii = 0; ii < fftLen; ++ii)
|
||||||
scratch3[ii] *= tWindow[ii];
|
scratch3[ii] *= tWindow[ii];
|
||||||
RealFFTf(scratch3, hFFT);
|
RealFFTf(scratch3, hFFT);
|
||||||
@ -1025,7 +1024,7 @@ bool SpecCache::CalculateOneSpectrum
|
|||||||
|
|
||||||
// This function mutates useBuffer
|
// This function mutates useBuffer
|
||||||
ComputeSpectrumUsingRealFFTf
|
ComputeSpectrumUsingRealFFTf
|
||||||
(useBuffer, settings.hFFT, settings.window, fftLen, results);
|
(useBuffer, settings.hFFT, settings.window.get(), fftLen, results);
|
||||||
if (!gainFactors.empty()) {
|
if (!gainFactors.empty()) {
|
||||||
// Apply a frequency-dependant gain factor
|
// Apply a frequency-dependant gain factor
|
||||||
for (size_t ii = 0; ii < nBins; ++ii)
|
for (size_t ii = 0; ii < nBins; ++ii)
|
||||||
@ -1825,9 +1824,9 @@ bool WaveClip::Resample(int rate, ProgressDialog *progress)
|
|||||||
double factor = (double)rate / (double)mRate;
|
double factor = (double)rate / (double)mRate;
|
||||||
::Resample resample(true, factor, factor); // constant rate resampling
|
::Resample resample(true, factor, factor); // constant rate resampling
|
||||||
|
|
||||||
size_t bufsize = 65536;
|
const size_t bufsize = 65536;
|
||||||
float* inBuffer = new float[bufsize];
|
Floats inBuffer{ bufsize };
|
||||||
float* outBuffer = new float[bufsize];
|
Floats outBuffer{ bufsize };
|
||||||
sampleCount pos = 0;
|
sampleCount pos = 0;
|
||||||
bool error = false;
|
bool error = false;
|
||||||
int outGenerated = 0;
|
int outGenerated = 0;
|
||||||
@ -1847,14 +1846,14 @@ bool WaveClip::Resample(int rate, ProgressDialog *progress)
|
|||||||
|
|
||||||
bool isLast = ((pos + inLen) == numSamples);
|
bool isLast = ((pos + inLen) == numSamples);
|
||||||
|
|
||||||
if (!mSequence->Get((samplePtr)inBuffer, floatSample, pos, inLen))
|
if (!mSequence->Get((samplePtr)inBuffer.get(), floatSample, pos, inLen))
|
||||||
{
|
{
|
||||||
error = true;
|
error = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
const auto results = resample.Process(factor, inBuffer, inLen, isLast,
|
const auto results = resample.Process(factor, inBuffer.get(), inLen, isLast,
|
||||||
outBuffer, bufsize);
|
outBuffer.get(), bufsize);
|
||||||
outGenerated = results.second;
|
outGenerated = results.second;
|
||||||
|
|
||||||
pos += results.first;
|
pos += results.first;
|
||||||
@ -1865,7 +1864,7 @@ bool WaveClip::Resample(int rate, ProgressDialog *progress)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!newSequence->Append((samplePtr)outBuffer, floatSample,
|
if (!newSequence->Append((samplePtr)outBuffer.get(), floatSample,
|
||||||
outGenerated))
|
outGenerated))
|
||||||
{
|
{
|
||||||
error = true;
|
error = true;
|
||||||
@ -1886,9 +1885,6 @@ bool WaveClip::Resample(int rate, ProgressDialog *progress)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
delete[] inBuffer;
|
|
||||||
delete[] outBuffer;
|
|
||||||
|
|
||||||
if (!error)
|
if (!error)
|
||||||
{
|
{
|
||||||
mSequence = std::move(newSequence);
|
mSequence = std::move(newSequence);
|
||||||
|
@ -118,22 +118,17 @@ public:
|
|||||||
class SpecPxCache {
|
class SpecPxCache {
|
||||||
public:
|
public:
|
||||||
SpecPxCache(size_t cacheLen)
|
SpecPxCache(size_t cacheLen)
|
||||||
|
: len{ cacheLen }
|
||||||
|
, values{ len }
|
||||||
{
|
{
|
||||||
len = cacheLen;
|
|
||||||
values = new float[len];
|
|
||||||
valid = false;
|
valid = false;
|
||||||
scaleType = 0;
|
scaleType = 0;
|
||||||
range = gain = -1;
|
range = gain = -1;
|
||||||
minFreq = maxFreq = -1;
|
minFreq = maxFreq = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
~SpecPxCache()
|
|
||||||
{
|
|
||||||
delete[] values;
|
|
||||||
}
|
|
||||||
|
|
||||||
size_t len;
|
size_t len;
|
||||||
float *values;
|
Floats values;
|
||||||
bool valid;
|
bool valid;
|
||||||
|
|
||||||
int scaleType;
|
int scaleType;
|
||||||
|
@ -1425,8 +1425,8 @@ bool WaveTrack::InsertSilence(double t, double len)
|
|||||||
bool WaveTrack::Disjoin(double t0, double t1)
|
bool WaveTrack::Disjoin(double t0, double t1)
|
||||||
{
|
{
|
||||||
auto minSamples = TimeToLongSamples( WAVETRACK_MERGE_POINT_TOLERANCE );
|
auto minSamples = TimeToLongSamples( WAVETRACK_MERGE_POINT_TOLERANCE );
|
||||||
size_t maxAtOnce = 1048576;
|
const size_t maxAtOnce = 1048576;
|
||||||
float *buffer = new float[ maxAtOnce ];
|
Floats buffer{ maxAtOnce };
|
||||||
Regions regions;
|
Regions regions;
|
||||||
|
|
||||||
wxBusyCursor busy;
|
wxBusyCursor busy;
|
||||||
@ -1457,7 +1457,7 @@ bool WaveTrack::Disjoin(double t0, double t1)
|
|||||||
{
|
{
|
||||||
auto numSamples = limitSampleBufferSize( maxAtOnce, len - done );
|
auto numSamples = limitSampleBufferSize( maxAtOnce, len - done );
|
||||||
|
|
||||||
clip->GetSamples( ( samplePtr )buffer, floatSample, start + done,
|
clip->GetSamples( ( samplePtr )buffer.get(), floatSample, start + done,
|
||||||
numSamples );
|
numSamples );
|
||||||
for( decltype(numSamples) i = 0; i < numSamples; i++ )
|
for( decltype(numSamples) i = 0; i < numSamples; i++ )
|
||||||
{
|
{
|
||||||
@ -1498,7 +1498,6 @@ bool WaveTrack::Disjoin(double t0, double t1)
|
|||||||
SplitDelete(region.start, region.end );
|
SplitDelete(region.start, region.end );
|
||||||
}
|
}
|
||||||
|
|
||||||
delete[] buffer;
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2609,7 +2608,6 @@ void WaveTrack::SetAutoSaveIdent(int ident)
|
|||||||
|
|
||||||
WaveTrackCache::~WaveTrackCache()
|
WaveTrackCache::~WaveTrackCache()
|
||||||
{
|
{
|
||||||
Free();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void WaveTrackCache::SetTrack(const WaveTrack *pTrack)
|
void WaveTrackCache::SetTrack(const WaveTrack *pTrack)
|
||||||
@ -2620,8 +2618,8 @@ void WaveTrackCache::SetTrack(const WaveTrack *pTrack)
|
|||||||
if (!mPTrack ||
|
if (!mPTrack ||
|
||||||
mPTrack->GetMaxBlockSize() != mBufferSize) {
|
mPTrack->GetMaxBlockSize() != mBufferSize) {
|
||||||
Free();
|
Free();
|
||||||
mBuffers[0].data = new float[mBufferSize];
|
mBuffers[0].data = Floats{ mBufferSize };
|
||||||
mBuffers[1].data = new float[mBufferSize];
|
mBuffers[1].data = Floats{ mBufferSize };
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -2682,7 +2680,7 @@ constSamplePtr WaveTrackCache::Get(sampleFormat format,
|
|||||||
if (start0 >= 0) {
|
if (start0 >= 0) {
|
||||||
const auto len0 = mPTrack->GetBestBlockSize(start0);
|
const auto len0 = mPTrack->GetBestBlockSize(start0);
|
||||||
wxASSERT(len0 <= mBufferSize);
|
wxASSERT(len0 <= mBufferSize);
|
||||||
if (!mPTrack->Get(samplePtr(mBuffers[0].data), floatSample, start0, len0))
|
if (!mPTrack->Get(samplePtr(mBuffers[0].data.get()), floatSample, start0, len0))
|
||||||
return 0;
|
return 0;
|
||||||
mBuffers[0].start = start0;
|
mBuffers[0].start = start0;
|
||||||
mBuffers[0].len = len0;
|
mBuffers[0].len = len0;
|
||||||
@ -2708,7 +2706,7 @@ constSamplePtr WaveTrackCache::Get(sampleFormat format,
|
|||||||
if (start1 == end0) {
|
if (start1 == end0) {
|
||||||
const auto len1 = mPTrack->GetBestBlockSize(start1);
|
const auto len1 = mPTrack->GetBestBlockSize(start1);
|
||||||
wxASSERT(len1 <= mBufferSize);
|
wxASSERT(len1 <= mBufferSize);
|
||||||
if (!mPTrack->Get(samplePtr(mBuffers[1].data), floatSample, start1, len1))
|
if (!mPTrack->Get(samplePtr(mBuffers[1].data.get()), floatSample, start1, len1))
|
||||||
return 0;
|
return 0;
|
||||||
mBuffers[1].start = start1;
|
mBuffers[1].start = start1;
|
||||||
mBuffers[1].len = len1;
|
mBuffers[1].len = len1;
|
||||||
@ -2755,7 +2753,7 @@ constSamplePtr WaveTrackCache::Get(sampleFormat format,
|
|||||||
// All is contiguous already. We can completely avoid copying
|
// All is contiguous already. We can completely avoid copying
|
||||||
// leni is nonnegative, therefore start falls within mBuffers[ii],
|
// leni is nonnegative, therefore start falls within mBuffers[ii],
|
||||||
// so starti is bounded between 0 and buffer length
|
// so starti is bounded between 0 and buffer length
|
||||||
return samplePtr(mBuffers[ii].data + starti.as_size_t() );
|
return samplePtr(mBuffers[ii].data.get() + starti.as_size_t() );
|
||||||
}
|
}
|
||||||
else if (leni > 0) {
|
else if (leni > 0) {
|
||||||
// leni is nonnegative, therefore start falls within mBuffers[ii]
|
// leni is nonnegative, therefore start falls within mBuffers[ii]
|
||||||
@ -2767,7 +2765,7 @@ constSamplePtr WaveTrackCache::Get(sampleFormat format,
|
|||||||
// leni is positive and not more than remaining
|
// leni is positive and not more than remaining
|
||||||
const size_t size = sizeof(float) * leni.as_size_t();
|
const size_t size = sizeof(float) * leni.as_size_t();
|
||||||
// starti is less than mBuffers[ii].len and nonnegative
|
// starti is less than mBuffers[ii].len and nonnegative
|
||||||
memcpy(buffer, mBuffers[ii].data + starti.as_size_t(), size);
|
memcpy(buffer, mBuffers[ii].data.get() + starti.as_size_t(), size);
|
||||||
wxASSERT( leni <= remaining );
|
wxASSERT( leni <= remaining );
|
||||||
remaining -= leni.as_size_t();
|
remaining -= leni.as_size_t();
|
||||||
start += leni;
|
start += leni;
|
||||||
|
@ -653,17 +653,17 @@ private:
|
|||||||
void Free();
|
void Free();
|
||||||
|
|
||||||
struct Buffer {
|
struct Buffer {
|
||||||
float *data;
|
Floats data;
|
||||||
sampleCount start;
|
sampleCount start;
|
||||||
sampleCount len;
|
sampleCount len;
|
||||||
|
|
||||||
Buffer() : data(0), start(0), len(0) {}
|
Buffer() : start(0), len(0) {}
|
||||||
void Free() { delete[] data; data = 0; start = 0; len = 0; }
|
void Free() { data.reset(); start = 0; len = 0; }
|
||||||
sampleCount end() const { return start + len; }
|
sampleCount end() const { return start + len; }
|
||||||
|
|
||||||
void swap ( Buffer &other )
|
void swap ( Buffer &other )
|
||||||
{
|
{
|
||||||
std::swap( data, other.data );
|
data .swap ( other.data );
|
||||||
std::swap( start, other.start );
|
std::swap( start, other.start );
|
||||||
std::swap( len, other.len );
|
std::swap( len, other.len );
|
||||||
}
|
}
|
||||||
|
@ -352,18 +352,9 @@ void SpectrogramSettings::DestroyWindows()
|
|||||||
EndFFT(hFFT);
|
EndFFT(hFFT);
|
||||||
hFFT = NULL;
|
hFFT = NULL;
|
||||||
}
|
}
|
||||||
if (window != NULL) {
|
window.reset();
|
||||||
delete[] window;
|
dWindow.reset();
|
||||||
window = NULL;
|
tWindow.reset();
|
||||||
}
|
|
||||||
if (dWindow != NULL) {
|
|
||||||
delete[] dWindow;
|
|
||||||
dWindow = NULL;
|
|
||||||
}
|
|
||||||
if (tWindow != NULL) {
|
|
||||||
delete[] tWindow;
|
|
||||||
tWindow = NULL;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -371,13 +362,11 @@ namespace
|
|||||||
{
|
{
|
||||||
enum { WINDOW, TWINDOW, DWINDOW };
|
enum { WINDOW, TWINDOW, DWINDOW };
|
||||||
void RecreateWindow(
|
void RecreateWindow(
|
||||||
float *&window, int which, size_t fftLen,
|
Floats &window, int which, size_t fftLen,
|
||||||
size_t padding, int windowType, size_t windowSize, double &scale)
|
size_t padding, int windowType, size_t windowSize, double &scale)
|
||||||
{
|
{
|
||||||
if (window != NULL)
|
|
||||||
delete[] window;
|
|
||||||
// Create the requested window function
|
// Create the requested window function
|
||||||
window = new float[fftLen];
|
window = Floats{ fftLen };
|
||||||
int ii;
|
int ii;
|
||||||
|
|
||||||
const bool extra = padding > 0;
|
const bool extra = padding > 0;
|
||||||
@ -397,16 +386,15 @@ namespace
|
|||||||
// Overwrite middle as needed
|
// Overwrite middle as needed
|
||||||
switch (which) {
|
switch (which) {
|
||||||
case WINDOW:
|
case WINDOW:
|
||||||
NewWindowFunc(windowType, windowSize, extra, window + padding);
|
NewWindowFunc(windowType, windowSize, extra, window.get() + padding);
|
||||||
break;
|
break;
|
||||||
// Future, reassignment
|
|
||||||
case TWINDOW:
|
case TWINDOW:
|
||||||
NewWindowFunc(windowType, windowSize, extra, window + padding);
|
NewWindowFunc(windowType, windowSize, extra, window.get() + padding);
|
||||||
for (int ii = padding, multiplier = -(int)windowSize / 2; ii < endOfWindow; ++ii, ++multiplier)
|
for (int ii = padding, multiplier = -(int)windowSize / 2; ii < endOfWindow; ++ii, ++multiplier)
|
||||||
window[ii] *= multiplier;
|
window[ii] *= multiplier;
|
||||||
break;
|
break;
|
||||||
case DWINDOW:
|
case DWINDOW:
|
||||||
DerivativeOfWindowFunc(windowType, windowSize, extra, window + padding);
|
DerivativeOfWindowFunc(windowType, windowSize, extra, window.get() + padding);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
wxASSERT(false);
|
wxASSERT(false);
|
||||||
|
@ -12,6 +12,7 @@ Paul Licameli
|
|||||||
#define __AUDACITY_SPECTROGRAM_SETTINGS__
|
#define __AUDACITY_SPECTROGRAM_SETTINGS__
|
||||||
|
|
||||||
#include "../Experimental.h"
|
#include "../Experimental.h"
|
||||||
|
#include "../SampleFormat.h"
|
||||||
|
|
||||||
#undef SPECTRAL_SELECTION_GLOBAL_SWITCH
|
#undef SPECTRAL_SELECTION_GLOBAL_SWITCH
|
||||||
|
|
||||||
@ -153,10 +154,10 @@ public:
|
|||||||
|
|
||||||
// Variables used for computing the spectrum
|
// Variables used for computing the spectrum
|
||||||
mutable FFTParam *hFFT{};
|
mutable FFTParam *hFFT{};
|
||||||
mutable float *window{};
|
mutable Floats window;
|
||||||
|
|
||||||
// Two other windows for computing reassigned spectrogram
|
// Two other windows for computing reassigned spectrogram
|
||||||
mutable float *tWindow{}; // Window times time parameter
|
mutable Floats tWindow; // Window times time parameter
|
||||||
mutable float *dWindow{}; // Derivative of window
|
mutable Floats dWindow; // Derivative of window
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
x
Reference in New Issue
Block a user