samplebuffer: added convenience functions for altering sample data
This commit is contained in:
@@ -193,6 +193,34 @@ void SampleBuffer::speed(double speed)
|
||||
data_ = output_data;
|
||||
}
|
||||
|
||||
void SampleBuffer::transform_volume(float f)
|
||||
{
|
||||
for (int i=0;i<audio_params().channel_count();i++) {
|
||||
for (int j=0;j<sample_count_per_channel_;j++) {
|
||||
data_[i][j] *= f;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void SampleBuffer::transform_volume_for_channel(int channel, float volume)
|
||||
{
|
||||
for (int i=0;i<sample_count_per_channel_;i++) {
|
||||
data_[channel][i] *= volume;
|
||||
}
|
||||
}
|
||||
|
||||
void SampleBuffer::transform_volume_for_sample(int sample_index, float volume)
|
||||
{
|
||||
for (int i=0;i<audio_params().channel_count();i++) {
|
||||
data_[i][sample_index] *= volume;
|
||||
}
|
||||
}
|
||||
|
||||
void SampleBuffer::transform_volume_for_sample_on_channel(int sample_index, int channel, float volume)
|
||||
{
|
||||
data_[channel][sample_index] *= volume;
|
||||
}
|
||||
|
||||
void SampleBuffer::fill(const float &f)
|
||||
{
|
||||
fill(f, 0, sample_count_per_channel_);
|
||||
|
||||
@@ -60,7 +60,6 @@ public:
|
||||
float** data();
|
||||
const float** const_data() const;
|
||||
float* channel_data(int channel);
|
||||
float* sample_data(int index);
|
||||
|
||||
bool is_allocated() const;
|
||||
void allocate();
|
||||
@@ -68,6 +67,10 @@ public:
|
||||
|
||||
void reverse();
|
||||
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 fill(const float& f);
|
||||
void fill(const float& f, int start_sample, int end_sample);
|
||||
|
||||
Reference in New Issue
Block a user