Skip to content

Commit

Permalink
Add converter methods
Browse files Browse the repository at this point in the history
  • Loading branch information
lpugin committed Dec 16, 2024
1 parent 7907644 commit 8da8e58
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
15 changes: 15 additions & 0 deletions libmei/addons/att.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,21 @@ data_BULGE Att::StrToBulge(const std::string &value, bool logWarning) const
return bulge;
}

std::string Att::DegreesToStr(data_DEGREES data) const
{
return StringFormat("%f", data);
}

data_DEGREES Att::StrToDegrees(const std::string &value, bool logWarning) const
{
double degrees = atof(value.c_str());
if ((degrees > 360.0) || (degrees < -360.0)) {
if (logWarning) LogWarning("Unsupported data.DEGREES '%s'", value.c_str());
return 0;
}
return degrees;
}

std::string Att::DurationToStr(data_DURATION data) const
{
std::string value;
Expand Down
3 changes: 3 additions & 0 deletions libmei/addons/att.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,9 @@ class Att : public AttConverterBase {
std::string BulgeToStr(const data_BULGE &data) const;
data_BULGE StrToBulge(const std::string &value, bool logWarning = true) const;

std::string DegreesToStr(data_DEGREES data) const;
data_DEGREES StrToDegrees(const std::string &value, bool logWarning = true) const;

std::string DurationToStr(data_DURATION data) const;
data_DURATION StrToDuration(const std::string &value, bool = true) const;

Expand Down

0 comments on commit 8da8e58

Please sign in to comment.