diff --git a/include/Score.hpp b/include/Score.hpp index 776e9f1..ca788bd 100644 --- a/include/Score.hpp +++ b/include/Score.hpp @@ -1419,7 +1419,7 @@ void Score::from(const Score &other, const std::optional min_dur) { auto new_pedals = other.template convert_ttype(track.pedals); if constexpr (std::is_same_v) { if(min_dur.has_value()) { - const auto min_dur_tick = min_dur.value(); + const auto min_dur_tick = *min_dur; for(auto ¬e: new_notes) { if(note.duration < min_dur_tick) note.duration = min_dur_tick; } diff --git a/src/symusic.cpp b/src/symusic.cpp index c6b6eb6..57a4146 100644 --- a/src/symusic.cpp +++ b/src/symusic.cpp @@ -181,8 +181,8 @@ py::class_> bind_tempo_class(py::module &m, const std::string & return time_stamp_base>(m, name) // .def(py::init(), py::arg("time"), py::arg("qpm")) .def(py::init([](unit time, std::optional qpm, std::optional mspq) { - if (qpm.has_value()) return score::Tempo::from_qpm(time, qpm.value()); - else if (mspq.has_value()) return score::Tempo(time, mspq.value()); + if (qpm.has_value()) return score::Tempo::from_qpm(time, *qpm); + else if (mspq.has_value()) return score::Tempo(time, *mspq); else throw std::invalid_argument("qpm or mspq must be specified"); }), py::arg("time"), py::arg("qpm")=py::none(), py::arg("mspq")=py::none()) .def_readwrite("mspq", &score::Tempo::mspq, "Microseconds per quarter note") @@ -513,13 +513,15 @@ py::module & core_module(py::module & m){ py::init &, std::optional>(), "Convert Quarter to Tick", py::arg("other"), py::arg("min_dur")=std::nullopt) .def("to", &convert_score, py::arg("ttype"), py::arg("min_dur") = std::nullopt, "Convert to another time unit") .def("resample", [](const Score &self, const i32 tpq, const std::optional min_dur) { - return resample(self, tpq, min_dur.value_or(0)); + const auto min_dur_ = min_dur.has_value()? *min_dur: 0; + return resample(self, tpq, min_dur_); }, py::arg("tpq"), py::arg("min_dur")=std::nullopt, "Resample to another ticks per quarter"); score_quarter.def( py::init &, std::optional>(), "Convert Tick to Quarter", py::arg("other"), py::arg("min_dur")=std::nullopt) .def("to", &convert_score, py::arg("ttype"), py::arg("min_dur")=std::nullopt, "Convert to another time unit") .def("resample", [](const Score &self, const i32 tpq, const std::optional min_dur) { - return resample(Score(self), tpq, min_dur.value_or(0)); + const auto min_dur_ = min_dur.has_value()? *min_dur: 0; + return resample(Score(self), tpq, min_dur_); }, py::arg("tpq"), py::arg("min_dur")=std::nullopt, "Resample to another ticks per quarter"); // bind_score_class(m, second); return m;