Files
foo_input_joc/kernel/src/foundation/metadata_timing.h
T
TheM14 7cebf3e22e
build / windows (push) Canceled after 0s
build / release (push) Canceled after 0s
Sync the kernel copy with the OAMD ramp timing port
2026-10-28 18:11:57 +08:00

26 lines
1.0 KiB
C++

// Port of src/oamd_tracks.py align_metadata_sample: an OAMD position update is
// scheduled on the renderer's processing-block grid, the same 32-sample grid the
// speaker control blocks use. It lives in foundation because both the ADM track
// builder and the object position timeline need it, and the timeline must not
// depend on output.
#pragma once
#include <cstdint>
namespace joc::timing {
inline constexpr std::int64_t kMetadataBlockSamples = 32;
// Nearest block boundary, ties towards the earlier block; the negative branch
// floors like the reference's Python `//`.
inline std::int64_t align_metadata_sample(std::int64_t sample,
std::int64_t block_samples = kMetadataBlockSamples) {
const std::int64_t numerator = sample + block_samples / 2 - 1;
const std::int64_t quotient =
numerator >= 0 ? numerator / block_samples
: -((-numerator + block_samples - 1) / block_samples);
return block_samples * quotient;
}
} // namespace joc::timing