Minor code cleanup

pull/170/head
James Ball 2023-11-25 18:45:04 +00:00
rodzic 34c215bca7
commit 553e672f84
9 zmienionych plików z 28 dodań i 32 usunięć

Wyświetl plik

@ -39,8 +39,9 @@ http://www.audiosynth.com
#include "Env.h" #include "Env.h"
Env::Env(std::vector<double> levels, Env::Env(
std::vector<double> times, const std::vector<double>& levels,
const std::vector<double>& times,
EnvCurveList const& curves, EnvCurveList const& curves,
const int releaseNode, const int releaseNode,
const int loopNode) throw() const int loopNode) throw()

Wyświetl plik

@ -69,8 +69,8 @@ public:
/** /**
Creates an Env with supplied specification. Creates an Env with supplied specification.
*/ */
Env(std::vector<double> levels = { 0.0, 1.0, 0.0 }, /**< A Buffer of levels. e.g. B(0.0, 1.0, 1.0, 0.0) you can also use the macro LL - List Levels. */ Env(const std::vector<double>& levels = { 0.0, 1.0, 0.0 }, /**< A Buffer of levels. e.g. B(0.0, 1.0, 1.0, 0.0) you can also use the macro LL - List Levels. */
std::vector<double> times = { 1.0, 1.0 }, /**< A Buffer of times. e.g., B(0.1, 0.8, 0.1) would have a total duration of 1sec. Macro LT - List Times can be used. const std::vector<double>& times = { 1.0, 1.0 }, /**< A Buffer of times. e.g., B(0.1, 0.8, 0.1) would have a total duration of 1sec. Macro LT - List Times can be used.
There should be one fewer time than level. */ There should be one fewer time than level. */
EnvCurveList const& curves = EnvCurve(EnvCurve::Linear), /**< The shape of each segment. An EnvCurveList, with upto EnvCurveList const& curves = EnvCurve(EnvCurve::Linear), /**< The shape of each segment. An EnvCurveList, with upto
the same number of elements as the times Buffer. the same number of elements as the times Buffer.

Wyświetl plik

@ -41,9 +41,7 @@ EnvCurveList::EnvCurveList(EnvCurve const& i00) throw() {
data.push_back(i00); data.push_back(i00);
} }
EnvCurveList::EnvCurveList(std::vector<EnvCurve> curves) throw() { EnvCurveList::EnvCurveList(const std::vector<EnvCurve>& curves) throw() : data(curves) {}
data = curves;
}
EnvCurveList::EnvCurveList(EnvCurve::CurveType type, const int size) throw(){ EnvCurveList::EnvCurveList(EnvCurve::CurveType type, const int size) throw(){
for(int i = 0; i < size; i++) for(int i = 0; i < size; i++)

Wyświetl plik

@ -112,7 +112,7 @@ public:
/// @{ /// @{
EnvCurveList(EnvCurve const& i00) throw(); EnvCurveList(EnvCurve const& i00) throw();
EnvCurveList(std::vector<EnvCurve>) throw(); EnvCurveList(const std::vector<EnvCurve>&) throw();
EnvCurveList(EnvCurve::CurveType type, const int size = 1) throw(); EnvCurveList(EnvCurve::CurveType type, const int size = 1) throw();
EnvCurveList(const double curve, const int size = 1) throw(); EnvCurveList(const double curve, const int size = 1) throw();

Wyświetl plik

@ -1,15 +1,19 @@
#include "Effect.h" #include "Effect.h"
#include <numbers> #include <numbers>
Effect::Effect(std::shared_ptr<EffectApplication> effectApplication, std::vector<EffectParameter*> parameters) : effectApplication(effectApplication), parameters(parameters), enabled(nullptr) { Effect::Effect(std::shared_ptr<EffectApplication> effectApplication, const std::vector<EffectParameter*>& parameters) :
actualValues = std::vector<double>(parameters.size(), 0.0); effectApplication(effectApplication),
} parameters(parameters),
enabled(nullptr),
actualValues(std::vector<double>(parameters.size(), 0.0)) {}
Effect::Effect(std::shared_ptr<EffectApplication> effectApplication, EffectParameter* parameter) : Effect(effectApplication, std::vector<EffectParameter*>{parameter}) {} Effect::Effect(std::shared_ptr<EffectApplication> effectApplication, EffectParameter* parameter) : Effect(effectApplication, std::vector<EffectParameter*>{parameter}) {}
Effect::Effect(std::function<Vector2(int, Vector2, const std::vector<double>&, double)> application, std::vector<EffectParameter*> parameters) : application(application), parameters(parameters), enabled(nullptr) { Effect::Effect(std::function<Vector2(int, Vector2, const std::vector<double>&, double)> application, const std::vector<EffectParameter*>& parameters) :
actualValues = std::vector<double>(parameters.size(), 0.0); application(application),
} parameters(parameters),
enabled(nullptr),
actualValues(std::vector<double>(parameters.size(), 0.0)) {}
Effect::Effect(std::function<Vector2(int, Vector2, const std::vector<double>&, double)> application, EffectParameter* parameter) : Effect(application, std::vector<EffectParameter*>{parameter}) {} Effect::Effect(std::function<Vector2(int, Vector2, const std::vector<double>&, double)> application, EffectParameter* parameter) : Effect(application, std::vector<EffectParameter*>{parameter}) {}

Wyświetl plik

@ -8,9 +8,9 @@
class Effect { class Effect {
public: public:
Effect(std::shared_ptr<EffectApplication> effectApplication, std::vector<EffectParameter*> parameters); Effect(std::shared_ptr<EffectApplication> effectApplication, const std::vector<EffectParameter*>& parameters);
Effect(std::shared_ptr<EffectApplication> effectApplication, EffectParameter* parameter); Effect(std::shared_ptr<EffectApplication> effectApplication, EffectParameter* parameter);
Effect(std::function<Vector2(int, Vector2, const std::vector<double>&, double)> application, std::vector<EffectParameter*> parameters); Effect(std::function<Vector2(int, Vector2, const std::vector<double>&, double)> application, const std::vector<EffectParameter*>& parameters);
Effect(std::function<Vector2(int, Vector2, const std::vector<double>&, double)> application, EffectParameter* parameter); Effect(std::function<Vector2(int, Vector2, const std::vector<double>&, double)> application, EffectParameter* parameter);
Vector2 apply(int index, Vector2 input); Vector2 apply(int index, Vector2 input);

Wyświetl plik

@ -214,12 +214,12 @@ void Matching::Expand(int start, bool expandBlocked = false)
for (list<int>::iterator it = shallow[u].begin(); it != shallow[u].end() and not found; ) for (list<int>::iterator it = shallow[u].begin(); it != shallow[u].end() and not found; )
{ {
int si = *it; int si = *it;
for (vector<int>::iterator jt = deep[si].begin(); jt != deep[si].end() and not found; jt++) for (vector<int>::iterator jt = deep[si].begin(); jt != deep[si].end() and not found; ++jt)
{ {
if (*jt == p) if (*jt == p)
found = true; found = true;
} }
it++; ++it;
if (not found) if (not found)
{ {
shallow[u].push_back(si); shallow[u].push_back(si);
@ -230,16 +230,16 @@ void Matching::Expand(int start, bool expandBlocked = false)
list<int>::iterator it = shallow[u].begin(); list<int>::iterator it = shallow[u].begin();
//Adjust the mate of the tip //Adjust the mate of the tip
mate[*it] = mate[u]; mate[*it] = mate[u];
it++; ++it;
// //
//Now we go through the odd circuit adjusting the new mates //Now we go through the odd circuit adjusting the new mates
while (it != shallow[u].end()) while (it != shallow[u].end())
{ {
list<int>::iterator itnext = it; list<int>::iterator itnext = it;
itnext++; ++itnext;
mate[*it] = *itnext; mate[*it] = *itnext;
mate[*itnext] = *it; mate[*itnext] = *it;
itnext++; ++itnext;
it = itnext; it = itnext;
} }
@ -378,7 +378,7 @@ int Matching::Blossom(int u, int v)
shallow[t].clear(); shallow[t].clear();
deep[t].clear(); deep[t].clear();
for(list<int>::iterator it = circuit.begin(); it != circuit.end(); it++) for(list<int>::iterator it = circuit.begin(); it != circuit.end(); ++it)
{ {
shallow[t].push_back(*it); shallow[t].push_back(*it);
} }
@ -547,16 +547,9 @@ pair< list<int>, double> Matching::SolveMinimumCostPerfectMatching(vector<double
list<int> matching = RetrieveMatching(); list<int> matching = RetrieveMatching();
double obj = 0; double obj = 0;
for(list<int>::iterator it = matching.begin(); it != matching.end(); it++) for(list<int>::iterator it = matching.begin(); it != matching.end(); ++it)
obj += cost[*it]; obj += cost[*it];
double dualObj = 0;
for(int i = 0; i < 2*n; i++)
{
if(i < n) dualObj += dual[i];
else if(blocked[i]) dualObj += dual[i];
}
return pair< list<int>, double >(matching, obj); return pair< list<int>, double >(matching, obj);
} }

Wyświetl plik

@ -42,7 +42,7 @@ std::vector<std::vector<int>> ConnectedComponents(Graph& G) {
return components; return components;
} }
WorldObject::WorldObject(std::string obj_string) { WorldObject::WorldObject(const std::string& obj_string) {
tinyobj::ObjReaderConfig reader_config; tinyobj::ObjReaderConfig reader_config;
reader_config.triangulate = false; reader_config.triangulate = false;
reader_config.vertex_color = false; reader_config.vertex_color = false;

Wyświetl plik

@ -4,7 +4,7 @@
class WorldObject { class WorldObject {
public: public:
WorldObject(std::string); WorldObject(const std::string&);
void setBaseRotationX(double x); void setBaseRotationX(double x);
void setBaseRotationY(double y); void setBaseRotationY(double y);