Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Find single characters rather than single character strings. #75

Merged
merged 2 commits into from
Nov 21, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions include/TuningsImpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ inline std::istream &getlineEndingIndependent(std::istream &is, std::string &t)
t.clear();

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ooooh removing the sentry is not correct. Thats a guard class which sets internal bits

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@baconpaul
OK, so perhaps the fix should be to test the sentry object is valid after construction?
That way it wouldn't be flagged as unused by an analyser.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@baconpaul See what you think of the latest commit.

std::istream::sentry se(is, true);
if (!se)
return is;

std::streambuf *sb = is.rdbuf();

for (;;)
Expand Down Expand Up @@ -72,15 +75,15 @@ inline Tone toneFromString(const std::string &line, int lineno)
Tone t;
t.stringRep = line;
t.lineno = lineno;
if (line.find(".") != std::string::npos)
if (line.find('.') != std::string::npos)
{
t.type = Tone::kToneCents;
t.cents = locale_atof(line.c_str());
}
else
{
t.type = Tone::kToneRatio;
auto slashPos = line.find("/");
auto slashPos = line.find('/');
if (slashPos == std::string::npos)
{
t.ratio_n = atoll(line.c_str());
Expand Down Expand Up @@ -508,7 +511,7 @@ inline Tuning::Tuning(const Scale &s_, const KeyboardMapping &k_, bool allowTuni
{
for (const auto &t : s.tones)
{
auto tCopy = t;
Tunings::Tone tCopy = t;
tCopy.type = Tone::kToneCents;
tCopy.cents += pushOff;
tCopy.floatValue = tCopy.cents / 1200.0 + 1;
Expand All @@ -531,8 +534,6 @@ inline Tuning::Tuning(const Scale &s_, const KeyboardMapping &k_, bool allowTuni
" to smaller scale of size " + std::to_string(s.count));
}

double pitches[N];

int posPitch0 = 256 + k.tuningConstantNote;
int posScale0 = 256 + useMiddleNote;

Expand Down Expand Up @@ -633,6 +634,8 @@ inline Tuning::Tuning(const Scale &s_, const KeyboardMapping &k_, bool allowTuni
}
}

double pitches[N];

for (int i = 0; i < N; ++i)
{
// TODO: ScaleCenter and PitchCenter are now two different notes.
Expand Down
Loading