samplebuffer: use std::vector and size_t for all calculations
This commit is contained in:
+16
-16
@@ -40,13 +40,13 @@ class SampleBuffer
|
||||
public:
|
||||
SampleBuffer();
|
||||
SampleBuffer(const AudioParams& audio_params, const rational& length);
|
||||
SampleBuffer(const AudioParams& audio_params, int samples_per_channel);
|
||||
SampleBuffer(const AudioParams& audio_params, size_t samples_per_channel);
|
||||
|
||||
const AudioParams& audio_params() const;
|
||||
void set_audio_params(const AudioParams& params);
|
||||
|
||||
const int &sample_count() const;
|
||||
void set_sample_count(const int &sample_count);
|
||||
const size_t &sample_count() const { return sample_count_per_channel_; }
|
||||
void set_sample_count(const size_t &sample_count);
|
||||
void set_sample_count(const rational &length)
|
||||
{
|
||||
set_sample_count(audio_params_.time_to_samples(length));
|
||||
@@ -59,13 +59,13 @@ public:
|
||||
|
||||
const float* data(int channel) const
|
||||
{
|
||||
return data_.at(channel).constData();
|
||||
return data_.at(channel).data();
|
||||
}
|
||||
|
||||
QVector<float *> to_raw_ptrs()
|
||||
std::vector<float *> to_raw_ptrs()
|
||||
{
|
||||
QVector<float *> r(data_.size());
|
||||
for (int i=0; i<r.size(); i++) {
|
||||
std::vector<float *> r(data_.size());
|
||||
for (size_t i=0; i<r.size(); i++) {
|
||||
r[i] = data_[i].data();
|
||||
}
|
||||
return r;
|
||||
@@ -73,7 +73,7 @@ public:
|
||||
|
||||
int channel_count() const { return data_.size(); }
|
||||
|
||||
bool is_allocated() const;
|
||||
bool is_allocated() const { return !data_.empty(); }
|
||||
void allocate();
|
||||
void destroy();
|
||||
|
||||
@@ -81,17 +81,17 @@ public:
|
||||
void speed(double speed);
|
||||
void transform_volume(float f);
|
||||
void transform_volume_for_channel(int channel, float volume);
|
||||
void transform_volume_for_sample(int sample_index, float volume);
|
||||
void transform_volume_for_sample_on_channel(int sample_index, int channel, float volume);
|
||||
void transform_volume_for_sample(size_t sample_index, float volume);
|
||||
void transform_volume_for_sample_on_channel(size_t sample_index, int channel, float volume);
|
||||
|
||||
void clamp();
|
||||
|
||||
void silence();
|
||||
void silence(int start_sample, int end_sample);
|
||||
void silence_bytes(int start_byte, int end_byte);
|
||||
void silence(size_t start_sample, size_t end_sample);
|
||||
void silence_bytes(size_t start_byte, size_t end_byte);
|
||||
|
||||
void set(int channel, const float* data, int sample_offset, int sample_length);
|
||||
void set(int channel, const float* data, int sample_length)
|
||||
void set(int channel, const float* data, size_t sample_offset, size_t sample_length);
|
||||
void set(int channel, const float* data, size_t sample_length)
|
||||
{
|
||||
set(channel, data, 0, sample_length);
|
||||
}
|
||||
@@ -101,9 +101,9 @@ private:
|
||||
|
||||
AudioParams audio_params_;
|
||||
|
||||
int sample_count_per_channel_;
|
||||
size_t sample_count_per_channel_;
|
||||
|
||||
QVector< QVector<float> > data_;
|
||||
std::vector< std::vector<float> > data_;
|
||||
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user