61 lines
1.4 KiB
C++
61 lines
1.4 KiB
C++
#pragma once
|
|
|
|
#include <cstdint>
|
|
#include <compare>
|
|
|
|
class audio_frame;
|
|
|
|
class midi_tick {
|
|
public:
|
|
midi_tick(int64_t in_ticks) : ticks(in_ticks) {
|
|
|
|
}
|
|
explicit midi_tick(const audio_frame& in_frame);
|
|
|
|
[[nodiscard]] auto to_audio_frame() const -> audio_frame;
|
|
[[nodiscard]] auto get_ticks() const -> int64_t {
|
|
return ticks;
|
|
}
|
|
operator int64_t() const {
|
|
return ticks;
|
|
}
|
|
auto operator<=>(const midi_tick&) const = default;
|
|
auto operator+=(const midi_tick& in_tick) -> midi_tick {
|
|
ticks += in_tick.ticks;
|
|
return *this;
|
|
}
|
|
auto operator-=(const midi_tick& in_tick) -> midi_tick {
|
|
ticks -= in_tick.ticks;
|
|
return *this;
|
|
}
|
|
private:
|
|
int64_t ticks;
|
|
};
|
|
|
|
class audio_frame {
|
|
public:
|
|
audio_frame(int64_t in_frames) : frames(in_frames) {
|
|
|
|
}
|
|
explicit audio_frame(const midi_tick& in_tick);
|
|
|
|
[[nodiscard]] auto to_midi_tick() const -> midi_tick;
|
|
[[nodiscard]] auto get_frames() const -> int64_t {
|
|
return frames;
|
|
}
|
|
operator int64_t() const {
|
|
return frames;
|
|
}
|
|
auto operator<=>(const audio_frame&) const = default;
|
|
auto operator+=(const audio_frame& in_frame) -> audio_frame {
|
|
frames += in_frame.frames;
|
|
return *this;
|
|
}
|
|
auto operator-=(const audio_frame& in_frame) -> audio_frame {
|
|
frames -= in_frame.frames;
|
|
return *this;
|
|
}
|
|
private:
|
|
int64_t frames;
|
|
};
|