/*** Olive - Non-Linear Video Editor Copyright (C) 2019 Olive Team This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . ***/ #include "paneffect.h" #include #include #include #include #include "ui/labelslider.h" #include "ui/collapsiblewidget.h" PanEffect::PanEffect(Clip* c, const EffectMeta *em) : Effect(c, em) { EffectRow* pan_row = new EffectRow(this, tr("Pan")); pan_val = new DoubleField(pan_row, "pan"); pan_val->SetMinimum(-100); pan_val->SetDefault(0); pan_val->SetMaximum(100); } void PanEffect::process_audio(double timecode_start, double timecode_end, float **samples, int nb_samples, int channel_count, int type) { // This has no effect on mono sources if (channel_count < 2) { return; } double interval = (timecode_end - timecode_start)/nb_samples; for (int i=0;iGetDoubleAt(timecode_start+(interval*i)); double pval = log_volume(qAbs(pan_field_val)*0.01); if (pan_field_val < 0) { // affect right channel samples[1][i] *= (1.0-pval); } else { // affect left channel samples[0][i] *= (1.0-pval); } } }