Skip to content

Commit c801a88

Browse files
committed
merge main into shared
1 parent 6925c98 commit c801a88

File tree

1 file changed

+15
-15
lines changed

1 file changed

+15
-15
lines changed

src/conversion.cpp

+15-15
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
#include <cmath>
77
#include "symusic/conversion.h"
88
#include "symusic/ops.h"
9-
#include "symusic/mtype.h"
109

1110
namespace symusic {
1211

@@ -53,9 +52,8 @@ struct SimpleConverter {
5352
}
5453

5554
template<template<class> class T>
56-
[[nodiscard]] pyvec<T<To>> duration_vec(
57-
const pyvec<T<From>>& data, typename To::unit min_dur
58-
) const {
55+
[[nodiscard]] pyvec<T<To>> duration_vec(const pyvec<T<From>>& data, typename To::unit min_dur)
56+
const {
5957
const auto self = static_cast<const Converter*>(this);
6058
min_dur = std::max(min_dur, static_cast<typename To::unit>(0));
6159

@@ -352,30 +350,32 @@ shared<pyvec<T>> resample_dur(
352350
capsule.reserve(data.size());
353351

354352
for (const auto& item : data) {
355-
capsule.emplace_back(
356-
convert(item->time), std::max(convert(item->duration), min_dur), item
357-
);
353+
capsule.emplace_back(convert(item->time), std::max(convert(item->duration), min_dur), item);
358354
}
359355
return std::make_shared<pyvec<T>>(std::move(capsule));
360356
}
361357

362358
Score<Tick> resample_inner(const Score<Tick>& score, const i32 tpq, const i32 min_dur) {
363-
if(tpq <= 0) {
359+
if (tpq <= 0) {
364360
throw std::invalid_argument("symusic::resample: ticks_per_quarter must be positive");
365361
}
366-
if(min_dur < 0) {
362+
if (min_dur < 0) {
367363
throw std::invalid_argument("symusic::resample: min_dur must be non-negative");
368364
}
369365
Score<Tick> ans(tpq);
370-
const f64 scale_rate = static_cast<f64>(tpq) / static_cast<f64>(score.ticks_per_quarter);
366+
const f64 scale_rate = static_cast<f64>(tpq) / static_cast<f64>(score.ticks_per_quarter);
367+
371368
auto f64toi32 = [](const f64 x) {
372-
if(x > static_cast<f64>(std::numeric_limits<i32>::max())) {
373-
throw std::overflow_error("symusic::resample: time after resample (" + std::to_string(x) + ") is out of int32 range");
374-
} return static_cast<i32>(std::round(x));
369+
if (x > static_cast<f64>(std::numeric_limits<i32>::max())) {
370+
throw std::overflow_error(
371+
"symusic::resample: time after resample (" + std::to_string(x)
372+
+ ") is out of int32 range"
373+
);
374+
}
375+
return static_cast<i32>(std::round(x));
375376
};
376377

377-
const auto from_tpq = static_cast<double>(score.ticks_per_quarter);
378-
auto convert = [f64toi32, scale_rate](const Tick::unit t) -> Tick::unit {
378+
auto convert = [f64toi32, scale_rate](const Tick::unit t) -> Tick::unit {
379379
return f64toi32(scale_rate * static_cast<f64>(t));
380380
};
381381

0 commit comments

Comments
 (0)