From f369b5109b33d2fffd9857dfbdbe97a975418c67 Mon Sep 17 00:00:00 2001 From: Paul Licameli Date: Sun, 23 May 2021 17:43:38 -0400 Subject: [PATCH] Change almost all uses of WaveTrack::Get() to GetFloats() ... ... A call graph browser easily shows that the extra generality of fetching samples in some other format is only used in Benchmark -- where the format is always the same as what the track is constructed with. This makes re-verification of the claims in comments two commits ago easier. --- src/FreqWindow.cpp | 4 +-- src/MixerBoard.cpp | 8 +++--- src/VoiceKey.cpp | 14 +++++----- src/WaveTrack.cpp | 22 +++++++++------- src/WaveTrack.h | 26 +++++++++++++++++++ src/commands/CompareAudioCommand.cpp | 4 +-- src/effects/AutoDuck.cpp | 4 +-- src/effects/ChangePitch.cpp | 2 +- src/effects/ChangeSpeed.cpp | 2 +- src/effects/ClickRemoval.cpp | 2 +- src/effects/Effect.cpp | 4 +-- src/effects/Equalization.cpp | 2 +- src/effects/FindClipping.cpp | 2 +- src/effects/Loudness.cpp | 2 +- src/effects/NoiseReduction.cpp | 2 +- src/effects/Normalize.cpp | 4 +-- src/effects/Paulstretch.cpp | 6 ++--- src/effects/Repair.cpp | 2 +- src/effects/Reverse.cpp | 4 +-- src/effects/SBSMSEffect.cpp | 8 +++--- src/effects/SimpleMono.cpp | 2 +- src/effects/SoundTouchEffect.cpp | 6 ++--- src/effects/TruncSilence.cpp | 6 ++--- src/effects/TwoPassSimpleMono.cpp | 4 +-- src/effects/nyquist/Nyquist.cpp | 4 +-- src/effects/vamp/VampEffect.cpp | 4 +-- src/menus/SelectMenus.cpp | 2 +- src/menus/TransportMenus.cpp | 2 +- .../wavetrack/ui/SampleHandle.cpp | 4 +-- src/tracks/ui/SelectHandle.cpp | 6 ++--- 30 files changed, 97 insertions(+), 67 deletions(-) diff --git a/src/FreqWindow.cpp b/src/FreqWindow.cpp index 02a2ba7b1..3c81b1292 100644 --- a/src/FreqWindow.cpp +++ b/src/FreqWindow.cpp @@ -602,7 +602,7 @@ void FrequencyPlotDialog::GetAudio() mDataLen = dataLen.as_size_t(); mData = Floats{ mDataLen }; // Don't allow throw for bad reads - track->Get((samplePtr)mData.get(), floatSample, start, mDataLen, + track->GetFloats(mData.get(), start, mDataLen, fillZero, false); } else { @@ -617,7 +617,7 @@ void FrequencyPlotDialog::GetAudio() auto start = track->TimeToLongSamples(selectedRegion.t0()); Floats buffer2{ mDataLen }; // Again, stop exceptions - track->Get((samplePtr)buffer2.get(), floatSample, start, mDataLen, + track->GetFloats(buffer2.get(), start, mDataLen, fillZero, false); for (size_t i = 0; i < mDataLen; i++) mData[i] += buffer2[i]; diff --git a/src/MixerBoard.cpp b/src/MixerBoard.cpp index 4ea01f77f..a0ade17d0 100644 --- a/src/MixerBoard.cpp +++ b/src/MixerBoard.cpp @@ -610,8 +610,8 @@ void MixerTrackCluster::UpdateMeter(const double t0, const double t1) Floats tempFloatsArray{ nFrames }; decltype(tempFloatsArray) meterFloatsArray; // Don't throw on read error in this drawing update routine - bool bSuccess = pTrack->Get((samplePtr)tempFloatsArray.get(), - floatSample, startSample, nFrames, fillZero, false); + bool bSuccess = pTrack->GetFloats(tempFloatsArray.get(), + startSample, nFrames, fillZero, false); if (bSuccess) { // We always pass a stereo sample array to the meter, as it shows 2 channels. @@ -625,8 +625,8 @@ void MixerTrackCluster::UpdateMeter(const double t0, const double t1) if (GetRight()) // Again, don't throw - bSuccess = GetRight()->Get((samplePtr)tempFloatsArray.get(), - floatSample, startSample, nFrames, fillZero, false); + bSuccess = GetRight()->GetFloats(tempFloatsArray.get(), + startSample, nFrames, fillZero, false); if (bSuccess) // Interleave right channel, or duplicate same signal for "right" channel in mono case. diff --git a/src/VoiceKey.cpp b/src/VoiceKey.cpp index 17db53c69..f522e3da8 100644 --- a/src/VoiceKey.cpp +++ b/src/VoiceKey.cpp @@ -149,7 +149,7 @@ sampleCount VoiceKey::OnForward ( //To speed things up, create a local buffer to store things in, to avoid the costly t.Get(); //Only go through the first SignalWindowSizeInt samples, and choose the first that trips the key. Floats buffer{ remaining }; - t.Get((samplePtr)buffer.get(), floatSample, + t.GetFloats(buffer.get(), lastsubthresholdsample, remaining); @@ -299,7 +299,7 @@ sampleCount VoiceKey::OnBackward ( //To speed things up, create a local buffer to store things in, to avoid the costly t.Get(); //Only go through the first mSilentWindowSizeInt samples, and choose the first that trips the key. Floats buffer{ remaining }; - t.Get((samplePtr)buffer.get(), floatSample, + t.GetFloats(buffer.get(), lastsubthresholdsample - remaining, remaining); //Initialize these trend markers atrend and ztrend. They keep track of the @@ -442,7 +442,7 @@ sampleCount VoiceKey::OffForward ( //To speed things up, create a local buffer to store things in, to avoid the costly t.Get(); //Only go through the first SilentWindowSizeInt samples, and choose the first that trips the key. Floats buffer{ remaining }; - t.Get((samplePtr)buffer.get(), floatSample, + t.GetFloats(buffer.get(), lastsubthresholdsample, remaining); //Initialize these trend markers atrend and ztrend. They keep track of the @@ -579,7 +579,7 @@ sampleCount VoiceKey::OffBackward ( //To speed things up, create a local buffer to store things in, to avoid the costly t.Get(); //Only go through the first SilentWindowSizeInt samples, and choose the first that trips the key. Floats buffer{ remaining }; - t.Get((samplePtr)buffer.get(), floatSample, + t.GetFloats(buffer.get(), lastsubthresholdsample - remaining, remaining); //Initialize these trend markers atrend and ztrend. They keep track of the @@ -870,7 +870,7 @@ double VoiceKey::TestEnergy ( //Figure out how much to grab auto block = limitSampleBufferSize ( t.GetBestBlockSize(s), len ); - t.Get((samplePtr)buffer.get(), floatSample, s,block); //grab the block; + t.GetFloats(buffer.get(), s,block); //grab the block; //Now, go through the block and calculate energy for(decltype(block) i = 0; i< block; i++) @@ -913,7 +913,7 @@ double VoiceKey::TestSignChanges( //Figure out how much to grab auto block = limitSampleBufferSize ( t.GetBestBlockSize(s), len ); - t.Get((samplePtr)buffer.get(), floatSample, s, block); //grab the block; + t.GetFloats(buffer.get(), s, block); //grab the block; if (len == originalLen) { @@ -970,7 +970,7 @@ double VoiceKey::TestDirectionChanges( //Figure out how much to grab auto block = limitSampleBufferSize ( t.GetBestBlockSize(s), len ); - t.Get((samplePtr)buffer.get(), floatSample, s, block); //grab the block; + t.GetFloats(buffer.get(), s, block); //grab the block; if (len == originalLen) { //The first time through, set stuff up special. diff --git a/src/WaveTrack.cpp b/src/WaveTrack.cpp index dda66e2dc..7ee6f8a89 100644 --- a/src/WaveTrack.cpp +++ b/src/WaveTrack.cpp @@ -2594,8 +2594,8 @@ const float *WaveTrackCache::GetFloats( if (start0 >= 0) { const auto len0 = mPTrack->GetBestBlockSize(start0); wxASSERT(len0 <= mBufferSize); - if (!mPTrack->Get( - samplePtr(mBuffers[0].data.get()), floatSample, start0, len0, + if (!mPTrack->GetFloats( + mBuffers[0].data.get(), start0, len0, fillZero, mayThrow)) return nullptr; mBuffers[0].start = start0; @@ -2622,7 +2622,7 @@ const float *WaveTrackCache::GetFloats( if (start1 == end0) { const auto len1 = mPTrack->GetBestBlockSize(start1); wxASSERT(len1 <= mBufferSize); - if (!mPTrack->Get(samplePtr(mBuffers[1].data.get()), floatSample, start1, len1, fillZero, mayThrow)) + if (!mPTrack->GetFloats(mBuffers[1].data.get(), start1, len1, fillZero, mayThrow)) return nullptr; mBuffers[1].start = start1; mBuffers[1].len = len1; @@ -2632,7 +2632,7 @@ const float *WaveTrackCache::GetFloats( } wxASSERT(mNValidBuffers < 2 || mBuffers[0].end() == mBuffers[1].start); - samplePtr buffer = 0; + samplePtr buffer = nullptr; // will point into mOverlapBuffer auto remaining = len; // Possibly get an initial portion that is uncached @@ -2647,8 +2647,10 @@ const float *WaveTrackCache::GetFloats( mOverlapBuffer.Resize(len, format); // initLen is not more than len: auto sinitLen = initLen.as_size_t(); - if (!mPTrack->Get(mOverlapBuffer.ptr(), format, start, sinitLen, - fillZero, mayThrow)) + if (!mPTrack->GetFloats( + // See comment below about casting + reinterpret_cast(mOverlapBuffer.ptr()), + start, sinitLen, fillZero, mayThrow)) return nullptr; wxASSERT( sinitLen <= remaining ); remaining -= sinitLen; @@ -2675,7 +2677,7 @@ const float *WaveTrackCache::GetFloats( else if (leni > 0) { // leni is nonnegative, therefore start falls within mBuffers[ii] // But we can't satisfy all from one buffer, so copy - if (buffer == 0) { + if (!buffer) { mOverlapBuffer.Resize(len, format); buffer = mOverlapBuffer.ptr(); } @@ -2693,11 +2695,13 @@ const float *WaveTrackCache::GetFloats( if (remaining > 0) { // Very big request! // Fall back to direct fetch - if (buffer == 0) { + if (!buffer) { mOverlapBuffer.Resize(len, format); buffer = mOverlapBuffer.ptr(); } - if (!mPTrack->Get(buffer, format, start, remaining, fillZero, mayThrow)) + // See comment below about casting + if (!mPTrack->GetFloats( reinterpret_cast(buffer), + start, remaining, fillZero, mayThrow)) return 0; } diff --git a/src/WaveTrack.h b/src/WaveTrack.h index f9c4ea94e..89aad4dd3 100644 --- a/src/WaveTrack.h +++ b/src/WaveTrack.h @@ -246,6 +246,31 @@ private: /// same value for "start" in both calls to "Set" and "Get" it is /// guaranteed that the same samples are affected. /// + + //! Retrieve samples from a track in floating-point format, regardless of the storage format + /*! + @param buffer receives the samples + @param start starting sample, relative to absolute time zero (not to the track's offset value) + @param len how many samples to get. buffer is assumed sufficiently large + @param fill how to assign values for sample positions between clips + @param mayThrow if false, fill buffer with zeros when there is failure to retrieve samples; else throw + @param[out] pNumWithinClips Report how many samples were copied from within clips, rather + than filled according to fillFormat; but these were not necessarily one contiguous range. + */ + bool GetFloats(float *buffer, sampleCount start, size_t len, + fillFormat fill = fillZero, bool mayThrow = true, + sampleCount * pNumWithinClips = nullptr) const + { + //! Cast the pointer to pass it to Get() which handles multiple destination formats + return Get(reinterpret_cast(buffer), + floatSample, start, len, fill, mayThrow, pNumWithinClips); + } + + //! Retrieve samples from a track in a specified format + /*! + @copydetails WaveTrack::GetFloats() + @param format sample format of the destination buffer + */ bool Get(samplePtr buffer, sampleFormat format, sampleCount start, size_t len, fillFormat fill = fillZero, @@ -254,6 +279,7 @@ private: // filled according to fillFormat; but these were not necessarily one // contiguous range. sampleCount * pNumWithinClips = nullptr) const; + void Set(constSamplePtr buffer, sampleFormat format, sampleCount start, size_t len); diff --git a/src/commands/CompareAudioCommand.cpp b/src/commands/CompareAudioCommand.cpp index 1cd893975..b21c60ad8 100644 --- a/src/commands/CompareAudioCommand.cpp +++ b/src/commands/CompareAudioCommand.cpp @@ -138,8 +138,8 @@ bool CompareAudioCommand::Apply(const CommandContext & context) auto block = limitSampleBufferSize( mTrack0->GetBestBlockSize(position), s1 - position ); - mTrack0->Get((samplePtr)buff0.get(), floatSample, position, block); - mTrack1->Get((samplePtr)buff1.get(), floatSample, position, block); + mTrack0->GetFloats(buff0.get(), position, block); + mTrack1->GetFloats(buff1.get(), position, block); for (decltype(block) buffPos = 0; buffPos < block; ++buffPos) { diff --git a/src/effects/AutoDuck.cpp b/src/effects/AutoDuck.cpp index 572b3b230..104973a1f 100644 --- a/src/effects/AutoDuck.cpp +++ b/src/effects/AutoDuck.cpp @@ -321,7 +321,7 @@ bool EffectAutoDuck::Process() { const auto len = limitSampleBufferSize( kBufSize, end - pos ); - mControlTrack->Get((samplePtr)buf.get(), floatSample, pos, len); + mControlTrack->GetFloats(buf.get(), pos, len); for (auto i = pos; i < pos + len; i++) { @@ -559,7 +559,7 @@ bool EffectAutoDuck::ApplyDuckFade(int trackNum, WaveTrack* t, { const auto len = limitSampleBufferSize( kBufSize, end - pos ); - t->Get((samplePtr)buf.get(), floatSample, pos, len); + t->GetFloats(buf.get(), pos, len); for (auto i = pos; i < pos + len; i++) { diff --git a/src/effects/ChangePitch.cpp b/src/effects/ChangePitch.cpp index 802a94dd9..2eb022fb2 100644 --- a/src/effects/ChangePitch.cpp +++ b/src/effects/ChangePitch.cpp @@ -477,7 +477,7 @@ void EffectChangePitch::DeduceFrequencies() Floats freq{ windowSize / 2 }; Floats freqa{ windowSize / 2, true }; - track->Get((samplePtr) buffer.get(), floatSample, start, analyzeSize); + track->GetFloats(buffer.get(), start, analyzeSize); for(unsigned i = 0; i < numWindows; i++) { ComputeSpectrum(buffer.get() + i * windowSize, windowSize, windowSize, rate, freq.get(), true); diff --git a/src/effects/ChangeSpeed.cpp b/src/effects/ChangeSpeed.cpp index a7129f4c4..98252b17c 100644 --- a/src/effects/ChangeSpeed.cpp +++ b/src/effects/ChangeSpeed.cpp @@ -520,7 +520,7 @@ bool EffectChangeSpeed::ProcessOne(WaveTrack * track, ); //Get the samples from the track and put them in the buffer - track->Get((samplePtr) inBuffer.get(), floatSample, samplePos, blockSize); + track->GetFloats(inBuffer.get(), samplePos, blockSize); const auto results = resample.Process(mFactor, inBuffer.get(), diff --git a/src/effects/ClickRemoval.cpp b/src/effects/ClickRemoval.cpp index 2f8daa13e..4c8b0a624 100644 --- a/src/effects/ClickRemoval.cpp +++ b/src/effects/ClickRemoval.cpp @@ -233,7 +233,7 @@ bool EffectClickRemoval::ProcessOne(int count, WaveTrack * track, sampleCount st { auto block = limitSampleBufferSize( idealBlockLen, len - s ); - track->Get((samplePtr) buffer.get(), floatSample, start + s, block); + track->GetFloats(buffer.get(), start + s, block); for (decltype(block) i = 0; i + windowSize / 2 < block; i += windowSize / 2) { diff --git a/src/effects/Effect.cpp b/src/effects/Effect.cpp index 4921ba5ae..1cfc2e802 100644 --- a/src/effects/Effect.cpp +++ b/src/effects/Effect.cpp @@ -1637,10 +1637,10 @@ bool Effect::ProcessTrack(int count, limitSampleBufferSize( mBufferSize, inputRemaining ); // Fill the input buffers - left->Get((samplePtr) inBuffer[0].get(), floatSample, inPos, inputBufferCnt); + left->GetFloats(inBuffer[0].get(), inPos, inputBufferCnt); if (right) { - right->Get((samplePtr) inBuffer[1].get(), floatSample, inPos, inputBufferCnt); + right->GetFloats(inBuffer[1].get(), inPos, inputBufferCnt); } // Reset the input buffer positions diff --git a/src/effects/Equalization.cpp b/src/effects/Equalization.cpp index 83082bc5b..ad1fbd0fa 100644 --- a/src/effects/Equalization.cpp +++ b/src/effects/Equalization.cpp @@ -1330,7 +1330,7 @@ bool EffectEqualization::ProcessOne(int count, WaveTrack * t, { auto block = limitSampleBufferSize( idealBlockLen, len ); - t->Get((samplePtr)buffer.get(), floatSample, s, block); + t->GetFloats(buffer.get(), s, block); for(size_t i = 0; i < block; i += L) //go through block in lumps of length L { diff --git a/src/effects/FindClipping.cpp b/src/effects/FindClipping.cpp index b3dab31fc..180bdc737 100644 --- a/src/effects/FindClipping.cpp +++ b/src/effects/FindClipping.cpp @@ -198,7 +198,7 @@ bool EffectFindClipping::ProcessOne(LabelTrack * lt, block = limitSampleBufferSize( blockSize, len - s ); - wt->Get((samplePtr)buffer.get(), floatSample, start + s, block); + wt->GetFloats(buffer.get(), start + s, block); ptr = buffer.get(); } diff --git a/src/effects/Loudness.cpp b/src/effects/Loudness.cpp index 02c947ecf..3c17d9c87 100644 --- a/src/effects/Loudness.cpp +++ b/src/effects/Loudness.cpp @@ -515,7 +515,7 @@ void EffectLoudness::LoadBufferBlock(TrackIterRange range, int idx = 0; for(auto channel : range) { - channel->Get((samplePtr) mTrackBuffer[idx].get(), floatSample, pos, len ); + channel->GetFloats(mTrackBuffer[idx].get(), pos, len ); ++idx; } mTrackBufferLen = len; diff --git a/src/effects/NoiseReduction.cpp b/src/effects/NoiseReduction.cpp index 64aa2ab7d..9215f9fc8 100644 --- a/src/effects/NoiseReduction.cpp +++ b/src/effects/NoiseReduction.cpp @@ -1330,7 +1330,7 @@ bool EffectNoiseReduction::Worker::ProcessOne ); //Get the samples from the track and put them in the buffer - track->Get((samplePtr)&buffer[0], floatSample, samplePos, blockSize); + track->GetFloats(&buffer[0], samplePos, blockSize); samplePos += blockSize; mInSampleCount += blockSize; diff --git a/src/effects/Normalize.cpp b/src/effects/Normalize.cpp index 2bce11cae..30b50d0c2 100644 --- a/src/effects/Normalize.cpp +++ b/src/effects/Normalize.cpp @@ -435,7 +435,7 @@ bool EffectNormalize::AnalyseTrackData(const WaveTrack * track, const Translatab ); //Get the samples from the track and put them in the buffer - track->Get((samplePtr) buffer.get(), floatSample, s, block, fillZero, true, &blockSamples); + track->GetFloats(buffer.get(), s, block, fillZero, true, &blockSamples); totalSamples += blockSamples; //Process the buffer. @@ -495,7 +495,7 @@ bool EffectNormalize::ProcessOne( ); //Get the samples from the track and put them in the buffer - track->Get((samplePtr) buffer.get(), floatSample, s, block); + track->GetFloats(buffer.get(), s, block); //Process the buffer. ProcessData(buffer.get(), block, offset); diff --git a/src/effects/Paulstretch.cpp b/src/effects/Paulstretch.cpp index 28687fd78..6a504104e 100644 --- a/src/effects/Paulstretch.cpp +++ b/src/effects/Paulstretch.cpp @@ -359,7 +359,7 @@ bool EffectPaulstretch::ProcessOne(WaveTrack *track,double t0,double t1,int coun decltype(len) s=0; while (s < len) { - track->Get((samplePtr)bufferptr0, floatSample, start + s, nget); + track->GetFloats(bufferptr0, start + s, nget); stretch.process(buffer0.get(), nget); if (first_time) { @@ -369,7 +369,7 @@ bool EffectPaulstretch::ProcessOne(WaveTrack *track,double t0,double t1,int coun s += nget; if (first_time){//blend the start of the selection - track->Get((samplePtr)fade_track_smps.get(), floatSample, start, fade_len); + track->GetFloats(fade_track_smps.get(), start, fade_len); first_time = false; for (size_t i = 0; i < fade_len; i++){ float fi = (float)i / (float)fade_len; @@ -378,7 +378,7 @@ bool EffectPaulstretch::ProcessOne(WaveTrack *track,double t0,double t1,int coun } } if (s >= len){//blend the end of the selection - track->Get((samplePtr)fade_track_smps.get(), floatSample, end - fade_len, fade_len); + track->GetFloats(fade_track_smps.get(), end - fade_len, fade_len); for (size_t i = 0; i < fade_len; i++){ float fi = (float)i / (float)fade_len; auto i2 = bufsize / 2 - 1 - i; diff --git a/src/effects/Repair.cpp b/src/effects/Repair.cpp index e1c516fd6..57fff709f 100644 --- a/src/effects/Repair.cpp +++ b/src/effects/Repair.cpp @@ -146,7 +146,7 @@ bool EffectRepair::ProcessOne(int count, WaveTrack * track, size_t repairStart, size_t repairLen) { Floats buffer{ len }; - track->Get((samplePtr) buffer.get(), floatSample, start, len); + track->GetFloats(buffer.get(), start, len); InterpolateAudio(buffer.get(), len, repairStart, repairLen); track->Set((samplePtr)&buffer[repairStart], floatSample, start + repairStart, repairLen); diff --git a/src/effects/Reverse.cpp b/src/effects/Reverse.cpp index f97c5e998..1fd884d77 100644 --- a/src/effects/Reverse.cpp +++ b/src/effects/Reverse.cpp @@ -232,8 +232,8 @@ bool EffectReverse::ProcessOneClip(int count, WaveTrack *track, limitSampleBufferSize( track->GetBestBlockSize(first), len / 2 ); auto second = first + (len - block); - track->Get((samplePtr)buffer1.get(), floatSample, first, block); - track->Get((samplePtr)buffer2.get(), floatSample, second, block); + track->GetFloats(buffer1.get(), first, block); + track->GetFloats(buffer2.get(), second, block); for (decltype(block) i = 0; i < block; i++) { tmp = buffer1[i]; buffer1[i] = buffer2[block-i-1]; diff --git a/src/effects/SBSMSEffect.cpp b/src/effects/SBSMSEffect.cpp index 7cba9c5b2..6078c827f 100644 --- a/src/effects/SBSMSEffect.cpp +++ b/src/effects/SBSMSEffect.cpp @@ -99,10 +99,10 @@ long resampleCB(void *cb_data, SBSMSFrame *data) // does not seem to let us report error codes, so use this roundabout to // stop the effect early. try { - r->leftTrack->Get( - (samplePtr)(r->leftBuffer.get()), floatSample, r->offset, blockSize); - r->rightTrack->Get( - (samplePtr)(r->rightBuffer.get()), floatSample, r->offset, blockSize); + r->leftTrack->GetFloats( + (r->leftBuffer.get()), r->offset, blockSize); + r->rightTrack->GetFloats( + (r->rightBuffer.get()), r->offset, blockSize); } catch ( ... ) { // Save the exception object for re-throw when out of the library diff --git a/src/effects/SimpleMono.cpp b/src/effects/SimpleMono.cpp index 7faf3b721..dc95a1fff 100644 --- a/src/effects/SimpleMono.cpp +++ b/src/effects/SimpleMono.cpp @@ -96,7 +96,7 @@ bool EffectSimpleMono::ProcessOne(WaveTrack * track, limitSampleBufferSize( track->GetBestBlockSize(s), end - s ); //Get the samples from the track and put them in the buffer - track->Get((samplePtr) buffer.get(), floatSample, s, block); + track->GetFloats(buffer.get(), s, block); //Process the buffer. If it fails, clean up and exit. if (!ProcessSimpleMono(buffer.get(), block)) diff --git a/src/effects/SoundTouchEffect.cpp b/src/effects/SoundTouchEffect.cpp index 7cc73a47a..96ffb869b 100644 --- a/src/effects/SoundTouchEffect.cpp +++ b/src/effects/SoundTouchEffect.cpp @@ -217,7 +217,7 @@ bool EffectSoundTouch::ProcessOne(WaveTrack *track, limitSampleBufferSize( track->GetBestBlockSize(s), end - s )); //Get the samples from the track and put them in the buffer - track->Get((samplePtr)buffer.get(), floatSample, s, block); + track->GetFloats(buffer.get(), s, block); //Add samples to SoundTouch mSoundTouch->putSamples(buffer.get(), block); @@ -298,8 +298,8 @@ bool EffectSoundTouch::ProcessStereo( ); // Get the samples from the tracks and put them in the buffers. - leftTrack->Get((samplePtr)(leftBuffer.get()), floatSample, sourceSampleCount, blockSize); - rightTrack->Get((samplePtr)(rightBuffer.get()), floatSample, sourceSampleCount, blockSize); + leftTrack->GetFloats((leftBuffer.get()), sourceSampleCount, blockSize); + rightTrack->GetFloats((rightBuffer.get()), sourceSampleCount, blockSize); // Interleave into soundTouchBuffer. for (decltype(blockSize) index = 0; index < blockSize; index++) { diff --git a/src/effects/TruncSilence.cpp b/src/effects/TruncSilence.cpp index b05a7ae97..d45742025 100644 --- a/src/effects/TruncSilence.cpp +++ b/src/effects/TruncSilence.cpp @@ -568,8 +568,8 @@ bool EffectTruncSilence::DoRemoval auto t1 = wt->TimeToLongSamples(cutStart) - blendFrames / 2; auto t2 = wt->TimeToLongSamples(cutEnd) - blendFrames / 2; - wt->Get((samplePtr)buf1.get(), floatSample, t1, blendFrames); - wt->Get((samplePtr)buf2.get(), floatSample, t2, blendFrames); + wt->GetFloats(buf1.get(), t1, blendFrames); + wt->GetFloats(buf2.get(), t2, blendFrames); for (decltype(blendFrames) i = 0; i < blendFrames; ++i) { @@ -689,7 +689,7 @@ bool EffectTruncSilence::Analyze(RegionList& silenceList, auto count = limitSampleBufferSize( blockLen, end - *index ); // Fill buffer - wt->Get((samplePtr)(buffer.get()), floatSample, *index, count); + wt->GetFloats((buffer.get()), *index, count); // Look for silenceList in current block for (decltype(count) i = 0; i < count; ++i) { diff --git a/src/effects/TwoPassSimpleMono.cpp b/src/effects/TwoPassSimpleMono.cpp index 97294850b..4f5ecce27 100644 --- a/src/effects/TwoPassSimpleMono.cpp +++ b/src/effects/TwoPassSimpleMono.cpp @@ -130,7 +130,7 @@ bool EffectTwoPassSimpleMono::ProcessOne(WaveTrack * track, WaveTrack * outTrack std::min( maxblock, track->GetBestBlockSize(start) ), end - start ); //Get the samples from the track and put them in the buffer - track->Get((samplePtr) buffer1.get(), floatSample, start, samples1); + track->GetFloats(buffer1.get(), start, samples1); // Process the first buffer with a NULL previous buffer if (mPass == 0) @@ -152,7 +152,7 @@ bool EffectTwoPassSimpleMono::ProcessOne(WaveTrack * track, WaveTrack * outTrack ); //Get the samples from the track and put them in the buffer - track->Get((samplePtr)buffer2.get(), floatSample, s, samples2); + track->GetFloats(buffer2.get(), s, samples2); //Process the buffer. If it fails, clean up and exit. if (mPass == 0) diff --git a/src/effects/nyquist/Nyquist.cpp b/src/effects/nyquist/Nyquist.cpp index d011e3243..3780732f0 100644 --- a/src/effects/nyquist/Nyquist.cpp +++ b/src/effects/nyquist/Nyquist.cpp @@ -2449,8 +2449,8 @@ int NyquistEffect::GetCallback(float *buffer, int ch, mCurBuffer[ch].Allocate(mCurBufferLen[ch], floatSample); try { - mCurTrack[ch]->Get( - mCurBuffer[ch].ptr(), floatSample, + mCurTrack[ch]->GetFloats( + reinterpret_cast(mCurBuffer[ch].ptr()), mCurBufferStart[ch], mCurBufferLen[ch]); } catch ( ... ) { diff --git a/src/effects/vamp/VampEffect.cpp b/src/effects/vamp/VampEffect.cpp index 9125f5625..de7e298a2 100644 --- a/src/effects/vamp/VampEffect.cpp +++ b/src/effects/vamp/VampEffect.cpp @@ -453,12 +453,12 @@ bool VampEffect::Process() if (left) { - left->Get((samplePtr)data[0].get(), floatSample, pos, request); + left->GetFloats(data[0].get(), pos, request); } if (right) { - right->Get((samplePtr)data[1].get(), floatSample, pos, request); + right->GetFloats(data[1].get(), pos, request); } if (request < block) diff --git a/src/menus/SelectMenus.cpp b/src/menus/SelectMenus.cpp index 6e3d428cd..00c6ce68d 100644 --- a/src/menus/SelectMenus.cpp +++ b/src/menus/SelectMenus.cpp @@ -70,7 +70,7 @@ double NearestZeroCrossing auto s = one->TimeToLongSamples(t0); // fillTwo to ensure that missing values are treated as 2, and hence do // not get used as zero crossings. - one->Get((samplePtr)oneDist.get(), floatSample, + one->GetFloats(oneDist.get(), s - (int)oneWindowSize/2, oneWindowSize, fillTwo); diff --git a/src/menus/TransportMenus.cpp b/src/menus/TransportMenus.cpp index aa91ca852..cdabd31e8 100644 --- a/src/menus/TransportMenus.cpp +++ b/src/menus/TransportMenus.cpp @@ -593,7 +593,7 @@ void OnPunchAndRoll(const CommandContext &context) if (getLen > 0) { float *const samples = data.data(); const sampleCount pos = wt->TimeToLongSamples(t1); - wt->Get((samplePtr)samples, floatSample, pos, getLen); + wt->GetFloats(samples, pos, getLen); } crossfadeData.push_back(std::move(data)); } diff --git a/src/tracks/playabletrack/wavetrack/ui/SampleHandle.cpp b/src/tracks/playabletrack/wavetrack/ui/SampleHandle.cpp index 1c7e64dc8..8fb755735 100644 --- a/src/tracks/playabletrack/wavetrack/ui/SampleHandle.cpp +++ b/src/tracks/playabletrack/wavetrack/ui/SampleHandle.cpp @@ -127,7 +127,7 @@ UIHandlePtr SampleHandle::HitTest float oneSample; const double rate = wavetrack->GetRate(); const auto s0 = (sampleCount)(tt * rate + 0.5); - if (! wavetrack->Get((samplePtr)&oneSample, floatSample, s0, 1, fillZero, + if (! wavetrack->GetFloats(&oneSample, s0, 1, fillZero, // Do not propagate exception but return a failure value false) ) return {}; @@ -238,7 +238,7 @@ UIHandle::Result SampleHandle::Click Floats newSampleRegion{ 1 + 2 * (size_t)SMOOTHING_BRUSH_RADIUS }; //Get a sample from the track to do some tricks on. - mClickedTrack->Get((samplePtr)sampleRegion.get(), floatSample, + mClickedTrack->GetFloats(sampleRegion.get(), mClickedStartSample - SMOOTHING_KERNEL_RADIUS - SMOOTHING_BRUSH_RADIUS, sampleRegionSize); diff --git a/src/tracks/ui/SelectHandle.cpp b/src/tracks/ui/SelectHandle.cpp index 705e0845e..9bce385cf 100644 --- a/src/tracks/ui/SelectHandle.cpp +++ b/src/tracks/ui/SelectHandle.cpp @@ -1364,9 +1364,9 @@ void SelectHandle::StartSnappingFreqSelection end - start)); const auto effectiveLength = std::max(minLength, length); frequencySnappingData.resize(effectiveLength, 0.0f); - pTrack->Get( - reinterpret_cast(&frequencySnappingData[0]), - floatSample, start, length, fillZero, + pTrack->GetFloats( + &frequencySnappingData[0], + start, length, fillZero, // Don't try to cope with exceptions, just read zeroes instead. false);