diff options
author | André Nusser <andre.nusser@googlemail.com> | 2020-04-17 23:32:32 +0200 |
---|---|---|
committer | André Nusser <andre.nusser@googlemail.com> | 2020-04-17 23:32:32 +0200 |
commit | 4191e78012ad4cd5fc216aa355ee97a682065ce4 (patch) | |
tree | ac40968eed1b85b0e77b37d2e3158977d8a724f9 /src/powermap.cc | |
parent | 20c5726e9442ebaf3711043cc0f317a600fb9c75 (diff) |
Initial design of the Powermap class.
Diffstat (limited to 'src/powermap.cc')
-rw-r--r-- | src/powermap.cc | 66 |
1 files changed, 66 insertions, 0 deletions
diff --git a/src/powermap.cc b/src/powermap.cc new file mode 100644 index 0000000..6a5bba0 --- /dev/null +++ b/src/powermap.cc @@ -0,0 +1,66 @@ +/* -*- Mode: c++ -*- */ +/*************************************************************************** + * powermap.cc + * + * Fri Apr 17 23:06:12 CEST 2020 + * Copyright 2020 André Nusser + * andre.nusser@googlemail.com + ****************************************************************************/ + +/* + * This file is part of DrumGizmo. + * + * DrumGizmo is free software; you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * DrumGizmo 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 Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with DrumGizmo; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. + */ +#include "powermap.h" + +#include <cmath> + +Power Powermap::map(Power in) const +{ + if (in < fixed_map.in) { + return a1*pow(in,3) + b1*pow(in,2) + c1*in + d1; + } + else { + return a2*pow(in,3) + b2*pow(in,2) + c2*in + d2; + } +} + +void Powermap::reset() +{ + min_input = 0.; + max_input = 1.; + fixed_map = {.5, .5}; +} + +void Powermap::setMinInput(Power min_input) +{ + this->min_input = min_input; +} + +void Powermap::setMaxInput(Power max_input) +{ + this->max_input = max_input; +} + +void Powermap::setFixed(PowerPair fixed) +{ + this->fixed = fixed; +} + +void Powermap::updateSpline() +{ + // TODO +} |