Fixed constness

This commit is contained in:
Daniel Wolf 2016-04-19 21:12:44 +02:00
parent c14fb1c7b2
commit ce204c68de
10 changed files with 40 additions and 40 deletions

View File

@ -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();
}

View File

@ -7,12 +7,12 @@
class AudioStream {
public:
virtual ~AudioStream() {}
virtual std::unique_ptr<AudioStream> clone(bool reset) = 0;
virtual int getSampleRate() = 0;
virtual int getSampleCount() = 0;
TimeRange getTruncatedRange();
virtual int getSampleIndex() = 0;
virtual std::unique_ptr<AudioStream> 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;
};

View File

@ -14,19 +14,19 @@ DCOffset::DCOffset(const DCOffset& rhs, bool reset) :
factor(rhs.factor)
{}
std::unique_ptr<AudioStream> DCOffset::clone(bool reset) {
std::unique_ptr<AudioStream> DCOffset::clone(bool reset) const {
return std::make_unique<DCOffset>(*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();
}

View File

@ -8,10 +8,10 @@ class DCOffset : public AudioStream {
public:
DCOffset(std::unique_ptr<AudioStream> inputStream, float offset);
DCOffset(const DCOffset& rhs, bool reset);
std::unique_ptr<AudioStream> clone(bool reset) override;
int getSampleRate() override;
int getSampleCount() override;
int getSampleIndex() override;
std::unique_ptr<AudioStream> 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;

View File

@ -29,19 +29,19 @@ SampleRateConverter::SampleRateConverter(const SampleRateConverter& rhs, bool re
nextOutputSampleIndex = reset ? 0 : rhs.nextOutputSampleIndex;
}
std::unique_ptr<AudioStream> SampleRateConverter::clone(bool reset) {
std::unique_ptr<AudioStream> SampleRateConverter::clone(bool reset) const {
return std::make_unique<SampleRateConverter>(*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;
}

View File

@ -7,10 +7,10 @@ class SampleRateConverter : public AudioStream {
public:
SampleRateConverter(std::unique_ptr<AudioStream> inputStream, int outputSampleRate);
SampleRateConverter(const SampleRateConverter& rhs, bool reset);
std::unique_ptr<AudioStream> clone(bool reset) override;
int getSampleRate() override;
int getSampleCount() override;
int getSampleIndex() override;
std::unique_ptr<AudioStream> 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:

View File

@ -16,19 +16,19 @@ UnboundedStream::UnboundedStream(const UnboundedStream& rhs, bool reset) :
lastSample(rhs.lastSample)
{}
std::unique_ptr<AudioStream> UnboundedStream::clone(bool reset) {
std::unique_ptr<AudioStream> UnboundedStream::clone(bool reset) const {
return std::make_unique<UnboundedStream>(*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;
}

View File

@ -8,10 +8,10 @@ class UnboundedStream : public AudioStream {
public:
UnboundedStream(std::unique_ptr<AudioStream> inputStream);
UnboundedStream(const UnboundedStream& rhs, bool reset);
std::unique_ptr<AudioStream> clone(bool reset) override;
int getSampleRate() override;
int getSampleCount() override;
int getSampleIndex() override;
std::unique_ptr<AudioStream> 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;

View File

@ -148,7 +148,7 @@ WaveFileReader::WaveFileReader(const WaveFileReader& rhs, bool reset) :
seek(reset ? 0 : rhs.sampleIndex);
}
std::unique_ptr<AudioStream> WaveFileReader::clone(bool reset) {
std::unique_ptr<AudioStream> WaveFileReader::clone(bool reset) const {
return std::make_unique<WaveFileReader>(*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;
}

View File

@ -15,10 +15,10 @@ class WaveFileReader : public AudioStream {
public:
WaveFileReader(boost::filesystem::path filePath);
WaveFileReader(const WaveFileReader& rhs, bool reset);
std::unique_ptr<AudioStream> clone(bool reset) override;
int getSampleRate() override ;
int getSampleCount() override;
int getSampleIndex() override;
std::unique_ptr<AudioStream> 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;