mirror of
https://github.com/TomHarte/CLK.git
synced 2024-09-27 18:55:48 +00:00
Sometimes avoid unnecessary zero-fills.
This commit is contained in:
parent
f14e45f93e
commit
507c3da927
@ -49,23 +49,10 @@ template <typename... T> class CompoundSource:
|
|||||||
private:
|
private:
|
||||||
template <typename... S> class CompoundSourceHolder {
|
template <typename... S> class CompoundSourceHolder {
|
||||||
public:
|
public:
|
||||||
template <Outputs::Speaker::Action action, bool output_stereo>
|
|
||||||
void apply_samples(std::size_t number_of_samples, typename SampleT<output_stereo>::type *target) {
|
|
||||||
// Default-construct all samples, to fill with silence.
|
|
||||||
Outputs::Speaker::fill<action>(target, target + number_of_samples, typename SampleT<output_stereo>::type());
|
|
||||||
}
|
|
||||||
|
|
||||||
void set_scaled_volume_range(int16_t, double *, double) {}
|
|
||||||
|
|
||||||
static constexpr std::size_t size() {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static constexpr bool is_stereo = false;
|
static constexpr bool is_stereo = false;
|
||||||
|
void set_scaled_volume_range(int16_t, double *, double) {}
|
||||||
double total_scale(double *) const {
|
static constexpr std::size_t size() { return 0; }
|
||||||
return 0.0;
|
double total_scale(double *) const { return 0.0; }
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
template <typename S, typename... R> class CompoundSourceHolder<S, R...> {
|
template <typename S, typename... R> class CompoundSourceHolder<S, R...> {
|
||||||
@ -95,17 +82,24 @@ template <typename... T> class CompoundSource:
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get the rest of the output.
|
constexpr bool is_final_source = sizeof...(R) == 0;
|
||||||
next_source_.template apply_samples<action, output_stereo>(number_of_samples, target);
|
|
||||||
|
// Get the rest of the output, if any.
|
||||||
|
if constexpr (!is_final_source) {
|
||||||
|
next_source_.template apply_samples<action, output_stereo>(number_of_samples, target);
|
||||||
|
}
|
||||||
|
|
||||||
if(source_.is_zero_level()) {
|
if(source_.is_zero_level()) {
|
||||||
// This component is currently outputting silence; therefore don't add anything to the output
|
// This component is currently outputting silence; therefore don't add anything to the output
|
||||||
// audio — just pass the call onward.
|
// audio. Zero fill only if this is the final source (as everything above will be additive).
|
||||||
|
if constexpr (is_final_source) {
|
||||||
|
Outputs::Speaker::fill<action>(target, target + number_of_samples, typename SampleT<output_stereo>::type());
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add in this component's output.
|
// Add in this component's output.
|
||||||
source_.template apply_samples<Action::Mix>(number_of_samples, target);
|
source_.template apply_samples<is_final_source ? Action::Store : Action::Mix>(number_of_samples, target);
|
||||||
}
|
}
|
||||||
|
|
||||||
void set_scaled_volume_range(int16_t range, double *volumes, double scale) {
|
void set_scaled_volume_range(int16_t range, double *volumes, double scale) {
|
||||||
|
Loading…
Reference in New Issue
Block a user