diff --git a/include/audacity/EffectInterface.h b/include/audacity/EffectInterface.h index 7e23671d0..a4ce21845 100755 --- a/include/audacity/EffectInterface.h +++ b/include/audacity/EffectInterface.h @@ -124,15 +124,15 @@ public: virtual int GetMidiOutCount() = 0; virtual void SetSampleRate(double rate) = 0; - virtual sampleCount SetBlockSize(sampleCount maxBlockSize) = 0; + virtual size_t SetBlockSize(size_t maxBlockSize) = 0; virtual sampleCount GetLatency() = 0; - virtual sampleCount GetTailSize() = 0; + virtual size_t GetTailSize() = 0; virtual bool IsReady() = 0; virtual bool ProcessInitialize(sampleCount totalLen, ChannelNames chanMap = NULL) = 0; virtual bool ProcessFinalize() = 0; - virtual sampleCount ProcessBlock(float **inBlock, float **outBlock, sampleCount blockLen) = 0; + virtual size_t ProcessBlock(float **inBlock, float **outBlock, size_t blockLen) = 0; virtual bool RealtimeInitialize() = 0; virtual bool RealtimeAddProcessor(unsigned numChannels, float sampleRate) = 0; @@ -140,7 +140,7 @@ public: virtual bool RealtimeSuspend() = 0; virtual bool RealtimeResume() = 0; virtual bool RealtimeProcessStart() = 0; - virtual sampleCount RealtimeProcess(int group, float **inBuf, float **outBuf, sampleCount numSamples) = 0; + virtual size_t RealtimeProcess(int group, float **inBuf, float **outBuf, size_t numSamples) = 0; virtual bool RealtimeProcessEnd() = 0; virtual bool ShowInterface(wxWindow *parent, bool forceModal = false) = 0; diff --git a/include/audacity/ImporterInterface.h b/include/audacity/ImporterInterface.h index aeecf7345..5fe3329c2 100644 --- a/include/audacity/ImporterInterface.h +++ b/include/audacity/ImporterInterface.h @@ -99,10 +99,10 @@ public: ChannelName *channelMap) = 0; // Accepts interleaved samples from the client. - virtual bool PutSamples(int stream, sampleCount numSamples, samplePtr inBuffer) = 0; + virtual bool PutSamples(int stream, size_t numSamples, samplePtr inBuffer) = 0; // Accepts non-interleaved samples from the client. - virtual bool PutSamples(int stream, int channel, sampleCount numSamples, samplePtr inBuffer) = 0; + virtual bool PutSamples(int stream, int channel, size_t numSamples, samplePtr inBuffer) = 0; // The client will call this as the import progresses. virtual bool UpdateProgress(float current, float total) = 0; diff --git a/src/AudioIO.cpp b/src/AudioIO.cpp index d3b6c732d..fed87be66 100644 --- a/src/AudioIO.cpp +++ b/src/AudioIO.cpp @@ -1770,6 +1770,7 @@ int AudioIO::StartStream(const ConstWaveTrackArray &playbackTracks, // mouse input, so make fillings more and shorter. // What Audio thread produces for playback is then consumed by the PortAudio // thread, in many smaller pieces. + wxASSERT( playbackTime >= 0 ); mPlaybackSamplesToCopy = playbackTime * mRate; // Capacity of the playback buffer. @@ -1853,9 +1854,9 @@ int AudioIO::StartStream(const ConstWaveTrackArray &playbackTracks, // Allocate output buffers. For every output track we allocate // a ring buffer of five seconds auto playbackBufferSize = - (sampleCount)lrint(mRate * mPlaybackRingBufferSecs); + (size_t)lrint(mRate * mPlaybackRingBufferSecs); auto playbackMixBufferSize = - (sampleCount)mPlaybackSamplesToCopy; + mPlaybackSamplesToCopy; mPlaybackBuffers = new RingBuffer* [mPlaybackTracks.size()]; mPlaybackMixers = new Mixer* [mPlaybackTracks.size()]; @@ -1892,8 +1893,7 @@ int AudioIO::StartStream(const ConstWaveTrackArray &playbackTracks, { // Allocate input buffers. For every input track we allocate // a ring buffer of five seconds - auto captureBufferSize = - (sampleCount)(mRate * mCaptureRingBufferSecs + 0.5); + auto captureBufferSize = (size_t)(mRate * mCaptureRingBufferSecs + 0.5); // In the extraordinarily rare case that we can't even afford 100 samples, just give up. if(captureBufferSize < 100) @@ -1931,10 +1931,8 @@ int AudioIO::StartStream(const ConstWaveTrackArray &playbackTracks, bDone = false; // In the extraordinarily rare case that we can't even afford 100 samples, just give up. - auto playbackBufferSize = - (sampleCount)lrint(mRate * mPlaybackRingBufferSecs); - auto playbackMixBufferSize = - (sampleCount)mPlaybackSamplesToCopy; + auto playbackBufferSize = (size_t)lrint(mRate * mPlaybackRingBufferSecs); + auto playbackMixBufferSize = mPlaybackSamplesToCopy; if(playbackBufferSize < 100 || playbackMixBufferSize < 100) { StartStreamCleanup(); diff --git a/src/AudioIO.h b/src/AudioIO.h index 7c1260455..3f89b1d69 100644 --- a/src/AudioIO.h +++ b/src/AudioIO.h @@ -573,7 +573,7 @@ private: double mSeek; double mPlaybackRingBufferSecs; double mCaptureRingBufferSecs; - long mPlaybackSamplesToCopy; + size_t mPlaybackSamplesToCopy; double mMinCaptureSecsToCopy; bool mPaused; PaStream *mPortStreamV19; diff --git a/src/BlockFile.cpp b/src/BlockFile.cpp index 4cb74e054..c472a2149 100644 --- a/src/BlockFile.cpp +++ b/src/BlockFile.cpp @@ -70,7 +70,7 @@ out. static const int headerTagLen = 20; static char headerTag[headerTagLen + 1] = "AudacityBlockFile112"; -SummaryInfo::SummaryInfo(sampleCount samples) +SummaryInfo::SummaryInfo(size_t samples) { format = floatSample; @@ -98,7 +98,7 @@ ArrayOf BlockFile::fullSummary; /// will store at least the summary data here. /// /// @param samples The number of samples this BlockFile contains. -BlockFile::BlockFile(wxFileNameWrapper &&fileName, sampleCount samples): +BlockFile::BlockFile(wxFileNameWrapper &&fileName, size_t samples): mLockCount(0), mFileName(std::move(fileName)), mLen(samples), @@ -177,7 +177,7 @@ bool BlockFile::IsLocked() /// @param buffer A buffer containing the sample data to be analyzed /// @param len The length of the sample data /// @param format The format of the sample data. -void *BlockFile::CalcSummary(samplePtr buffer, sampleCount len, +void *BlockFile::CalcSummary(samplePtr buffer, size_t len, sampleFormat format, ArrayOf &cleanup) { // Caller has nothing to deallocate @@ -201,7 +201,7 @@ void *BlockFile::CalcSummary(samplePtr buffer, sampleCount len, return fullSummary.get(); } -void BlockFile::CalcSummaryFromBuffer(const float *fbuffer, sampleCount len, +void BlockFile::CalcSummaryFromBuffer(const float *fbuffer, size_t len, float *summary256, float *summary64K) { decltype(len) sumLen; @@ -375,7 +375,7 @@ void BlockFile::FixSummary(void *data) /// should be stored /// @param *outRMS A pointer to where the maximum RMS value for this /// region should be stored. -void BlockFile::GetMinMax(sampleCount start, sampleCount len, +void BlockFile::GetMinMax(size_t start, size_t len, float *outMin, float *outMax, float *outRMS) const { // TODO: actually use summaries @@ -429,12 +429,12 @@ void BlockFile::GetMinMax(float *outMin, float *outMax, float *outRMS) const /// @param start The offset in 256-sample increments /// @param len The number of 256-sample summary frames to read bool BlockFile::Read256(float *buffer, - sampleCount start, sampleCount len) + size_t start, size_t len) { wxASSERT(start >= 0); char *summary = new char[mSummaryInfo.totalSummaryBytes]; - // FIXME: TRAP_ERR ReadSummay() could return fail. + // FIXME: TRAP_ERR ReadSummary() could return fail. this->ReadSummary(summary); start = std::min( start, mSummaryInfo.frames256 ); @@ -468,12 +468,12 @@ bool BlockFile::Read256(float *buffer, /// @param start The offset in 64K-sample increments /// @param len The number of 64K-sample summary frames to read bool BlockFile::Read64K(float *buffer, - sampleCount start, sampleCount len) + size_t start, size_t len) { wxASSERT(start >= 0); char *summary = new char[mSummaryInfo.totalSummaryBytes]; - // FIXME: TRAP_ERR ReadSummay() could return fail. + // FIXME: TRAP_ERR ReadSummary() could return fail. this->ReadSummary(summary); start = std::min( start, mSummaryInfo.frames64K ); @@ -520,7 +520,7 @@ bool BlockFile::Read64K(float *buffer, AliasBlockFile::AliasBlockFile(wxFileNameWrapper &&baseFileName, wxFileNameWrapper &&aliasedFileName, sampleCount aliasStart, - sampleCount aliasLen, int aliasChannel): + size_t aliasLen, int aliasChannel): BlockFile { (baseFileName.SetExt(wxT("auf")), std::move(baseFileName)), aliasLen @@ -535,7 +535,7 @@ AliasBlockFile::AliasBlockFile(wxFileNameWrapper &&baseFileName, AliasBlockFile::AliasBlockFile(wxFileNameWrapper &&existingSummaryFileName, wxFileNameWrapper &&aliasedFileName, sampleCount aliasStart, - sampleCount aliasLen, + size_t aliasLen, int aliasChannel, float min, float max, float rms): BlockFile{ std::move(existingSummaryFileName), aliasLen }, diff --git a/src/BlockFile.h b/src/BlockFile.h index 053fa2d8b..61e843795 100644 --- a/src/BlockFile.h +++ b/src/BlockFile.h @@ -29,14 +29,14 @@ class SummaryInfo { public: - SummaryInfo(sampleCount samples); + SummaryInfo(size_t samples); int fields; /* Usually 3 for Min, Max, RMS */ sampleFormat format; int bytesPerFrame; - sampleCount frames64K; + size_t frames64K; int offset64K; - sampleCount frames256; + size_t frames256; int offset256; int totalSummaryBytes; }; @@ -58,7 +58,7 @@ class PROFILE_DLL_API BlockFile /* not final, abstract */ { // Constructor / Destructor /// Construct a BlockFile. - BlockFile(wxFileNameWrapper &&fileName, sampleCount samples); + BlockFile(wxFileNameWrapper &&fileName, size_t samples); virtual ~BlockFile(); static unsigned long gBlockFileDestructionCount; @@ -66,8 +66,8 @@ class PROFILE_DLL_API BlockFile /* not final, abstract */ { // Reading /// Retrieves audio data from this BlockFile - virtual int ReadData(samplePtr data, sampleFormat format, - sampleCount start, sampleCount len) const = 0; + virtual size_t ReadData(samplePtr data, sampleFormat format, + size_t start, size_t len) const = 0; // Other Properties @@ -105,8 +105,8 @@ class PROFILE_DLL_API BlockFile /* not final, abstract */ { virtual GetFileNameResult GetFileName() const; virtual void SetFileName(wxFileNameWrapper &&name); - sampleCount GetLength() const { return mLen; } - void SetLength(const sampleCount newLen) { mLen = newLen; } + size_t GetLength() const { return mLen; } + void SetLength(size_t newLen) { mLen = newLen; } /// Locks this BlockFile, to prevent it from being moved virtual void Lock(); @@ -116,14 +116,14 @@ class PROFILE_DLL_API BlockFile /* not final, abstract */ { virtual bool IsLocked(); /// Gets extreme values for the specified region - virtual void GetMinMax(sampleCount start, sampleCount len, + virtual void GetMinMax(size_t start, size_t len, float *outMin, float *outMax, float *outRMS) const; /// Gets extreme values for the entire block virtual void GetMinMax(float *outMin, float *outMax, float *outRMS) const; /// Returns the 256 byte summary data block - virtual bool Read256(float *buffer, sampleCount start, sampleCount len); + virtual bool Read256(float *buffer, size_t start, size_t len); /// Returns the 64K summary data block - virtual bool Read64K(float *buffer, sampleCount start, sampleCount len); + virtual bool Read64K(float *buffer, size_t start, size_t len); /// Returns TRUE if this block references another disk file virtual bool IsAlias() const { return false; } @@ -170,12 +170,12 @@ class PROFILE_DLL_API BlockFile /* not final, abstract */ { protected: /// Calculate summary data for the given sample data /// Overrides have differing details of memory management - virtual void *CalcSummary(samplePtr buffer, sampleCount len, + virtual void *CalcSummary(samplePtr buffer, size_t len, sampleFormat format, // This gets filled, if the caller needs to deallocate. Else it is null. ArrayOf &cleanup); // Common, nonvirtual calculation routine for the use of the above - void CalcSummaryFromBuffer(const float *fbuffer, sampleCount len, + void CalcSummaryFromBuffer(const float *fbuffer, size_t len, float *summary256, float *summary64K); /// Read the summary section of the file. Derived classes implement. @@ -192,7 +192,7 @@ class PROFILE_DLL_API BlockFile /* not final, abstract */ { protected: wxFileNameWrapper mFileName; - sampleCount mLen; + size_t mLen; SummaryInfo mSummaryInfo; float mMin, mMax, mRMS; mutable bool mSilentLog; @@ -216,10 +216,10 @@ class AliasBlockFile /* not final */ : public BlockFile /// Constructs an AliasBlockFile AliasBlockFile(wxFileNameWrapper &&baseFileName, wxFileNameWrapper &&aliasedFileName, sampleCount aliasStart, - sampleCount aliasLen, int aliasChannel); + size_t aliasLen, int aliasChannel); AliasBlockFile(wxFileNameWrapper &&existingSummaryFileName, wxFileNameWrapper &&aliasedFileName, sampleCount aliasStart, - sampleCount aliasLen, int aliasChannel, + size_t aliasLen, int aliasChannel, float min, float max, float RMS); virtual ~AliasBlockFile(); diff --git a/src/CrossFade.cpp b/src/CrossFade.cpp index 83ea1657e..4ef335c45 100644 --- a/src/CrossFade.cpp +++ b/src/CrossFade.cpp @@ -38,7 +38,7 @@ CrossFader::~CrossFader() bool CrossFader::GetSamples(samplePtr buffer, sampleFormat format, - sampleCount start, sampleCount len) + sampleCount start, size_t len) { switch (mType) { @@ -57,7 +57,7 @@ bool CrossFader::GetSamples(samplePtr buffer, sampleFormat format, } -bool CrossFader::CrossFadeMix(samplePtr buffer, sampleFormat format, sampleCount start, sampleCount len) +bool CrossFader::CrossFadeMix(samplePtr buffer, sampleFormat format, sampleCount start, size_t len) { std::cout << "Crossfading from " << start.as_long_long() diff --git a/src/CrossFade.h b/src/CrossFade.h index 800137779..1e10c4594 100644 --- a/src/CrossFade.h +++ b/src/CrossFade.h @@ -42,14 +42,14 @@ class CrossFader void ClearClips(); //Produces samples according to crossfading rules. bool GetSamples(samplePtr buffer, sampleFormat format, - sampleCount start, sampleCount len); + sampleCount start, size_t len); protected: WaveClipHolders mClips; private: - bool CrossFadeMix(samplePtr buffer, sampleFormat format, sampleCount start, sampleCount len); + bool CrossFadeMix(samplePtr buffer, sampleFormat format, sampleCount start, size_t len); FadeType mType; diff --git a/src/DirManager.cpp b/src/DirManager.cpp index e0df79180..9cee92516 100644 --- a/src/DirManager.cpp +++ b/src/DirManager.cpp @@ -345,7 +345,7 @@ DirManager::DirManager() mLoadingTarget = NULL; mLoadingTargetIdx = 0; - mMaxSamples = -1; + mMaxSamples = ~size_t(0); // toplevel pool hash is fully populated to begin { @@ -925,7 +925,7 @@ wxFileNameWrapper DirManager::MakeBlockFileName() } BlockFilePtr DirManager::NewSimpleBlockFile( - samplePtr sampleData, sampleCount sampleLen, + samplePtr sampleData, size_t sampleLen, sampleFormat format, bool allowDeferredWrite) { @@ -942,7 +942,7 @@ BlockFilePtr DirManager::NewSimpleBlockFile( BlockFilePtr DirManager::NewAliasBlockFile( const wxString &aliasedFile, sampleCount aliasStart, - sampleCount aliasLen, int aliasChannel) + size_t aliasLen, int aliasChannel) { wxFileNameWrapper filePath{ MakeBlockFileName() }; const wxString fileName = filePath.GetName(); @@ -959,7 +959,7 @@ BlockFilePtr DirManager::NewAliasBlockFile( BlockFilePtr DirManager::NewODAliasBlockFile( const wxString &aliasedFile, sampleCount aliasStart, - sampleCount aliasLen, int aliasChannel) + size_t aliasLen, int aliasChannel) { wxFileNameWrapper filePath{ MakeBlockFileName() }; const wxString fileName{ filePath.GetName() }; @@ -976,7 +976,7 @@ BlockFilePtr DirManager::NewODAliasBlockFile( BlockFilePtr DirManager::NewODDecodeBlockFile( const wxString &aliasedFile, sampleCount aliasStart, - sampleCount aliasLen, int aliasChannel, int decodeType) + size_t aliasLen, int aliasChannel, int decodeType) { wxFileNameWrapper filePath{ MakeBlockFileName() }; const wxString fileName{ filePath.GetName() }; @@ -1135,7 +1135,7 @@ bool DirManager::HandleXMLTag(const wxChar *tag, const wxChar **attrs) return false; // Check the length here so we don't have to do it in each BuildFromXML method. - if ((mMaxSamples > -1) && // is initialized + if ((mMaxSamples != ~size_t(0)) && // is initialized (pBlockFile->GetLength() > mMaxSamples)) { // See http://bugzilla.audacityteam.org/show_bug.cgi?id=451#c13. diff --git a/src/DirManager.h b/src/DirManager.h index c322f8388..d2f67d64c 100644 --- a/src/DirManager.h +++ b/src/DirManager.h @@ -63,21 +63,21 @@ class PROFILE_DLL_API DirManager final : public XMLTagHandler { BlockFilePtr NewSimpleBlockFile(samplePtr sampleData, - sampleCount sampleLen, + size_t sampleLen, sampleFormat format, bool allowDeferredWrite = false); BlockFilePtr NewAliasBlockFile( const wxString &aliasedFile, sampleCount aliasStart, - sampleCount aliasLen, int aliasChannel); + size_t aliasLen, int aliasChannel); BlockFilePtr NewODAliasBlockFile( const wxString &aliasedFile, sampleCount aliasStart, - sampleCount aliasLen, int aliasChannel); + size_t aliasLen, int aliasChannel); BlockFilePtr NewODDecodeBlockFile( const wxString &aliasedFile, sampleCount aliasStart, - sampleCount aliasLen, int aliasChannel, int decodeType); + size_t aliasLen, int aliasChannel, int decodeType); /// Returns true if the blockfile pointed to by b is contained by the DirManager bool ContainsBlockFile(const BlockFile *b) const; @@ -108,10 +108,10 @@ class PROFILE_DLL_API DirManager final : public XMLTagHandler { mLoadingTargetIdx = idx; } void SetLoadingFormat(sampleFormat format) { mLoadingFormat = format; } - void SetLoadingBlockLength(sampleCount len) { mLoadingBlockLen = len; } + void SetLoadingBlockLength(size_t len) { mLoadingBlockLen = len; } // Note: following affects only the loading of block files when opening a project - void SetLoadingMaxSamples(sampleCount max) { mMaxSamples = max; } + void SetLoadingMaxSamples(size_t max) { mMaxSamples = max; } bool HandleXMLTag(const wxChar *tag, const wxChar **attrs); XMLTagHandler *HandleXMLChild(const wxChar * WXUNUSED(tag)) { return NULL; } @@ -204,9 +204,9 @@ class PROFILE_DLL_API DirManager final : public XMLTagHandler { BlockArray *mLoadingTarget; unsigned mLoadingTargetIdx; sampleFormat mLoadingFormat; - sampleCount mLoadingBlockLen; + size_t mLoadingBlockLen; - sampleCount mMaxSamples; // max samples per block + size_t mMaxSamples; // max samples per block unsigned long mLastBlockFileDestructionCount { 0 }; diff --git a/src/Menus.cpp b/src/Menus.cpp index 30a26ca78..1face9b57 100644 --- a/src/Menus.cpp +++ b/src/Menus.cpp @@ -6216,7 +6216,7 @@ class ASAProgress final : public SAProgress { long mixer_process(void *mixer, float **buffer, long n) { Mixer *mix = (Mixer *) mixer; - long frame_count = mix->Process(n); + long frame_count = mix->Process(std::max(0L, n)); *buffer = (float *) mix->GetBuffer(); return frame_count; } @@ -6301,7 +6301,7 @@ void AudacityProject::OnScoreAlign() 0.0, // double startTime endTime, // double stopTime 2, // int numOutChannels - 44100, // int outBufferSize + 44100u, // size_t outBufferSize true, // bool outInterleaved mRate, // double outRate floatSample, // sampleFormat outFormat diff --git a/src/Mix.cpp b/src/Mix.cpp index a5fe02559..6eaa9bef9 100644 --- a/src/Mix.cpp +++ b/src/Mix.cpp @@ -241,7 +241,7 @@ Mixer::WarpOptions::WarpOptions(double min, double max) Mixer::Mixer(const WaveTrackConstArray &inputTracks, const WarpOptions &warpOptions, double startTime, double stopTime, - unsigned numOutChannels, int outBufferSize, bool outInterleaved, + unsigned numOutChannels, size_t outBufferSize, bool outInterleaved, double outRate, sampleFormat outFormat, bool highQuality, MixerSpec *mixerSpec) { @@ -405,7 +405,7 @@ void MixBuffers(unsigned numChannels, int *channelFlags, float *gains, } } -sampleCount Mixer::MixVariableRates(int *channelFlags, WaveTrackCache &cache, +size_t Mixer::MixVariableRates(int *channelFlags, WaveTrackCache &cache, sampleCount *pos, float *queue, int *queueStart, int *queueLen, Resample * pResample) @@ -546,7 +546,7 @@ sampleCount Mixer::MixVariableRates(int *channelFlags, WaveTrackCache &cache, return out; } -sampleCount Mixer::MixSameRate(int *channelFlags, WaveTrackCache &cache, +size_t Mixer::MixSameRate(int *channelFlags, WaveTrackCache &cache, sampleCount *pos) { const WaveTrack *const track = cache.GetTrack(); @@ -601,7 +601,7 @@ sampleCount Mixer::MixSameRate(int *channelFlags, WaveTrackCache &cache, return slen; } -sampleCount Mixer::Process(sampleCount maxToProcess) +size_t Mixer::Process(size_t maxToProcess) { // MB: this is wrong! mT represented warped time, and mTime is too inaccurate to use // it here. It's also unnecessary I think. diff --git a/src/Mix.h b/src/Mix.h index 536ca92b3..fbaa1c0de 100644 --- a/src/Mix.h +++ b/src/Mix.h @@ -95,7 +95,7 @@ class AUDACITY_DLL_API Mixer { Mixer(const WaveTrackConstArray &inputTracks, const WarpOptions &warpOptions, double startTime, double stopTime, - unsigned numOutChannels, int outBufferSize, bool outInterleaved, + unsigned numOutChannels, size_t outBufferSize, bool outInterleaved, double outRate, sampleFormat outFormat, bool highQuality = true, MixerSpec *mixerSpec = NULL); @@ -115,7 +115,7 @@ class AUDACITY_DLL_API Mixer { /// a buffer which can be retrieved by calling GetBuffer(). /// Returns number of output samples, or 0, if there are no /// more samples that must be processed. - sampleCount Process(sampleCount maxSamples); + size_t Process(size_t maxSamples); /// Restart processing at beginning of buffer next time /// Process() is called. @@ -141,10 +141,10 @@ class AUDACITY_DLL_API Mixer { private: void Clear(); - sampleCount MixSameRate(int *channelFlags, WaveTrackCache &cache, + size_t MixSameRate(int *channelFlags, WaveTrackCache &cache, sampleCount *pos); - sampleCount MixVariableRates(int *channelFlags, WaveTrackCache &cache, + size_t MixVariableRates(int *channelFlags, WaveTrackCache &cache, sampleCount *pos, float *queue, int *queueStart, int *queueLen, Resample * pResample); @@ -167,16 +167,16 @@ class AUDACITY_DLL_API Mixer { float **mSampleQueue; int *mQueueStart; int *mQueueLen; - int mQueueMaxLen; - int mProcessLen; + size_t mQueueMaxLen; + size_t mProcessLen; MixerSpec *mMixerSpec; // Output - int mMaxOut; + size_t mMaxOut; unsigned mNumChannels; unsigned mNumBuffers; - int mBufferSize; - int mInterleavedBufferSize; + size_t mBufferSize; + size_t mInterleavedBufferSize; sampleFormat mFormat; bool mInterleaved; SampleBuffer *mBuffer; diff --git a/src/RingBuffer.cpp b/src/RingBuffer.cpp index 824338385..09b5f51c0 100644 --- a/src/RingBuffer.cpp +++ b/src/RingBuffer.cpp @@ -27,7 +27,7 @@ RingBuffer::RingBuffer(sampleFormat format, size_t size) : mFormat{ format } , mBufferSize{ std::max(size, 64) } - , mBuffer( mBufferSize, mFormat ) + , mBuffer{ mBufferSize, mFormat } { } diff --git a/src/SampleFormat.cpp b/src/SampleFormat.cpp index c461273c0..8f5aa9251 100644 --- a/src/SampleFormat.cpp +++ b/src/SampleFormat.cpp @@ -74,7 +74,7 @@ const wxChar *GetSampleFormatStr(sampleFormat format) return wxT("Unknown format"); // compiler food } -AUDACITY_DLL_API samplePtr NewSamples(int count, sampleFormat format) +AUDACITY_DLL_API samplePtr NewSamples(size_t count, sampleFormat format) { return (samplePtr)malloc(count * SAMPLE_SIZE(format)); } diff --git a/src/SampleFormat.h b/src/SampleFormat.h index 84a05141a..67f312fec 100644 --- a/src/SampleFormat.h +++ b/src/SampleFormat.h @@ -48,7 +48,7 @@ const wxChar *GetSampleFormatStr(sampleFormat format); // Allocating/Freeing Samples // -AUDACITY_DLL_API samplePtr NewSamples(int count, sampleFormat format); +AUDACITY_DLL_API samplePtr NewSamples(size_t count, sampleFormat format); AUDACITY_DLL_API void DeleteSamples(samplePtr p); // RAII version of above @@ -58,7 +58,7 @@ public: SampleBuffer() : mPtr(0) {} - SampleBuffer(int count, sampleFormat format) + SampleBuffer(size_t count, sampleFormat format) : mPtr(NewSamples(count, format)) {} ~SampleBuffer() @@ -67,7 +67,7 @@ public: } // WARNING! May not preserve contents. - SampleBuffer &Allocate(int count, sampleFormat format) + SampleBuffer &Allocate(size_t count, sampleFormat format) { Free(); mPtr = NewSamples(count, format); @@ -96,12 +96,12 @@ public: , mCount(0) {} - GrowableSampleBuffer(int count, sampleFormat format) + GrowableSampleBuffer(size_t count, sampleFormat format) : SampleBuffer(count, format) , mCount(count) {} - GrowableSampleBuffer &Resize(int count, sampleFormat format) + GrowableSampleBuffer &Resize(size_t count, sampleFormat format) { if (!ptr() || mCount < count) { Allocate(count, format); @@ -119,7 +119,7 @@ public: using SampleBuffer::ptr; private: - int mCount; + size_t mCount; }; // diff --git a/src/Sequence.cpp b/src/Sequence.cpp index 5d01e9a69..6db5ed548 100644 --- a/src/Sequence.cpp +++ b/src/Sequence.cpp @@ -48,7 +48,7 @@ #include "blockfile/SimpleBlockFile.h" #include "blockfile/SilentBlockFile.h" -int Sequence::sMaxDiskBlockSize = 1048576; +size_t Sequence::sMaxDiskBlockSize = 1048576; // Sequence methods Sequence::Sequence(const std::shared_ptr &projDirManager, sampleFormat format) @@ -77,12 +77,12 @@ Sequence::~Sequence() { } -sampleCount Sequence::GetMaxBlockSize() const +size_t Sequence::GetMaxBlockSize() const { return mMaxSamples; } -sampleCount Sequence::GetIdealBlockSize() const +size_t Sequence::GetIdealBlockSize() const { return mMaxSamples; } @@ -698,7 +698,7 @@ bool Sequence::InsertSilence(sampleCount s0, sampleCount len) bool Sequence::AppendAlias(const wxString &fullPath, sampleCount start, - sampleCount len, int channel, bool useOD) + size_t len, int channel, bool useOD) { // Quick check to make sure that it doesn't overflow if (Overflows((mNumSamples.as_double()) + ((double)len))) @@ -717,7 +717,7 @@ bool Sequence::AppendAlias(const wxString &fullPath, } bool Sequence::AppendCoded(const wxString &fName, sampleCount start, - sampleCount len, int channel, int decodeType) + size_t len, int channel, int decodeType) { // Quick check to make sure that it doesn't overflow if (Overflows((mNumSamples.as_double()) + ((double)len))) @@ -781,7 +781,7 @@ sampleCount Sequence::GetBlockStart(sampleCount position) const return mBlock[b].start; } -sampleCount Sequence::GetBestBlockSize(sampleCount start) const +size_t Sequence::GetBestBlockSize(sampleCount start) const { // This method returns a nice number of samples you should try to grab in // one big chunk in order to land on a block boundary, based on the starting @@ -897,6 +897,8 @@ bool Sequence::HandleXMLTag(const wxChar *tag, const wxChar **attrs) mErrorOpening = true; return false; } + + // nValue is now safe for size_t mMaxSamples = nValue; // PRL: Is the following really okay? DirManager might be shared across projects! @@ -1111,21 +1113,19 @@ int Sequence::FindBlock(sampleCount pos) const } bool Sequence::Read(samplePtr buffer, sampleFormat format, - const SeqBlock &b, sampleCount start, sampleCount len) const + const SeqBlock &b, size_t blockRelativeStart, size_t len) + const { const auto &f = b.f; - wxASSERT(start >= 0); - wxASSERT(start + len <= f->GetLength()); + wxASSERT(blockRelativeStart + len <= f->GetLength()); - int result = f->ReadData(buffer, format, start, len); + auto result = f->ReadData(buffer, format, blockRelativeStart, len); if (result != len) { wxLogWarning(wxT("Expected to read %ld samples, got %d samples."), - (long long)len, result); - if (result < 0) - result = 0; + len, result); ClearSamples(buffer, format, result, len-result); } @@ -1134,7 +1134,7 @@ bool Sequence::Read(samplePtr buffer, sampleFormat format, bool Sequence::CopyWrite(SampleBuffer &scratch, samplePtr buffer, SeqBlock &b, - sampleCount start, sampleCount len) + size_t blockRelativeStart, size_t len) { // We don't ever write to an existing block; to support Undo, // we copy the old block entirely into memory, dereference it, @@ -1142,13 +1142,13 @@ bool Sequence::CopyWrite(SampleBuffer &scratch, const auto length = b.f->GetLength(); wxASSERT(length <= mMaxSamples); - wxASSERT(start + len <= length); - wxASSERT(start >= 0); + wxASSERT(blockRelativeStart + len <= length); auto sampleSize = SAMPLE_SIZE(mSampleFormat); Read(scratch.ptr(), mSampleFormat, b, 0, length); - memcpy(scratch.ptr() + start*sampleSize, buffer, len*sampleSize); + memcpy(scratch.ptr() + + blockRelativeStart * sampleSize, buffer, len*sampleSize); b.f = mDirManager->NewSimpleBlockFile(scratch.ptr(), length, mSampleFormat); @@ -1156,7 +1156,7 @@ bool Sequence::CopyWrite(SampleBuffer &scratch, } bool Sequence::Get(samplePtr buffer, sampleFormat format, - sampleCount start, sampleCount len) const + sampleCount start, size_t len) const { if (start == mNumSamples) { return len == 0; @@ -1171,7 +1171,7 @@ bool Sequence::Get(samplePtr buffer, sampleFormat format, } bool Sequence::Get(int b, samplePtr buffer, sampleFormat format, - sampleCount start, sampleCount len) const + sampleCount start, size_t len) const { while (len) { const SeqBlock &block = mBlock[b]; @@ -1497,7 +1497,7 @@ bool Sequence::GetWaveDisplay(float *min, float *max, float *rms, int* bl, return true; } -sampleCount Sequence::GetIdealAppendLen() +size_t Sequence::GetIdealAppendLen() const { int numBlocks = mBlock.size(); const auto max = GetMaxBlockSize(); @@ -1513,7 +1513,7 @@ sampleCount Sequence::GetIdealAppendLen() } bool Sequence::Append(samplePtr buffer, sampleFormat format, - sampleCount len, XMLWriter* blockFileLog /*=NULL*/) + size_t len, XMLWriter* blockFileLog /*=NULL*/) { // Quick check to make sure that it doesn't overflow if (Overflows(mNumSamples.as_double() + ((double)len))) @@ -1592,7 +1592,7 @@ bool Sequence::Append(samplePtr buffer, sampleFormat format, return true; } -void Sequence::Blockify(BlockArray &list, sampleCount start, samplePtr buffer, sampleCount len) +void Sequence::Blockify(BlockArray &list, sampleCount start, samplePtr buffer, size_t len) { if (len <= 0) return; @@ -1846,12 +1846,12 @@ void Sequence::DebugPrintf(wxString *dest) const } // static -void Sequence::SetMaxDiskBlockSize(int bytes) +void Sequence::SetMaxDiskBlockSize(size_t bytes) { sMaxDiskBlockSize = bytes; } -int Sequence::GetMaxDiskBlockSize() +size_t Sequence::GetMaxDiskBlockSize() { return sMaxDiskBlockSize; } diff --git a/src/Sequence.h b/src/Sequence.h index 623d22e35..dda233070 100644 --- a/src/Sequence.h +++ b/src/Sequence.h @@ -59,8 +59,8 @@ class PROFILE_DLL_API Sequence final : public XMLTagHandler{ // Static methods // - static void SetMaxDiskBlockSize(int bytes); - static int GetMaxDiskBlockSize(); + static void SetMaxDiskBlockSize(size_t bytes); + static size_t GetMaxDiskBlockSize(); // // Constructor / Destructor / Duplicator @@ -82,7 +82,10 @@ class PROFILE_DLL_API Sequence final : public XMLTagHandler{ sampleCount GetNumSamples() const { return mNumSamples; } bool Get(samplePtr buffer, sampleFormat format, - sampleCount start, sampleCount len) const; + sampleCount start, size_t len) const; + + // Note that len is not size_t, because nullptr may be passed for buffer, in + // which case, silence is inserted, possibly a large amount. bool Set(samplePtr buffer, sampleFormat format, sampleCount start, sampleCount len); @@ -99,16 +102,16 @@ class PROFILE_DLL_API Sequence final : public XMLTagHandler{ bool Copy(sampleCount s0, sampleCount s1, std::unique_ptr &dest) const; bool Paste(sampleCount s0, const Sequence *src); - sampleCount GetIdealAppendLen(); - bool Append(samplePtr buffer, sampleFormat format, sampleCount len, + size_t GetIdealAppendLen() const; + bool Append(samplePtr buffer, sampleFormat format, size_t len, XMLWriter* blockFileLog=NULL); bool Delete(sampleCount start, sampleCount len); bool AppendAlias(const wxString &fullPath, sampleCount start, - sampleCount len, int channel, bool useOD); + size_t len, int channel, bool useOD); bool AppendCoded(const wxString &fName, sampleCount start, - sampleCount len, int channel, int decodeType); + size_t len, int channel, int decodeType); ///gets an int with OD flags so that we can determine which ODTasks should be run on this track after save/open, etc. unsigned int GetODFlags(); @@ -171,10 +174,13 @@ class PROFILE_DLL_API Sequence final : public XMLTagHandler{ // Getting block size and alignment information // + // This returns a possibly large or negative value sampleCount GetBlockStart(sampleCount position) const; - sampleCount GetBestBlockSize(sampleCount start) const; - sampleCount GetMaxBlockSize() const; - sampleCount GetIdealBlockSize() const; + + // These return a nonnegative number of samples meant to size a memory buffer + size_t GetBestBlockSize(sampleCount start) const; + size_t GetMaxBlockSize() const; + size_t GetIdealBlockSize() const; // // This should only be used if you really, really know what @@ -208,7 +214,7 @@ class PROFILE_DLL_API Sequence final : public XMLTagHandler{ // Private static variables // - static int sMaxDiskBlockSize; + static size_t sMaxDiskBlockSize; // // Private variables @@ -218,10 +224,12 @@ class PROFILE_DLL_API Sequence final : public XMLTagHandler{ BlockArray mBlock; sampleFormat mSampleFormat; + + // Not size_t! May need to be large: sampleCount mNumSamples{ 0 }; - sampleCount mMinSamples; // min samples per block - sampleCount mMaxSamples; // max samples per block + size_t mMinSamples; // min samples per block + size_t mMaxSamples; // max samples per block bool mErrorOpening{ false }; @@ -238,16 +246,16 @@ class PROFILE_DLL_API Sequence final : public XMLTagHandler{ bool Read(samplePtr buffer, sampleFormat format, const SeqBlock &b, - sampleCount start, sampleCount len) const; + size_t blockRelativeStart, size_t len) const; bool CopyWrite(SampleBuffer &scratch, - samplePtr buffer, SeqBlock &b, - sampleCount start, sampleCount len); + samplePtr buffer, SeqBlock &b, + size_t blockRelativeStart, size_t len); - void Blockify(BlockArray &list, sampleCount start, samplePtr buffer, sampleCount len); + void Blockify(BlockArray &list, sampleCount start, samplePtr buffer, size_t len); bool Get(int b, samplePtr buffer, sampleFormat format, - sampleCount start, sampleCount len) const; + sampleCount start, size_t len) const; public: diff --git a/src/VoiceKey.cpp b/src/VoiceKey.cpp index e961aa89c..16b77c2d7 100644 --- a/src/VoiceKey.cpp +++ b/src/VoiceKey.cpp @@ -102,8 +102,8 @@ sampleCount VoiceKey::OnForward (WaveTrack & t, sampleCount start, sampleCount l //Change the millisecond-based parameters into sample-based parameters double rate = t.GetRate(); //Translates seconds to samples - unsigned int WindowSizeInt = (unsigned int)(rate * mWindowSize); //Size of window to examine - unsigned int SignalWindowSizeInt = (unsigned int)(rate * mSignalWindowSize); //This much signal is necessary to trip key + size_t WindowSizeInt = (rate * mWindowSize); //Size of window to examine + size_t SignalWindowSizeInt = (rate * mSignalWindowSize); //This much signal is necessary to trip key auto samplesleft = len - WindowSizeInt; //Indexes the number of samples remaining in the selection auto lastsubthresholdsample = start; //start this off at the selection start @@ -144,7 +144,7 @@ sampleCount VoiceKey::OnForward (WaveTrack & t, sampleCount start, sampleCount l //Calculate how many to scan through--we only have to go through (at most) //the first window + 1 samples--but we need another window samples to draw from. - auto remaining = 2*WindowSizeInt+1; + size_t remaining = 2*WindowSizeInt+1; //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. @@ -249,7 +249,7 @@ sampleCount VoiceKey::OnBackward (WaveTrack & t, sampleCount end, sampleCount le //Change the millisecond-based parameters into sample-based parameters double rate = t.GetRate(); //Translates seconds to samples - unsigned int WindowSizeInt = (unsigned int)(rate * mWindowSize); //Size of window to examine + size_t WindowSizeInt = (rate * mWindowSize); //Size of window to examine //unsigned int SilentWindowSizeInt = (unsigned int)(rate * mSilentWindowSize); //This much signal is necessary to trip key auto samplesleft = len - WindowSizeInt; //Indexes the number of samples remaining in the selection @@ -293,7 +293,7 @@ sampleCount VoiceKey::OnBackward (WaveTrack & t, sampleCount end, sampleCount le //Calculate how many to scan through--we only have to go through (at most) //the first window + 1 samples--but we need another window samples to draw from. - auto remaining = 2*WindowSizeInt+1; + size_t remaining = 2*WindowSizeInt+1; //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. @@ -320,7 +320,7 @@ sampleCount VoiceKey::OnBackward (WaveTrack & t, sampleCount end, sampleCount le //Now, go through the sound again, sample by sample. size_t i; - for(i = remaining - 1; i > WindowSizeInt; i--) { + for(i = remaining - 1; i > WindowSizeInt; i--) { int tests = 0; int testThreshold = 0; //Update the test statistics @@ -428,7 +428,7 @@ sampleCount VoiceKey::OffForward (WaveTrack & t, sampleCount start, sampleCount //Calculate how many to scan through--we only have to go through (at most) //the first window + 1 samples--but we need another window samples to draw from. - auto remaining = 2*WindowSizeInt+1; + size_t remaining = 2*WindowSizeInt+1; //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. @@ -564,7 +564,7 @@ sampleCount VoiceKey::OffBackward (WaveTrack & t, sampleCount end, sampleCount l //Calculate how many to scan through--we only have to go through (at most) //the first window + 1 samples--but we need another window samples to draw from. - auto remaining = 2*WindowSizeInt+1; + const size_t remaining = 2*WindowSizeInt+1; //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. diff --git a/src/WaveClip.cpp b/src/WaveClip.cpp index d98c85246..f027cf9df 100644 --- a/src/WaveClip.cpp +++ b/src/WaveClip.cpp @@ -350,13 +350,13 @@ void WaveClip::SetOffset(double offset) } bool WaveClip::GetSamples(samplePtr buffer, sampleFormat format, - sampleCount start, sampleCount len) const + sampleCount start, size_t len) const { return mSequence->Get(buffer, format, start, len); } bool WaveClip::SetSamples(samplePtr buffer, sampleFormat format, - sampleCount start, sampleCount len) + sampleCount start, size_t len) { bool bResult = mSequence->Set(buffer, format, start, len); MarkChanged(); @@ -1297,7 +1297,7 @@ void WaveClip::GetDisplayRect(wxRect* r) } bool WaveClip::Append(samplePtr buffer, sampleFormat format, - sampleCount len, unsigned int stride /* = 1 */, + size_t len, unsigned int stride /* = 1 */, XMLWriter* blockFileLog /*=NULL*/) { //wxLogDebug(wxT("Append: len=%lli"), (long long) len); @@ -1348,7 +1348,7 @@ bool WaveClip::Append(samplePtr buffer, sampleFormat format, } bool WaveClip::AppendAlias(const wxString &fName, sampleCount start, - sampleCount len, int channel,bool useOD) + size_t len, int channel,bool useOD) { bool result = mSequence->AppendAlias(fName, start, len, channel,useOD); if (result) @@ -1360,7 +1360,7 @@ bool WaveClip::AppendAlias(const wxString &fName, sampleCount start, } bool WaveClip::AppendCoded(const wxString &fName, sampleCount start, - sampleCount len, int channel, int decodeType) + size_t len, int channel, int decodeType) { bool result = mSequence->AppendCoded(fName, start, len, channel, decodeType); if (result) @@ -1786,7 +1786,7 @@ bool WaveClip::Resample(int rate, ProgressDialog *progress) double factor = (double)rate / (double)mRate; ::Resample resample(true, factor, factor); // constant rate resampling - int bufsize = 65536; + size_t bufsize = 65536; float* inBuffer = new float[bufsize]; float* outBuffer = new float[bufsize]; sampleCount pos = 0; diff --git a/src/WaveClip.h b/src/WaveClip.h index ea6d490f1..062fa0d64 100644 --- a/src/WaveClip.h +++ b/src/WaveClip.h @@ -119,7 +119,7 @@ public: class SpecPxCache { public: - SpecPxCache(int cacheLen) + SpecPxCache(size_t cacheLen) { len = cacheLen; values = new float[len]; @@ -134,7 +134,7 @@ public: delete[] values; } - sampleCount len; + size_t len; float *values; bool valid; @@ -250,9 +250,9 @@ public: bool AfterClip(double t) const; bool GetSamples(samplePtr buffer, sampleFormat format, - sampleCount start, sampleCount len) const; + sampleCount start, size_t len) const; bool SetSamples(samplePtr buffer, sampleFormat format, - sampleCount start, sampleCount len); + sampleCount start, size_t len); Envelope* GetEnvelope() { return mEnvelope.get(); } const Envelope* GetEnvelope() const { return mEnvelope.get(); } @@ -295,16 +295,16 @@ public: /// You must call Flush after the last Append bool Append(samplePtr buffer, sampleFormat format, - sampleCount len, unsigned int stride=1, + size_t len, unsigned int stride=1, XMLWriter* blockFileLog = NULL); /// Flush must be called after last Append bool Flush(); bool AppendAlias(const wxString &fName, sampleCount start, - sampleCount len, int channel,bool useOD); + size_t len, int channel,bool useOD); bool AppendCoded(const wxString &fName, sampleCount start, - sampleCount len, int channel, int decodeType); + size_t len, int channel, int decodeType); /// This name is consistent with WaveTrack::Clear. It performs a "Cut" /// operation (but without putting the cutted audio to the clipboard) @@ -389,7 +389,7 @@ protected: mutable ODLock mWaveCacheMutex; mutable std::unique_ptr mSpecCache; SampleBuffer mAppendBuffer; - sampleCount mAppendBufferLen; + size_t mAppendBufferLen; // Cut Lines are nothing more than ordinary wave clips, with the // offset relative to the start of the clip. diff --git a/src/WaveTrack.cpp b/src/WaveTrack.cpp index 556d1840a..d65f6536c 100644 --- a/src/WaveTrack.cpp +++ b/src/WaveTrack.cpp @@ -1563,7 +1563,7 @@ bool WaveTrack::Join(double t0, double t1) } bool WaveTrack::Append(samplePtr buffer, sampleFormat format, - sampleCount len, unsigned int stride /* = 1 */, + size_t len, unsigned int stride /* = 1 */, XMLWriter *blockFileLog /* = NULL */) { return RightmostOrNewClip()->Append(buffer, format, len, stride, @@ -1571,14 +1571,14 @@ bool WaveTrack::Append(samplePtr buffer, sampleFormat format, } bool WaveTrack::AppendAlias(const wxString &fName, sampleCount start, - sampleCount len, int channel,bool useOD) + size_t len, int channel,bool useOD) { return RightmostOrNewClip()->AppendAlias(fName, start, len, channel, useOD); } bool WaveTrack::AppendCoded(const wxString &fName, sampleCount start, - sampleCount len, int channel, int decodeType) + size_t len, int channel, int decodeType) { return RightmostOrNewClip()->AppendCoded(fName, start, len, channel, decodeType); } @@ -1608,7 +1608,7 @@ sampleCount WaveTrack::GetBlockStart(sampleCount s) const return -1; } -sampleCount WaveTrack::GetBestBlockSize(sampleCount s) const +size_t WaveTrack::GetBestBlockSize(sampleCount s) const { auto bestBlockSize = GetMaxBlockSize(); @@ -1626,7 +1626,7 @@ sampleCount WaveTrack::GetBestBlockSize(sampleCount s) const return bestBlockSize; } -sampleCount WaveTrack::GetMaxBlockSize() const +size_t WaveTrack::GetMaxBlockSize() const { decltype(GetMaxBlockSize()) maxblocksize = 0; for (const auto &clip : mClips) @@ -1646,7 +1646,7 @@ sampleCount WaveTrack::GetMaxBlockSize() const return maxblocksize; } -sampleCount WaveTrack::GetIdealBlockSize() +size_t WaveTrack::GetIdealBlockSize() { return NewestOrNewClip()->GetSequence()->GetIdealBlockSize(); } @@ -1993,7 +1993,7 @@ bool WaveTrack::GetRMS(float *rms, double t0, double t1) } bool WaveTrack::Get(samplePtr buffer, sampleFormat format, - sampleCount start, sampleCount len, fillFormat fill ) const + sampleCount start, size_t len, fillFormat fill ) const { // Simple optimization: When this buffer is completely contained within one clip, // don't clear anything (because we won't have to). Otherwise, just clear @@ -2071,7 +2071,7 @@ bool WaveTrack::Get(samplePtr buffer, sampleFormat format, } bool WaveTrack::Set(samplePtr buffer, sampleFormat format, - sampleCount start, sampleCount len) + sampleCount start, size_t len) { bool result = true; @@ -2648,7 +2648,7 @@ void WaveTrackCache::SetTrack(const WaveTrack *pTrack) } constSamplePtr WaveTrackCache::Get(sampleFormat format, - sampleCount start, sampleCount len) + sampleCount start, size_t len) { if (format == floatSample && len > 0) { const auto end = start + len; diff --git a/src/WaveTrack.h b/src/WaveTrack.h index 88ff55adf..616f024fc 100644 --- a/src/WaveTrack.h +++ b/src/WaveTrack.h @@ -201,20 +201,20 @@ class AUDACITY_DLL_API WaveTrack final : public Track { * one is created. */ bool Append(samplePtr buffer, sampleFormat format, - sampleCount len, unsigned int stride=1, + size_t len, unsigned int stride=1, XMLWriter* blockFileLog=NULL); /// Flush must be called after last Append bool Flush(); bool AppendAlias(const wxString &fName, sampleCount start, - sampleCount len, int channel,bool useOD); + size_t len, int channel,bool useOD); ///for use with On-Demand decoding of compressed files. ///decodeType should be an enum from ODDecodeTask that specifies what ///Type of encoded file this is, such as eODFLAC //vvv Why not use the ODTypeEnum typedef to enforce that for the parameter? bool AppendCoded(const wxString &fName, sampleCount start, - sampleCount len, int channel, int decodeType); + size_t len, int channel, int decodeType); ///gets an int with OD flags so that we can determine which ODTasks should be run on this track after save/open, etc. unsigned int GetODFlags(); @@ -236,9 +236,9 @@ class AUDACITY_DLL_API WaveTrack final : public Track { /// guaranteed that the same samples are affected. /// bool Get(samplePtr buffer, sampleFormat format, - sampleCount start, sampleCount len, fillFormat fill=fillZero) const; + sampleCount start, size_t len, fillFormat fill=fillZero) const; bool Set(samplePtr buffer, sampleFormat format, - sampleCount start, sampleCount len); + sampleCount start, size_t len); void GetEnvelopeValues(double *buffer, size_t bufferLen, double t0) const; bool GetMinMax(float *min, float *max, @@ -262,11 +262,14 @@ class AUDACITY_DLL_API WaveTrack final : public Track { // Getting information about the track's internal block sizes // and alignment for efficiency // - + + // This returns a possibly large or negative value sampleCount GetBlockStart(sampleCount t) const; - sampleCount GetBestBlockSize(sampleCount t) const; - sampleCount GetMaxBlockSize() const; - sampleCount GetIdealBlockSize(); + + // These return a nonnegative number of samples meant to size a memory buffer + size_t GetBestBlockSize(sampleCount t) const; + size_t GetMaxBlockSize() const; + size_t GetIdealBlockSize(); // // XMLTagHandler callback methods for loading and saving @@ -617,7 +620,7 @@ public: // Returns null on failure // Returned pointer may be invalidated if Get is called again // Do not DELETE[] the pointer - constSamplePtr Get(sampleFormat format, sampleCount start, sampleCount len); + constSamplePtr Get(sampleFormat format, sampleCount start, size_t len); private: void Free(); @@ -633,7 +636,7 @@ private: }; const WaveTrack *mPTrack; - sampleCount mBufferSize; + size_t mBufferSize; Buffer mBuffers[2]; GrowableSampleBuffer mOverlapBuffer; int mNValidBuffers; diff --git a/src/blockfile/LegacyAliasBlockFile.cpp b/src/blockfile/LegacyAliasBlockFile.cpp index b04271cfa..8c20bc06c 100644 --- a/src/blockfile/LegacyAliasBlockFile.cpp +++ b/src/blockfile/LegacyAliasBlockFile.cpp @@ -23,9 +23,9 @@ LegacyAliasBlockFile::LegacyAliasBlockFile(wxFileNameWrapper &&fileName, wxFileNameWrapper &&aliasedFileName, sampleCount aliasStart, - sampleCount aliasLen, + size_t aliasLen, int aliasChannel, - sampleCount summaryLen, + size_t summaryLen, bool noRMS) : PCMAliasBlockFile{ std::move(fileName), std::move(aliasedFileName), aliasStart, aliasLen, aliasChannel, 0.0, 0.0, 0.0 } diff --git a/src/blockfile/LegacyAliasBlockFile.h b/src/blockfile/LegacyAliasBlockFile.h index c2e8551ca..a7dcf1e25 100644 --- a/src/blockfile/LegacyAliasBlockFile.h +++ b/src/blockfile/LegacyAliasBlockFile.h @@ -25,9 +25,9 @@ class LegacyAliasBlockFile final : public PCMAliasBlockFile LegacyAliasBlockFile(wxFileNameWrapper &&fileName, wxFileNameWrapper &&aliasedFileName, sampleCount aliasStart, - sampleCount aliasLen, + size_t aliasLen, int aliasChannel, - sampleCount summaryLen, + size_t summaryLen, bool noRMS); virtual ~LegacyAliasBlockFile(); diff --git a/src/blockfile/LegacyBlockFile.cpp b/src/blockfile/LegacyBlockFile.cpp index d5f1d02d5..3cf7a9c2c 100644 --- a/src/blockfile/LegacyBlockFile.cpp +++ b/src/blockfile/LegacyBlockFile.cpp @@ -128,8 +128,8 @@ void ComputeLegacySummaryInfo(const wxFileName &fileName, /// @param existingFile The disk file this LegacyBlockFile should use. LegacyBlockFile::LegacyBlockFile(wxFileNameWrapper &&existingFile, sampleFormat format, - sampleCount summaryLen, - sampleCount len, + size_t summaryLen, + size_t len, bool noRMS): BlockFile{ std::move(existingFile), len }, mFormat(format) @@ -188,8 +188,8 @@ bool LegacyBlockFile::ReadSummary(void *data) /// @param format The format the data will be stored in /// @param start The offset in this block file /// @param len The number of samples to read -int LegacyBlockFile::ReadData(samplePtr data, sampleFormat format, - sampleCount start, sampleCount len) const +size_t LegacyBlockFile::ReadData(samplePtr data, sampleFormat format, + size_t start, size_t len) const { SF_INFO info; @@ -246,7 +246,7 @@ int LegacyBlockFile::ReadData(samplePtr data, sampleFormat format, SFCall(sf_seek, sf.get(), seekstart , SEEK_SET); SampleBuffer buffer(len, floatSample); - int framesRead = 0; + size_t framesRead = 0; // If both the src and dest formats are integer formats, // read integers from the file (otherwise we would be @@ -295,7 +295,7 @@ void LegacyBlockFile::SaveXML(XMLWriter &xmlFile) // as testing will be done in DirManager::ProjectFSCK(). /// static BlockFilePtr LegacyBlockFile::BuildFromXML(const wxString &projDir, const wxChar **attrs, - sampleCount len, sampleFormat format) + size_t len, sampleFormat format) { wxFileNameWrapper fileName; size_t summaryLen = 0; diff --git a/src/blockfile/LegacyBlockFile.h b/src/blockfile/LegacyBlockFile.h index 1382c179d..a743b0b4f 100644 --- a/src/blockfile/LegacyBlockFile.h +++ b/src/blockfile/LegacyBlockFile.h @@ -40,8 +40,8 @@ class LegacyBlockFile final : public BlockFile { /// Create the memory structure to refer to the given block file LegacyBlockFile(wxFileNameWrapper &&existingFile, sampleFormat format, - sampleCount summaryLen, - sampleCount len, + size_t summaryLen, + size_t len, bool noRMS); virtual ~LegacyBlockFile(); @@ -50,8 +50,8 @@ class LegacyBlockFile final : public BlockFile { /// Read the summary section of the disk file bool ReadSummary(void *data) override; /// Read the data section of the disk file - int ReadData(samplePtr data, sampleFormat format, - sampleCount start, sampleCount len) const override; + size_t ReadData(samplePtr data, sampleFormat format, + size_t start, size_t len) const override; /// Create a NEW block file identical to this one BlockFilePtr Copy(wxFileNameWrapper &&newFileName) override; @@ -61,7 +61,7 @@ class LegacyBlockFile final : public BlockFile { void Recover() override; static BlockFilePtr BuildFromXML(const wxString &dir, const wxChar **attrs, - sampleCount len, + size_t len, sampleFormat format); protected: diff --git a/src/blockfile/ODDecodeBlockFile.cpp b/src/blockfile/ODDecodeBlockFile.cpp index a89d1e669..127f2cb53 100644 --- a/src/blockfile/ODDecodeBlockFile.cpp +++ b/src/blockfile/ODDecodeBlockFile.cpp @@ -37,7 +37,7 @@ char bheaderTag[bheaderTagLen + 1] = "AudacityBlockFile112"; /// Create a disk file and write summary and sample data to it ODDecodeBlockFile::ODDecodeBlockFile(wxFileNameWrapper &&baseFileName, wxFileNameWrapper &&audioFileName, sampleCount aliasStart, - sampleCount aliasLen, int aliasChannel,unsigned int decodeType): + size_t aliasLen, int aliasChannel,unsigned int decodeType): SimpleBlockFile{ std::move(baseFileName), NULL, aliasLen, floatSample, true, true }, //floatSample has no effect. last two bools - bypass writing of blockfile and cache @@ -54,7 +54,7 @@ ODDecodeBlockFile::ODDecodeBlockFile(wxFileNameWrapper &&baseFileName, wxFileNam /// Create the memory structure to refer to the given block file ODDecodeBlockFile::ODDecodeBlockFile(wxFileNameWrapper &&existingFile, wxFileNameWrapper &&audioFileName, sampleCount aliasStart, - sampleCount aliasLen, int aliasChannel, unsigned int decodeType, + size_t aliasLen, int aliasChannel, unsigned int decodeType, float min, float max, float rms, bool dataAvailable): SimpleBlockFile{ std::move(existingFile), aliasLen, min, max, rms }, @@ -92,7 +92,7 @@ auto ODDecodeBlockFile::GetSpaceUsage() const -> DiskByteCount /// Gets extreme values for the specified region -void ODDecodeBlockFile::GetMinMax(sampleCount start, sampleCount len, +void ODDecodeBlockFile::GetMinMax(size_t start, size_t len, float *outMin, float *outMax, float *outRMS) const { if(IsSummaryAvailable()) @@ -127,7 +127,7 @@ void ODDecodeBlockFile::GetMinMax(float *outMin, float *outMax, float *outRMS) c } /// Returns the 256 byte summary data block -bool ODDecodeBlockFile::Read256(float *buffer, sampleCount start, sampleCount len) +bool ODDecodeBlockFile::Read256(float *buffer, size_t start, size_t len) { if(IsSummaryAvailable()) { @@ -142,7 +142,7 @@ bool ODDecodeBlockFile::Read256(float *buffer, sampleCount start, sampleCount le } /// Returns the 64K summary data block -bool ODDecodeBlockFile::Read64K(float *buffer, sampleCount start, sampleCount len) +bool ODDecodeBlockFile::Read64K(float *buffer, size_t start, size_t len) { if(IsSummaryAvailable()) { @@ -228,7 +228,8 @@ BlockFilePtr ODDecodeBlockFile::BuildFromXML(DirManager &dm, const wxChar **attr { wxFileNameWrapper summaryFileName; wxFileNameWrapper audioFileName; - sampleCount aliasStart=0, aliasLen=0; + sampleCount aliasStart = 0; + size_t aliasLen = 0; int aliasChannel=0; long nValue; long long nnValue; @@ -397,7 +398,7 @@ auto ODDecodeBlockFile::GetFileName() const -> GetFileNameResult /// @param buffer A buffer containing the sample data to be analyzed /// @param len The length of the sample data /// @param format The format of the sample data. -void *ODDecodeBlockFile::CalcSummary(samplePtr buffer, sampleCount len, +void *ODDecodeBlockFile::CalcSummary(samplePtr buffer, size_t len, sampleFormat format, ArrayOf &cleanup) { cleanup.reinit(mSummaryInfo.totalSummaryBytes); @@ -442,19 +443,19 @@ void *ODDecodeBlockFile::CalcSummary(samplePtr buffer, sampleCount len, /// @param format The format to convert the data into /// @param start The offset within the block to begin reading /// @param len The number of samples to read -int ODDecodeBlockFile::ReadData(samplePtr data, sampleFormat format, - sampleCount start, sampleCount len) const +size_t ODDecodeBlockFile::ReadData(samplePtr data, sampleFormat format, + size_t start, size_t len) const { - int ret; + size_t ret; LockRead(); if(IsSummaryAvailable()) - ret= SimpleBlockFile::ReadData(data,format,start,len); + ret = SimpleBlockFile::ReadData(data,format,start,len); else { //we should do an ODRequest to start processing the data here, and wait till it finishes. and just do a SimpleBlockFIle //ReadData. ClearSamples(data, format, 0, len); - ret= len; + ret = len; } UnlockRead(); return ret; diff --git a/src/blockfile/ODDecodeBlockFile.h b/src/blockfile/ODDecodeBlockFile.h index bb01cd2ae..741967431 100644 --- a/src/blockfile/ODDecodeBlockFile.h +++ b/src/blockfile/ODDecodeBlockFile.h @@ -43,10 +43,10 @@ class ODDecodeBlockFile final : public SimpleBlockFile /// Create a disk file and write summary and sample data to it ODDecodeBlockFile(wxFileNameWrapper &&baseFileName, wxFileNameWrapper &&audioFileName, sampleCount aliasStart, - sampleCount aliasLen, int aliasChannel, unsigned int decodeType); + size_t aliasLen, int aliasChannel, unsigned int decodeType); /// Create the memory structure to refer to the given block file ODDecodeBlockFile(wxFileNameWrapper &&existingFile, wxFileNameWrapper &&audioFileName, sampleCount aliasStart, - sampleCount aliasLen, int aliasChannel, unsigned int decodeType, + size_t aliasLen, int aliasChannel, unsigned int decodeType, float min, float max, float rms, bool dataAvailable); virtual ~ODDecodeBlockFile(); @@ -62,14 +62,14 @@ class ODDecodeBlockFile final : public SimpleBlockFile //Calls that rely on summary files need to be overidden DiskByteCount GetSpaceUsage() const override; /// Gets extreme values for the specified region - void GetMinMax(sampleCount start, sampleCount len, + void GetMinMax(size_t start, size_t len, float *outMin, float *outMax, float *outRMS) const override; /// Gets extreme values for the entire block void GetMinMax(float *outMin, float *outMax, float *outRMS) const override; /// Returns the 256 byte summary data block - bool Read256(float *buffer, sampleCount start, sampleCount len) override; + bool Read256(float *buffer, size_t start, size_t len) override; /// Returns the 64K summary data block - bool Read64K(float *buffer, sampleCount start, sampleCount len) override; + bool Read64K(float *buffer, size_t start, size_t len) override; /// returns true before decoding is complete, because it is linked to the encoded file until then. /// returns false afterwards. @@ -108,8 +108,8 @@ class ODDecodeBlockFile final : public SimpleBlockFile //Below calls are overrided just so we can take wxlog calls out, which are not threadsafe. /// Reads the specified data from the aliased file using libsndfile - int ReadData(samplePtr data, sampleFormat format, - sampleCount start, sampleCount len) const override; + size_t ReadData(samplePtr data, sampleFormat format, + size_t start, size_t len) const override; /// Read the summary into a buffer bool ReadSummary(void *data) override; @@ -155,7 +155,7 @@ class ODDecodeBlockFile final : public SimpleBlockFile protected: // void WriteSimpleBlockFile() override; - void *CalcSummary(samplePtr buffer, sampleCount len, + void *CalcSummary(samplePtr buffer, size_t len, sampleFormat format, ArrayOf &cleanup) override; //The on demand type. unsigned int mType; diff --git a/src/blockfile/ODPCMAliasBlockFile.cpp b/src/blockfile/ODPCMAliasBlockFile.cpp index b7366d433..53c6870b6 100644 --- a/src/blockfile/ODPCMAliasBlockFile.cpp +++ b/src/blockfile/ODPCMAliasBlockFile.cpp @@ -48,7 +48,7 @@ ODPCMAliasBlockFile::ODPCMAliasBlockFile( wxFileNameWrapper &&fileName, wxFileNameWrapper &&aliasedFileName, sampleCount aliasStart, - sampleCount aliasLen, int aliasChannel) + size_t aliasLen, int aliasChannel) : PCMAliasBlockFile { std::move(fileName), std::move(aliasedFileName), aliasStart, aliasLen, aliasChannel, false } { @@ -60,7 +60,7 @@ ODPCMAliasBlockFile::ODPCMAliasBlockFile( wxFileNameWrapper &&existingSummaryFileName, wxFileNameWrapper &&aliasedFileName, sampleCount aliasStart, - sampleCount aliasLen, int aliasChannel, + size_t aliasLen, int aliasChannel, float min, float max, float rms, bool summaryAvailable) : PCMAliasBlockFile(std::move(existingSummaryFileName), std::move(aliasedFileName), aliasStart, aliasLen, @@ -121,7 +121,7 @@ void ODPCMAliasBlockFile::Unlock() /// Gets extreme values for the specified region -void ODPCMAliasBlockFile::GetMinMax(sampleCount start, sampleCount len, +void ODPCMAliasBlockFile::GetMinMax(size_t start, size_t len, float *outMin, float *outMax, float *outRMS) const { if(IsSummaryAvailable()) @@ -156,7 +156,7 @@ void ODPCMAliasBlockFile::GetMinMax(float *outMin, float *outMax, float *outRMS) } /// Returns the 256 byte summary data block. Clients should check to see if the summary is available before trying to read it with this call. -bool ODPCMAliasBlockFile::Read256(float *buffer, sampleCount start, sampleCount len) +bool ODPCMAliasBlockFile::Read256(float *buffer, size_t start, size_t len) { if(IsSummaryAvailable()) { @@ -171,7 +171,7 @@ bool ODPCMAliasBlockFile::Read256(float *buffer, sampleCount start, sampleCount } /// Returns the 64K summary data block. Clients should check to see if the summary is available before trying to read it with this call. -bool ODPCMAliasBlockFile::Read64K(float *buffer, sampleCount start, sampleCount len) +bool ODPCMAliasBlockFile::Read64K(float *buffer, size_t start, size_t len) { if(IsSummaryAvailable()) { @@ -267,7 +267,8 @@ BlockFilePtr ODPCMAliasBlockFile::BuildFromXML(DirManager &dm, const wxChar **at { wxFileNameWrapper summaryFileName; wxFileNameWrapper aliasFileName; - sampleCount aliasStart=0, aliasLen=0; + sampleCount aliasStart = 0; + size_t aliasLen = 0; int aliasChannel=0; long nValue; long long nnValue; @@ -437,7 +438,7 @@ void ODPCMAliasBlockFile::WriteSummary() /// @param buffer A buffer containing the sample data to be analyzed /// @param len The length of the sample data /// @param format The format of the sample data. -void *ODPCMAliasBlockFile::CalcSummary(samplePtr buffer, sampleCount len, +void *ODPCMAliasBlockFile::CalcSummary(samplePtr buffer, size_t len, sampleFormat format, ArrayOf &cleanup) { cleanup.reinit(mSummaryInfo.totalSummaryBytes); @@ -483,8 +484,8 @@ void *ODPCMAliasBlockFile::CalcSummary(samplePtr buffer, sampleCount len, /// @param format The format to convert the data into /// @param start The offset within the block to begin reading /// @param len The number of samples to read -int ODPCMAliasBlockFile::ReadData(samplePtr data, sampleFormat format, - sampleCount start, sampleCount len) const +size_t ODPCMAliasBlockFile::ReadData(samplePtr data, sampleFormat format, + size_t start, size_t len) const { LockRead(); @@ -537,7 +538,7 @@ int ODPCMAliasBlockFile::ReadData(samplePtr data, sampleFormat format, wxASSERT(info.channels >= 0); SampleBuffer buffer(len * info.channels, floatSample); - int framesRead = 0; + size_t framesRead = 0; if (format == int16Sample && !sf_subtype_more_than_16_bits(info.format)) { diff --git a/src/blockfile/ODPCMAliasBlockFile.h b/src/blockfile/ODPCMAliasBlockFile.h index 1b943f0bd..ea6434a8a 100644 --- a/src/blockfile/ODPCMAliasBlockFile.h +++ b/src/blockfile/ODPCMAliasBlockFile.h @@ -49,10 +49,10 @@ class ODPCMAliasBlockFile final : public PCMAliasBlockFile /// Constructs a PCMAliasBlockFile, writing the summary to disk ODPCMAliasBlockFile(wxFileNameWrapper &&baseFileName, wxFileNameWrapper &&aliasedFileName, sampleCount aliasStart, - sampleCount aliasLen, int aliasChannel); + size_t aliasLen, int aliasChannel); ODPCMAliasBlockFile(wxFileNameWrapper &&existingSummaryFileName, wxFileNameWrapper &&aliasedFileName, sampleCount aliasStart, - sampleCount aliasLen, int aliasChannel, + size_t aliasLen, int aliasChannel, float min, float max, float rms, bool summaryAvailable); virtual ~ODPCMAliasBlockFile(); @@ -65,14 +65,14 @@ class ODPCMAliasBlockFile final : public PCMAliasBlockFile //Calls that rely on summary files need to be overidden DiskByteCount GetSpaceUsage() const override; /// Gets extreme values for the specified region - void GetMinMax(sampleCount start, sampleCount len, + void GetMinMax(size_t start, size_t len, float *outMin, float *outMax, float *outRMS) const override; /// Gets extreme values for the entire block void GetMinMax(float *outMin, float *outMax, float *outRMS) const override; /// Returns the 256 byte summary data block - bool Read256(float *buffer, sampleCount start, sampleCount len) override; + bool Read256(float *buffer, size_t start, size_t len) override; /// Returns the 64K summary data block - bool Read64K(float *buffer, sampleCount start, sampleCount len) override; + bool Read64K(float *buffer, size_t start, size_t len) override; ///Makes NEW ODPCMAliasBlockFile or PCMAliasBlockFile depending on summary availability BlockFilePtr Copy(wxFileNameWrapper &&fileName) override; @@ -117,8 +117,8 @@ class ODPCMAliasBlockFile final : public PCMAliasBlockFile //Below calls are overrided just so we can take wxlog calls out, which are not threadsafe. /// Reads the specified data from the aliased file using libsndfile - int ReadData(samplePtr data, sampleFormat format, - sampleCount start, sampleCount len) const override; + size_t ReadData(samplePtr data, sampleFormat format, + size_t start, size_t len) const override; /// Read the summary into a buffer bool ReadSummary(void *data) override; @@ -139,7 +139,7 @@ class ODPCMAliasBlockFile final : public PCMAliasBlockFile protected: void WriteSummary() override; - void *CalcSummary(samplePtr buffer, sampleCount len, + void *CalcSummary(samplePtr buffer, size_t len, sampleFormat format, ArrayOf &cleanup) override; private: diff --git a/src/blockfile/PCMAliasBlockFile.cpp b/src/blockfile/PCMAliasBlockFile.cpp index bd9520c01..f7ee92081 100644 --- a/src/blockfile/PCMAliasBlockFile.cpp +++ b/src/blockfile/PCMAliasBlockFile.cpp @@ -31,7 +31,7 @@ PCMAliasBlockFile::PCMAliasBlockFile( wxFileNameWrapper &&fileName, wxFileNameWrapper &&aliasedFileName, sampleCount aliasStart, - sampleCount aliasLen, int aliasChannel) + size_t aliasLen, int aliasChannel) : AliasBlockFile{ std::move(fileName), std::move(aliasedFileName), aliasStart, aliasLen, aliasChannel } { @@ -42,7 +42,7 @@ PCMAliasBlockFile::PCMAliasBlockFile( wxFileNameWrapper&& fileName, wxFileNameWrapper&& aliasedFileName, sampleCount aliasStart, - sampleCount aliasLen, int aliasChannel,bool writeSummary) + size_t aliasLen, int aliasChannel,bool writeSummary) : AliasBlockFile{ std::move(fileName), std::move(aliasedFileName), aliasStart, aliasLen, aliasChannel } { @@ -54,7 +54,7 @@ PCMAliasBlockFile::PCMAliasBlockFile( wxFileNameWrapper &&existingSummaryFileName, wxFileNameWrapper &&aliasedFileName, sampleCount aliasStart, - sampleCount aliasLen, int aliasChannel, + size_t aliasLen, int aliasChannel, float min, float max, float rms) : AliasBlockFile{ std::move(existingSummaryFileName), std::move(aliasedFileName), aliasStart, aliasLen, @@ -73,8 +73,8 @@ PCMAliasBlockFile::~PCMAliasBlockFile() /// @param format The format to convert the data into /// @param start The offset within the block to begin reading /// @param len The number of samples to read -int PCMAliasBlockFile::ReadData(samplePtr data, sampleFormat format, - sampleCount start, sampleCount len) const +size_t PCMAliasBlockFile::ReadData(samplePtr data, sampleFormat format, + size_t start, size_t len) const { SF_INFO info; @@ -124,7 +124,7 @@ int PCMAliasBlockFile::ReadData(samplePtr data, sampleFormat format, wxASSERT(info.channels >= 0); SampleBuffer buffer(len * info.channels, floatSample); - int framesRead = 0; + size_t framesRead = 0; if (format == int16Sample && !sf_subtype_more_than_16_bits(info.format)) { diff --git a/src/blockfile/PCMAliasBlockFile.h b/src/blockfile/PCMAliasBlockFile.h index dfe68c0d1..738d84091 100644 --- a/src/blockfile/PCMAliasBlockFile.h +++ b/src/blockfile/PCMAliasBlockFile.h @@ -22,23 +22,23 @@ class PCMAliasBlockFile /* not final */ : public AliasBlockFile PCMAliasBlockFile(wxFileNameWrapper &&baseFileName, wxFileNameWrapper &&aliasedFileName, sampleCount aliasStart, - sampleCount aliasLen, int aliasChannel); + size_t aliasLen, int aliasChannel); ///Constructs a PCMAliasBlockFile with the option of not writing to disk PCMAliasBlockFile(wxFileNameWrapper &&fileName, wxFileNameWrapper &&aliasedFileName, sampleCount aliasStart, - sampleCount aliasLen, int aliasChannel,bool writeSummary); + size_t aliasLen, int aliasChannel,bool writeSummary); PCMAliasBlockFile(wxFileNameWrapper &&existingSummaryFileName, wxFileNameWrapper &&aliasedFileName, sampleCount aliasStart, - sampleCount aliasLen, int aliasChannel, + size_t aliasLen, int aliasChannel, float min, float max, float rms); virtual ~PCMAliasBlockFile(); /// Reads the specified data from the aliased file using libsndfile - int ReadData(samplePtr data, sampleFormat format, - sampleCount start, sampleCount len) const override; + size_t ReadData(samplePtr data, sampleFormat format, + size_t start, size_t len) const override; void SaveXML(XMLWriter &xmlFile) override; BlockFilePtr Copy(wxFileNameWrapper &&fileName) override; diff --git a/src/blockfile/SilentBlockFile.cpp b/src/blockfile/SilentBlockFile.cpp index a25a79ac4..59323d424 100644 --- a/src/blockfile/SilentBlockFile.cpp +++ b/src/blockfile/SilentBlockFile.cpp @@ -12,7 +12,7 @@ #include "SilentBlockFile.h" #include "../FileFormats.h" -SilentBlockFile::SilentBlockFile(sampleCount sampleLen): +SilentBlockFile::SilentBlockFile(size_t sampleLen): BlockFile{ wxFileNameWrapper{}, sampleLen } { mMin = 0.; @@ -30,8 +30,8 @@ bool SilentBlockFile::ReadSummary(void *data) return true; } -int SilentBlockFile::ReadData(samplePtr data, sampleFormat format, - sampleCount WXUNUSED(start), sampleCount len) const +size_t SilentBlockFile::ReadData(samplePtr data, sampleFormat format, + size_t WXUNUSED(start), size_t len) const { ClearSamples(data, format, 0, len); @@ -54,7 +54,7 @@ void SilentBlockFile::SaveXML(XMLWriter &xmlFile) BlockFilePtr SilentBlockFile::BuildFromXML(DirManager & WXUNUSED(dm), const wxChar **attrs) { long nValue; - sampleCount len = 0; + size_t len = 0; while(*attrs) { diff --git a/src/blockfile/SilentBlockFile.h b/src/blockfile/SilentBlockFile.h index b06a70547..24b6452dd 100644 --- a/src/blockfile/SilentBlockFile.h +++ b/src/blockfile/SilentBlockFile.h @@ -26,7 +26,7 @@ class SilentBlockFile final : public BlockFile { // Constructor / Destructor - SilentBlockFile(sampleCount sampleLen); + SilentBlockFile(size_t sampleLen); virtual ~SilentBlockFile(); @@ -35,8 +35,8 @@ class SilentBlockFile final : public BlockFile { /// Read the summary section of the disk file bool ReadSummary(void *data) override; /// Read the data section of the disk file - int ReadData(samplePtr data, sampleFormat format, - sampleCount start, sampleCount len) const override; + size_t ReadData(samplePtr data, sampleFormat format, + size_t start, size_t len) const override; /// Create a NEW block file identical to this one BlockFilePtr Copy(wxFileNameWrapper &&newFileName) override; diff --git a/src/blockfile/SimpleBlockFile.cpp b/src/blockfile/SimpleBlockFile.cpp index 894c71959..4e008875e 100644 --- a/src/blockfile/SimpleBlockFile.cpp +++ b/src/blockfile/SimpleBlockFile.cpp @@ -96,7 +96,7 @@ static wxUint32 SwapUintEndianess(wxUint32 in) /// @param format The format of the given samples. /// @param allowDeferredWrite Allow deferred write-caching SimpleBlockFile::SimpleBlockFile(wxFileNameWrapper &&baseFileName, - samplePtr sampleData, sampleCount sampleLen, + samplePtr sampleData, size_t sampleLen, sampleFormat format, bool allowDeferredWrite /* = false */, bool bypassCache /* = false */): @@ -139,7 +139,7 @@ SimpleBlockFile::SimpleBlockFile(wxFileNameWrapper &&baseFileName, /// existing block file. This file must exist and be a valid block file. /// /// @param existingFile The disk file this SimpleBlockFile should use. -SimpleBlockFile::SimpleBlockFile(wxFileNameWrapper &&existingFile, sampleCount len, +SimpleBlockFile::SimpleBlockFile(wxFileNameWrapper &&existingFile, size_t len, float min, float max, float rms): BlockFile{ std::move(existingFile), len } { @@ -164,7 +164,7 @@ SimpleBlockFile::~SimpleBlockFile() bool SimpleBlockFile::WriteSimpleBlockFile( samplePtr sampleData, - sampleCount sampleLen, + size_t sampleLen, sampleFormat format, void* summaryData) { @@ -388,8 +388,8 @@ bool SimpleBlockFile::ReadSummary(void *data) /// @param format The format the data will be stored in /// @param start The offset in this block file /// @param len The number of samples to read -int SimpleBlockFile::ReadData(samplePtr data, sampleFormat format, - sampleCount start, sampleCount len) const +size_t SimpleBlockFile::ReadData(samplePtr data, sampleFormat format, + size_t start, size_t len) const { if (mCache.active) { @@ -439,7 +439,7 @@ int SimpleBlockFile::ReadData(samplePtr data, sampleFormat format, SFCall(sf_seek, sf.get(), start, SEEK_SET); SampleBuffer buffer(len, floatSample); - int framesRead = 0; + size_t framesRead = 0; // If both the src and dest formats are integer formats, // read integers from the file (otherwise we would be @@ -495,7 +495,7 @@ BlockFilePtr SimpleBlockFile::BuildFromXML(DirManager &dm, const wxChar **attrs) { wxFileNameWrapper fileName; float min = 0.0f, max = 0.0f, rms = 0.0f; - sampleCount len = 0; + size_t len = 0; double dblValue; long nValue; @@ -597,11 +597,11 @@ auto SimpleBlockFile::GetSpaceUsage() const -> DiskByteCount file.Close(); } - return + return { sizeof(auHeader) + mSummaryInfo.totalSummaryBytes + (GetLength() * SAMPLE_SIZE_DISK(mFormat)) - ; + }; } void SimpleBlockFile::Recover(){ diff --git a/src/blockfile/SimpleBlockFile.h b/src/blockfile/SimpleBlockFile.h index d4f34ffe9..05b8c9b0a 100644 --- a/src/blockfile/SimpleBlockFile.h +++ b/src/blockfile/SimpleBlockFile.h @@ -49,12 +49,12 @@ class PROFILE_DLL_API SimpleBlockFile /* not final */ : public BlockFile { /// Create a disk file and write summary and sample data to it SimpleBlockFile(wxFileNameWrapper &&baseFileName, - samplePtr sampleData, sampleCount sampleLen, + samplePtr sampleData, size_t sampleLen, sampleFormat format, bool allowDeferredWrite = false, bool bypassCache = false ); /// Create the memory structure to refer to the given block file - SimpleBlockFile(wxFileNameWrapper &&existingFile, sampleCount len, + SimpleBlockFile(wxFileNameWrapper &&existingFile, size_t len, float min, float max, float rms); virtual ~SimpleBlockFile(); @@ -64,8 +64,8 @@ class PROFILE_DLL_API SimpleBlockFile /* not final */ : public BlockFile { /// Read the summary section of the disk file bool ReadSummary(void *data) override; /// Read the data section of the disk file - int ReadData(samplePtr data, sampleFormat format, - sampleCount start, sampleCount len) const override; + size_t ReadData(samplePtr data, sampleFormat format, + size_t start, size_t len) const override; /// Create a NEW block file identical to this one BlockFilePtr Copy(wxFileNameWrapper &&newFileName) override; @@ -85,7 +85,7 @@ class PROFILE_DLL_API SimpleBlockFile /* not final */ : public BlockFile { protected: - bool WriteSimpleBlockFile(samplePtr sampleData, sampleCount sampleLen, + bool WriteSimpleBlockFile(samplePtr sampleData, size_t sampleLen, sampleFormat format, void* summaryData); static bool GetCache(); void ReadIntoCache(); diff --git a/src/effects/Amplify.cpp b/src/effects/Amplify.cpp index 60e8459ec..3f4f2e52e 100644 --- a/src/effects/Amplify.cpp +++ b/src/effects/Amplify.cpp @@ -109,7 +109,7 @@ unsigned EffectAmplify::GetAudioOutCount() return 1; } -sampleCount EffectAmplify::ProcessBlock(float **inBlock, float **outBlock, sampleCount blockLen) +size_t EffectAmplify::ProcessBlock(float **inBlock, float **outBlock, size_t blockLen) { for (decltype(blockLen) i = 0; i < blockLen; i++) { diff --git a/src/effects/Amplify.h b/src/effects/Amplify.h index 83e332724..aa36513ae 100644 --- a/src/effects/Amplify.h +++ b/src/effects/Amplify.h @@ -46,7 +46,7 @@ public: unsigned GetAudioInCount() override; unsigned GetAudioOutCount() override; - sampleCount ProcessBlock(float **inBlock, float **outBlock, sampleCount blockLen) override; + size_t ProcessBlock(float **inBlock, float **outBlock, size_t blockLen) override; bool GetAutomationParameters(EffectAutomationParameters & parms) override; bool SetAutomationParameters(EffectAutomationParameters & parms) override; bool LoadFactoryDefaults() override; diff --git a/src/effects/BassTreble.cpp b/src/effects/BassTreble.cpp index b65b3eff2..e4af3da5f 100644 --- a/src/effects/BassTreble.cpp +++ b/src/effects/BassTreble.cpp @@ -128,7 +128,7 @@ bool EffectBassTreble::ProcessInitialize(sampleCount WXUNUSED(totalLen), Channel return true; } -sampleCount EffectBassTreble::ProcessBlock(float **inBlock, float **outBlock, sampleCount blockLen) +size_t EffectBassTreble::ProcessBlock(float **inBlock, float **outBlock, size_t blockLen) { return InstanceProcess(mMaster, inBlock, outBlock, blockLen); } @@ -160,10 +160,10 @@ bool EffectBassTreble::RealtimeFinalize() return true; } -sampleCount EffectBassTreble::RealtimeProcess(int group, +size_t EffectBassTreble::RealtimeProcess(int group, float **inbuf, float **outbuf, - sampleCount numSamples) + size_t numSamples) { return InstanceProcess(mSlaves[group], inbuf, outbuf, numSamples); } @@ -335,10 +335,10 @@ void EffectBassTreble::InstanceInit(EffectBassTrebleState & data, float sampleRa // EffectClientInterface implementation -sampleCount EffectBassTreble::InstanceProcess(EffectBassTrebleState & data, +size_t EffectBassTreble::InstanceProcess(EffectBassTrebleState & data, float **inBlock, float **outBlock, - sampleCount blockLen) + size_t blockLen) { float *ibuf = inBlock[0]; float *obuf = outBlock[0]; diff --git a/src/effects/BassTreble.h b/src/effects/BassTreble.h index a6958c19a..7bf3dc67f 100644 --- a/src/effects/BassTreble.h +++ b/src/effects/BassTreble.h @@ -62,14 +62,14 @@ public: unsigned GetAudioInCount() override; unsigned GetAudioOutCount() override; bool ProcessInitialize(sampleCount totalLen, ChannelNames chanMap = NULL) override; - sampleCount ProcessBlock(float **inBlock, float **outBlock, sampleCount blockLen) override; + size_t ProcessBlock(float **inBlock, float **outBlock, size_t blockLen) override; bool RealtimeInitialize() override; bool RealtimeAddProcessor(unsigned numChannels, float sampleRate) override; bool RealtimeFinalize() override; - sampleCount RealtimeProcess(int group, + size_t RealtimeProcess(int group, float **inbuf, float **outbuf, - sampleCount numSamples) override; + size_t numSamples) override; bool GetAutomationParameters(EffectAutomationParameters & parms) override; bool SetAutomationParameters(EffectAutomationParameters & parms) override; @@ -86,7 +86,7 @@ private: // EffectBassTreble implementation void InstanceInit(EffectBassTrebleState & data, float sampleRate); - sampleCount InstanceProcess(EffectBassTrebleState & data, float **inBlock, float **outBlock, sampleCount blockLen); + size_t InstanceProcess(EffectBassTrebleState & data, float **inBlock, float **outBlock, size_t blockLen); void Coefficents(double hz, double slope, double gain, double samplerate, int type, double& a0, double& a1, double& a2, double& b0, double& b1, double& b2); diff --git a/src/effects/ChangeSpeed.cpp b/src/effects/ChangeSpeed.cpp index 54a50f143..02d9ca5d9 100644 --- a/src/effects/ChangeSpeed.cpp +++ b/src/effects/ChangeSpeed.cpp @@ -488,8 +488,7 @@ bool EffectChangeSpeed::ProcessOne(WaveTrack * track, float * inBuffer = new float[inBufferSize]; // mFactor is at most 100-fold so this shouldn't overflow size_t - auto outBufferSize = - (sampleCount)((mFactor * inBufferSize) + 10); + auto outBufferSize = size_t( mFactor * inBufferSize + 10 ); float * outBuffer = new float[outBufferSize]; // Set up the resampling stuff for this track. diff --git a/src/effects/ClickRemoval.cpp b/src/effects/ClickRemoval.cpp index c61cf540a..3baa65615 100644 --- a/src/effects/ClickRemoval.cpp +++ b/src/effects/ClickRemoval.cpp @@ -255,7 +255,7 @@ bool EffectClickRemoval::ProcessOne(int count, WaveTrack * track, sampleCount st return bResult; } -bool EffectClickRemoval::RemoveClicks(sampleCount len, float *buffer) +bool EffectClickRemoval::RemoveClicks(int len, float *buffer) { bool bResult = false; // This effect usually does nothing. int i; diff --git a/src/effects/ClickRemoval.h b/src/effects/ClickRemoval.h index 5f3b4b2fd..c9a2f78f6 100644 --- a/src/effects/ClickRemoval.h +++ b/src/effects/ClickRemoval.h @@ -61,7 +61,7 @@ private: bool ProcessOne(int count, WaveTrack * track, sampleCount start, sampleCount len); - bool RemoveClicks(sampleCount len, float *buffer); + bool RemoveClicks(int len, float *buffer); void OnWidthText(wxCommandEvent & evt); void OnThreshText(wxCommandEvent & evt); diff --git a/src/effects/Compressor.cpp b/src/effects/Compressor.cpp index 1250e72aa..bc85fef40 100644 --- a/src/effects/Compressor.cpp +++ b/src/effects/Compressor.cpp @@ -370,7 +370,7 @@ bool EffectCompressor::InitPass1() SelectedTrackListOfKindIterator iter(Track::Wave, mTracks); WaveTrack *track = (WaveTrack *) iter.First(); while (track) { - maxlen = std::max(maxlen, track->GetMaxBlockSize()); + maxlen = std::max(maxlen, track->GetMaxBlockSize()); //Iterate to the next track track = (WaveTrack *) iter.Next(); } @@ -402,7 +402,8 @@ bool EffectCompressor::InitPass2() // Process the input with 2 buffers available at a time // buffer1 will be written upon return // buffer2 will be passed as buffer1 on the next call -bool EffectCompressor::TwoBufferProcessPass1(float *buffer1, sampleCount len1, float *buffer2, sampleCount len2) +bool EffectCompressor::TwoBufferProcessPass1 + (float *buffer1, size_t len1, float *buffer2, size_t len2) { int i; @@ -448,7 +449,7 @@ bool EffectCompressor::TwoBufferProcessPass1(float *buffer1, sampleCount len1, f return true; } -bool EffectCompressor::ProcessPass2(float *buffer, sampleCount len) +bool EffectCompressor::ProcessPass2(float *buffer, size_t len) { if (mMax != 0) { @@ -483,7 +484,7 @@ float EffectCompressor::AvgCircle(float value) return level; } -void EffectCompressor::Follow(float *buffer, float *env, int len, float *previous, int previous_len) +void EffectCompressor::Follow(float *buffer, float *env, size_t len, float *previous, size_t previous_len) { /* @@ -553,7 +554,7 @@ void EffectCompressor::Follow(float *buffer, float *env, int len, float *previou // Next do the same process in reverse direction to get the requested attack rate last = mLastLevel; - for(i=len-1; i>=0; i--) { + for(i = len; i--;) { last *= mAttackInverseFactor; if(last < mThreshold) last = mThreshold; @@ -565,7 +566,7 @@ void EffectCompressor::Follow(float *buffer, float *env, int len, float *previou if((previous != NULL) && (previous_len > 0)) { // If the previous envelope was passed, propagate the rise back until we intersect - for(i=previous_len-1; i>0; i--) { + for(i = previous_len; i--;) { last *= mAttackInverseFactor; if(last < mThreshold) last = mThreshold; diff --git a/src/effects/Compressor.h b/src/effects/Compressor.h index ca931b059..1f95a67d2 100644 --- a/src/effects/Compressor.h +++ b/src/effects/Compressor.h @@ -62,15 +62,16 @@ protected: bool InitPass1() override; bool InitPass2() override; bool NewTrackPass1() override; - bool ProcessPass2(float *buffer, sampleCount len) override; - bool TwoBufferProcessPass1(float *buffer1, sampleCount len1, float *buffer2, sampleCount len2) override; + bool ProcessPass2(float *buffer, size_t len) override; + bool TwoBufferProcessPass1 + (float *buffer1, size_t len1, float *buffer2, size_t len2) override; private: // EffectCompressor implementation void FreshenCircle(); float AvgCircle(float x); - void Follow(float *buffer, float *env, int len, float *previous, int previous_len); + void Follow(float *buffer, float *env, size_t len, float *previous, size_t previous_len); float DoCompression(float x, double env); void OnSlider(wxCommandEvent & evt); @@ -101,7 +102,7 @@ private: double mLastLevel; float *mFollow1; float *mFollow2; - sampleCount mFollowLen; + size_t mFollowLen; double mMax; //MJS diff --git a/src/effects/Distortion.cpp b/src/effects/Distortion.cpp index 03bf49cff..1452b0365 100644 --- a/src/effects/Distortion.cpp +++ b/src/effects/Distortion.cpp @@ -224,7 +224,7 @@ bool EffectDistortion::ProcessInitialize(sampleCount WXUNUSED(totalLen), Channel return true; } -sampleCount EffectDistortion::ProcessBlock(float **inBlock, float **outBlock, sampleCount blockLen) +size_t EffectDistortion::ProcessBlock(float **inBlock, float **outBlock, size_t blockLen) { return InstanceProcess(mMaster, inBlock, outBlock, blockLen); } @@ -256,10 +256,10 @@ bool EffectDistortion::RealtimeFinalize() return true; } -sampleCount EffectDistortion::RealtimeProcess(int group, +size_t EffectDistortion::RealtimeProcess(int group, float **inbuf, float **outbuf, - sampleCount numSamples) + size_t numSamples) { return InstanceProcess(mSlaves[group], inbuf, outbuf, numSamples); @@ -503,7 +503,7 @@ void EffectDistortion::InstanceInit(EffectDistortionState & data, float sampleRa return; } -sampleCount EffectDistortion::InstanceProcess(EffectDistortionState& data, float** inBlock, float** outBlock, sampleCount blockLen) +size_t EffectDistortion::InstanceProcess(EffectDistortionState& data, float** inBlock, float** outBlock, size_t blockLen) { float *ibuf = inBlock[0]; float *obuf = outBlock[0]; diff --git a/src/effects/Distortion.h b/src/effects/Distortion.h index a218b4199..bce4877aa 100644 --- a/src/effects/Distortion.h +++ b/src/effects/Distortion.h @@ -79,14 +79,14 @@ public: unsigned GetAudioInCount() override; unsigned GetAudioOutCount() override; bool ProcessInitialize(sampleCount totalLen, ChannelNames chanMap = NULL) override; - sampleCount ProcessBlock(float **inBlock, float **outBlock, sampleCount blockLen) override; + size_t ProcessBlock(float **inBlock, float **outBlock, size_t blockLen) override; bool RealtimeInitialize() override; bool RealtimeAddProcessor(unsigned numChannels, float sampleRate) override; bool RealtimeFinalize() override; - sampleCount RealtimeProcess(int group, + size_t RealtimeProcess(int group, float **inbuf, float **outbuf, - sampleCount numSamples) override; + size_t numSamples) override; bool GetAutomationParameters(EffectAutomationParameters & parms) override; bool SetAutomationParameters(EffectAutomationParameters & parms) override; wxArrayString GetFactoryPresets() override; @@ -113,10 +113,10 @@ private: // EffectDistortion implementation void InstanceInit(EffectDistortionState & data, float sampleRate); - sampleCount InstanceProcess(EffectDistortionState & data, + size_t InstanceProcess(EffectDistortionState & data, float **inBlock, float **outBlock, - sampleCount blockLen); + size_t blockLen); // Control Handlers diff --git a/src/effects/DtmfGen.cpp b/src/effects/DtmfGen.cpp index eaed64aa1..9d86dab7f 100644 --- a/src/effects/DtmfGen.cpp +++ b/src/effects/DtmfGen.cpp @@ -150,7 +150,7 @@ bool EffectDtmf::ProcessInitialize(sampleCount WXUNUSED(totalLen), ChannelNames return true; } -sampleCount EffectDtmf::ProcessBlock(float **WXUNUSED(inbuf), float **outbuf, sampleCount size) +size_t EffectDtmf::ProcessBlock(float **WXUNUSED(inbuf), float **outbuf, size_t size) { float *buffer = outbuf[0]; decltype(size) processed = 0; @@ -429,7 +429,7 @@ void EffectDtmf::Recalculate() } } -bool EffectDtmf::MakeDtmfTone(float *buffer, sampleCount len, float fs, wxChar tone, sampleCount last, sampleCount total, float amplitude) +bool EffectDtmf::MakeDtmfTone(float *buffer, size_t len, float fs, wxChar tone, sampleCount last, sampleCount total, float amplitude) { /* -------------------------------------------- @@ -546,7 +546,7 @@ bool EffectDtmf::MakeDtmfTone(float *buffer, sampleCount len, float fs, wxChar t // we are at the last buffer of 'len' size, so, offset is to // backup 'A' samples, from 'len' A = (fs / kFadeInOut); - auto offset = len - decltype(len)(fs / kFadeInOut); + auto offset = long(len) - long(fs / kFadeInOut); // protect against negative offset, which can occur if too a // small selection is made if (offset >= 0) { diff --git a/src/effects/DtmfGen.h b/src/effects/DtmfGen.h index 2c912c08c..1b93cffae 100644 --- a/src/effects/DtmfGen.h +++ b/src/effects/DtmfGen.h @@ -46,7 +46,7 @@ public: unsigned GetAudioOutCount() override; bool ProcessInitialize(sampleCount totalLen, ChannelNames chanMap = NULL) override; - sampleCount ProcessBlock(float **inBlock, float **outBlock, sampleCount blockLen) override; + size_t ProcessBlock(float **inBlock, float **outBlock, size_t blockLen) override; bool GetAutomationParameters(EffectAutomationParameters & parms) override; bool SetAutomationParameters(EffectAutomationParameters & parms) override; @@ -61,7 +61,7 @@ public: private: // EffectDtmf implementation - bool MakeDtmfTone(float *buffer, sampleCount len, float fs, + bool MakeDtmfTone(float *buffer, size_t len, float fs, wxChar tone, sampleCount last, sampleCount total, float amplitude); void Recalculate(); diff --git a/src/effects/Echo.cpp b/src/effects/Echo.cpp index 4993b7bc3..87f6c45ef 100644 --- a/src/effects/Echo.cpp +++ b/src/effects/Echo.cpp @@ -114,7 +114,7 @@ bool EffectEcho::ProcessFinalize() return true; } -sampleCount EffectEcho::ProcessBlock(float **inBlock, float **outBlock, sampleCount blockLen) +size_t EffectEcho::ProcessBlock(float **inBlock, float **outBlock, size_t blockLen) { float *ibuf = inBlock[0]; float *obuf = outBlock[0]; diff --git a/src/effects/Echo.h b/src/effects/Echo.h index 0a700c2f5..a74b17a47 100644 --- a/src/effects/Echo.h +++ b/src/effects/Echo.h @@ -43,7 +43,7 @@ public: unsigned GetAudioOutCount() override; bool ProcessInitialize(sampleCount totalLen, ChannelNames chanMap = NULL) override; bool ProcessFinalize() override; - sampleCount ProcessBlock(float **inBlock, float **outBlock, sampleCount blockLen) override; + size_t ProcessBlock(float **inBlock, float **outBlock, size_t blockLen) override; bool GetAutomationParameters(EffectAutomationParameters & parms) override; bool SetAutomationParameters(EffectAutomationParameters & parms) override; @@ -59,8 +59,8 @@ private: double delay; double decay; float *history; - sampleCount histPos; - sampleCount histLen; + size_t histPos; + size_t histLen; }; #endif // __AUDACITY_EFFECT_ECHO__ diff --git a/src/effects/Effect.cpp b/src/effects/Effect.cpp index 50191a945..b0a097d66 100644 --- a/src/effects/Effect.cpp +++ b/src/effects/Effect.cpp @@ -335,7 +335,7 @@ void Effect::SetSampleRate(double rate) mSampleRate = rate; } -sampleCount Effect::SetBlockSize(sampleCount maxBlockSize) +size_t Effect::SetBlockSize(size_t maxBlockSize) { if (mClient) { @@ -357,7 +357,7 @@ sampleCount Effect::GetLatency() return 0; } -sampleCount Effect::GetTailSize() +size_t Effect::GetTailSize() { if (mClient) { @@ -397,7 +397,7 @@ bool Effect::ProcessFinalize() return true; } -sampleCount Effect::ProcessBlock(float **inBlock, float **outBlock, sampleCount blockLen) +size_t Effect::ProcessBlock(float **inBlock, float **outBlock, size_t blockLen) { if (mClient) { @@ -494,10 +494,10 @@ bool Effect::RealtimeProcessStart() return true; } -sampleCount Effect::RealtimeProcess(int group, +size_t Effect::RealtimeProcess(int group, float **inbuf, float **outbuf, - sampleCount numSamples) + size_t numSamples) { if (mClient) { @@ -2355,11 +2355,11 @@ bool Effect::RealtimeAddProcessor(int group, unsigned chans, float rate) // RealtimeAddProcessor and RealtimeProcess use the same method of // determining the current processor group, so updates to one should // be reflected in the other. -sampleCount Effect::RealtimeProcess(int group, +size_t Effect::RealtimeProcess(int group, unsigned chans, float **inbuf, float **outbuf, - sampleCount numSamples) + size_t numSamples) { // // The caller passes the number of channels to process and specifies diff --git a/src/effects/Effect.h b/src/effects/Effect.h index b523bdb5d..f0e667d00 100644 --- a/src/effects/Effect.h +++ b/src/effects/Effect.h @@ -104,15 +104,15 @@ class AUDACITY_DLL_API Effect /* not final */ : public wxEvtHandler, int GetMidiOutCount() override; sampleCount GetLatency() override; - sampleCount GetTailSize() override; + size_t GetTailSize() override; void SetSampleRate(double rate) override; - sampleCount SetBlockSize(sampleCount maxBlockSize) override; + size_t SetBlockSize(size_t maxBlockSize) override; bool IsReady() override; bool ProcessInitialize(sampleCount totalLen, ChannelNames chanMap = NULL) override; bool ProcessFinalize() override; - sampleCount ProcessBlock(float **inBlock, float **outBlock, sampleCount blockLen) override; + size_t ProcessBlock(float **inBlock, float **outBlock, size_t blockLen) override; bool RealtimeInitialize() override; bool RealtimeAddProcessor(unsigned numChannels, float sampleRate) override; @@ -120,10 +120,10 @@ class AUDACITY_DLL_API Effect /* not final */ : public wxEvtHandler, bool RealtimeSuspend() override; bool RealtimeResume() override; bool RealtimeProcessStart() override; - sampleCount RealtimeProcess(int group, + size_t RealtimeProcess(int group, float **inbuf, float **outbuf, - sampleCount numSamples) override; + size_t numSamples) override; bool RealtimeProcessEnd() override; bool ShowInterface(wxWindow *parent, bool forceModal = false) override; @@ -243,11 +243,11 @@ class AUDACITY_DLL_API Effect /* not final */ : public wxEvtHandler, // Realtime Effect Processing /* not virtual */ bool RealtimeAddProcessor(int group, unsigned chans, float rate); - /* not virtual */ sampleCount RealtimeProcess(int group, + /* not virtual */ size_t RealtimeProcess(int group, unsigned chans, float **inbuf, float **outbuf, - sampleCount numSamples); + size_t numSamples); /* not virtual */ bool IsRealtimeActive(); virtual bool IsHidden(); @@ -510,8 +510,8 @@ private: float **mInBufPos; float **mOutBufPos; - sampleCount mBufferSize; - sampleCount mBlockSize; + size_t mBufferSize; + size_t mBlockSize; unsigned mNumChannels; wxArrayInt mGroupProcessor; diff --git a/src/effects/EffectManager.cpp b/src/effects/EffectManager.cpp index 787938b43..e6cc9f08d 100644 --- a/src/effects/EffectManager.cpp +++ b/src/effects/EffectManager.cpp @@ -587,7 +587,7 @@ void EffectManager::RealtimeProcessStart() // // This will be called in a different thread than the main GUI thread. // -sampleCount EffectManager::RealtimeProcess(int group, unsigned chans, float **buffers, sampleCount numSamples) +size_t EffectManager::RealtimeProcess(int group, unsigned chans, float **buffers, size_t numSamples) { // Protect ourselves from the main thread mRealtimeLock.Enter(); diff --git a/src/effects/EffectManager.h b/src/effects/EffectManager.h index 841c04caf..e093c77c1 100644 --- a/src/effects/EffectManager.h +++ b/src/effects/EffectManager.h @@ -108,7 +108,7 @@ public: void RealtimeSuspend(); void RealtimeResume(); void RealtimeProcessStart(); - sampleCount RealtimeProcess(int group, unsigned chans, float **buffers, sampleCount numSamples); + size_t RealtimeProcess(int group, unsigned chans, float **buffers, size_t numSamples); void RealtimeProcessEnd(); int GetRealtimeLatency(); diff --git a/src/effects/Equalization48x.h b/src/effects/Equalization48x.h index 1ea956e7d..37ae9139c 100644 --- a/src/effects/Equalization48x.h +++ b/src/effects/Equalization48x.h @@ -45,8 +45,8 @@ public: float* mBufferSouce[__MAXBUFFERCOUNT]; float* mBufferDest[__MAXBUFFERCOUNT]; int mBufferLength; - sampleCount mFftWindowSize; - sampleCount mFftFilterSize; + size_t mFftWindowSize; + size_t mFftFilterSize; float* mScratchBuffer; int mContiguousBufferSize; EQBufferStatus mBufferStatus; diff --git a/src/effects/Fade.cpp b/src/effects/Fade.cpp index 03affe152..6f5d6c1e0 100644 --- a/src/effects/Fade.cpp +++ b/src/effects/Fade.cpp @@ -75,7 +75,7 @@ bool EffectFade::ProcessInitialize(sampleCount WXUNUSED(totalLen), ChannelNames return true; } -sampleCount EffectFade::ProcessBlock(float **inBlock, float **outBlock, sampleCount blockLen) +size_t EffectFade::ProcessBlock(float **inBlock, float **outBlock, size_t blockLen) { float *ibuf = inBlock[0]; float *obuf = outBlock[0]; diff --git a/src/effects/Fade.h b/src/effects/Fade.h index 457c3d698..cdede1678 100644 --- a/src/effects/Fade.h +++ b/src/effects/Fade.h @@ -39,7 +39,7 @@ public: unsigned GetAudioInCount() override; unsigned GetAudioOutCount() override; bool ProcessInitialize(sampleCount totalLen, ChannelNames chanMap = NULL) override; - sampleCount ProcessBlock(float **inBlock, float **outBlock, sampleCount blockLen) override; + size_t ProcessBlock(float **inBlock, float **outBlock, size_t blockLen) override; private: // EffectFadeIn implementation diff --git a/src/effects/FindClipping.cpp b/src/effects/FindClipping.cpp index 90d1d991c..577cecca0 100644 --- a/src/effects/FindClipping.cpp +++ b/src/effects/FindClipping.cpp @@ -153,7 +153,7 @@ bool EffectFindClipping::ProcessOne(LabelTrack * lt, sampleCount len) { bool bGoodResult = true; - auto blockSize = (sampleCount) (mStart * 1000); + size_t blockSize = (mStart * 1000); if (len < mStart) { return true; diff --git a/src/effects/Generator.h b/src/effects/Generator.h index 80ffc12be..f26034b18 100644 --- a/src/effects/Generator.h +++ b/src/effects/Generator.h @@ -66,7 +66,7 @@ protected: // Postcondition: data[0..block) filled with generated samples virtual void GenerateBlock(float *data, const WaveTrack &track, - sampleCount block) = 0; + size_t block) = 0; // Generate the track, one block at a time, & adding the results to tmp bool GenerateTrack(WaveTrack *tmp, const WaveTrack &track, int ntrack) override; diff --git a/src/effects/Invert.cpp b/src/effects/Invert.cpp index c46ba9b42..a283d0b3b 100644 --- a/src/effects/Invert.cpp +++ b/src/effects/Invert.cpp @@ -64,7 +64,7 @@ unsigned EffectInvert::GetAudioOutCount() return 1; } -sampleCount EffectInvert::ProcessBlock(float **inBlock, float **outBlock, sampleCount blockLen) +size_t EffectInvert::ProcessBlock(float **inBlock, float **outBlock, size_t blockLen) { float *ibuf = inBlock[0]; float *obuf = outBlock[0]; diff --git a/src/effects/Invert.h b/src/effects/Invert.h index ec673bf1e..6f7edefd4 100644 --- a/src/effects/Invert.h +++ b/src/effects/Invert.h @@ -39,7 +39,7 @@ public: unsigned GetAudioInCount() override; unsigned GetAudioOutCount() override; - sampleCount ProcessBlock(float **inBlock, float **outBlock, sampleCount blockLen) override; + size_t ProcessBlock(float **inBlock, float **outBlock, size_t blockLen) override; }; #endif diff --git a/src/effects/Leveller.cpp b/src/effects/Leveller.cpp index a3642d3ca..839d640e1 100644 --- a/src/effects/Leveller.cpp +++ b/src/effects/Leveller.cpp @@ -102,7 +102,7 @@ unsigned EffectLeveller::GetAudioOutCount() return 1; } -sampleCount EffectLeveller::ProcessBlock(float **inBlock, float **outBlock, sampleCount blockLen) +size_t EffectLeveller::ProcessBlock(float **inBlock, float **outBlock, size_t blockLen) { float *ibuf = inBlock[0]; float *obuf = outBlock[0]; diff --git a/src/effects/Leveller.h b/src/effects/Leveller.h index dcb04bf35..5e87c24fa 100644 --- a/src/effects/Leveller.h +++ b/src/effects/Leveller.h @@ -39,7 +39,7 @@ public: unsigned GetAudioInCount() override; unsigned GetAudioOutCount() override; - sampleCount ProcessBlock(float **inBlock, float **outBlock, sampleCount blockLen) override; + size_t ProcessBlock(float **inBlock, float **outBlock, size_t blockLen) override; bool GetAutomationParameters(EffectAutomationParameters & parms) override; bool SetAutomationParameters(EffectAutomationParameters & parms) override; diff --git a/src/effects/Noise.cpp b/src/effects/Noise.cpp index 85f350a39..790779a46 100644 --- a/src/effects/Noise.cpp +++ b/src/effects/Noise.cpp @@ -92,7 +92,7 @@ unsigned EffectNoise::GetAudioOutCount() return 1; } -sampleCount EffectNoise::ProcessBlock(float **WXUNUSED(inbuf), float **outbuf, sampleCount size) +size_t EffectNoise::ProcessBlock(float **WXUNUSED(inbuf), float **outbuf, size_t size) { float *buffer = outbuf[0]; diff --git a/src/effects/Noise.h b/src/effects/Noise.h index dc458c248..a4045a3d0 100644 --- a/src/effects/Noise.h +++ b/src/effects/Noise.h @@ -41,7 +41,7 @@ public: // EffectClientInterface implementation unsigned GetAudioOutCount() override; - sampleCount ProcessBlock(float **inBlock, float **outBlock, sampleCount blockLen) override; + size_t ProcessBlock(float **inBlock, float **outBlock, size_t blockLen) override; bool GetAutomationParameters(EffectAutomationParameters & parms) override; bool SetAutomationParameters(EffectAutomationParameters & parms) override; diff --git a/src/effects/NoiseReduction.cpp b/src/effects/NoiseReduction.cpp index 61b8a5db7..9e4ad907e 100644 --- a/src/effects/NoiseReduction.cpp +++ b/src/effects/NoiseReduction.cpp @@ -270,7 +270,7 @@ private: void StartNewTrack(); void ProcessSamples(Statistics &statistics, - WaveTrack *outputTrack, sampleCount len, float *buffer); + WaveTrack *outputTrack, size_t len, float *buffer); void FillFirstHistoryWindow(); void ApplyFreqSmoothing(FloatVector &gains); void GatherStatistics(Statistics &statistics); @@ -911,10 +911,10 @@ void EffectNoiseReduction::Worker::StartNewTrack() void EffectNoiseReduction::Worker::ProcessSamples (Statistics &statistics, WaveTrack *outputTrack, - sampleCount len, float *buffer) + size_t len, float *buffer) { while (len && mOutStepCount * mStepSize < mInSampleCount) { - auto avail = std::min(len, sampleCount(mWindowSize - mInWavePos)); + auto avail = std::min(len, mWindowSize - mInWavePos); memmove(&mInWaveBuffer[mInWavePos], buffer, avail * sizeof(float)); buffer += avail; len -= avail; diff --git a/src/effects/NoiseRemoval.cpp b/src/effects/NoiseRemoval.cpp index 86324d768..1536acbf2 100644 --- a/src/effects/NoiseRemoval.cpp +++ b/src/effects/NoiseRemoval.cpp @@ -366,7 +366,7 @@ void EffectNoiseRemoval::StartNewTrack() mOutSampleCount = -(int)((mWindowSize / 2) * (mHistoryLen - 1)); } -void EffectNoiseRemoval::ProcessSamples(sampleCount len, float *buffer) +void EffectNoiseRemoval::ProcessSamples(size_t len, float *buffer) { int i; diff --git a/src/effects/NoiseRemoval.h b/src/effects/NoiseRemoval.h index 62a9bc4cf..ba01f8139 100644 --- a/src/effects/NoiseRemoval.h +++ b/src/effects/NoiseRemoval.h @@ -90,7 +90,7 @@ private: void Initialize(); void StartNewTrack(); - void ProcessSamples(sampleCount len, float *buffer); + void ProcessSamples(size_t len, float *buffer); void FillFirstHistoryWindow(); void ApplyFreqSmoothing(float *spec); void GetProfile(); diff --git a/src/effects/Normalize.cpp b/src/effects/Normalize.cpp index c2960887e..6837a6340 100644 --- a/src/effects/Normalize.cpp +++ b/src/effects/Normalize.cpp @@ -480,14 +480,14 @@ bool EffectNormalize::ProcessOne(WaveTrack * track, const wxString &msg) return rc; } -void EffectNormalize::AnalyzeData(float *buffer, sampleCount len) +void EffectNormalize::AnalyzeData(float *buffer, size_t len) { for(decltype(len) i = 0; i < len; i++) mSum += (double)buffer[i]; mCount += len; } -void EffectNormalize::ProcessData(float *buffer, sampleCount len) +void EffectNormalize::ProcessData(float *buffer, size_t len) { for(decltype(len) i = 0; i < len; i++) { float adjFrame = (buffer[i] + mOffset) * mMult; diff --git a/src/effects/Normalize.h b/src/effects/Normalize.h index d01226857..8096b7841 100644 --- a/src/effects/Normalize.h +++ b/src/effects/Normalize.h @@ -58,9 +58,9 @@ private: bool ProcessOne(WaveTrack * t, const wxString &msg); void AnalyseTrack(WaveTrack * track, const wxString &msg); - void AnalyzeData(float *buffer, sampleCount len); + void AnalyzeData(float *buffer, size_t len); bool AnalyseDC(WaveTrack * track, const wxString &msg); - void ProcessData(float *buffer, sampleCount len); + void ProcessData(float *buffer, size_t len); void OnUpdateUI(wxCommandEvent & evt); void UpdateUI(); diff --git a/src/effects/Phaser.cpp b/src/effects/Phaser.cpp index 56e443f02..e8f759a68 100644 --- a/src/effects/Phaser.cpp +++ b/src/effects/Phaser.cpp @@ -151,7 +151,7 @@ bool EffectPhaser::ProcessInitialize(sampleCount WXUNUSED(totalLen), ChannelName return true; } -sampleCount EffectPhaser::ProcessBlock(float **inBlock, float **outBlock, sampleCount blockLen) +size_t EffectPhaser::ProcessBlock(float **inBlock, float **outBlock, size_t blockLen) { return InstanceProcess(mMaster, inBlock, outBlock, blockLen); } @@ -183,10 +183,10 @@ bool EffectPhaser::RealtimeFinalize() return true; } -sampleCount EffectPhaser::RealtimeProcess(int group, +size_t EffectPhaser::RealtimeProcess(int group, float **inbuf, float **outbuf, - sampleCount numSamples) + size_t numSamples) { return InstanceProcess(mSlaves[group], inbuf, outbuf, numSamples); @@ -372,7 +372,7 @@ void EffectPhaser::InstanceInit(EffectPhaserState & data, float sampleRate) return; } -sampleCount EffectPhaser::InstanceProcess(EffectPhaserState & data, float **inBlock, float **outBlock, sampleCount blockLen) +size_t EffectPhaser::InstanceProcess(EffectPhaserState & data, float **inBlock, float **outBlock, size_t blockLen) { float *ibuf = inBlock[0]; float *obuf = outBlock[0]; diff --git a/src/effects/Phaser.h b/src/effects/Phaser.h index 6f6bf0fc4..d8d203d4d 100644 --- a/src/effects/Phaser.h +++ b/src/effects/Phaser.h @@ -67,14 +67,14 @@ public: unsigned GetAudioInCount() override; unsigned GetAudioOutCount() override; bool ProcessInitialize(sampleCount totalLen, ChannelNames chanMap = NULL) override; - sampleCount ProcessBlock(float **inBlock, float **outBlock, sampleCount blockLen) override; + size_t ProcessBlock(float **inBlock, float **outBlock, size_t blockLen) override; bool RealtimeInitialize() override; bool RealtimeAddProcessor(unsigned numChannels, float sampleRate) override; bool RealtimeFinalize() override; - sampleCount RealtimeProcess(int group, + size_t RealtimeProcess(int group, float **inbuf, float **outbuf, - sampleCount numSamples) override; + size_t numSamples) override; bool GetAutomationParameters(EffectAutomationParameters & parms) override; bool SetAutomationParameters(EffectAutomationParameters & parms) override; @@ -88,7 +88,7 @@ private: // EffectPhaser implementation void InstanceInit(EffectPhaserState & data, float sampleRate); - sampleCount InstanceProcess(EffectPhaserState & data, float **inBlock, float **outBlock, sampleCount blockLen); + size_t InstanceProcess(EffectPhaserState & data, float **inBlock, float **outBlock, size_t blockLen); void OnStagesSlider(wxCommandEvent & evt); void OnDryWetSlider(wxCommandEvent & evt); diff --git a/src/effects/Repair.cpp b/src/effects/Repair.cpp index 400008f1e..c7d3c5d52 100644 --- a/src/effects/Repair.cpp +++ b/src/effects/Repair.cpp @@ -135,8 +135,8 @@ bool EffectRepair::Process() bool EffectRepair::ProcessOne(int count, WaveTrack * track, sampleCount start, - sampleCount len, - sampleCount repairStart, sampleCount repairLen) + size_t len, + size_t repairStart, size_t repairLen) { float *buffer = new float[len]; track->Get((samplePtr) buffer, floatSample, start, len); diff --git a/src/effects/Repair.h b/src/effects/Repair.h index a27b6b4d3..43b8422f0 100644 --- a/src/effects/Repair.h +++ b/src/effects/Repair.h @@ -44,8 +44,9 @@ private: bool ProcessOne(int count, WaveTrack * track, sampleCount start, - sampleCount len, - sampleCount repairStart, sampleCount repairLen); + size_t len, + size_t repairStart, // offset relative to start + size_t repairLen); }; #endif // __AUDACITY_EFFECT_REPAIT__ diff --git a/src/effects/Reverb.cpp b/src/effects/Reverb.cpp index bc8dc6085..ce367b71e 100644 --- a/src/effects/Reverb.cpp +++ b/src/effects/Reverb.cpp @@ -159,7 +159,7 @@ unsigned EffectReverb::GetAudioOutCount() return mParams.mStereoWidth ? 2 : 1; } -#define BLOCK 16384 +static size_t BLOCK = 16384; bool EffectReverb::ProcessInitialize(sampleCount WXUNUSED(totalLen), ChannelNames chanMap) { @@ -204,7 +204,7 @@ bool EffectReverb::ProcessFinalize() return true; } -sampleCount EffectReverb::ProcessBlock(float **inBlock, float **outBlock, sampleCount blockLen) +size_t EffectReverb::ProcessBlock(float **inBlock, float **outBlock, size_t blockLen) { float *ichans[2] = {NULL, NULL}; float *ochans[2] = {NULL, NULL}; diff --git a/src/effects/Reverb.h b/src/effects/Reverb.h index 8d0c2f86b..6757a450d 100644 --- a/src/effects/Reverb.h +++ b/src/effects/Reverb.h @@ -61,7 +61,7 @@ public: unsigned GetAudioOutCount() override; bool ProcessInitialize(sampleCount totalLen, ChannelNames chanMap = NULL) override; bool ProcessFinalize() override; - sampleCount ProcessBlock(float **inBlock, float **outBlock, sampleCount blockLen) override; + size_t ProcessBlock(float **inBlock, float **outBlock, size_t blockLen) override; bool GetAutomationParameters(EffectAutomationParameters & parms) override; bool SetAutomationParameters(EffectAutomationParameters & parms) override; wxArrayString GetFactoryPresets() override; diff --git a/src/effects/SBSMSEffect.cpp b/src/effects/SBSMSEffect.cpp index e8a1a1d8b..b908e1e60 100644 --- a/src/effects/SBSMSEffect.cpp +++ b/src/effects/SBSMSEffect.cpp @@ -54,8 +54,8 @@ public: audio *buf; double ratio; sampleCount processed; - sampleCount blockSize; - sampleCount SBSMSBlockSize; + size_t blockSize; + long SBSMSBlockSize; sampleCount offset; sampleCount end; float *leftBuffer; diff --git a/src/effects/ScienFilter.cpp b/src/effects/ScienFilter.cpp index 005452730..9e3fbc7b4 100644 --- a/src/effects/ScienFilter.cpp +++ b/src/effects/ScienFilter.cpp @@ -228,7 +228,7 @@ bool EffectScienFilter::ProcessInitialize(sampleCount WXUNUSED(totalLen), Channe return true; } -sampleCount EffectScienFilter::ProcessBlock(float **inBlock, float **outBlock, sampleCount blockLen) +size_t EffectScienFilter::ProcessBlock(float **inBlock, float **outBlock, size_t blockLen) { float *ibuf = inBlock[0]; for (int iPair = 0; iPair < (mOrder + 1) / 2; iPair++) diff --git a/src/effects/ScienFilter.h b/src/effects/ScienFilter.h index b6c80979c..da47af1f0 100644 --- a/src/effects/ScienFilter.h +++ b/src/effects/ScienFilter.h @@ -55,7 +55,7 @@ public: unsigned GetAudioInCount() override; unsigned GetAudioOutCount() override; bool ProcessInitialize(sampleCount totalLen, ChannelNames chanMap = NULL) override; - sampleCount ProcessBlock(float **inBlock, float **outBlock, sampleCount blockLen) override; + size_t ProcessBlock(float **inBlock, float **outBlock, size_t blockLen) override; bool GetAutomationParameters(EffectAutomationParameters & parms) override; bool SetAutomationParameters(EffectAutomationParameters & parms) override; diff --git a/src/effects/SimpleMono.h b/src/effects/SimpleMono.h index d251fb5b9..5d7535738 100644 --- a/src/effects/SimpleMono.h +++ b/src/effects/SimpleMono.h @@ -34,7 +34,7 @@ protected: virtual bool NewTrackSimpleMono() = 0; // Override this method to actually process audio - virtual bool ProcessSimpleMono(float *buffer, sampleCount len) = 0; + virtual bool ProcessSimpleMono(float *buffer, size_t len) = 0; protected: // Other useful information diff --git a/src/effects/ToneGen.cpp b/src/effects/ToneGen.cpp index 4971a03fa..e46a4b24d 100644 --- a/src/effects/ToneGen.cpp +++ b/src/effects/ToneGen.cpp @@ -155,7 +155,7 @@ bool EffectToneGen::ProcessInitialize(sampleCount WXUNUSED(totalLen), ChannelNam return true; } -sampleCount EffectToneGen::ProcessBlock(float **WXUNUSED(inBlock), float **outBlock, sampleCount blockLen) +size_t EffectToneGen::ProcessBlock(float **WXUNUSED(inBlock), float **outBlock, size_t blockLen) { float *buffer = outBlock[0]; double throwaway = 0; //passed to modf but never used diff --git a/src/effects/ToneGen.h b/src/effects/ToneGen.h index 9ee15f917..943cd8166 100644 --- a/src/effects/ToneGen.h +++ b/src/effects/ToneGen.h @@ -44,7 +44,7 @@ public: unsigned GetAudioOutCount() override; bool ProcessInitialize(sampleCount totalLen, ChannelNames chanMap = NULL) override; - sampleCount ProcessBlock(float **inBlock, float **outBlock, sampleCount blockLen) override; + size_t ProcessBlock(float **inBlock, float **outBlock, size_t blockLen) override; bool GetAutomationParameters(EffectAutomationParameters & parms) override; bool SetAutomationParameters(EffectAutomationParameters & parms) override; diff --git a/src/effects/TruncSilence.cpp b/src/effects/TruncSilence.cpp index 2bc1494e8..74105c989 100644 --- a/src/effects/TruncSilence.cpp +++ b/src/effects/TruncSilence.cpp @@ -65,7 +65,7 @@ Param( Truncate, double, XO("Truncate"), 0.5, 0.0, 10000.0, Param( Compress, double, XO("Compress"), 50.0, 0.0, 99.9, 1 ); Param( Independent, bool, XO("Independent"), false, false, true, 1 ); -static const sampleCount DEF_BlendFrameCount = 100; +static const size_t DEF_BlendFrameCount = 100; // Lower bound on the amount of silence to find at a time -- this avoids // detecting silence repeatedly in low-frequency sounds. diff --git a/src/effects/TruncSilence.h b/src/effects/TruncSilence.h index 591a1fa24..c19ffacfc 100644 --- a/src/effects/TruncSilence.h +++ b/src/effects/TruncSilence.h @@ -104,7 +104,7 @@ private: wxArrayString mDbChoices; - sampleCount mBlendFrameCount; + size_t mBlendFrameCount; wxChoice *mTruncDbChoice; wxChoice *mActionChoice; diff --git a/src/effects/TwoPassSimpleMono.h b/src/effects/TwoPassSimpleMono.h index 48b526030..cc2639fb7 100644 --- a/src/effects/TwoPassSimpleMono.h +++ b/src/effects/TwoPassSimpleMono.h @@ -41,16 +41,23 @@ protected: virtual bool NewTrackPass2(); // Override this method to actually process audio - virtual bool ProcessPass1(float * WXUNUSED(buffer), sampleCount WXUNUSED(len)) { return false; } - virtual bool ProcessPass2(float * WXUNUSED(buffer), sampleCount WXUNUSED(len)) { return false; } + virtual bool ProcessPass1 + (float * WXUNUSED(buffer), size_t WXUNUSED(len)) + { return false; } + + virtual bool ProcessPass2 + (float * WXUNUSED(buffer), size_t WXUNUSED(len)) + { return false; } // Override this method to actually process audio with access to 2 sequential buffers at a time // Either buffer1 or buffer2 may be modified as needed // This allows implementation of processing with delays // The default just calls the one-buffer-at-a-time method - virtual bool TwoBufferProcessPass1(float *buffer1, sampleCount len1, float * WXUNUSED(buffer2), sampleCount WXUNUSED(len2)) + virtual bool TwoBufferProcessPass1 + (float *buffer1, size_t len1, float * WXUNUSED(buffer2), size_t WXUNUSED(len2)) { if(buffer1 != NULL) return ProcessPass1(buffer1, len1); else return true; } - virtual bool TwoBufferProcessPass2(float *buffer1, sampleCount len1, float * WXUNUSED(buffer2), sampleCount WXUNUSED(len2)) + virtual bool TwoBufferProcessPass2 + (float *buffer1, size_t len1, float * WXUNUSED(buffer2), size_t WXUNUSED(len2)) { if(buffer1 != NULL) return ProcessPass2(buffer1, len1); else return true; } // End of NEW virtuals diff --git a/src/effects/VST/VSTEffect.cpp b/src/effects/VST/VSTEffect.cpp index dc8fc3a5b..a9586eece 100644 --- a/src/effects/VST/VSTEffect.cpp +++ b/src/effects/VST/VSTEffect.cpp @@ -1326,7 +1326,7 @@ int VSTEffect::GetMidiOutCount() return mMidiOuts; } -sampleCount VSTEffect::SetBlockSize(sampleCount maxBlockSize) +size_t VSTEffect::SetBlockSize(size_t maxBlockSize) { mBlockSize = std::min((int)maxBlockSize, mUserBlockSize); return mBlockSize; @@ -1350,7 +1350,7 @@ sampleCount VSTEffect::GetLatency() return 0; } -sampleCount VSTEffect::GetTailSize() +size_t VSTEffect::GetTailSize() { return 0; } @@ -1395,7 +1395,7 @@ bool VSTEffect::ProcessFinalize() return true; } -sampleCount VSTEffect::ProcessBlock(float **inBlock, float **outBlock, sampleCount blockLen) +size_t VSTEffect::ProcessBlock(float **inBlock, float **outBlock, size_t blockLen) { // Only call the effect if there's something to do...some do not like zero-length block if (blockLen) @@ -1534,7 +1534,7 @@ bool VSTEffect::RealtimeProcessStart() return true; } -sampleCount VSTEffect::RealtimeProcess(int group, float **inbuf, float **outbuf, sampleCount numSamples) +size_t VSTEffect::RealtimeProcess(int group, float **inbuf, float **outbuf, size_t numSamples) { wxASSERT(numSamples <= mBlockSize); diff --git a/src/effects/VST/VSTEffect.h b/src/effects/VST/VSTEffect.h index 727b86f3b..7b8d5cdf0 100644 --- a/src/effects/VST/VSTEffect.h +++ b/src/effects/VST/VSTEffect.h @@ -106,15 +106,15 @@ class VSTEffect final : public wxEvtHandler, int GetMidiOutCount() override; sampleCount GetLatency() override; - sampleCount GetTailSize() override; + size_t GetTailSize() override; void SetSampleRate(double rate) override; - sampleCount SetBlockSize(sampleCount maxBlockSize) override; + size_t SetBlockSize(size_t maxBlockSize) override; bool IsReady() override; bool ProcessInitialize(sampleCount totalLen, ChannelNames chanMap = NULL) override; bool ProcessFinalize() override; - sampleCount ProcessBlock(float **inBlock, float **outBlock, sampleCount blockLen) override; + size_t ProcessBlock(float **inBlock, float **outBlock, size_t blockLen) override; bool RealtimeInitialize() override; bool RealtimeAddProcessor(unsigned numChannels, float sampleRate) override; @@ -122,10 +122,10 @@ class VSTEffect final : public wxEvtHandler, bool RealtimeSuspend() override; bool RealtimeResume() override; bool RealtimeProcessStart() override; - sampleCount RealtimeProcess(int group, + size_t RealtimeProcess(int group, float **inbuf, float **outbuf, - sampleCount numSamples) override; + size_t numSamples) override; bool RealtimeProcessEnd() override; bool ShowInterface(wxWindow *parent, bool forceModal = false) override; @@ -331,7 +331,7 @@ private: unsigned mNumChannels; float **mMasterIn; float **mMasterOut; - sampleCount mNumSamples; + size_t mNumSamples; // UI wxDialog *mDialog; diff --git a/src/effects/Wahwah.cpp b/src/effects/Wahwah.cpp index dee12d669..c60a548dd 100644 --- a/src/effects/Wahwah.cpp +++ b/src/effects/Wahwah.cpp @@ -143,7 +143,7 @@ bool EffectWahwah::ProcessInitialize(sampleCount WXUNUSED(totalLen), ChannelName return true; } -sampleCount EffectWahwah::ProcessBlock(float **inBlock, float **outBlock, sampleCount blockLen) +size_t EffectWahwah::ProcessBlock(float **inBlock, float **outBlock, size_t blockLen) { return InstanceProcess(mMaster, inBlock, outBlock, blockLen); } @@ -175,10 +175,10 @@ bool EffectWahwah::RealtimeFinalize() return true; } -sampleCount EffectWahwah::RealtimeProcess(int group, +size_t EffectWahwah::RealtimeProcess(int group, float **inbuf, float **outbuf, - sampleCount numSamples) + size_t numSamples) { return InstanceProcess(mSlaves[group], inbuf, outbuf, numSamples); @@ -341,7 +341,7 @@ void EffectWahwah::InstanceInit(EffectWahwahState & data, float sampleRate) data.outgain = DB_TO_LINEAR(mOutGain); } -sampleCount EffectWahwah::InstanceProcess(EffectWahwahState & data, float **inBlock, float **outBlock, sampleCount blockLen) +size_t EffectWahwah::InstanceProcess(EffectWahwahState & data, float **inBlock, float **outBlock, size_t blockLen) { float *ibuf = inBlock[0]; float *obuf = outBlock[0]; diff --git a/src/effects/Wahwah.h b/src/effects/Wahwah.h index 6f2b804a3..35ec02587 100644 --- a/src/effects/Wahwah.h +++ b/src/effects/Wahwah.h @@ -64,14 +64,14 @@ public: unsigned GetAudioInCount() override; unsigned GetAudioOutCount() override; bool ProcessInitialize(sampleCount totalLen, ChannelNames chanMap = NULL) override; - sampleCount ProcessBlock(float **inBlock, float **outBlock, sampleCount blockLen) override; + size_t ProcessBlock(float **inBlock, float **outBlock, size_t blockLen) override; bool RealtimeInitialize() override; bool RealtimeAddProcessor(unsigned numChannels, float sampleRate) override; bool RealtimeFinalize() override; - sampleCount RealtimeProcess(int group, + size_t RealtimeProcess(int group, float **inbuf, float **outbuf, - sampleCount numSamples) override; + size_t numSamples) override; bool GetAutomationParameters(EffectAutomationParameters & parms) override; bool SetAutomationParameters(EffectAutomationParameters & parms) override; @@ -85,7 +85,7 @@ private: // EffectWahwah implementation void InstanceInit(EffectWahwahState & data, float sampleRate); - sampleCount InstanceProcess(EffectWahwahState & data, float **inBlock, float **outBlock, sampleCount blockLen); + size_t InstanceProcess(EffectWahwahState & data, float **inBlock, float **outBlock, size_t blockLen); void OnFreqSlider(wxCommandEvent & evt); void OnPhaseSlider(wxCommandEvent & evt); diff --git a/src/effects/audiounits/AudioUnitEffect.cpp b/src/effects/audiounits/AudioUnitEffect.cpp index 9f00a5975..22284a61a 100644 --- a/src/effects/audiounits/AudioUnitEffect.cpp +++ b/src/effects/audiounits/AudioUnitEffect.cpp @@ -1192,7 +1192,7 @@ void AudioUnitEffect::SetSampleRate(double rate) mSampleRate = rate; } -sampleCount AudioUnitEffect::SetBlockSize(sampleCount maxBlockSize) +size_t AudioUnitEffect::SetBlockSize(size_t maxBlockSize) { return mBlockSize; } @@ -1219,7 +1219,7 @@ sampleCount AudioUnitEffect::GetLatency() return 0; } -sampleCount AudioUnitEffect::GetTailSize() +size_t AudioUnitEffect::GetTailSize() { // Retrieve the tail time Float64 tailTime = 0.0; @@ -1306,7 +1306,7 @@ bool AudioUnitEffect::ProcessFinalize() return true; } -sampleCount AudioUnitEffect::ProcessBlock(float **inBlock, float **outBlock, sampleCount blockLen) +size_t AudioUnitEffect::ProcessBlock(float **inBlock, float **outBlock, size_t blockLen) { for (int i = 0; i < mAudioIns; i++) { @@ -1431,10 +1431,10 @@ bool AudioUnitEffect::RealtimeProcessStart() return true; } -sampleCount AudioUnitEffect::RealtimeProcess(int group, +size_t AudioUnitEffect::RealtimeProcess(int group, float **inbuf, float **outbuf, - sampleCount numSamples) + size_t numSamples) { wxASSERT(numSamples <= mBlockSize); diff --git a/src/effects/audiounits/AudioUnitEffect.h b/src/effects/audiounits/AudioUnitEffect.h index f52a1a1ac..efe424305 100644 --- a/src/effects/audiounits/AudioUnitEffect.h +++ b/src/effects/audiounits/AudioUnitEffect.h @@ -79,15 +79,15 @@ public: int GetMidiOutCount() override; void SetSampleRate(double rate) override; - sampleCount SetBlockSize(sampleCount maxBlockSize) override; + size_t SetBlockSize(size_t maxBlockSize) override; sampleCount GetLatency() override; - sampleCount GetTailSize() override; + size_t GetTailSize() override; bool IsReady() override; bool ProcessInitialize(sampleCount totalLen, ChannelNames chanMap = NULL) override; bool ProcessFinalize() override; - sampleCount ProcessBlock(float **inBlock, float **outBlock, sampleCount blockLen) override; + size_t ProcessBlock(float **inBlock, float **outBlock, size_t blockLen) override; bool RealtimeInitialize() override; bool RealtimeAddProcessor(unsigned numChannels, float sampleRate) override; @@ -95,10 +95,10 @@ public: bool RealtimeSuspend() override; bool RealtimeResume() override; bool RealtimeProcessStart() override; - sampleCount RealtimeProcess(int group, + size_t RealtimeProcess(int group, float **inbuf, float **outbuf, - sampleCount numSamples) override; + size_t numSamples) override; bool RealtimeProcessEnd() override; bool ShowInterface(wxWindow *parent, bool forceModal = false) override; @@ -208,7 +208,7 @@ private: unsigned mNumChannels; float **mMasterIn; float **mMasterOut; - sampleCount mNumSamples; + size_t mNumSamples; AUEventListenerRef mEventListenerRef; diff --git a/src/effects/ladspa/LadspaEffect.cpp b/src/effects/ladspa/LadspaEffect.cpp index 120fcf9fc..793dbcc2c 100644 --- a/src/effects/ladspa/LadspaEffect.cpp +++ b/src/effects/ladspa/LadspaEffect.cpp @@ -891,7 +891,7 @@ void LadspaEffect::SetSampleRate(double rate) mSampleRate = rate; } -sampleCount LadspaEffect::SetBlockSize(sampleCount maxBlockSize) +size_t LadspaEffect::SetBlockSize(size_t maxBlockSize) { mBlockSize = maxBlockSize; @@ -909,7 +909,7 @@ sampleCount LadspaEffect::GetLatency() return 0; } -sampleCount LadspaEffect::GetTailSize() +size_t LadspaEffect::GetTailSize() { return 0; } @@ -950,7 +950,7 @@ bool LadspaEffect::ProcessFinalize() return true; } -sampleCount LadspaEffect::ProcessBlock(float **inBlock, float **outBlock, sampleCount blockLen) +size_t LadspaEffect::ProcessBlock(float **inBlock, float **outBlock, size_t blockLen) { for (int i = 0; i < mAudioIns; i++) { @@ -1013,10 +1013,10 @@ bool LadspaEffect::RealtimeProcessStart() return true; } -sampleCount LadspaEffect::RealtimeProcess(int group, +size_t LadspaEffect::RealtimeProcess(int group, float **inbuf, float **outbuf, - sampleCount numSamples) + size_t numSamples) { for (int i = 0; i < mAudioIns; i++) { diff --git a/src/effects/ladspa/LadspaEffect.h b/src/effects/ladspa/LadspaEffect.h index 63adad92d..7c3600af6 100644 --- a/src/effects/ladspa/LadspaEffect.h +++ b/src/effects/ladspa/LadspaEffect.h @@ -74,15 +74,15 @@ public: int GetMidiOutCount() override; void SetSampleRate(double rate) override; - sampleCount SetBlockSize(sampleCount maxBlockSize) override; + size_t SetBlockSize(size_t maxBlockSize) override; sampleCount GetLatency() override; - sampleCount GetTailSize() override; + size_t GetTailSize() override; bool IsReady() override; bool ProcessInitialize(sampleCount totalLen, ChannelNames chanMap = NULL) override; bool ProcessFinalize() override; - sampleCount ProcessBlock(float **inBlock, float **outBlock, sampleCount blockLen) override; + size_t ProcessBlock(float **inBlock, float **outBlock, size_t blockLen) override; bool RealtimeInitialize() override; bool RealtimeAddProcessor(unsigned numChannels, float sampleRate) override; @@ -90,10 +90,10 @@ public: bool RealtimeSuspend() override; bool RealtimeResume() override; bool RealtimeProcessStart() override; - sampleCount RealtimeProcess(int group, + size_t RealtimeProcess(int group, float **inbuf, float **outbuf, - sampleCount numSamples) override; + size_t numSamples) override; bool RealtimeProcessEnd() override; bool ShowInterface(wxWindow *parent, bool forceModal = false) override; @@ -157,8 +157,8 @@ private: LADSPA_Handle mMaster; double mSampleRate; - sampleCount mBlockSize; - sampleCount mUserBlockSize; + size_t mBlockSize; + int mUserBlockSize; bool mInteractive; diff --git a/src/effects/lv2/LV2Effect.cpp b/src/effects/lv2/LV2Effect.cpp index f54a60070..91b123cc6 100644 --- a/src/effects/lv2/LV2Effect.cpp +++ b/src/effects/lv2/LV2Effect.cpp @@ -745,7 +745,7 @@ void LV2Effect::SetSampleRate(double rate) } } -sampleCount LV2Effect::SetBlockSize(sampleCount maxBlockSize) +size_t LV2Effect::SetBlockSize(size_t maxBlockSize) { mBlockSize = (int) maxBlockSize; @@ -780,7 +780,7 @@ sampleCount LV2Effect::GetLatency() return 0; } -sampleCount LV2Effect::GetTailSize() +size_t LV2Effect::GetTailSize() { return 0; } @@ -818,7 +818,7 @@ bool LV2Effect::ProcessFinalize() return true; } -sampleCount LV2Effect::ProcessBlock(float **inbuf, float **outbuf, sampleCount size) +size_t LV2Effect::ProcessBlock(float **inbuf, float **outbuf, size_t size) { for (size_t p = 0, cnt = mAudioInputs.GetCount(); p < cnt; p++) { @@ -905,10 +905,10 @@ bool LV2Effect::RealtimeProcessStart() return true; } -sampleCount LV2Effect::RealtimeProcess(int group, +size_t LV2Effect::RealtimeProcess(int group, float **inbuf, float **outbuf, - sampleCount numSamples) + size_t numSamples) { wxASSERT(group >= 0 && group < (int) mSlaves.GetCount()); wxASSERT(numSamples <= mBlockSize); diff --git a/src/effects/lv2/LV2Effect.h b/src/effects/lv2/LV2Effect.h index 82e61c66d..277de6019 100644 --- a/src/effects/lv2/LV2Effect.h +++ b/src/effects/lv2/LV2Effect.h @@ -129,15 +129,15 @@ public: int GetMidiOutCount() override; void SetSampleRate(double rate) override; - sampleCount SetBlockSize(sampleCount maxBlockSize) override; + size_t SetBlockSize(size_t maxBlockSize) override; sampleCount GetLatency() override; - sampleCount GetTailSize() override; + size_t GetTailSize() override; bool IsReady() override; bool ProcessInitialize(sampleCount totalLen, ChannelNames chanMap = NULL) override; bool ProcessFinalize() override; - sampleCount ProcessBlock(float **inbuf, float **outbuf, sampleCount size) override; + size_t ProcessBlock(float **inbuf, float **outbuf, size_t size) override; bool RealtimeInitialize() override; bool RealtimeAddProcessor(unsigned numChannels, float sampleRate) override; @@ -145,10 +145,10 @@ public: bool RealtimeSuspend() override; bool RealtimeResume() override; bool RealtimeProcessStart() override; - sampleCount RealtimeProcess(int group, + size_t RealtimeProcess(int group, float **inbuf, float **outbuf, - sampleCount numSamples) override; + size_t numSamples) override; bool RealtimeProcessEnd() override; bool ShowInterface(wxWindow *parent, bool forceModal = false) override; @@ -276,7 +276,7 @@ private: float **mMasterIn; float **mMasterOut; - sampleCount mNumSamples; + size_t mNumSamples; double mLength; diff --git a/src/export/ExportCL.cpp b/src/export/ExportCL.cpp index 59b608f9e..061b0af32 100644 --- a/src/export/ExportCL.cpp +++ b/src/export/ExportCL.cpp @@ -375,7 +375,7 @@ int ExportCL::Export(AudacityProject *project, // establish parameters int rate = lrint(project->GetRate()); - sampleCount maxBlockLen = 44100 * 5; + const size_t maxBlockLen = 44100 * 5; unsigned long totalSamples = lrint((t1 - t0) * rate); unsigned long sampleBytes = totalSamples * channels * SAMPLE_SIZE(int16Sample); diff --git a/src/export/ExportFFmpeg.cpp b/src/export/ExportFFmpeg.cpp index 0ce67c017..1262b96eb 100644 --- a/src/export/ExportFFmpeg.cpp +++ b/src/export/ExportFFmpeg.cpp @@ -113,7 +113,7 @@ public: void SetMetadata(const Tags *tags, const char *name, const wxChar *tag); /// Encodes audio - bool EncodeAudioFrame(int16_t *pFrame, int frameSize); + bool EncodeAudioFrame(int16_t *pFrame, size_t frameSize); /// Flushes audio encoder bool Finalize(); @@ -760,7 +760,7 @@ void ExportFFmpeg::FreeResources() av_log_set_callback(av_log_default_callback); } -bool ExportFFmpeg::EncodeAudioFrame(int16_t *pFrame, int frameSize) +bool ExportFFmpeg::EncodeAudioFrame(int16_t *pFrame, size_t frameSize) { int nBytesToWrite = 0; uint8_t *pRawSamples = NULL; diff --git a/src/import/ImportGStreamer.cpp b/src/import/ImportGStreamer.cpp index ac956c24a..99fa758c6 100644 --- a/src/import/ImportGStreamer.cpp +++ b/src/import/ImportGStreamer.cpp @@ -815,7 +815,7 @@ GStreamerImportFileHandle::OnNewSample(GStreamContext *c, GstSample *sample) auto nChannels = c->mNumChannels; sampleFormat fmt = c->mFmt; samplePtr data = (samplePtr) info.data; - sampleCount samples = info.size / nChannels / SAMPLE_SIZE(fmt); + size_t samples = info.size / nChannels / SAMPLE_SIZE(fmt); // Add sample data to tracks...depends on interleaved src data for (int chn = 0; chn < nChannels; chn++) diff --git a/src/ondemand/ODDecodeFFmpegTask.cpp b/src/ondemand/ODDecodeFFmpegTask.cpp index 8f2d4b77a..fa00d9118 100644 --- a/src/ondemand/ODDecodeFFmpegTask.cpp +++ b/src/ondemand/ODDecodeFFmpegTask.cpp @@ -48,7 +48,7 @@ struct FFMpegDecodeCache uint8_t* samplePtr{};//interleaved samples sampleCount start; - sampleCount len; + size_t len; unsigned numChannels; AVSampleFormat samplefmt; // input (from libav) sample format @@ -76,7 +76,7 @@ public: ///this->ReadData(sampleData, floatSample, 0, mLen); ///This class should call ReadHeader() first, so it knows the length, and can prepare ///the file object if it needs to. - int Decode(SampleBuffer & data, sampleFormat & format, sampleCount start, sampleCount len, unsigned int channel) override; + int Decode(SampleBuffer & data, sampleFormat & format, sampleCount start, size_t len, unsigned int channel) override; ///This is a must implement abstract virtual in the superclass. ///However it doesn't do anything because ImportFFMpeg does all that for us. @@ -88,7 +88,7 @@ private: void InsertCache(movable_ptr &&cache); //puts the actual audio samples into the blockfile's data array - int FillDataFromCache(samplePtr & data, sampleFormat outFormat, sampleCount & start, sampleCount& len, unsigned int channel); + int FillDataFromCache(samplePtr & data, sampleFormat outFormat, sampleCount & start, size_t& len, unsigned int channel); ///REFACTORABLE CODE FROM IMPORT FFMPEG ///! Reads next audio frame ///\return pointer to the stream context structure to which the frame belongs to or NULL on error, or 1 if stream is not to be imported. @@ -106,7 +106,7 @@ private: std::vector> mDecodeCache; int mNumSamplesInCache; sampleCount mCurrentPos; //the index of the next sample to be decoded - sampleCount mCurrentLen; //length of the last packet decoded + size_t mCurrentLen; //length of the last packet decoded bool mSeekingAllowedStatus; int mStreamIndex; @@ -289,7 +289,7 @@ ODFFmpegDecoder::~ODFFmpegDecoder() #define kDecodeSampleAllowance 400000 //number of jump backwards seeks #define kMaxSeekRewindAttempts 8 -int ODFFmpegDecoder::Decode(SampleBuffer & data, sampleFormat & format, sampleCount start, sampleCount len, unsigned int channel) +int ODFFmpegDecoder::Decode(SampleBuffer & data, sampleFormat & format, sampleCount start, size_t len, unsigned int channel) { auto mFormatContext = mContext->ic_ptr; @@ -301,7 +301,7 @@ int ODFFmpegDecoder::Decode(SampleBuffer & data, sampleFormat & format, sampleCo samplePtr bufStart = data.ptr(); streamContext* sc = NULL; - // printf("start %llu len %llu\n", start, len); + // printf("start %llu len %lu\n", start, len); //TODO update this to work with seek - this only works linearly now. if(mCurrentPos > start && mCurrentPos <= start+len + kDecodeSampleAllowance) { @@ -387,7 +387,7 @@ int ODFFmpegDecoder::Decode(SampleBuffer & data, sampleFormat & format, sampleCo seeking = false; } if(actualDecodeStart != mCurrentPos) - printf("ts not matching - now:%llu , last:%llu, lastlen:%llu, start %llu, len %llu\n",actualDecodeStart.as_long_long(), mCurrentPos.as_long_long(), mCurrentLen, start.as_long_long(), len); + printf("ts not matching - now:%llu , last:%llu, lastlen:%lu, start %llu, len %lu\n",actualDecodeStart.as_long_long(), mCurrentPos.as_long_long(), mCurrentLen, start.as_long_long(), len); //if we've skipped over some samples, fill the gap with silence. This could happen often in the beginning of the file. if(actualDecodeStart>start && firstpass) { // find the number of samples for the leading silence @@ -398,7 +398,7 @@ int ODFFmpegDecoder::Decode(SampleBuffer & data, sampleFormat & format, sampleCo auto amt = (actualDecodeStart - start).as_size_t(); auto cache = make_movable(); - //printf("skipping/zeroing %i samples. - now:%llu (%f), last:%llu, lastlen:%llu, start %llu, len %llu\n",amt,actualDecodeStart, actualDecodeStartdouble, mCurrentPos, mCurrentLen, start, len); + //printf("skipping/zeroing %i samples. - now:%llu (%f), last:%llu, lastlen:%lu, start %llu, len %lu\n",amt,actualDecodeStart, actualDecodeStartdouble, mCurrentPos, mCurrentLen, start, len); //put it in the cache so the other channels can use it. // wxASSERT(sc->m_stream->codec->channels > 0); @@ -466,7 +466,7 @@ int ODFFmpegDecoder::Decode(SampleBuffer & data, sampleFormat & format, sampleCo #define kODFFmpegSearchThreshold 10 ///returns the number of samples filled in from start. //also updates data and len to reflect NEW unfilled area - start is unmodified. -int ODFFmpegDecoder::FillDataFromCache(samplePtr & data, sampleFormat outFormat, sampleCount &start, sampleCount& len, unsigned int channel) +int ODFFmpegDecoder::FillDataFromCache(samplePtr & data, sampleFormat outFormat, sampleCount &start, size_t& len, unsigned int channel) { if(mDecodeCache.size() <= 0) return 0; @@ -529,7 +529,7 @@ int ODFFmpegDecoder::FillDataFromCache(samplePtr & data, sampleFormat outFormat, FFMAX(sampleCount{0},start-mDecodeCache[i]->start).as_size_t(); //we also need to find out which end was hit - if it is the tail only we need to update from a later index. const auto hitStartInRequest = start < mDecodeCache[i]->start - ? len - samplesHit : sampleCount{ 0 }; + ? len - samplesHit : 0; for(decltype(samplesHit) j = 0; j < samplesHit; j++) { const auto outIndex = hitStartInRequest + j; @@ -537,27 +537,27 @@ int ODFFmpegDecoder::FillDataFromCache(samplePtr & data, sampleFormat outFormat, switch (mDecodeCache[i]->samplefmt) { case AV_SAMPLE_FMT_U8: - //printf("u8 in %llu out %llu cachelen %llu outLen %llu\n", inIndex, outIndex, mDecodeCache[i]->len, len); + //printf("u8 in %lu out %lu cachelen %lu outLen %lu\n", inIndex, outIndex, mDecodeCache[i]->len, len); ((int16_t *)outBuf)[outIndex] = (int16_t) (((uint8_t*)mDecodeCache[i]->samplePtr)[inIndex] - 0x80) << 8; break; case AV_SAMPLE_FMT_S16: - //printf("u16 in %llu out %llu cachelen %llu outLen %llu\n", inIndex, outIndex, mDecodeCache[i]->len, len); + //printf("u16 in %lu out %lu cachelen %lu outLen % lu\n", inIndex, outIndex, mDecodeCache[i]->len, len); ((int16_t *)outBuf)[outIndex] = ((int16_t*)mDecodeCache[i]->samplePtr)[inIndex]; break; case AV_SAMPLE_FMT_S32: - //printf("s32 in %llu out %llu cachelen %llu outLen %llu\n", inIndex, outIndex, mDecodeCache[i]->len, len); + //printf("s32 in %lu out %lu cachelen %lu outLen %lu\n", inIndex, outIndex, mDecodeCache[i]->len, len); ((float *)outBuf)[outIndex] = (float) ((int32_t*)mDecodeCache[i]->samplePtr)[inIndex] * (1.0 / (1 << 31)); break; case AV_SAMPLE_FMT_FLT: - //printf("f in %llu out %llu cachelen %llu outLen %llu\n", inIndex, outIndex, mDecodeCache[i]->len, len); + //printf("f in %lu out %lu cachelen %lu outLen %lu\n", inIndex, outIndex, mDecodeCache[i]->len, len); ((float *)outBuf)[outIndex] = (float) ((float*)mDecodeCache[i]->samplePtr)[inIndex]; break; case AV_SAMPLE_FMT_DBL: - //printf("dbl in %llu out %llu cachelen %llu outLen %llu\n", inIndex, outIndex, mDecodeCache[i]->len, len); + //printf("dbl in %lu out %lu cachelen %lu outLen %lu\n", inIndex, outIndex, mDecodeCache[i]->len, len); ((float *)outBuf)[outIndex] = (float) ((double*)mDecodeCache[i]->samplePtr)[inIndex]; break; diff --git a/src/ondemand/ODDecodeFlacTask.cpp b/src/ondemand/ODDecodeFlacTask.cpp index d15ef6319..53851fb17 100644 --- a/src/ondemand/ODDecodeFlacTask.cpp +++ b/src/ondemand/ODDecodeFlacTask.cpp @@ -168,7 +168,7 @@ FLAC__StreamDecoderWriteStatus ODFLACFile::write_callback(const FLAC__Frame *fra ///this->ReadData(sampleData, floatSample, 0, mLen); ///This class should call ReadHeader() first, so it knows the length, and can prepare ///the file object if it needs to. -int ODFlacDecoder::Decode(SampleBuffer & data, sampleFormat & format, sampleCount start, sampleCount len, unsigned int channel) +int ODFlacDecoder::Decode(SampleBuffer & data, sampleFormat & format, sampleCount start, size_t len, unsigned int channel) { //we need to lock this so the target stays fixed over the seek/write callback. diff --git a/src/ondemand/ODDecodeFlacTask.h b/src/ondemand/ODDecodeFlacTask.h index 4081e63d2..ba9b47d2d 100644 --- a/src/ondemand/ODDecodeFlacTask.h +++ b/src/ondemand/ODDecodeFlacTask.h @@ -106,7 +106,7 @@ public: ///this->ReadData(sampleData, floatSample, 0, mLen); ///This class should call ReadHeader() first, so it knows the length, and can prepare ///the file object if it needs to. - int Decode(SampleBuffer & data, sampleFormat & format, sampleCount start, sampleCount len, unsigned int channel) override; + int Decode(SampleBuffer & data, sampleFormat & format, sampleCount start, size_t len, unsigned int channel) override; ///Read header. Subclasses must override. Probably should save the info somewhere. diff --git a/src/ondemand/ODDecodeTask.h b/src/ondemand/ODDecodeTask.h index 59eb27ec6..f00e051f3 100644 --- a/src/ondemand/ODDecodeTask.h +++ b/src/ondemand/ODDecodeTask.h @@ -119,7 +119,7 @@ public: ///This class should call ReadHeader() first, so it knows the length, and can prepare ///the file object if it needs to. ///returns negative value for failure, 0 or positive value for success. - virtual int Decode(SampleBuffer & data, sampleFormat & format, sampleCount start, sampleCount len, unsigned int channel)=0; + virtual int Decode(SampleBuffer & data, sampleFormat & format, sampleCount start, size_t len, unsigned int channel) = 0; const wxString &GetFileName(){return mFName;} diff --git a/src/widgets/Meter.cpp b/src/widgets/Meter.cpp index d1f7b8fb7..e29593fd8 100644 --- a/src/widgets/Meter.cpp +++ b/src/widgets/Meter.cpp @@ -942,7 +942,7 @@ void Meter::UpdateDisplay(unsigned numChannels, int numFrames, float *sampleData // // Need to make these double-indexed arrays if we handle more than 2 channels. // float* maxLeft, float* rmsLeft, // float* maxRight, float* rmsRight, -// const sampleCount kSampleCount) +// const size_t kSampleCount) //{ // int i, j; // int num = intmin(numChannels, mNumBars); diff --git a/src/widgets/Meter.h b/src/widgets/Meter.h index 72bec094c..f5d7c1f05 100644 --- a/src/widgets/Meter.h +++ b/src/widgets/Meter.h @@ -161,7 +161,7 @@ class Meter final : public wxPanelWrapper // // Need to make these double-indexed max and min arrays if we handle more than 2 channels. // float* maxLeft, float* rmsLeft, // float* maxRight, float* rmsRight, - // const sampleCount kSampleCount); + // const size_t kSampleCount); /** \brief Find out if the level meter is disabled or not. *