diff --git a/src/audio/AudioStream.cpp b/src/audio/AudioStream.cpp index 0ceece5..25667b5 100644 --- a/src/audio/AudioStream.cpp +++ b/src/audio/AudioStream.cpp @@ -1,9 +1,9 @@ #include "AudioStream.h" -TimeRange AudioStream::getTruncatedRange() { +TimeRange AudioStream::getTruncatedRange() const { return TimeRange(centiseconds::zero(), centiseconds(100 * getSampleCount() / getSampleRate())); } -bool AudioStream::endOfStream() { +bool AudioStream::endOfStream() const { return getSampleIndex() >= getSampleCount(); } diff --git a/src/audio/AudioStream.h b/src/audio/AudioStream.h index 41df2ff..f368be3 100644 --- a/src/audio/AudioStream.h +++ b/src/audio/AudioStream.h @@ -7,12 +7,12 @@ class AudioStream { public: virtual ~AudioStream() {} - virtual std::unique_ptr clone(bool reset) = 0; - virtual int getSampleRate() = 0; - virtual int getSampleCount() = 0; - TimeRange getTruncatedRange(); - virtual int getSampleIndex() = 0; + virtual std::unique_ptr clone(bool reset) const = 0; + virtual int getSampleRate() const = 0; + virtual int getSampleCount() const = 0; + TimeRange getTruncatedRange() const; + virtual int getSampleIndex() const = 0; virtual void seek(int sampleIndex) = 0; - bool endOfStream(); + bool endOfStream() const; virtual float readSample() = 0; }; diff --git a/src/audio/DCOffset.cpp b/src/audio/DCOffset.cpp index 1316e3b..dcde649 100644 --- a/src/audio/DCOffset.cpp +++ b/src/audio/DCOffset.cpp @@ -14,19 +14,19 @@ DCOffset::DCOffset(const DCOffset& rhs, bool reset) : factor(rhs.factor) {} -std::unique_ptr DCOffset::clone(bool reset) { +std::unique_ptr DCOffset::clone(bool reset) const { return std::make_unique(*this, reset); } -int DCOffset::getSampleRate() { +int DCOffset::getSampleRate() const { return inputStream->getSampleRate(); } -int DCOffset::getSampleCount() { +int DCOffset::getSampleCount() const { return inputStream->getSampleCount(); } -int DCOffset::getSampleIndex() { +int DCOffset::getSampleIndex() const { return inputStream->getSampleIndex(); } diff --git a/src/audio/DCOffset.h b/src/audio/DCOffset.h index 070fd3d..b5d6cb5 100644 --- a/src/audio/DCOffset.h +++ b/src/audio/DCOffset.h @@ -8,10 +8,10 @@ class DCOffset : public AudioStream { public: DCOffset(std::unique_ptr inputStream, float offset); DCOffset(const DCOffset& rhs, bool reset); - std::unique_ptr clone(bool reset) override; - int getSampleRate() override; - int getSampleCount() override; - int getSampleIndex() override; + std::unique_ptr clone(bool reset) const override; + int getSampleRate() const override; + int getSampleCount() const override; + int getSampleIndex() const override; void seek(int sampleIndex) override; float readSample() override; diff --git a/src/audio/SampleRateConverter.cpp b/src/audio/SampleRateConverter.cpp index d94a8f0..0f4b1a0 100644 --- a/src/audio/SampleRateConverter.cpp +++ b/src/audio/SampleRateConverter.cpp @@ -29,19 +29,19 @@ SampleRateConverter::SampleRateConverter(const SampleRateConverter& rhs, bool re nextOutputSampleIndex = reset ? 0 : rhs.nextOutputSampleIndex; } -std::unique_ptr SampleRateConverter::clone(bool reset) { +std::unique_ptr SampleRateConverter::clone(bool reset) const { return std::make_unique(*this, reset); } -int SampleRateConverter::getSampleRate() { +int SampleRateConverter::getSampleRate() const { return outputSampleRate; } -int SampleRateConverter::getSampleCount() { +int SampleRateConverter::getSampleCount() const { return outputSampleCount; } -int SampleRateConverter::getSampleIndex() { +int SampleRateConverter::getSampleIndex() const { return nextOutputSampleIndex; } diff --git a/src/audio/SampleRateConverter.h b/src/audio/SampleRateConverter.h index 50835d4..14dfa21 100644 --- a/src/audio/SampleRateConverter.h +++ b/src/audio/SampleRateConverter.h @@ -7,10 +7,10 @@ class SampleRateConverter : public AudioStream { public: SampleRateConverter(std::unique_ptr inputStream, int outputSampleRate); SampleRateConverter(const SampleRateConverter& rhs, bool reset); - std::unique_ptr clone(bool reset) override; - int getSampleRate() override; - int getSampleCount() override; - int getSampleIndex() override; + std::unique_ptr clone(bool reset) const override; + int getSampleRate() const override; + int getSampleCount() const override; + int getSampleIndex() const override; void seek(int sampleIndex) override; float readSample() override; private: diff --git a/src/audio/UnboundedStream.cpp b/src/audio/UnboundedStream.cpp index cd38ea8..ecd88fb 100644 --- a/src/audio/UnboundedStream.cpp +++ b/src/audio/UnboundedStream.cpp @@ -16,19 +16,19 @@ UnboundedStream::UnboundedStream(const UnboundedStream& rhs, bool reset) : lastSample(rhs.lastSample) {} -std::unique_ptr UnboundedStream::clone(bool reset) { +std::unique_ptr UnboundedStream::clone(bool reset) const { return std::make_unique(*this, reset); } -int UnboundedStream::getSampleRate() { +int UnboundedStream::getSampleRate() const { return innerStream->getSampleRate(); } -int UnboundedStream::getSampleCount() { +int UnboundedStream::getSampleCount() const { return innerStream->getSampleCount(); } -int UnboundedStream::getSampleIndex() { +int UnboundedStream::getSampleIndex() const { return sampleIndex; } diff --git a/src/audio/UnboundedStream.h b/src/audio/UnboundedStream.h index d20e441..09bc787 100644 --- a/src/audio/UnboundedStream.h +++ b/src/audio/UnboundedStream.h @@ -8,10 +8,10 @@ class UnboundedStream : public AudioStream { public: UnboundedStream(std::unique_ptr inputStream); UnboundedStream(const UnboundedStream& rhs, bool reset); - std::unique_ptr clone(bool reset) override; - int getSampleRate() override; - int getSampleCount() override; - int getSampleIndex() override; + std::unique_ptr clone(bool reset) const override; + int getSampleRate() const override; + int getSampleCount() const override; + int getSampleIndex() const override; void seek(int sampleIndex) override; float readSample() override; diff --git a/src/audio/WaveFileReader.cpp b/src/audio/WaveFileReader.cpp index 269879e..f3b574a 100644 --- a/src/audio/WaveFileReader.cpp +++ b/src/audio/WaveFileReader.cpp @@ -148,7 +148,7 @@ WaveFileReader::WaveFileReader(const WaveFileReader& rhs, bool reset) : seek(reset ? 0 : rhs.sampleIndex); } -std::unique_ptr WaveFileReader::clone(bool reset) { +std::unique_ptr WaveFileReader::clone(bool reset) const { return std::make_unique(*this, reset); } @@ -170,15 +170,15 @@ void WaveFileReader::openFile() { } } -int WaveFileReader::getSampleRate() { +int WaveFileReader::getSampleRate() const { return frameRate; } -int WaveFileReader::getSampleCount() { +int WaveFileReader::getSampleCount() const { return frameCount; } -int WaveFileReader::getSampleIndex() { +int WaveFileReader::getSampleIndex() const { return sampleIndex; } diff --git a/src/audio/WaveFileReader.h b/src/audio/WaveFileReader.h index 3946a2a..4b34ec3 100644 --- a/src/audio/WaveFileReader.h +++ b/src/audio/WaveFileReader.h @@ -15,10 +15,10 @@ class WaveFileReader : public AudioStream { public: WaveFileReader(boost::filesystem::path filePath); WaveFileReader(const WaveFileReader& rhs, bool reset); - std::unique_ptr clone(bool reset) override; - int getSampleRate() override ; - int getSampleCount() override; - int getSampleIndex() override; + std::unique_ptr clone(bool reset) const override; + int getSampleRate() const override ; + int getSampleCount() const override; + int getSampleIndex() const override; void seek(int sampleIndex) override; float readSample() override;